载入中...
搜索中...
未找到
Mechanism3D.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4#include <string>
5
6namespace eve::physics {
7
8class Body3D;
9class Joint3D;
10class World3D;
11
26public:
28 enum class Kind { CrankSlider, Shaft, Ratchet };
29
30 Mechanism3D(const Mechanism3D &) = delete;
31 Mechanism3D &operator=(const Mechanism3D &) = delete;
32
34 int getId() const { return id_; }
36 std::string getKind() const;
38 World3D *getWorld() const { return world_; }
40 bool isValid() const;
41
48 Joint3D *getDriveJoint() const { return drive_; }
55 Joint3D *getCrankPinJoint() const { return crankPin_; }
62 Joint3D *getSliderPinJoint() const { return sliderPin_; }
69 Joint3D *getSliderJoint() const { return slider_; }
70
72 float getDriveAngle() const;
74 float getSliderTranslation() const;
76 float getSpinSpeed() const;
77
84 void setDrive(float speed, float maxTorque);
86 void clearDrive();
88 bool isDriveEnabled() const { return driveEnabled_; }
89
94 void setRatchetDirection(int direction);
96 int getRatchetDirection() const { return ratchetDirection_; }
101 void setRatchetEngagementTorque(float torque);
103 float getRatchetEngagementTorque() const { return engagementTorque_; }
104
106 void destroy();
108 void invalidate();
110 void syncBeforeStep();
111
112 ~Mechanism3D();
113
114private:
115 friend class World3D;
116
117 Mechanism3D(World3D *world, Kind kind, int id, Joint3D *drive, Joint3D *crankPin, Joint3D *sliderPin,
118 Joint3D *slider, float axisX, float axisY, float axisZ, int ratchetDirection,
119 float engagementTorque);
120
121 void requireKind(Kind expected, const char *operation) const;
122 float axisSpinSpeed() const;
123
124 World3D *world_ = nullptr;
125 Kind kind_ = Kind::Shaft;
126 int id_ = 0;
127 Joint3D *drive_ = nullptr;
128 Joint3D *crankPin_ = nullptr;
129 Joint3D *sliderPin_ = nullptr;
130 Joint3D *slider_ = nullptr;
131 float axisX_ = 0.f, axisY_ = 0.f, axisZ_ = 1.f;
132 bool driveEnabled_ = false;
133 float driveSpeed_ = 0.f;
134 float driveMaxTorque_ = 0.f;
135 int ratchetDirection_ = 1;
136 float engagementTorque_ = 0.f;
137};
138
139} // namespace eve::physics
ActionParameterOperation operation
#define EVENGINE_API_WORLD
Definition Export.h:109
void(* destroy)(void *)
TokenKind kind
World3D * world
RoadLaneDirection direction
float axisZ
Definition RockMesh.cpp:22
float axisY
Definition RockMesh.cpp:22
float axisX
Definition RockMesh.cpp:22
Script-facing Box3D joint owned by a World3D.
Definition Joint3D.h:17
Composed mechanical assembly owned by a World3D.
Definition Mechanism3D.h:25
Mechanism3D(const Mechanism3D &)=delete
Joint3D * getCrankPinJoint() const
Crank-to-rod revolute, or null for shaft/ratchet.
Definition Mechanism3D.h:55
Joint3D * getSliderPinJoint() const
Rod-to-slider revolute, or null for shaft/ratchet.
Definition Mechanism3D.h:62
int getId() const
Stable world-local identifier.
Definition Mechanism3D.h:34
int getRatchetDirection() const
Current ratchet freewheel direction (+1 or -1).
Definition Mechanism3D.h:96
float getRatchetEngagementTorque() const
Current ratchet engagement torque in newton-metres.
bool isDriveEnabled() const
Whether a continuous drive motor is configured.
Definition Mechanism3D.h:88
Joint3D * getDriveJoint() const
Primary revolute (crank / shaft / ratchet wheel).
Definition Mechanism3D.h:48
World3D * getWorld() const
Owning world, or null after invalidation.
Definition Mechanism3D.h:38
Joint3D * getSliderJoint() const
Frame-to-slider prismatic, or null for shaft/ratchet.
Definition Mechanism3D.h:69
Mechanism3D & operator=(const Mechanism3D &)=delete
Box3D rigid-body world. Script coordinates are meters (Box3D native), unlike 2D World which uses pixe...
Definition World3D.h:63
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36