RigsofRods
Soft-body Physics Simulation
FlexMeshWheel.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  Copyright 2013-2020 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #pragma once
23 
24 #include "ForwardDeclarations.h"
25 #include "FlexMesh.h"
26 
27 #include <Ogre.h>
28 #include <string>
29 #include <vector>
30 
31 namespace RoR {
32 
35 
38 
40 class FlexMeshWheel: public Flexable
41 {
42  friend class RoR::FlexFactory;
43 
44 public:
45 
47 
48  Ogre::Entity* GetTireEntity() { return m_tire_entity; }
49 
50  Ogre::Vector3 updateVertices();
51 
52  // Flexable
53  bool flexitPrepare();
54  void flexitCompute();
55  Ogre::Vector3 flexitFinal();
56 
57  void setVisible(bool visible);
58 
59 private:
60 
61  FlexMeshWheel( // Use FlexFactory
62  Ogre::Entity* rim_prop_entity,
63  Ogre::SceneNode* rim_scene_node,
64  RoR::GfxActor* gfx_actor,
65  int axis_node_1_index,
66  int axis_node_2_index,
67  int nstart,
68  int nrays,
69  std::string const& tire_mesh_name,
70  std::string const& tire_mesh_rg,
71  std::string const& tire_material_name,
72  std::string const& tire_material_rg,
73  float rimradius,
74  bool rimreverse
75  );
76 
78  {
79  Ogre::Vector3 position;
80  Ogre::Vector3 normal;
81  Ogre::Vector2 texcoord;
82  };
83 
84  // Wheel
85  size_t m_num_rays;
86  float m_rim_radius;
91 
92  // Meshes
93  Ogre::Vector3 m_flexit_center;
94  Ogre::MeshPtr m_mesh;
95  Ogre::SubMesh* m_submesh;
97  Ogre::Entity* m_rim_entity;
98  Ogre::Entity* m_tire_entity; // Assigned by friend FlexFactory
99  Ogre::SceneNode* m_rim_scene_node;
100 
101  // Vertices
102  float m_norm_y;
104  std::vector<FlexMeshWheelVertex> m_vertices;
105  Ogre::VertexDeclaration* m_vertex_format;
106  Ogre::HardwareVertexBufferSharedPtr m_hw_vbuf;
107 
108  // Indices
110  std::vector<unsigned short> m_indices;
111 };
112 
115 
116 } // namespace RoR
RoR::FlexMeshWheel::m_vertices
std::vector< FlexMeshWheelVertex > m_vertices
Definition: FlexMeshWheel.h:104
RoR::FlexMeshWheel::FlexMeshWheelVertex::texcoord
Ogre::Vector2 texcoord
Definition: FlexMeshWheel.h:81
ForwardDeclarations.h
Global forward declarations.
RoR::FlexMeshWheel::m_hw_vbuf
Ogre::HardwareVertexBufferSharedPtr m_hw_vbuf
Definition: FlexMeshWheel.h:106
RoR::FlexMeshWheel::m_flexit_center
Ogre::Vector3 m_flexit_center
Definition: FlexMeshWheel.h:93
RoR::FlexMeshWheel::GetTireEntity
Ogre::Entity * GetTireEntity()
Definition: FlexMeshWheel.h:48
RoR::FlexMeshWheel::FlexMeshWheel
FlexMeshWheel(Ogre::Entity *rim_prop_entity, Ogre::SceneNode *rim_scene_node, RoR::GfxActor *gfx_actor, int axis_node_1_index, int axis_node_2_index, int nstart, int nrays, std::string const &tire_mesh_name, std::string const &tire_mesh_rg, std::string const &tire_material_name, std::string const &tire_material_rg, float rimradius, bool rimreverse)
Definition: FlexMeshWheel.cpp:34
RoR::FlexMeshWheel
Consists of static mesh, representing the rim, and dynamic mesh, representing the tire.
Definition: FlexMeshWheel.h:40
RoR::Flexable
Definition: Flexable.h:34
RoR::FlexMeshWheel::m_tire_entity
Ogre::Entity * m_tire_entity
Definition: FlexMeshWheel.h:98
RoR::FlexMeshWheel::m_rim_scene_node
Ogre::SceneNode * m_rim_scene_node
Definition: FlexMeshWheel.h:99
RoR::FlexFactory
Definition: FlexFactory.h:163
RoR::FlexMeshWheel::m_index_count
size_t m_index_count
Definition: FlexMeshWheel.h:109
RoR::FlexMeshWheel::m_indices
std::vector< unsigned short > m_indices
Definition: FlexMeshWheel.h:110
RoR::FlexMeshWheel::FlexMeshWheelVertex::normal
Ogre::Vector3 normal
Definition: FlexMeshWheel.h:80
RoR::FlexMeshWheel::m_axis_node1_idx
int m_axis_node1_idx
Definition: FlexMeshWheel.h:89
RoR::FlexMeshWheel::m_submesh
Ogre::SubMesh * m_submesh
Definition: FlexMeshWheel.h:95
RoR::FlexMeshWheel::m_rim_radius
float m_rim_radius
Definition: FlexMeshWheel.h:86
RoR::FlexMeshWheel::m_vertex_count
size_t m_vertex_count
Definition: FlexMeshWheel.h:103
RoR::FlexMeshWheel::~FlexMeshWheel
~FlexMeshWheel()
Definition: FlexMeshWheel.cpp:168
RoR::FlexMeshWheel::FlexMeshWheelVertex
Definition: FlexMeshWheel.h:77
RoR::FlexMeshWheel::flexitFinal
Ogre::Vector3 flexitFinal()
Definition: FlexMeshWheel.cpp:261
RoR::FlexMeshWheel::m_axis_node0_idx
int m_axis_node0_idx
Definition: FlexMeshWheel.h:88
RoR::FlexMeshWheel::flexitCompute
void flexitCompute()
Definition: FlexMeshWheel.cpp:256
RoR::FlexMeshWheel::m_start_node_idx
int m_start_node_idx
First node (lowest index) belonging to this wheel.
Definition: FlexMeshWheel.h:90
RoR::FlexMeshWheel::m_gfx_actor
RoR::GfxActor * m_gfx_actor
Definition: FlexMeshWheel.h:87
RoR::FlexMeshWheel::flexitPrepare
bool flexitPrepare()
Definition: FlexMeshWheel.cpp:237
FlexMesh.h
RoR::FlexMeshWheel::m_num_rays
size_t m_num_rays
Definition: FlexMeshWheel.h:85
RoR::FlexMeshWheel::updateVertices
Ogre::Vector3 updateVertices()
Definition: FlexMeshWheel.cpp:187
RoR::FlexMeshWheel::m_norm_y
float m_norm_y
Definition: FlexMeshWheel.h:102
RoR::FlexMeshWheel::m_rim_entity
Ogre::Entity * m_rim_entity
Definition: FlexMeshWheel.h:97
RoR::GfxActor
Definition: GfxActor.h:52
RoR::FlexMeshWheel::m_vertex_format
Ogre::VertexDeclaration * m_vertex_format
Definition: FlexMeshWheel.h:105
RoR::FlexMeshWheel::FlexMeshWheelVertex::position
Ogre::Vector3 position
Definition: FlexMeshWheel.h:79
RoR::FlexMeshWheel::m_is_rim_reverse
bool m_is_rim_reverse
Definition: FlexMeshWheel.h:96
RoR::FlexMeshWheel::setVisible
void setVisible(bool visible)
Definition: FlexMeshWheel.cpp:232
RoR::FlexMeshWheel::m_mesh
Ogre::MeshPtr m_mesh
Definition: FlexMeshWheel.h:94
RoR
Definition: AppContext.h:36