Kiwano Engine v1.2.x
Joint.h
1// Copyright (c) 2018-2019 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano-physics/PhysicBody.h>
23
24namespace kiwano
25{
26namespace physics
27{
28KGE_DECLARE_SMART_PTR(Joint);
29KGE_DECLARE_SMART_PTR(DistanceJoint);
30KGE_DECLARE_SMART_PTR(FrictionJoint);
31KGE_DECLARE_SMART_PTR(GearJoint);
32KGE_DECLARE_SMART_PTR(MotorJoint);
33KGE_DECLARE_SMART_PTR(MouseJoint);
34KGE_DECLARE_SMART_PTR(PrismaticJoint);
35KGE_DECLARE_SMART_PTR(PulleyJoint);
36KGE_DECLARE_SMART_PTR(RevoluteJoint);
37KGE_DECLARE_SMART_PTR(RopeJoint);
38KGE_DECLARE_SMART_PTR(WeldJoint);
39KGE_DECLARE_SMART_PTR(WheelJoint);
40
48class KGE_API Joint : public ObjectBase
49{
50public:
53 enum class Type
54 {
55 Unknown = 0,
56 Revolute,
57 Prismatic,
58 Distance,
59 Pulley,
60 Mouse,
61 Gear,
62 Wheel,
63 Weld,
64 Friction,
65 Rope,
66 Motor
67 };
68
71 struct ParamBase
72 {
75 bool collide_connected; // 关节连接的物体是否允许碰撞
76
77 ParamBase(PhysicBody* body_a, PhysicBody* body_b)
78 : body_a(body_a)
79 , body_b(body_b)
80 , collide_connected(false)
81 {
82 }
83
84 ParamBase(PhysicBodyPtr body_a, PhysicBodyPtr body_b)
85 : ParamBase(body_a.Get(), body_b.Get())
86 {
87 }
88 };
89
90 Joint();
91
92 virtual ~Joint();
93
96 virtual bool Init(PhysicWorld* world);
97
100 bool Init(PhysicWorld* world, b2JointDef* joint_def);
101
104 PhysicBodyPtr GetBodyA() const;
105
108 PhysicBodyPtr GetBodyB() const;
109
112 PhysicWorld* GetWorld() const;
113
116 void Destroy();
117
120 b2Joint* GetB2Joint() const;
121
124 void SetB2Joint(b2Joint* joint);
125
126private:
127 b2Joint* joint_;
128 PhysicWorld* world_;
129 Type type_;
130};
131
134class KGE_API DistanceJoint : public Joint
135{
136public:
139 struct Param : public Joint::ParamBase
140 {
145
146 Param()
147 : Param(nullptr, nullptr, Point(), Point())
148 {
149 }
150
151 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& anchor_a, const Point& anchor_b)
152 : ParamBase(body_a, body_b)
153 , anchor_a(anchor_a)
154 , anchor_b(anchor_b)
155 , frequency_hz(0.0f)
156 , damping_ratio(0.0f)
157 {
158 }
159 };
160
164 DistanceJoint(const Param& param);
165
168 bool Init(PhysicWorld* world) override;
169
172 void SetLength(float length);
173
176 float GetLength() const;
177
180 void SetFrequency(float hz);
181
184 float GetFrequency() const;
185
188 void SetDampingRatio(float ratio);
189
192 float GetDampingRatio() const;
193
194private:
195 Param param_;
196 b2DistanceJoint* raw_joint_;
197};
198
201class KGE_API FrictionJoint : public Joint
202{
203public:
204 struct Param : public Joint::ParamBase
205 {
207 float max_force;
209
210 Param()
211 : Param(nullptr, nullptr, Point())
212 {
213 }
214
215 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& anchor, float max_force = 0.f, float max_torque = 0.f)
216 : ParamBase(body_a, body_b)
217 , anchor(anchor)
218 , max_force(max_force)
219 , max_torque(max_torque)
220 {
221 }
222 };
223
227 FrictionJoint(const Param& param);
228
231 bool Init(PhysicWorld* world) override;
232
235 void SetMaxForce(float force);
236
239 float GetMaxForce() const;
240
243 void SetMaxTorque(float torque);
244
247 float GetMaxTorque() const;
248
249private:
250 Param param_;
251 b2FrictionJoint* raw_joint_;
252};
253
256class KGE_API GearJoint : public Joint
257{
258public:
261 struct Param : public Joint::ParamBase
262 {
265 float ratio;
266
267 Param()
268 : Param(nullptr, nullptr)
269 {
270 }
271
272 Param(JointPtr joint_a, JointPtr joint_b, float ratio = 1.f)
273 : ParamBase(nullptr, nullptr)
274 , joint_a(joint_a.Get())
275 , joint_b(joint_b.Get())
276 , ratio(ratio)
277 {
278 }
279 };
280
284 GearJoint(const Param& param);
285
288 bool Init(PhysicWorld* world) override;
289
292 void SetRatio(float ratio);
293
296 float GetRatio() const;
297
298private:
299 Param param_;
300 b2GearJoint* raw_joint_;
301};
302
305class KGE_API MotorJoint : public Joint
306{
307public:
310 struct Param : public Joint::ParamBase
311 {
312 float max_force;
315
316 Param()
317 : Param(nullptr, nullptr)
318 {
319 }
320
321 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, float max_force = 0.f, float max_torque = 0.f)
322 : ParamBase(body_a, body_b)
323 , max_force(max_force)
324 , max_torque(max_torque)
325 , correction_factor(0.3f)
326 {
327 }
328 };
329
333 MotorJoint(const Param& param);
334
337 bool Init(PhysicWorld* world) override;
338
341 void SetMaxForce(float force);
342
345 float GetMaxForce() const;
346
349 void SetMaxTorque(float torque);
350
353 float GetMaxTorque() const;
354
355private:
356 Param param_;
357 b2MotorJoint* raw_joint_;
358};
359
362class KGE_API PrismaticJoint : public Joint
363{
364public:
367 struct Param : public Joint::ParamBase
368 {
377
378 Param()
379 : Param(nullptr, nullptr, Point(), Vec2())
380 {
381 }
382
383 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& anchor, const Vec2& axis)
384 : ParamBase(body_a, body_b)
385 , anchor(anchor)
386 , axis(axis)
387 , enable_limit(false)
388 , lower_translation(0.0f)
389 , upper_translation(0.0f)
390 , enable_motor(false)
391 , max_motor_force(0.0f)
392 , motor_speed(0.0f)
393 {
394 }
395 };
396
400 PrismaticJoint(const Param& param);
401
404 bool Init(PhysicWorld* world) override;
405
408 float GetReferenceAngle() const;
409
412 float GetJointTranslation() const;
413
416 float GetJointSpeed() const;
417
420 bool IsLimitEnabled() const;
421
424 void EnableLimit(bool flag);
425
428 float GetLowerLimit() const;
429
432 float GetUpperLimit() const;
433
436 void SetLimits(float lower, float upper);
437
440 bool IsMotorEnabled() const;
441
444 void EnableMotor(bool flag);
445
448 void SetMotorSpeed(float speed);
449
452 float GetMotorSpeed() const;
453
456 void SetMaxMotorForce(float force);
457
460 float GetMaxMotorForce() const;
461
462private:
463 Param param_;
464 b2PrismaticJoint* raw_joint_;
465};
466
469class KGE_API PulleyJoint : public Joint
470{
471public:
474 struct Param : public Joint::ParamBase
475 {
480 float ratio;
481
482 Param()
483 : Param(nullptr, nullptr, Point(), Point(), Point(), Point())
484 {
485 }
486
487 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& anchor_a, const Point& anchor_b,
488 const Point& ground_anchor_a, const Point& ground_anchor_b, float ratio = 1.0f)
489 : ParamBase(body_a, body_b)
490 , anchor_a(anchor_a)
491 , anchor_b(anchor_b)
492 , ground_anchor_a(ground_anchor_a)
493 , ground_anchor_b(ground_anchor_b)
494 , ratio(ratio)
495 {
496 }
497 };
498
502 PulleyJoint(const Param& param);
503
506 bool Init(PhysicWorld* world) override;
507
510 Point GetGroundAnchorA() const;
511
514 Point GetGroundAnchorB() const;
515
518 float GetRatio() const;
519
522 float GetLengthA() const;
523
526 float GetLengthB() const;
527
530 float GetCurrentLengthA() const;
531
534 float GetCurrentLengthB() const;
535
536private:
537 Param param_;
538 b2PulleyJoint* raw_joint_;
539};
540
543class KGE_API RevoluteJoint : public Joint
544{
545public:
548 struct Param : public Joint::ParamBase
549 {
557
558 Param()
559 : Param(nullptr, nullptr, Point())
560 {
561 }
562
563 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& anchor)
564 : ParamBase(body_a, body_b)
565 , anchor(anchor)
566 , enable_limit(false)
567 , lower_angle(0.0f)
568 , upper_angle(0.0f)
569 , enable_motor(false)
570 , max_motor_torque(0.0f)
571 , motor_speed(0.0f)
572 {
573 }
574 };
575
579 RevoluteJoint(const Param& param);
580
583 bool Init(PhysicWorld* world) override;
584
587 float GetReferenceAngle() const;
588
591 float GetJointAngle() const;
592
595 float GetJointSpeed() const;
596
599 bool IsLimitEnabled() const;
600
603 void EnableLimit(bool flag);
604
607 float GetLowerLimit() const;
608
611 float GetUpperLimit() const;
612
615 void SetLimits(float lower, float upper);
616
619 bool IsMotorEnabled() const;
620
623 void EnableMotor(bool flag);
624
627 void SetMotorSpeed(float speed);
628
631 float GetMotorSpeed() const;
632
635 void SetMaxMotorTorque(float torque);
636
639 float GetMaxMotorTorque() const;
640
641private:
642 Param param_;
643 b2RevoluteJoint* raw_joint_;
644};
645
648class KGE_API RopeJoint : public Joint
649{
650public:
653 struct Param : public Joint::ParamBase
654 {
658
659 Param()
660 : Param(nullptr, nullptr, Point(), Point())
661 {
662 }
663
664 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& local_anchor_a, const Point& local_anchor_b)
665 : ParamBase(body_a, body_b)
666 , local_anchor_a(local_anchor_a)
667 , local_anchor_b(local_anchor_b)
668 , max_length(0.0f)
669 {
670 }
671 };
672
676 RopeJoint(const Param& param);
677
680 bool Init(PhysicWorld* world) override;
681
684 void SetMaxLength(float length);
685
688 float GetMaxLength() const;
689
690private:
691 Param param_;
692 b2RopeJoint* raw_joint_;
693};
694
697class KGE_API WeldJoint : public Joint
698{
699public:
702 struct Param : public Joint::ParamBase
703 {
707
708 Param()
709 : Param(nullptr, nullptr, Point())
710 {
711 }
712
713 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& anchor)
714 : ParamBase(body_a, body_b)
715 , anchor(anchor)
716 , frequency_hz(0.0f)
717 , damping_ratio(0.0f)
718 {
719 }
720 };
721
725 WeldJoint(const Param& param);
726
729 bool Init(PhysicWorld* world) override;
730
733 float GetReferenceAngle() const;
734
737 void SetFrequency(float hz);
738
741 float GetFrequency() const;
742
745 void SetDampingRatio(float ratio);
746
749 float GetDampingRatio() const;
750
751private:
752 Param param_;
753 b2WeldJoint* raw_joint_;
754};
755
758class KGE_API WheelJoint : public Joint
759{
760public:
763 struct Param : public Joint::ParamBase
764 {
772
773 Param()
774 : Param(nullptr, nullptr, Point(), Vec2())
775 {
776 }
777
778 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& anchor, const Vec2& axis)
779 : ParamBase(body_a, body_b)
780 , anchor(anchor)
781 , axis(axis)
782 , enable_motor(false)
783 , max_motor_torque(0.0f)
784 , motor_speed(0.0f)
785 , frequency_hz(2.0f)
786 , damping_ratio(0.7f)
787 {
788 }
789 };
790
794 WheelJoint(const Param& param);
795
798 bool Init(PhysicWorld* world) override;
799
802 float GetJointTranslation() const;
803
806 float GetJointLinearSpeed() const;
807
810 float GetJointAngle() const;
811
814 float GetJointAngularSpeed() const;
815
818 bool IsMotorEnabled() const;
819
822 void EnableMotor(bool flag);
823
826 void SetMotorSpeed(float speed);
827
830 float GetMotorSpeed() const;
831
834 void SetMaxMotorTorque(float torque);
835
838 float GetMaxMotorTorque() const;
839
842 void SetSpringFrequencyHz(float hz);
843
846 float GetSpringFrequencyHz() const;
847
850 void SetSpringDampingRatio(float ratio);
851
854 float GetSpringDampingRatio() const;
855
856private:
857 Param param_;
858 b2WheelJoint* raw_joint_;
859};
860
864class KGE_API MouseJoint : public Joint
865{
866public:
869 struct Param : public Joint::ParamBase
870 {
872 float max_force;
875
876 Param()
877 : Param(nullptr, nullptr, Point())
878 {
879 }
880
881 Param(PhysicBodyPtr body_a, PhysicBodyPtr body_b, const Point& target)
882 : ParamBase(body_a, body_b)
883 , target(target)
884 , max_force(0.0f)
885 , frequency_hz(5.0f)
886 , damping_ratio(0.7f)
887 {
888 }
889 };
890
894 MouseJoint(const Param& param);
895
898 bool Init(PhysicWorld* world) override;
899
902 void SetMaxForce(float force);
903
906 float GetMaxForce() const;
907
910 void SetFrequency(float hz);
911
914 float GetFrequency() const;
915
918 void SetDampingRatio(float ratio);
919
922 float GetDampingRatio() const;
923
924private:
925 Param param_;
926 b2MouseJoint* raw_joint_;
927};
928
931inline b2Joint* Joint::GetB2Joint() const
932{
933 return joint_;
934}
936{
937 return world_;
938}
939
940inline void DistanceJoint::SetFrequency(float hz)
941{
942 KGE_ASSERT(raw_joint_);
943 raw_joint_->SetFrequency(hz);
944}
945inline float DistanceJoint::GetFrequency() const
946{
947 KGE_ASSERT(raw_joint_);
948 return raw_joint_->GetFrequency();
949}
950inline void DistanceJoint::SetDampingRatio(float ratio)
951{
952 KGE_ASSERT(raw_joint_);
953 raw_joint_->SetDampingRatio(ratio);
954}
956{
957 KGE_ASSERT(raw_joint_);
958 return raw_joint_->GetDampingRatio();
959}
960
962{
963 KGE_ASSERT(raw_joint_);
964 return math::Radian2Degree(raw_joint_->GetReferenceAngle());
965}
967{
968 KGE_ASSERT(raw_joint_);
969 return raw_joint_->IsLimitEnabled();
970}
971inline void PrismaticJoint::EnableLimit(bool flag)
972{
973 KGE_ASSERT(raw_joint_);
974 raw_joint_->EnableLimit(flag);
975}
977{
978 KGE_ASSERT(raw_joint_);
979 return raw_joint_->IsMotorEnabled();
980}
981inline void PrismaticJoint::EnableMotor(bool flag)
982{
983 KGE_ASSERT(raw_joint_);
984 raw_joint_->EnableMotor(flag);
985}
986inline void PrismaticJoint::SetMotorSpeed(float speed)
987{
988 KGE_ASSERT(raw_joint_);
989 raw_joint_->SetMotorSpeed(math::Degree2Radian(speed));
990}
992{
993 KGE_ASSERT(raw_joint_);
994 return math::Radian2Degree(raw_joint_->GetMotorSpeed());
995}
996inline void PrismaticJoint::SetMaxMotorForce(float force)
997{
998 KGE_ASSERT(raw_joint_);
999 raw_joint_->SetMaxMotorForce(force);
1000}
1002{
1003 KGE_ASSERT(raw_joint_);
1004 return raw_joint_->GetMaxMotorForce();
1005}
1006
1008{
1009 KGE_ASSERT(raw_joint_);
1010 return math::Radian2Degree(raw_joint_->GetReferenceAngle());
1011}
1013{
1014 KGE_ASSERT(raw_joint_);
1015 return raw_joint_->IsLimitEnabled();
1016}
1017inline void RevoluteJoint::EnableLimit(bool flag)
1018{
1019 KGE_ASSERT(raw_joint_);
1020 raw_joint_->EnableLimit(flag);
1021}
1023{
1024 KGE_ASSERT(raw_joint_);
1025 return raw_joint_->IsMotorEnabled();
1026}
1027inline void RevoluteJoint::EnableMotor(bool flag)
1028{
1029 KGE_ASSERT(raw_joint_);
1030 raw_joint_->EnableMotor(flag);
1031}
1032inline void RevoluteJoint::SetMotorSpeed(float speed)
1033{
1034 KGE_ASSERT(raw_joint_);
1035 raw_joint_->SetMotorSpeed(math::Degree2Radian(speed));
1036}
1038{
1039 KGE_ASSERT(raw_joint_);
1040 return math::Radian2Degree(raw_joint_->GetMotorSpeed());
1041}
1042
1044{
1045 KGE_ASSERT(raw_joint_);
1046 return math::Radian2Degree(raw_joint_->GetReferenceAngle());
1047}
1048inline void WeldJoint::SetFrequency(float hz)
1049{
1050 KGE_ASSERT(raw_joint_);
1051 raw_joint_->SetFrequency(hz);
1052}
1053inline float WeldJoint::GetFrequency() const
1054{
1055 KGE_ASSERT(raw_joint_);
1056 return raw_joint_->GetFrequency();
1057}
1058inline void WeldJoint::SetDampingRatio(float ratio)
1059{
1060 KGE_ASSERT(raw_joint_);
1061 raw_joint_->SetDampingRatio(ratio);
1062}
1063inline float WeldJoint::GetDampingRatio() const
1064{
1065 KGE_ASSERT(raw_joint_);
1066 return raw_joint_->GetDampingRatio();
1067}
1068
1069inline float WheelJoint::GetJointAngle() const
1070{
1071 KGE_ASSERT(raw_joint_);
1072 return math::Radian2Degree(raw_joint_->GetJointAngle());
1073}
1075{
1076 KGE_ASSERT(raw_joint_);
1077 return math::Radian2Degree(raw_joint_->GetJointAngularSpeed());
1078}
1080{
1081 KGE_ASSERT(raw_joint_);
1082 return raw_joint_->IsMotorEnabled();
1083}
1084inline void WheelJoint::EnableMotor(bool flag)
1085{
1086 KGE_ASSERT(raw_joint_);
1087 raw_joint_->EnableMotor(flag);
1088}
1089inline void WheelJoint::SetMotorSpeed(float speed)
1090{
1091 KGE_ASSERT(raw_joint_);
1092 raw_joint_->SetMotorSpeed(math::Degree2Radian(speed));
1093}
1094inline float WheelJoint::GetMotorSpeed() const
1095{
1096 KGE_ASSERT(raw_joint_);
1097 return math::Radian2Degree(raw_joint_->GetMotorSpeed());
1098}
1100{
1101 KGE_ASSERT(raw_joint_);
1102 raw_joint_->SetSpringFrequencyHz(hz);
1103}
1105{
1106 KGE_ASSERT(raw_joint_);
1107 return raw_joint_->GetSpringFrequencyHz();
1108}
1110{
1111 KGE_ASSERT(raw_joint_);
1112 raw_joint_->SetSpringDampingRatio(ratio);
1113}
1115{
1116 KGE_ASSERT(raw_joint_);
1117 return raw_joint_->GetSpringDampingRatio();
1118}
1119
1120inline void MouseJoint::SetFrequency(float hz)
1121{
1122 KGE_ASSERT(raw_joint_);
1123 raw_joint_->SetFrequency(hz);
1124}
1125inline float MouseJoint::GetFrequency() const
1126{
1127 KGE_ASSERT(raw_joint_);
1128 return raw_joint_->GetFrequency();
1129}
1130inline void MouseJoint::SetDampingRatio(float ratio)
1131{
1132 KGE_ASSERT(raw_joint_);
1133 raw_joint_->SetDampingRatio(ratio);
1134}
1136{
1137 KGE_ASSERT(raw_joint_);
1138 return raw_joint_->GetDampingRatio();
1139}
1140} // namespace physics
1141} // namespace kiwano
基础对象
Definition: ObjectBase.h:137
固定距离关节
Definition: Joint.h:135
void SetFrequency(float hz)
设置弹簧响应速度 [赫兹]
Definition: Joint.h:940
float GetFrequency() const
获取弹簧响应速度 [赫兹]
Definition: Joint.h:945
float GetDampingRatio() const
获取阻尼率
Definition: Joint.h:955
void SetDampingRatio(float ratio)
设置阻尼率
Definition: Joint.h:950
摩擦关节
Definition: Joint.h:202
齿轮关节
Definition: Joint.h:257
关节
Definition: Joint.h:49
PhysicWorld * GetWorld() const
获取物理世界
Definition: Joint.h:935
Type
关节类型
Definition: Joint.h:54
b2Joint * GetB2Joint() const
获取b2Joint
Definition: Joint.h:931
马达关节
Definition: Joint.h:306
鼠标关节
Definition: Joint.h:865
void SetDampingRatio(float ratio)
设置阻尼率
Definition: Joint.h:1130
float GetDampingRatio() const
获取阻尼率
Definition: Joint.h:1135
float GetFrequency() const
获取响应速度 [hz]
Definition: Joint.h:1125
void SetFrequency(float hz)
设置响应速度 [hz]
Definition: Joint.h:1120
物体
Definition: PhysicBody.h:40
物理世界
Definition: PhysicWorld.h:45
平移关节
Definition: Joint.h:363
void SetMaxMotorForce(float force)
设置最大马达力 [N]
Definition: Joint.h:996
float GetMaxMotorForce() const
获取最大马达力 [N]
Definition: Joint.h:1001
bool IsMotorEnabled() const
是否启用马达
Definition: Joint.h:976
bool IsLimitEnabled() const
是否启用关节限制
Definition: Joint.h:966
float GetMotorSpeed() const
获取马达转速 [degree/s]
Definition: Joint.h:991
float GetReferenceAngle() const
获取参考角
Definition: Joint.h:961
void EnableMotor(bool flag)
设置是否启用马达
Definition: Joint.h:981
void EnableLimit(bool flag)
设置是否启用关节限制
Definition: Joint.h:971
void SetMotorSpeed(float speed)
设置马达转速 [degree/s]
Definition: Joint.h:986
滑轮关节
Definition: Joint.h:470
旋转关节
Definition: Joint.h:544
bool IsMotorEnabled() const
是否启用马达
Definition: Joint.h:1022
float GetMotorSpeed() const
获取马达转速 [degree/s]
Definition: Joint.h:1037
bool IsLimitEnabled() const
是否启用关节限制
Definition: Joint.h:1012
void EnableLimit(bool flag)
设置是否启用关节限制
Definition: Joint.h:1017
float GetReferenceAngle() const
获取参考角
Definition: Joint.h:1007
void EnableMotor(bool flag)
设置是否启用马达
Definition: Joint.h:1027
void SetMotorSpeed(float speed)
设置马达转速 [degree/s]
Definition: Joint.h:1032
绳关节
Definition: Joint.h:649
焊接关节
Definition: Joint.h:698
float GetDampingRatio() const
获取阻尼率
Definition: Joint.h:1063
float GetReferenceAngle() const
获取物体B相对于物体A的角度
Definition: Joint.h:1043
void SetDampingRatio(float ratio)
设置阻尼率
Definition: Joint.h:1058
void SetFrequency(float hz)
设置弹簧响应速度 [赫兹]
Definition: Joint.h:1048
float GetFrequency() const
获取弹簧响应速度 [赫兹]
Definition: Joint.h:1053
轮关节
Definition: Joint.h:759
float GetSpringFrequencyHz() const
获取弹簧响应速度
Definition: Joint.h:1104
float GetSpringDampingRatio() const
获取弹簧阻尼率
Definition: Joint.h:1114
float GetJointAngle() const
获取关节当前的角度
Definition: Joint.h:1069
float GetJointAngularSpeed() const
获取关节当前的旋转速度
Definition: Joint.h:1074
void SetSpringFrequencyHz(float hz)
设置弹簧响应速度
Definition: Joint.h:1099
float GetMotorSpeed() const
获取马达转速 [degree/s]
Definition: Joint.h:1094
void SetMotorSpeed(float speed)
设置马达转速 [degree/s]
Definition: Joint.h:1089
void SetSpringDampingRatio(float ratio)
设置弹簧阻尼率
Definition: Joint.h:1109
void EnableMotor(bool flag)
设置是否启用马达
Definition: Joint.h:1084
bool IsMotorEnabled() const
是否启用马达
Definition: Joint.h:1079
固定距离关节参数
Definition: Joint.h:140
float damping_ratio
阻尼率,值越大关节运动阻尼越大
Definition: Joint.h:144
Point anchor_b
关节在物体B上的连接点
Definition: Joint.h:142
Point anchor_a
关节在物体A上的连接点
Definition: Joint.h:141
float frequency_hz
响应速度,数值越高关节响应的速度越快,看上去越坚固
Definition: Joint.h:143
float max_force
最大摩擦力
Definition: Joint.h:207
Point anchor
摩擦作用点
Definition: Joint.h:206
float max_torque
最大扭力
Definition: Joint.h:208
齿轮关节参数
Definition: Joint.h:262
float ratio
齿轮传动比
Definition: Joint.h:265
Joint * joint_b
关节B(旋转关节/平移关节)
Definition: Joint.h:264
Joint * joint_a
关节A(旋转关节/平移关节)
Definition: Joint.h:263
关节基础参数
Definition: Joint.h:72
PhysicBody * body_a
关节连接的物体A
Definition: Joint.h:73
PhysicBody * body_b
关节连接的物体B
Definition: Joint.h:74
马达关节参数
Definition: Joint.h:311
float max_force
最大摩擦力
Definition: Joint.h:312
float max_torque
最大转矩
Definition: Joint.h:313
float correction_factor
位置矫正因子(范围 0-1)
Definition: Joint.h:314
鼠标关节参数
Definition: Joint.h:870
float frequency_hz
响应速度,数值越高关节响应的速度越快,看上去越坚固
Definition: Joint.h:873
Point target
关节作用目标位置
Definition: Joint.h:871
float max_force
作用在物体A上的最大力
Definition: Joint.h:872
float damping_ratio
阻尼率,值越大关节运动阻尼越大
Definition: Joint.h:874
平移关节参数
Definition: Joint.h:368
Vec2 axis
物体A滑动的方向
Definition: Joint.h:370
float max_motor_force
最大马达力 [N]
Definition: Joint.h:375
Point anchor
关节位置
Definition: Joint.h:369
float lower_translation
移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
Definition: Joint.h:372
float motor_speed
马达转速 [degree/s]
Definition: Joint.h:376
float upper_translation
移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
Definition: Joint.h:373
bool enable_limit
是否启用限制
Definition: Joint.h:371
bool enable_motor
是否启用马达
Definition: Joint.h:374
滑轮关节参数
Definition: Joint.h:475
float ratio
滑轮比,关节传动时,滑轮上升和下降的两头的位移比例
Definition: Joint.h:480
Point anchor_a
关节在物体A上的作用点
Definition: Joint.h:476
Point ground_anchor_b
物体B对应的滑轮的位置
Definition: Joint.h:479
Point anchor_b
关节在物体B上的作用点
Definition: Joint.h:477
Point ground_anchor_a
物体A对应的滑轮的位置
Definition: Joint.h:478
旋转关节参数
Definition: Joint.h:549
float motor_speed
马达转速 [degree/s]
Definition: Joint.h:556
Point anchor
关节位置
Definition: Joint.h:550
bool enable_motor
是否启用马达
Definition: Joint.h:554
bool enable_limit
是否启用限制
Definition: Joint.h:551
float upper_angle
移动的最大限制,与方向同向为正,反向为负,启用限制后才有效果
Definition: Joint.h:553
float lower_angle
移动的最小限制,与方向同向为正,反向为负,启用限制后才有效果
Definition: Joint.h:552
float max_motor_torque
最大马达力 [N]
Definition: Joint.h:555
绳关节参数
Definition: Joint.h:654
float max_length
绳索最大长度
Definition: Joint.h:657
Point local_anchor_b
关节在物体B上的连接点
Definition: Joint.h:656
Point local_anchor_a
关节在物体A上的连接点
Definition: Joint.h:655
焊接关节参数
Definition: Joint.h:703
float frequency_hz
响应速度,数值越高关节响应的速度越快,看上去越坚固
Definition: Joint.h:705
float damping_ratio
阻尼率,值越大关节运动阻尼越大
Definition: Joint.h:706
Point anchor
焊接位置
Definition: Joint.h:704
轮关节参数
Definition: Joint.h:764
float max_motor_torque
最大马达力 [N]
Definition: Joint.h:768
float damping_ratio
弹簧阻尼率,值越大关节运动阻尼越大
Definition: Joint.h:771
float motor_speed
马达转速 [degree/s]
Definition: Joint.h:769
Vec2 axis
物体A滑动方向
Definition: Joint.h:766
bool enable_motor
是否启用马达
Definition: Joint.h:767
Point anchor
轮关节位置
Definition: Joint.h:765
float frequency_hz
响应速度,数值越高关节响应的速度越快,看上去越坚固
Definition: Joint.h:770