33 bool keep_reading =
true;
34 while (keep_reading && !stream->eof())
44 if ((line !=
nullptr) && (line[0] != 0))
58 m_def = std::make_shared<ODefDocument>();
63 std::shared_ptr<ODefDocument> def =
m_def;
68inline bool StartsWith(std::string
const & line,
const char* test)
70 return line.compare(0, strlen(test), test) == 0;
68inline bool StartsWith(std::string
const & line,
const char* test) {
…}
98 Ogre::StringUtil::trim(line_str);
100 if ((line_str[0] == 0) || (line_str[0] ==
'/') || (line_str[0] ==
';'))
105 if (line_str ==
"end")
110 if (line_str ==
"movable")
114 else if (line_str ==
"standard")
116 m_def->mode_standard =
true;
120 if (line_str.compare(10, 3,
"vor") == 0) {
m_def->localizers.push_back(
LOCALIZER_VOR );
return true; }
121 if (line_str.compare(10, 3,
"ndb") == 0) {
m_def->localizers.push_back(
LOCALIZER_NDB );
return true; }
125 LOG(
"[RoR|ODef] Invalid line: " + line_str);
130 sscanf(line_str.c_str(),
"sound %200s", tmp);
131 m_def->sounds.push_back(tmp);
133 else if (
StartsWith(line_str,
"particleSystem"))
136 char instance_name[201] =
"";
137 char template_name[201] =
"";
138 int res = sscanf(line_str.c_str(),
"particleSystem %f, %f, %f, %f, %200s %200s",
139 &psys.
scale, &psys.
pos.x, &psys.
pos.y, &psys.
pos.z, instance_name, template_name);
145 m_def->particle_systems.push_back(psys);
148 else if (
StartsWith(line_str,
"setMeshMaterial") && line_str.length() > 16)
150 m_def->mat_name = line_str.substr(16);
152 else if (
StartsWith(line_str,
"generateMaterialShaders") && line_str.length() > 24)
154 m_def->mat_name_generate = line_str.substr(24);
156 else if (
StartsWith(line_str,
"playanimation"))
159 char anim_name[201] =
"";
160 sscanf(line_str.c_str(),
"playanimation %f, %f, %200s", &anim.
speed_min, &anim.
speed_max, anim_name);
161 anim.
name = anim_name;
164 m_def->animations.push_back(anim);
167 else if (
StartsWith(line_str,
"drawTextOnMeshTexture"))
170 char font_name[201] =
"";
172 int res = sscanf(line_str.c_str(),
173 "drawTextOnMeshTexture %f, %f, %f, %f, %f, %f, %f, %f, %c, %i, %i, %200s %500s",
174 &tp.
x, &tp.
y, &tp.
w, &tp.
h, &tp.
r, &tp.
g, &tp.
b, &tp.
a,
181 m_def->texture_prints.push_back(tp);
184 LOG(
"[RoR|ODef] Warning: invalid 'drawTextOnMeshTexture' line.");
189 int res = sscanf(line_str.c_str(),
"spotlight %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f",
194 m_def->spotlights.push_back(sl);
198 LOG(
"[RoR|ODef] Warning: invalid 'spotlight' line.");
204 int res = sscanf(line_str.c_str(),
"pointlight %f, %f, %f, %f, %f, %f, %f, %f, %f, %f",
209 m_def->point_lights.push_back(pl);
213 LOG(
"[RoR|ODef] Warning: invalid 'pointlight' line.");
218 else if ((line_str ==
"beginbox") || (line_str ==
"beginmesh"))
224 sscanf(line_str.c_str(),
"boxcoords %f, %f, %f, %f, %f, %f",
232 sscanf(line_str.c_str(),
"mesh %200s", tmp);
237 sscanf(line_str.c_str(),
"rotate %f, %f, %f",
243 sscanf(line_str.c_str(),
"forcecamera %f, %f, %f",
249 sscanf(line_str.c_str(),
"direction %f, %f, %f",
252 else if (
StartsWith(line_str,
"frictionconfig") && line_str.length() > 15)
254 m_def->groundmodel_files.push_back(line_str.substr(15));
256 else if ((
StartsWith(line_str,
"stdfriction") ||
StartsWith(line_str,
"usefriction")) && line_str.length() > 12)
260 else if (line_str ==
"virtual")
266 char ev_name[301] =
"";
267 char ev_type[301] =
"";
268 sscanf(line_str.c_str(),
"event %300s %300s", ev_name, ev_type);
281 else if (
StartsWith(line_str,
"reverb_preset"))
284 sscanf(line_str.c_str(),
"reverb_preset %199s", tmp);
287 else if (line_str ==
"endbox")
289 m_def->collision_boxes.emplace_back(
297 else if (line_str ==
"endmesh")
299 m_def->collision_meshes.emplace_back(
302 else if (line_str ==
"nocast")
304 m_def->header.cast_shadows =
false;
void LOG(const char *msg)
Legacy alias - formerly a macro.
bool ProcessCurrentLine()
struct RoR::ODefParser::ODefParserContext m_ctx
Parser context.
std::shared_ptr< ODefDocument > Finalize()
Passes ownership.
bool ProcessLine(const char *line)
void ProcessOgreStream(Ogre::DataStream *stream)
std::shared_ptr< ODefDocument > m_def
@ EVENT_ALL
(default) ~ Triggered by any node on any vehicle
@ EVENT_TRUCK_WHEELS
'truck_wheels' ~ Triggered only by wheel nodes of land vehicle (ActorType::TRUCK)
@ EVENT_AIRPLANE
'airplane' ~ Triggered by any node of airplane (ActorType::AIRPLANE)
@ EVENT_AVATAR
'avatar' ~ Triggered by the character only
@ EVENT_TRUCK
'truck' ~ Triggered by any node of land vehicle (ActorType::TRUCK)
@ EVENT_NONE
Invalid value.
@ EVENT_BOAT
'boat' ~ Triggered by any node of boats (ActorType::BOAT)
std::string SanitizeUtf8String(std::string const &str_in)
std::string header_mesh_name
Ogre::Vector3 cbox_rotation
Ogre::Vector3 cbox_cam_pos
Section 'forcecamera'.
Ogre::Vector3 cbox_aabb_max
Ogre::Vector3 cbox_aabb_min
std::string cbox_mesh_name
CollisionEventFilter cbox_event_filter
std::string cbox_reverb_preset_name
Ogre::Vector3 header_scale
std::string cbox_event_name
std::string cbox_groundmodel_name
Ogre::Vector3 cbox_direction
std::string instance_name
std::string template_name
float angle_outer
Degrees.
float angle_inner
Degrees.