RigsofRods
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
35 namespace 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
60  bool is_rotating:1;
61  bool is_virtual:1;
62  bool force_cam_pos: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;
127  } header;
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 {
147 public:
148  void Prepare();
149  bool ProcessLine(const char* line);
150  void ProcessOgreStream(Ogre::DataStream* stream);
151  std::shared_ptr<ODefDocument> Finalize();
152 
153 private:
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;
176  } m_ctx;
177 
178  std::shared_ptr<ODefDocument> m_def;
180  const char* m_cur_line;
181 };
182 
183 } // namespace RoR
RoR::ODefSpotlight::range
float range
Definition: ODefFileFormat.h:106
RoR::ODefTexPrint::option
char option
Definition: ODefFileFormat.h:96
RoR::ODefParser::ODefParserContext::cbox_aabb_min
Ogre::Vector3 cbox_aabb_min
Definition: ODefFileFormat.h:174
RoR::ODefAnimation::name
std::string name
Definition: ODefFileFormat.h:87
RoR::ODefTexPrint::y
float y
Definition: ODefFileFormat.h:98
RoR::ODefDocument::spotlights
std::list< ODefSpotlight > spotlights
Definition: ODefFileFormat.h:138
RoR::ODefTexPrint
Definition: ODefFileFormat.h:90
RoR::ODefSpotlight::dir
Ogre::Vector3 dir
Definition: ODefFileFormat.h:105
RoR::ODefParser::ProcessOgreStream
void ProcessOgreStream(Ogre::DataStream *stream)
Definition: ODefFileFormat.cpp:30
RoR::ODefParser::m_ctx
struct RoR::ODefParser::ODefParserContext m_ctx
Parser context.
RoR::ODefTexPrint::r
float r
Definition: ODefFileFormat.h:99
RoR::ODefDocument::mat_name
std::string mat_name
Section 'setMeshMaterial'.
Definition: ODefFileFormat.h:140
RoR::ODefParser::ODefParserContext::header_done
bool header_done
Definition: ODefFileFormat.h:159
RoR::CollisionEventFilter
CollisionEventFilter
Specified in terrain object (.ODEF) file, syntax: 'event <type> <filter>'.
Definition: SimData.h:46
RoR::ODefCollisionBox::cam_pos
Ogre::Vector3 cam_pos
Definition: ODefFileFormat.h:52
RoR::ODefDocument::ODefDocumentHeader
Definition: ODefFileFormat.h:122
RoR::ODefCollisionBox::is_virtual
bool is_virtual
Definition: ODefFileFormat.h:61
RoR::ODefTexPrint::a
float a
Definition: ODefFileFormat.h:99
RoR::ODefParticleSys::template_name
std::string template_name
Definition: ODefFileFormat.h:79
RoR::ODefPointLight
Definition: ODefFileFormat.h:112
RoR::ODefParser::ODefParserContext::cbox_direction
Ogre::Vector3 cbox_direction
Definition: ODefFileFormat.h:163
RoR::ODefDocument::groundmodel_files
std::list< std::string > groundmodel_files
Definition: ODefFileFormat.h:132
RoR::ODefTexPrint::x
float x
Definition: ODefFileFormat.h:98
RoR::ODefCollisionBox::scale
Ogre::Vector3 scale
Definition: ODefFileFormat.h:54
RoR::ODefTexPrint::font_dpi
int font_dpi
Definition: ODefFileFormat.h:94
RoR::ODefCollisionBox::is_rotating
bool is_rotating
Definition: ODefFileFormat.h:60
RoR::ODefCollisionMesh::groundmodel_name
std::string groundmodel_name
Definition: ODefFileFormat.h:73
RoR::ODefCollisionBox::aabb_max
Ogre::Vector3 aabb_max
Definition: ODefFileFormat.h:50
RoR::ODefParser::ODefParserContext::cbox_event_filter
CollisionEventFilter cbox_event_filter
Definition: ODefFileFormat.h:169
RoR::ODefParticleSys::pos
Ogre::Vector3 pos
Definition: ODefFileFormat.h:80
RoR::ODefParser::ODefParserContext::cbox_reverb_preset_name
std::string cbox_reverb_preset_name
Definition: ODefFileFormat.h:172
RoR::ODefParser::ODefParserContext::header_mesh_name
std::string header_mesh_name
Definition: ODefFileFormat.h:160
RoR::ODefParticleSys::instance_name
std::string instance_name
Definition: ODefFileFormat.h:78
RoR::ODefDocument::animations
std::list< ODefAnimation > animations
Definition: ODefFileFormat.h:136
RoR::ODefDocument::collision_boxes
std::list< ODefCollisionBox > collision_boxes
Definition: ODefFileFormat.h:133
RoR::ODefTexPrint::g
float g
Definition: ODefFileFormat.h:99
RoR::ODefCollisionMesh
Definition: ODefFileFormat.h:65
RoR::ODefDocument::collision_meshes
std::list< ODefCollisionMesh > collision_meshes
Definition: ODefFileFormat.h:134
RoR::ODefParser::ODefParserContext::header_scale
Ogre::Vector3 header_scale
Definition: ODefFileFormat.h:161
RoR::ODefSpotlight::angle_outer
float angle_outer
Degrees.
Definition: ODefFileFormat.h:108
SimData.h
Core data structures for simulation; Everything affected by by either physics, network or user intera...
RoR::ODefParser::ODefParserContext::cbox_aabb_max
Ogre::Vector3 cbox_aabb_max
Definition: ODefFileFormat.h:175
RoR::ODefCollisionBox::reverb_preset_name
std::string reverb_preset_name
Definition: ODefFileFormat.h:55
RoR::ODefDocument::sounds
std::list< std::string > sounds
Definition: ODefFileFormat.h:131
RoR::ODefParticleSys
Definition: ODefFileFormat.h:76
RoR::ODefParser::Finalize
std::shared_ptr< ODefDocument > Finalize()
Passes ownership.
Definition: ODefFileFormat.cpp:61
RoR::ODefDocument::mat_name_generate
std::string mat_name_generate
Section 'generateMaterialShaders'.
Definition: ODefFileFormat.h:141
RoR::ODefCollisionBox::box_rot
Ogre::Vector3 box_rot
Definition: ODefFileFormat.h:51
RoR::ODefCollisionBox::force_cam_pos
bool force_cam_pos
Definition: ODefFileFormat.h:62
RoR::ODefPointLight::pos
Ogre::Vector3 pos
Definition: ODefFileFormat.h:114
RoR::ODefDocument
Definition: ODefFileFormat.h:120
RoR::ODefParser::m_def
std::shared_ptr< ODefDocument > m_def
Definition: ODefFileFormat.h:178
RoR::ODefParser::ODefParserContext::cbox_groundmodel_name
std::string cbox_groundmodel_name
Definition: ODefFileFormat.h:173
RoR::ODefParser::m_cur_line
const char * m_cur_line
Definition: ODefFileFormat.h:180
RoR::ODefParser::ODefParserContext::cbox_is_rotating
bool cbox_is_rotating
Definition: ODefFileFormat.h:164
RoR::ODefPointLight::dir
Ogre::Vector3 dir
Definition: ODefFileFormat.h:115
RoR::ODefPointLight::range
float range
Definition: ODefFileFormat.h:116
RoR::ODefDocument::point_lights
std::list< ODefPointLight > point_lights
Definition: ODefFileFormat.h:139
RoR::ODefDocument::localizers
std::vector< LocalizerType > localizers
Definition: ODefFileFormat.h:130
RoR::ODefDocument::ODefDocumentHeader::cast_shadows
bool cast_shadows
Definition: ODefFileFormat.h:126
RoR::ODefCollisionBox
Definition: ODefFileFormat.h:37
RoR::ODefTexPrint::font_name
std::string font_name
Definition: ODefFileFormat.h:92
RoR::ODefParser::ODefParserContext::cbox_rotation
Ogre::Vector3 cbox_rotation
Definition: ODefFileFormat.h:167
RoR::ODefCollisionBox::ODefCollisionBox
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)
Definition: ODefFileFormat.h:39
RoR::ODefDocument::ODefDocumentHeader::scale
Ogre::Vector3 scale
Definition: ODefFileFormat.h:125
RoR::ODefSpotlight::color
Ogre::ColourValue color
Definition: ODefFileFormat.h:109
RoR::ODefParser::ProcessLine
bool ProcessLine(const char *line)
Definition: ODefFileFormat.cpp:41
RoR::ODefSpotlight::pos
Ogre::Vector3 pos
Definition: ODefFileFormat.h:104
RoR::ODefCollisionBox::direction
Ogre::Vector3 direction
Definition: ODefFileFormat.h:53
RoR::ODefPointLight::color
Ogre::ColourValue color
Definition: ODefFileFormat.h:117
RoR::ODefParser::Prepare
void Prepare()
Definition: ODefFileFormat.cpp:53
RoR::ODefCollisionMesh::ODefCollisionMesh
ODefCollisionMesh(std::string meshname, Ogre::Vector3 scal, std::string gmodelname)
Definition: ODefFileFormat.h:67
RoR::ODefTexPrint::b
float b
Definition: ODefFileFormat.h:99
RoR::ODefAnimation::speed_min
float speed_min
Definition: ODefFileFormat.h:86
RoR::ODefParser::ResetCBoxContext
void ResetCBoxContext()
Definition: ODefFileFormat.cpp:310
RoR::ODefCollisionMesh::scale
Ogre::Vector3 scale
Definition: ODefFileFormat.h:72
RoR::ODefParser::ODefParserContext::cbox_force_cam
bool cbox_force_cam
Definition: ODefFileFormat.h:166
RoR::ODefCollisionBox::aabb_min
Ogre::Vector3 aabb_min
Definition: ODefFileFormat.h:49
RoR::ODefParser::ODefParserContext::cbox_cam_pos
Ogre::Vector3 cbox_cam_pos
Section 'forcecamera'.
Definition: ODefFileFormat.h:168
RoR::ODefCollisionMesh::mesh_name
std::string mesh_name
Definition: ODefFileFormat.h:71
RoR::ODefDocument::ODefDocumentHeader::mesh_name
std::string mesh_name
Definition: ODefFileFormat.h:124
RoR::ODefParser::ODefParserContext::cbox_event_name
std::string cbox_event_name
Definition: ODefFileFormat.h:170
RoR::ODefTexPrint::font_size
int font_size
Definition: ODefFileFormat.h:93
RoR::ODefParser
Definition: ODefFileFormat.h:145
RoR::ODefAnimation::speed_max
float speed_max
Definition: ODefFileFormat.h:86
RoR::ODefDocument::texture_prints
std::list< ODefTexPrint > texture_prints
Section 'drawTextOnMeshTexture'.
Definition: ODefFileFormat.h:137
RoR::ODefTexPrint::w
float w
Definition: ODefFileFormat.h:98
RoR::ODefParser::ODefParserContext::cbox_is_virtual
bool cbox_is_virtual
Definition: ODefFileFormat.h:165
RoR::ODefDocument::mode_standard
bool mode_standard
Definition: ODefFileFormat.h:129
RoR::ODefParser::m_line_number
int m_line_number
Definition: ODefFileFormat.h:179
RoR::ODefParser::ODefParserContext
Definition: ODefFileFormat.h:157
RoR::ODefDocument::header
struct RoR::ODefDocument::ODefDocumentHeader header
RoR::ODefDocument::particle_systems
std::list< ODefParticleSys > particle_systems
Definition: ODefFileFormat.h:135
RoR::ODefTexPrint::text
std::string text
Definition: ODefFileFormat.h:95
RoR::ODefParser::ProcessCurrentLine
bool ProcessCurrentLine()
Definition: ODefFileFormat.cpp:74
RoR
Definition: AppContext.h:36
RoR::ODefAnimation
Definition: ODefFileFormat.h:84
RoR::ODefParticleSys::scale
float scale
Definition: ODefFileFormat.h:81
RoR::ODefSpotlight
Definition: ODefFileFormat.h:102
RoR::ODefParser::ODefParserContext::cbox_mesh_name
std::string cbox_mesh_name
Definition: ODefFileFormat.h:171
RoR::ODefCollisionBox::event_name
std::string event_name
Definition: ODefFileFormat.h:56
RoR::ODefCollisionBox::event_filter
CollisionEventFilter event_filter
Definition: ODefFileFormat.h:57
RoR::ODefTexPrint::h
float h
Definition: ODefFileFormat.h:98
RoR::ODefSpotlight::angle_inner
float angle_inner
Degrees.
Definition: ODefFileFormat.h:107