X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmodel%2Fmodel.cpp;h=9a5801b2a10af3ce527cfae51f7aa66ed9c7c6c5;hb=HEAD;hp=cad62ac2ec0cea30c99e39685adbef0729b6f3a8;hpb=b9a63fedbc65e8659c43f7fa381017c0c70a48da;p=blank.git diff --git a/src/model/model.cpp b/src/model/model.cpp index cad62ac..9a5801b 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -27,6 +27,14 @@ Instance::~Instance() { } +Part::State &Instance::BodyState() noexcept { + return state[model->GetBodyPart().ID()]; +} + +glm::mat4 Instance::BodyTransform() const noexcept { + return model->GetBodyPart().GlobalTransform(*this); +} + Part::State &Instance::EyesState() noexcept { return state[model->GetEyesPart().ID()]; } @@ -44,6 +52,7 @@ Model::Model() : id(0) , root() , part() +, body_id(0) , eyes_id(0) { } @@ -100,8 +109,8 @@ Part::Part() , tex_map() , mesh() , initial() -, hsl_mod(0.0f, 1.0f, 1.0f) -, rgb_mod(1.0f, 1.0f, 1.0f) +, hsl_mod(0, 255, 255) +, rgb_mod(255, 255, 255) , id(0) { } @@ -114,6 +123,7 @@ void Part::Read(TokenStreamReader &in, ResourceIndex &tex_index, const ShapeRegi std::string name; std::string shape_name; std::string tex_name; + glm::vec3 color_conv; in.Skip(Token::ANGLE_BRACKET_OPEN); while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) { in.ReadIdentifier(name); @@ -126,9 +136,11 @@ void Part::Read(TokenStreamReader &in, ResourceIndex &tex_index, const ShapeRegi } else if (name == "orientation") { in.ReadQuat(initial.orientation); } else if (name == "hsl_mod") { - in.ReadVec(hsl_mod); + in.ReadVec(color_conv); + hsl_mod = EntityMesh::ColorMod(color_conv * 255.0f); } else if (name == "rgb_mod") { - in.ReadVec(rgb_mod); + in.ReadVec(color_conv); + rgb_mod = EntityMesh::ColorMod(color_conv * 255.0f); } else if (name == "textures") { in.Skip(Token::BRACKET_OPEN); while (in.HasMore() && in.Peek().type != Token::BRACKET_CLOSE) { @@ -181,7 +193,7 @@ void Part::Index(std::vector &index) noexcept { } glm::mat4 Part::LocalTransform(const Instance &inst) const noexcept { - glm::mat4 transform(toMat4(initial.orientation * inst.state[id].orientation)); + glm::mat4 transform(glm::toMat4(initial.orientation * inst.state[id].orientation)); transform[3] = glm::vec4(initial.position + inst.state[id].position, 1.0f); return transform; }