RigsofRods
Soft-body Physics Simulation
FlexAirfoil.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 <Ogre.h>
24 
25 #include "Application.h"
26 #include "SimData.h" // For MAX_AEROENGINES
27 
28 namespace RoR {
29 
32 
34 {
35 public:
36  FlexAirfoil(Ogre::String const& wname, ActorPtr actor,
37  NodeNum_t pnfld, NodeNum_t pnfrd, NodeNum_t pnflu, NodeNum_t pnfru, NodeNum_t pnbld, NodeNum_t pnbrd, NodeNum_t pnblu, NodeNum_t pnbru,
38  std::string const & texname,
39  Ogre::Vector2 texlf, Ogre::Vector2 texrf, Ogre::Vector2 texlb, Ogre::Vector2 texrb,
40  char mtype, float controlratio, float mind, float maxd, Ogre::String const& afname, float lift_coef, bool break_able);
41 
42  ~FlexAirfoil();
43 
44  // DEV NOTE: original `updateVertices()` updated both physics state + visuals.
45  void updateVerticesPhysics();
46  Ogre::Vector3 updateVerticesGfx(RoR::GfxActor* gfx_actor);
47  void uploadVertices();
48 
49  void setControlDeflection(float val);
50 
51  void enableInducedDrag(float span, float area, bool l);
52 
53  void addwash(int propid, float ratio);
54 
55  void updateForces();
56 
57  float aoa;
58  char type;
67 
68  bool broken;
69  bool breakable;
70  float liftcoef;
71 
72 private:
73 
74  float airfoilpos[90];
75 
76  typedef struct
77  {
78  Ogre::Vector3 vertex;
79  Ogre::Vector3 normal;
80  // Ogre::Vector3 color;
81  Ogre::Vector2 texcoord;
82  } CoVertice_t;
83 
84  Ogre::MeshPtr msh;
85  Ogre::SubMesh* subface;
86  Ogre::SubMesh* subband;
87 
88  Ogre::SubMesh* subcup;
89  Ogre::SubMesh* subcdn;
90 
91  Ogre::VertexDeclaration* decl;
92  Ogre::HardwareVertexBufferSharedPtr vbuf;
93 
94  size_t nVertices;
95  size_t vbufCount;
96 
97  union
98  {
99  float* vertices;
101  };
102 
105  size_t cupibufCount;
106  size_t cdnibufCount;
107  unsigned short* facefaces;
108  unsigned short* bandfaces;
109  unsigned short* cupfaces;
110  unsigned short* cdnfaces;
112 
113  float sref;
114 
115  float deflection;
116  float chordratio;
120  float lratio;
121  float rratio;
122  float mindef;
123  float maxdef;
124  float thickness;
126  float idSpan;
127  float idArea;
128  bool idLeft;
129 
135 };
136 
138 
139 } // namespace RoRs
RoR::FlexAirfoil::bandibufCount
size_t bandibufCount
Definition: FlexAirfoil.h:104
RoR::FlexAirfoil::washpropratio
float washpropratio[MAX_AEROENGINES]
Definition: FlexAirfoil.h:134
RoR::FlexAirfoil::idArea
float idArea
Definition: FlexAirfoil.h:127
RoR::FlexAirfoil::stabilleft
bool stabilleft
Definition: FlexAirfoil.h:119
RoR::FlexAirfoil::updateVerticesGfx
Ogre::Vector3 updateVerticesGfx(RoR::GfxActor *gfx_actor)
Definition: FlexAirfoil.cpp:442
RoR::FlexAirfoil::nfld
NodeNum_t nfld
Definition: FlexAirfoil.h:59
RoR::FlexAirfoil::aoa
float aoa
Definition: FlexAirfoil.h:57
RoR::FlexAirfoil::lratio
float lratio
Definition: FlexAirfoil.h:120
RoR::FlexAirfoil::isstabilator
bool isstabilator
Definition: FlexAirfoil.h:118
RoR::FlexAirfoil::vbuf
Ogre::HardwareVertexBufferSharedPtr vbuf
Definition: FlexAirfoil.h:92
RoR::FlexAirfoil::rratio
float rratio
Definition: FlexAirfoil.h:121
RoR::FlexAirfoil::liftcoef
float liftcoef
Definition: FlexAirfoil.h:70
RoR::FlexAirfoil::subcdn
Ogre::SubMesh * subcdn
Definition: FlexAirfoil.h:89
RoR::FlexAirfoil::washpropnum
int washpropnum[MAX_AEROENGINES]
Definition: FlexAirfoil.h:133
RoR::FlexAirfoil::thickness
float thickness
Definition: FlexAirfoil.h:124
RoR::FlexAirfoil::bandfaces
unsigned short * bandfaces
Definition: FlexAirfoil.h:108
RoR::FlexAirfoil::setControlDeflection
void setControlDeflection(float val)
Definition: FlexAirfoil.cpp:569
RoR::FlexAirfoil::covertices
CoVertice_t * covertices
Definition: FlexAirfoil.h:100
RoR::FlexAirfoil::breakable
bool breakable
Definition: FlexAirfoil.h:69
RoR::FlexAirfoil::nflu
NodeNum_t nflu
Definition: FlexAirfoil.h:61
RoR::AeroEngine
Definition: AeroEngine.h:36
RoR::FlexAirfoil::broken
bool broken
Definition: FlexAirfoil.h:68
RefCountingObjectPtr< Actor >
RoR::FlexAirfoil::uploadVertices
void uploadVertices()
Definition: FlexAirfoil.cpp:563
RoR::FlexAirfoil::deflection
float deflection
Definition: FlexAirfoil.h:115
RoR::FlexAirfoil::CoVertice_t::vertex
Ogre::Vector3 vertex
Definition: FlexAirfoil.h:78
RoR::FlexAirfoil::maxdef
float maxdef
Definition: FlexAirfoil.h:123
RoR::FlexAirfoil::addwash
void addwash(int propid, float ratio)
Definition: FlexAirfoil.cpp:583
RoR::FlexAirfoil::FlexAirfoil
FlexAirfoil(Ogre::String const &wname, ActorPtr actor, NodeNum_t pnfld, NodeNum_t pnfrd, NodeNum_t pnflu, NodeNum_t pnfru, NodeNum_t pnbld, NodeNum_t pnbrd, NodeNum_t pnblu, NodeNum_t pnbru, std::string const &texname, Ogre::Vector2 texlf, Ogre::Vector2 texrf, Ogre::Vector2 texlb, Ogre::Vector2 texrb, char mtype, float controlratio, float mind, float maxd, Ogre::String const &afname, float lift_coef, bool break_able)
Definition: FlexAirfoil.cpp:77
RoR::FlexAirfoil::aeroengines
AeroEngine ** aeroengines
Definition: FlexAirfoil.h:131
RoR::FlexAirfoil::nbld
NodeNum_t nbld
Definition: FlexAirfoil.h:63
RoR::NodeNum_t
uint16_t NodeNum_t
Node position within Actor::ar_nodes; use RoR::NODENUM_INVALID as empty value.
Definition: ForwardDeclarations.h:52
RoR::FlexAirfoil::airfoil
Airfoil * airfoil
Definition: FlexAirfoil.h:130
RoR::FlexAirfoil::airfoilpos
float airfoilpos[90]
Definition: FlexAirfoil.h:74
SimData.h
Core data structures for simulation; Everything affected by by either physics, network or user intera...
RoR::FlexAirfoil::faceibufCount
size_t faceibufCount
Definition: FlexAirfoil.h:103
RoR::FlexAirfoil::nfrd
NodeNum_t nfrd
Definition: FlexAirfoil.h:60
RoR::FlexAirfoil::cupfaces
unsigned short * cupfaces
Definition: FlexAirfoil.h:109
RoR::FlexAirfoil::subcup
Ogre::SubMesh * subcup
Definition: FlexAirfoil.h:88
RoR::FlexAirfoil::vertices
float * vertices
Definition: FlexAirfoil.h:99
Application.h
Central state/object manager and communications hub.
RoR::FlexAirfoil::type
char type
Definition: FlexAirfoil.h:58
RoR::FlexAirfoil::cdnfaces
unsigned short * cdnfaces
Definition: FlexAirfoil.h:110
RoR::node_t
Physics: A vertex in the softbody structure.
Definition: SimData.h:286
RoR::FlexAirfoil::nbru
NodeNum_t nbru
Definition: FlexAirfoil.h:66
RoR::FlexAirfoil::updateVerticesPhysics
void updateVerticesPhysics()
Definition: FlexAirfoil.cpp:413
RoR::FlexAirfoil::sref
float sref
Definition: FlexAirfoil.h:113
RoR::FlexAirfoil::chordratio
float chordratio
Definition: FlexAirfoil.h:116
RoR::FlexAirfoil::subface
Ogre::SubMesh * subface
Definition: FlexAirfoil.h:85
RoR::FlexAirfoil::CoVertice_t::normal
Ogre::Vector3 normal
Definition: FlexAirfoil.h:79
RoR::FlexAirfoil::enableInducedDrag
void enableInducedDrag(float span, float area, bool l)
Definition: FlexAirfoil.cpp:575
RoR::FlexAirfoil::cupibufCount
size_t cupibufCount
Definition: FlexAirfoil.h:105
RoR::FlexAirfoil::subband
Ogre::SubMesh * subband
Definition: FlexAirfoil.h:86
RoR::FlexAirfoil::idSpan
float idSpan
Definition: FlexAirfoil.h:126
RoR::FlexAirfoil::vbufCount
size_t vbufCount
Definition: FlexAirfoil.h:95
RoR::FlexAirfoil::cdnibufCount
size_t cdnibufCount
Definition: FlexAirfoil.h:106
RoR::FlexAirfoil::hascontrol
bool hascontrol
Definition: FlexAirfoil.h:117
RoR::FlexAirfoil::free_wash
int free_wash
Definition: FlexAirfoil.h:132
RoR::FlexAirfoil::updateForces
void updateForces()
Definition: FlexAirfoil.cpp:590
RoR::FlexAirfoil::idLeft
bool idLeft
Definition: FlexAirfoil.h:128
RoR::FlexAirfoil
Definition: FlexAirfoil.h:33
RoR::Airfoil
Represents an airfoil http://en.wikipedia.org/wiki/Airfoil.
Definition: Airfoil.h:31
RoR::GfxActor
Definition: GfxActor.h:52
RoR::FlexAirfoil::facefaces
unsigned short * facefaces
Definition: FlexAirfoil.h:107
RoR::FlexAirfoil::decl
Ogre::VertexDeclaration * decl
Definition: FlexAirfoil.h:91
RoR::FlexAirfoil::nodes
node_t * nodes
Definition: FlexAirfoil.h:111
RoR::FlexAirfoil::CoVertice_t::texcoord
Ogre::Vector2 texcoord
Definition: FlexAirfoil.h:81
RoR::FlexAirfoil::mindef
float mindef
Definition: FlexAirfoil.h:122
RoR::FlexAirfoil::useInducedDrag
bool useInducedDrag
Definition: FlexAirfoil.h:125
RoR::FlexAirfoil::nblu
NodeNum_t nblu
Definition: FlexAirfoil.h:65
RoR::FlexAirfoil::nfru
NodeNum_t nfru
Definition: FlexAirfoil.h:62
RoR::FlexAirfoil::nVertices
size_t nVertices
Definition: FlexAirfoil.h:94
RoR::FlexAirfoil::nbrd
NodeNum_t nbrd
Definition: FlexAirfoil.h:64
RoR
Definition: AppContext.h:36
RoR::FlexAirfoil::CoVertice_t
Definition: FlexAirfoil.h:76
RoR::FlexAirfoil::msh
Ogre::MeshPtr msh
Definition: FlexAirfoil.h:84
RoR::FlexAirfoil::~FlexAirfoil
~FlexAirfoil()
Definition: FlexAirfoil.cpp:682
MAX_AEROENGINES
static const int MAX_AEROENGINES
maximum number of aero engines per actor
Definition: SimConstants.h:30