RigsofRods
Soft-body Physics Simulation
Differentials.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 <vector>
24 #include <OgreUTFString.h>
25 
26 namespace RoR {
27 
30 
33 
35 {
36  float speed[2];
37  float delta_rotation; // sign is first relative to the second
38  float out_torque[2];
39  float in_torque;
40  float dt;
41 };
42 
44 {
45 public:
46  TransferCase(int a1, int a2, bool has_2wd, bool has_2wd_lo, std::vector<float> grs):
47  tr_ax_1(a1), tr_ax_2(a2), tr_2wd(has_2wd), tr_2wd_lo(has_2wd_lo), tr_4wd_mode(false), tr_gear_ratios(grs) {};
48 
49  int tr_ax_1;
50  int tr_ax_2;
51  bool tr_2wd;
52  bool tr_2wd_lo;
53  bool tr_4wd_mode;
54  std::vector<float> tr_gear_ratios;
55 };
56 
58 {
64 };
65 
67 {
68 public:
70 
71  int di_idx_1;
72  int di_idx_2;
74 
75  void AddDifferentialType(DiffType diff) { m_available_diffs.push_back(diff); }
77  void CalcAxleTorque(DifferentialData& diff_data);
78  Ogre::UTFString GetDifferentialTypeName();
80  int GetNumDiffTypes() { return static_cast<int>(m_available_diffs.size()); }
81 
82  static void CalcSeparateDiff(DifferentialData& diff_data);
83  static void CalcOpenDiff(DifferentialData& diff_data );
84  static void CalcViscousDiff(DifferentialData& diff_data );
85  static void CalcLockedDiff(DifferentialData& diff_data );
86 
87 private:
88  std::vector<DiffType> m_available_diffs;
89 };
90 
93 
94 } // namespace RoR
95 
RoR::TransferCase::tr_ax_2
int tr_ax_2
This axle is only driven in 4WD mode.
Definition: Differentials.h:50
RoR::Differential::CalcSeparateDiff
static void CalcSeparateDiff(DifferentialData &diff_data)
a differential that always splits the torque evenly, this is the original method
Definition: Differentials.cpp:64
RoR::Differential::CalcAxleTorque
void CalcAxleTorque(DifferentialData &diff_data)
Definition: Differentials.cpp:35
RoR::TransferCase::tr_2wd_lo
bool tr_2wd_lo
Does it support 2WD Lo mode?
Definition: Differentials.h:52
RoR::Differential::GetActiveDiffType
DiffType GetActiveDiffType() const
Definition: Differentials.h:79
RoR::DifferentialData::dt
float dt
Definition: Differentials.h:40
RoR::Differential::GetDifferentialTypeName
Ogre::UTFString GetDifferentialTypeName()
Definition: Differentials.cpp:49
RoR::TransferCase::tr_2wd
bool tr_2wd
Does it support 2WD mode?
Definition: Differentials.h:51
RoR::TransferCase::tr_4wd_mode
bool tr_4wd_mode
Enables 4WD mode.
Definition: Differentials.h:53
RoR::VISCOUS_DIFF
@ VISCOUS_DIFF
Definition: Differentials.h:61
RoR::Differential::CalcViscousDiff
static void CalcViscousDiff(DifferentialData &diff_data)
more power goes to the slower spining wheel
Definition: Differentials.cpp:98
RoR::TransferCase::tr_gear_ratios
std::vector< float > tr_gear_ratios
Gear reduction ratios.
Definition: Differentials.h:54
RoR::Differential::di_idx_2
int di_idx_2
array location of wheel / axle 2
Definition: Differentials.h:72
RoR::DifferentialData::in_torque
float in_torque
Definition: Differentials.h:39
RoR::Differential
Definition: Differentials.h:66
RoR::Differential::CalcLockedDiff
static void CalcLockedDiff(DifferentialData &diff_data)
ensures both wheels rotate at the the same speed
Definition: Differentials.cpp:118
RoR::Differential::AddDifferentialType
void AddDifferentialType(DiffType diff)
Definition: Differentials.h:75
RoR::DifferentialData::delta_rotation
float delta_rotation
Definition: Differentials.h:37
RoR::TransferCase
Definition: Differentials.h:43
RoR::DifferentialData::out_torque
float out_torque[2]
Definition: Differentials.h:38
RoR::OPEN_DIFF
@ OPEN_DIFF
Definition: Differentials.h:60
RoR::Differential::CalcOpenDiff
static void CalcOpenDiff(DifferentialData &diff_data)
more power goes to the faster spining wheel
Definition: Differentials.cpp:69
RoR::DifferentialData::speed
float speed[2]
Definition: Differentials.h:36
RoR::Differential::GetNumDiffTypes
int GetNumDiffTypes()
Definition: Differentials.h:80
RoR::Differential::ToggleDifferentialMode
void ToggleDifferentialMode()
Definition: Differentials.cpp:27
RoR::TransferCase::tr_ax_1
int tr_ax_1
This axle is always driven.
Definition: Differentials.h:47
RoR::DifferentialData
Definition: Differentials.h:34
RoR::DiffType
DiffType
Definition: Differentials.h:57
RoR::SPLIT_DIFF
@ SPLIT_DIFF
Definition: Differentials.h:59
RoR::Differential::di_idx_1
int di_idx_1
array location of wheel / axle 1
Definition: Differentials.h:69
RoR::Differential::Differential
Differential()
Definition: Differentials.h:69
RoR::Differential::di_delta_rotation
float di_delta_rotation
difference of rotational position between two wheels/axles... a kludge at best
Definition: Differentials.h:73
RoR::TransferCase::TransferCase
TransferCase(int a1, int a2, bool has_2wd, bool has_2wd_lo, std::vector< float > grs)
Definition: Differentials.h:46
RoR::Differential::m_available_diffs
std::vector< DiffType > m_available_diffs
Definition: Differentials.h:88
RoR
Definition: AppContext.h:36
RoR::LOCKED_DIFF
@ LOCKED_DIFF
Definition: Differentials.h:62
RoR::INVALID_DIFF
@ INVALID_DIFF
Definition: Differentials.h:63