summaryrefslogtreecommitdiff
path: root/Runtime/Dynamics/CharacterJoint.h
blob: ce941550534ffc091b7fee979e2fa14f3670d0b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef CHARACTERJOINT_H
#define CHARACTERJOINT_H

#include "Runtime/BaseClasses/GameObject.h"
#include "Runtime/Math/Vector3.h"
#include "Runtime/Math/Quaternion.h"
#include "JointDescriptions.h"
#include "Joint.h"
class Rigidbody;
class NxJointDesc;
class NxRevoluteJoint;

namespace Unity
{

class CharacterJoint : public Joint
{
	public:
	
	REGISTER_DERIVED_CLASS (CharacterJoint, Joint)
	DECLARE_OBJECT_SERIALIZE (CharacterJoint)

	CharacterJoint (MemLabelId label, ObjectCreationMode mode);
	
	JointDrive GetRotationDrive ();
	void SetRotationDrive (const JointDrive& drive);

	void SetTargetRotation (const Quaternionf& rot); 
	Quaternionf GetTargetRotation (); 

	void SetTargetAngularVelocity (const Vector3f& angular); 
	Vector3f GetTargetAngularVelocity ();

	virtual void ApplySetupAxesToDesc (int option);

	virtual void SetSwingAxis (const Vector3f& axis);
	Vector3f GetSwingAxis () { return m_SwingAxis; }
	
	void SetLowTwistLimit (const SoftJointLimit& limit);
	SoftJointLimit GetLowTwistLimit () { return m_LowTwistLimit; }

	void SetHighTwistLimit (const SoftJointLimit& limit);
	SoftJointLimit GetHighTwistLimit () { return m_HighTwistLimit; }

	void SetSwing1Limit (const SoftJointLimit& limit);
	SoftJointLimit GetSwing1Limit () { return m_Swing1Limit; }

	void SetSwing2Limit (const SoftJointLimit& limit);
	SoftJointLimit GetSwing2Limit () { return m_Swing2Limit; }
	
	virtual void Reset();

	void UpdateTargetRotation ();
	virtual void CheckConsistency ();
	
	////// THIS IS NOT GOOD!!!!!!!!!!!
	void CalculateGlobalHingeSpace (Vector3f& globalAnchor, Vector3f& globalAxis, Vector3f& globalNormal) const;

	private:

	virtual void Create ();
	void SetupDriveType ();

	bool           m_UseTargetRotation;
	Quaternionf    m_TargetRotation;
	Vector3f       m_TargetAngularVelocity;
	
	mutable Quaternionf    m_ConfigurationSpace;
	
	////// THIS IS NOT GOOD!!!!!!!!!!!
	Vector3f       m_SwingAxis;
	
	JointDrive     m_RotationDrive;
	
	SoftJointLimit m_LowTwistLimit;
	SoftJointLimit m_HighTwistLimit;
	SoftJointLimit m_Swing1Limit;
	SoftJointLimit m_Swing2Limit;
};

}

#endif