Skip to content

Commit

Permalink
Added tobj command rot_yxz to switch CalcRotation
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham authored and ohlidalp committed Mar 11, 2024
1 parent 085658e commit 8154504
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 19 additions & 4 deletions source/main/resources/tobj_fileformat/TObjFileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ void TObjParser::Prepare()
m_in_procedural_road = false;
m_cur_procedural_obj = new ProceduralObject();
m_cur_procedural_obj_start_line = -1;
m_road2_num_blocks = 0;
m_road2_num_blocks = 0;
m_default_rendering_distance = 0.f;
m_rot_yxz = false;

m_def = std::shared_ptr<TObjFile>(new TObjFile());
}
Expand Down Expand Up @@ -122,6 +123,11 @@ bool TObjParser::ProcessCurrentLine()
}
return true;
}
if (strncmp(m_cur_line, "rot_yxz", 7) == 0)
{
m_rot_yxz = true;
return true;
}
if (strncmp("begin_procedural_roads", m_cur_line, 22) == 0)
{
m_cur_procedural_obj = new ProceduralObject(); // Hard reset, discarding last "non-procedural" road strip. For backwards compatibility. ~ Petr Ohlidal, 08/2020
Expand Down Expand Up @@ -354,9 +360,18 @@ void TObjParser::ImportProceduralPoint(Ogre::Vector3 const& pos, Ogre::Vector3 c

Ogre::Quaternion TObjParser::CalcRotation(Ogre::Vector3 const& rot) const
{
return Quaternion(Degree(rot.y), Vector3::UNIT_Y) * // y global
Quaternion(Degree(rot.x), Vector3::UNIT_X) * // x local
Quaternion(Degree(rot.z), Vector3::UNIT_Z); // z local
if (m_rot_yxz)
{
return Quaternion(Degree(rot.y), Vector3::UNIT_Y) * // y global
Quaternion(Degree(rot.x), Vector3::UNIT_X) * // x local
Quaternion(Degree(rot.z), Vector3::UNIT_Z); // z local
}
else
{
return Quaternion(Degree(rot.x), Vector3::UNIT_X) *
Quaternion(Degree(rot.y), Vector3::UNIT_Y) *
Quaternion(Degree(rot.z), Vector3::UNIT_Z);
}
}

bool TObjParser::ParseObjectLine(TObjEntry& object)
Expand Down
2 changes: 2 additions & 0 deletions source/main/resources/tobj_fileformat/TObjFileFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ class TObjParser
Ogre::Vector3 m_road2_last_pos;
Ogre::Vector3 m_road2_last_rot;
int m_road2_num_blocks;

bool m_rot_yxz;
};

} // namespace RoR

0 comments on commit 8154504

Please sign in to comment.