25 #define LOGSTREAM Ogre::LogManager::getSingleton().stream() << "[RoR|TObj fileformat] "
75 if ((line !=
nullptr) && (line[0] != 0))
77 bool is_comment = (line[0] ==
'/') || (line[0] ==
';');
81 while (line[text_start] ==
'/')
112 if (strncmp(
m_cur_line,
"collision-tris", 14) == 0)
131 if (strncmp(
m_cur_line,
"set_default_rendering_distance", 30) == 0)
145 if (strncmp(
"begin_procedural_roads",
m_cur_line, 22) == 0)
152 if (strncmp(
"end_procedural_roads",
m_cur_line, 20) == 0)
194 if (
object.IsActor())
198 else if (
object.IsRoad())
204 m_def->objects.push_back(
object);
235 bool keep_reading =
true;
236 while (keep_reading && !stream->eof())
250 Ogre::Vector3 rot = Ogre::Vector3::ZERO;
251 sscanf(
m_cur_line,
"%f, %f, %f, %f, %f, %f, %f, %f, %f, %s",
253 &rot.x, &rot.y, &rot.z,
276 Ogre::Vector3 & pos =
m_def->grid_position;
277 sscanf(
m_cur_line,
"grid %f, %f, %f", &pos.x, &pos.y, &pos.z);
278 m_def->grid_enabled =
true;
284 sscanf(
m_cur_line,
"trees %f, %f, %f, %f, %f, %f, %f, %s %s %s %f %s",
292 m_def->trees.push_back(tree);
300 sscanf(
m_cur_line,
"grass2 %d, %f, %f, %f, %f, %f, %f, %f, %f, %d, %f, %f, %d, %s %s %s",
312 sscanf(
m_cur_line,
"grass %d, %f, %f, %f, %f, %f, %f, %f, %f, %d, %f, %f, %s %s %s",
327 LOGSTREAM <<
"Invalid parameter 'technique': '" << grass.
technique <<
"', falling back to default '1: GRASSTECH_CROSSQUADS'";
331 m_def->grass.push_back(grass);
340 v.
type =
object.special;
341 strcpy(v.
name,
object.type);
343 m_def->vehicles.push_back(v);
400 return Quaternion(Degree(rot.y), Vector3::UNIT_Y) *
401 Quaternion(Degree(rot.x), Vector3::UNIT_X) *
402 Quaternion(Degree(rot.z), Vector3::UNIT_Z);
406 return Quaternion(Degree(rot.x), Vector3::UNIT_X) *
407 Quaternion(Degree(rot.y), Vector3::UNIT_Y) *
408 Quaternion(Degree(rot.z), Vector3::UNIT_Z);
417 Ogre::Vector3 pos(Ogre::Vector3::ZERO);
418 Ogre::Vector3 rot(Ogre::Vector3::ZERO);
419 int r = sscanf(
m_cur_line,
"%f, %f, %f, %f, %f, %f, %s %s %s",
442 if (instance_name ==
"")
447 object =
TObjEntry(pos, rot, odef.
ToCStr(), special, type, instance_name);
470 std::string line =
fmt::format(
"\n\n// ~~~~~~~~~~ {} ({}) ~~~~~~~~~~\n\n", title, count);
471 stream->write(line.c_str(), line.length());
487 if (doc->grid_enabled)
489 std::string line =
fmt::format(
"grid {}, {}, {}\n");
490 stream->write(line.c_str(), line.length());
497 std::string line =
fmt::format(
"trees {:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {} {} {} {:9f} {}\n",
504 stream->write(line.c_str(), line.length());
511 std::string line =
fmt::format(
"grass2 {}, {:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {}, {:9f}, {:9f}, {}, {} {} {}\n",
519 stream->write(line.c_str(), line.length());
529 for (Ogre::String& commenttext : Ogre::StringUtil::split(vehicle.
comments,
"\n"))
531 std::string commentline =
fmt::format(
"// {}\n", commenttext);
532 stream->write(commentline.c_str(), commentline.length());
536 std::string line =
fmt::format(
"{:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {:9f}, {} {}\n",
540 stream->write(line.c_str(), line.length());
547 std::string bline =
"begin_procedural_roads\n";
548 stream->write(bline.c_str(), bline.length());
551 stream->write(sline.c_str(), sline.length());
554 stream->write(cline.c_str(), cline.length());
558 std::string type_str;
566 case RoadType::ROAD_BRIDGE: type_str = (point->pillartype == 1) ?
"bridge" :
"bridge_no_pillars";
break;
571 if (point->comments !=
"")
573 for (Ogre::String& commenttext : Ogre::StringUtil::split(point->comments,
"\n"))
575 std::string commentline =
fmt::format(
"// {}\n", commenttext);
576 stream->write(commentline.c_str(), commentline.length());
581 "\t{:13f}, {:13f}, {:13f}, 0, {:13f}, 0, {:13f}, {:13f}, {:13f}, {}\n",
582 point->position.x, point->position.y, point->position.z,
583 point->rotation.getYaw(
false).valueDegrees(),
584 point->width, point->bwidth, point->bheight, type_str);
585 stream->write(line.c_str(), line.length());
588 std::string eline =
"end_procedural_roads\n";
589 stream->write(eline.c_str(), eline.length());
599 for (Ogre::String& commenttext : Ogre::StringUtil::split(entry.
comments,
"\n"))
601 std::string commentline =
fmt::format(
"// {}\n", commenttext);
602 stream->write(commentline.c_str(), commentline.length());
607 std::string valid_instance_name;
613 std::string line =
fmt::format(
"{:8.3f}, {:8.3f}, {:8.3f}, {:9f}, {:9f}, {:9f}, {} {} {}\n",
617 stream->write(line.c_str(), line.length());