Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
ODefFileFormat.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2016-2017 Petr Ohlidal
4
5 For more information, see http://www.rigsofrods.org/
6
7 Rigs of Rods is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3, as
9 published by the Free Software Foundation.
10
11 Rigs of Rods is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include "SimData.h"
23
24#include <OgreColourValue.h>
25#include <OgreDataStream.h>
26#include <OgreVector3.h>
27
28#include <memory>
29#include <string>
30
31#ifdef DELETE // Windows hack: The `EventType::DELETE` name collides with `DELETE` from <winnt.h> which *MAY* be included at this point.
32# undef DELETE
33#endif
34
35namespace RoR {
36
38{
39 ODefCollisionBox(Ogre::Vector3 min, Ogre::Vector3 max, Ogre::Vector3 rot,
40 Ogre::Vector3 campos, Ogre::Vector3 dir, Ogre::Vector3 scal,
41 std::string reverb_preset_name, std::string ev_name, CollisionEventFilter ev_filter,
42 bool is_rot, bool is_virt, bool forcecam):
43
44 aabb_min(min), aabb_max(max), box_rot(rot), cam_pos(campos), direction(dir), scale(scal),
46 is_rotating(is_rot), is_virtual(is_virt), force_cam_pos(forcecam)
47 {}
48
49 Ogre::Vector3 aabb_min;
50 Ogre::Vector3 aabb_max;
51 Ogre::Vector3 box_rot;
52 Ogre::Vector3 cam_pos;
53 Ogre::Vector3 direction;
54 Ogre::Vector3 scale;
55 std::string reverb_preset_name;
56 std::string event_name;
58
59 // Flags
61 bool is_virtual:1;
63};
64
66{
67 ODefCollisionMesh(std::string meshname, Ogre::Vector3 scal, std::string gmodelname):
68 mesh_name(meshname), scale(scal), groundmodel_name(gmodelname)
69 {}
70
71 std::string mesh_name;
72 Ogre::Vector3 scale;
73 std::string groundmodel_name;
74};
75
77{
78 std::string instance_name;
79 std::string template_name;
80 Ogre::Vector3 pos = Ogre::Vector3::ZERO;
81 float scale = 0.f;
82};
83
85{
86 float speed_min=0.f, speed_max=0.f;
87 std::string name;
88};
89
91{
92 std::string font_name;
93 int font_size = 0;
94 int font_dpi = 0;
95 std::string text;
96 char option = '\0';
97
98 float x=0, y=0, w=0, h=0;
99 float a=0, r=0, g=0, b=0;
100};
101
103{
104 Ogre::Vector3 pos = Ogre::Vector3::ZERO;
105 Ogre::Vector3 dir = Ogre::Vector3::ZERO;
106 float range = 0.f;
107 float angle_inner = 0.f;
108 float angle_outer = 0.f;
109 Ogre::ColourValue color = Ogre::ColourValue::Black;
110};
111
113{
114 Ogre::Vector3 pos = Ogre::Vector3::ZERO;
115 Ogre::Vector3 dir = Ogre::Vector3::ZERO;
116 float range = 0.f;
117 Ogre::ColourValue color = Ogre::ColourValue::Black;
118};
119
121{
123 {
124 std::string mesh_name;
125 Ogre::Vector3 scale;
126 bool cast_shadows = true;
128
129 bool mode_standard = false;
130 std::vector<LocalizerType> localizers;
131 std::list<std::string> sounds;
132 std::list<std::string> groundmodel_files;
133 std::list<ODefCollisionBox> collision_boxes;
134 std::list<ODefCollisionMesh> collision_meshes;
135 std::list<ODefParticleSys> particle_systems;
136 std::list<ODefAnimation> animations;
137 std::list<ODefTexPrint> texture_prints;
138 std::list<ODefSpotlight> spotlights;
139 std::list<ODefPointLight> point_lights;
140 std::string mat_name;
141 std::string mat_name_generate;
142};
143
144// -----------------------------------------------------------------------------
146{
147public:
148 void Prepare();
149 bool ProcessLine(const char* line);
150 void ProcessOgreStream(Ogre::DataStream* stream);
151 std::shared_ptr<ODefDocument> Finalize();
152
153private:
154 bool ProcessCurrentLine();
155 void ResetCBoxContext();
156
158 {
160 std::string header_mesh_name;
161 Ogre::Vector3 header_scale;
162 // Collision boxes or meshes
163 Ogre::Vector3 cbox_direction;
167 Ogre::Vector3 cbox_rotation;
168 Ogre::Vector3 cbox_cam_pos;
170 std::string cbox_event_name;
171 std::string cbox_mesh_name;
174 Ogre::Vector3 cbox_aabb_min;
175 Ogre::Vector3 cbox_aabb_max;
177
178 std::shared_ptr<ODefDocument> m_def;
180 const char* m_cur_line;
181};
182
183} // namespace RoR
Core data structures for simulation; Everything affected by by either physics, network or user intera...
const char * m_cur_line
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
CollisionEventFilter
Specified in terrain object (.ODEF) file, syntax: 'event <type> <filter>'.
Definition SimData.h:47
ODefCollisionBox(Ogre::Vector3 min, Ogre::Vector3 max, Ogre::Vector3 rot, Ogre::Vector3 campos, Ogre::Vector3 dir, Ogre::Vector3 scal, std::string reverb_preset_name, std::string ev_name, CollisionEventFilter ev_filter, bool is_rot, bool is_virt, bool forcecam)
CollisionEventFilter event_filter
Ogre::Vector3 direction
std::string reverb_preset_name
ODefCollisionMesh(std::string meshname, Ogre::Vector3 scal, std::string gmodelname)
std::list< ODefAnimation > animations
std::list< ODefParticleSys > particle_systems
std::list< ODefCollisionMesh > collision_meshes
struct RoR::ODefDocument::ODefDocumentHeader header
std::list< ODefTexPrint > texture_prints
Section 'drawTextOnMeshTexture'.
std::string mat_name
Section 'setMeshMaterial'.
std::list< std::string > sounds
std::list< ODefPointLight > point_lights
std::list< std::string > groundmodel_files
std::vector< LocalizerType > localizers
std::list< ODefSpotlight > spotlights
std::list< ODefCollisionBox > collision_boxes
std::string mat_name_generate
Section 'generateMaterialShaders'.
Ogre::Vector3 cbox_cam_pos
Section 'forcecamera'.
CollisionEventFilter cbox_event_filter
std::string instance_name
std::string template_name
Ogre::ColourValue color
float angle_outer
Degrees.
float angle_inner
Degrees.
Ogre::ColourValue color
std::string font_name