RigsofRods
Soft-body Physics Simulation
Skidmark.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5 
6  For more information, see http://www.rigsofrods.org/
7 
8  Rigs of Rods is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License version 3, as
10  published by the Free Software Foundation.
11 
12  Rigs of Rods is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #pragma once
22 
23 #include "Application.h"
24 
25 #include <OgreMaterial.h>
26 #include <OgreString.h>
27 #include <OgreVector2.h>
28 #include <OgreVector3.h>
29 
30 namespace RoR {
31 
33 {
34 public:
35 
37 
38  int getTexture(Ogre::String model, Ogre::String ground, float slip, Ogre::String& texture);
39 
40 private:
41 
42  struct SkidmarkDef
43  {
44  Ogre::String ground;
45  Ogre::String texture;
46  float slipFrom;
47  float slipTo;
48  };
49 
50  int ProcessSkidmarkConfLine(Ogre::StringVector args, Ogre::String model);
51 
52  std::map<Ogre::String, std::vector<SkidmarkDef>> m_models;
53 };
54 
57 
58 class Skidmark
59 {
60 public:
61 
63  Skidmark(SkidmarkConfig* config, wheel_t* m_wheel, Ogre::SceneNode* snode, int m_length = 500, int m_bucket_count = 20);
64  virtual ~Skidmark();
65 
66  void reset();
67  void update(Ogre::Vector3 contact_point, int index, float slip, Ogre::String ground_model_name);
68 
69 private:
70 
72  {
73  Ogre::ManualObject* obj;
74  Ogre::MaterialPtr material;
75  std::vector<Ogre::Vector3> points;
76  std::vector<Ogre::Real> faceSizes;
77  std::vector<Ogre::String> groundTexture;
78  Ogre::Vector3 lastPointAv;
79  int pos;
81  };
82 
83  void PopSegment();
84  void LimitObjects();
85  void AddObject(Ogre::Vector3 start, Ogre::String texture);
86  void SetPointInt(unsigned short index, const Ogre::Vector3& value, Ogre::Real fsize, Ogre::String texture);
87  void AddPoint(const Ogre::Vector3& value, Ogre::Real fsize, Ogre::String texture);
88  void UpdatePoint(Ogre::Vector3 contact_point, int index, float slip, Ogre::String ground_model_name);
89 
90  static int m_instance_counter;
91  bool m_is_dirty;
92  std::queue<SkidmarkSegment> m_objects;
95  static Ogre::Vector2 m_tex_coords[4];
97  int m_length;
99  Ogre::SceneNode* m_scene_node;
101 };
102 
104 
105 } // namespace RoR
RoR::SkidmarkConfig
< Skidmark config file parser and data container
Definition: Skidmark.h:32
RoR::Skidmark::~Skidmark
virtual ~Skidmark()
Definition: Skidmark.cpp:129
RoR::Skidmark::SkidmarkSegment::groundTexture
std::vector< Ogre::String > groundTexture
Definition: Skidmark.h:77
RoR::Skidmark::m_objects
std::queue< SkidmarkSegment > m_objects
Definition: Skidmark.h:92
RoR::SkidmarkConfig::SkidmarkDef::slipFrom
float slipFrom
Minimum slipping velocity.
Definition: Skidmark.h:46
RoR::wheel_t
Definition: SimData.h:421
RoR::SkidmarkConfig::SkidmarkDef::slipTo
float slipTo
Maximum slipping velocity.
Definition: Skidmark.h:47
RoR::SkidmarkConfig::getTexture
int getTexture(Ogre::String model, Ogre::String ground, float slip, Ogre::String &texture)
Definition: Skidmark.cpp:94
RoR::SkidmarkConfig::LoadDefaultSkidmarkDefs
void LoadDefaultSkidmarkDefs()
Definition: Skidmark.cpp:34
RoR::Skidmark::SkidmarkSegment::points
std::vector< Ogre::Vector3 > points
Definition: Skidmark.h:75
RoR::Skidmark::m_config
SkidmarkConfig * m_config
Definition: Skidmark.h:100
RoR::Skidmark::SkidmarkSegment
< Also reffered to as 'bucket'
Definition: Skidmark.h:71
RoR::Skidmark
Definition: Skidmark.h:58
RoR::Skidmark::m_length
int m_length
Definition: Skidmark.h:97
RoR::Skidmark::Skidmark
Skidmark(SkidmarkConfig *config, wheel_t *m_wheel, Ogre::SceneNode *snode, int m_length=500, int m_bucket_count=20)
Constructor - see setOperationType() for description of argument.
Definition: Skidmark.cpp:112
RoR::Skidmark::UpdatePoint
void UpdatePoint(Ogre::Vector3 contact_point, int index, float slip, Ogre::String ground_model_name)
Definition: Skidmark.cpp:205
RoR::Skidmark::SkidmarkSegment::obj
Ogre::ManualObject * obj
Definition: Skidmark.h:73
RoR::Skidmark::m_max_distance
float m_max_distance
Definition: Skidmark.h:93
RoR::Skidmark::m_min_distance
float m_min_distance
Definition: Skidmark.h:94
Application.h
Central state/object manager and communications hub.
RoR::Skidmark::SkidmarkSegment::material
Ogre::MaterialPtr material
Definition: Skidmark.h:74
RoR::Skidmark::m_instance_counter
static int m_instance_counter
Definition: Skidmark.h:90
RoR::Skidmark::SkidmarkSegment::facecounter
int facecounter
Definition: Skidmark.h:80
RoR::Skidmark::PopSegment
void PopSegment()
Definition: Skidmark.cpp:177
RoR::Skidmark::LimitObjects
void LimitObjects()
Definition: Skidmark.cpp:188
RoR::Skidmark::m_wheel
wheel_t * m_wheel
Definition: Skidmark.h:98
RoR::Skidmark::m_bucket_count
int m_bucket_count
Definition: Skidmark.h:96
RoR::SkidmarkConfig::SkidmarkDef::texture
Ogre::String texture
Definition: Skidmark.h:45
RoR::Skidmark::m_tex_coords
static Ogre::Vector2 m_tex_coords[4]
Definition: Skidmark.h:95
RoR::Skidmark::SkidmarkSegment::lastPointAv
Ogre::Vector3 lastPointAv
Definition: Skidmark.h:78
RoR::SkidmarkConfig::SkidmarkDef
Definition: Skidmark.h:42
RoR::Skidmark::AddPoint
void AddPoint(const Ogre::Vector3 &value, Ogre::Real fsize, Ogre::String texture)
Definition: Skidmark.cpp:302
RoR::Skidmark::update
void update(Ogre::Vector3 contact_point, int index, float slip, Ogre::String ground_model_name)
Definition: Skidmark.cpp:318
RoR::Skidmark::AddObject
void AddObject(Ogre::Vector3 start, Ogre::String texture)
Definition: Skidmark.cpp:134
RoR::SkidmarkConfig::ProcessSkidmarkConfLine
int ProcessSkidmarkConfLine(Ogre::StringVector args, Ogre::String model)
Definition: Skidmark.cpp:71
RoR::Skidmark::SkidmarkSegment::faceSizes
std::vector< Ogre::Real > faceSizes
Definition: Skidmark.h:76
RoR::SkidmarkConfig::SkidmarkDef::ground
Ogre::String ground
Ground model name, see struct ground_model_t
Definition: Skidmark.h:44
RoR::Skidmark::SetPointInt
void SetPointInt(unsigned short index, const Ogre::Vector3 &value, Ogre::Real fsize, Ogre::String texture)
Definition: Skidmark.cpp:196
RoR::SkidmarkConfig::m_models
std::map< Ogre::String, std::vector< SkidmarkDef > > m_models
Definition: Skidmark.h:52
RoR
Definition: AppContext.h:36
RoR::Skidmark::SkidmarkSegment::pos
int pos
Definition: Skidmark.h:79
RoR::Skidmark::reset
void reset()
Definition: Skidmark.cpp:312
RoR::Skidmark::m_is_dirty
bool m_is_dirty
Definition: Skidmark.h:91
RoR::Skidmark::m_scene_node
Ogre::SceneNode * m_scene_node
Definition: Skidmark.h:99