Newton Dynamics  4.00
ndMultiBodyVehicleMotor.h
1 /* Copyright (c) <2003-2022> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __ND_MULTIBODY_VEHICLE_MOTOR_H__
23 #define __ND_MULTIBODY_VEHICLE_MOTOR_H__
24 
25 #include "ndNewtonStdafx.h"
26 #include "ndJointBilateralConstraint.h"
27 
28 class ndMultiBodyVehicle;
29 
31 {
32  public:
33  D_CLASS_REFLECTION(ndMultiBodyVehicleMotor);
35  D_NEWTON_API ndMultiBodyVehicleMotor(ndBodyKinematic* const motor, ndMultiBodyVehicle* const vehicelModel);
36 
37  D_NEWTON_API ndFloat32 GetRpm() const;
38  D_NEWTON_API void SetMaxRpm(ndFloat32 redLineRpm);
39  D_NEWTON_API void SetOmegaAccel(ndFloat32 rpmStep);
40  D_NEWTON_API void SetFrictionLoss(ndFloat32 newtonMeters);
41  D_NEWTON_API void SetTorqueAndRpm(ndFloat32 rpm, ndFloat32 newtonMeters);
42 
43  private:
44  void AlignMatrix();
45  void DebugJoint(ndConstraintDebugCallback&) const {}
46  void JacobianDerivative(ndConstraintDescritor& desc);
47  void Save(const ndLoadSaveBase::ndSaveDescriptor& desc) const;
48  ndFloat32 CalculateAcceleration(ndConstraintDescritor& desc);
49 
50  protected:
51  ndFloat32 m_omega;
52  ndFloat32 m_maxOmega;
53  ndFloat32 m_omegaStep;
54  ndFloat32 m_targetOmega;
55  ndFloat32 m_engineTorque;
56  ndFloat32 m_internalFriction;
57 
58  ndMultiBodyVehicle* m_vehicelModel;
59  friend class ndMultiBodyVehicle;
60  friend class ndMultiBodyVehicleGearBox;
61 };
62 
63 #endif
ndMultiBodyVehicle
Definition: ndMultiBodyVehicle.h:41
ndConstraintDescritor
Definition: ndConstraint.h:179
ndJointBilateralConstraint
Definition: ndJointBilateralConstraint.h:53
ndConstraintDebugCallback
Definition: ndConstraint.h:42
ndBodyKinematic
Definition: ndBodyKinematic.h:40
ndMultiBodyVehicleMotor
Definition: ndMultiBodyVehicleMotor.h:31
ndLoadSaveBase::ndLoadDescriptor
Definition: ndSaveLoadSytem.h:59
ndLoadSaveBase::ndSaveDescriptor
Definition: ndSaveLoadSytem.h:93
ndMultiBodyVehicleGearBox
Definition: ndMultiBodyVehicleGearBox.h:31