Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_JointSliderEntity.c
Go to the documentation of this file.
1[EntityEditorProps(category: "GameBase/Joints", description: "Physics joint - Slider", sizeMin: "-0.05 -0.05 -0.05", sizeMax: "0.05 0.05 0.05", color: "0 0 255 255")]
5
6//------------------------------------------------------------------------------------------------
10//------------------------------------------------------------------------------------------------
11class SCR_JointSliderEntity: SCR_JointBaseEntity
12{
13 [Attribute("0", UIWidgets.CheckBox, "Whether may rotate freely (ignores limits)")]
14 bool m_RotateIsFree;
15 [Attribute("0", UIWidgets.Slider, "Minimum rotate range in degrees (if minimum is higher than maximum, slider can rotate freely)", "-180 0 0.01")]
16 float m_RotateMin;
17 [Attribute("0", UIWidgets.Slider, "Maximum rotate range in degrees (if minimum is higher than maximum, slider can rotate freely)", "0 180 0.01")]
18 float m_RotateMax;
19 [Attribute("0", UIWidgets.Slider, "Minimum movement range in meters (if minimum is higher than maximum, slider can move along its axis freely)", "-50 0 0.01")]
20 float m_MoveMin;
21 [Attribute("0", UIWidgets.Slider, "Maximum movement range in meters (if minimum is higher than maximum, slider can move along its axis freely)", "0 50 0.01")]
22 float m_MoveMax;
23 //------------------------------------------------------------------------------------------------
24
25
26 //------------------------------------------------------------------------------------------------
27 override void DebugDisplay()
28 {
29 vector mat[4];
30 GetTransform(mat);
31 vector pos = mat[3];
32
33 vector axisVec = mat[2];
34 vector axisVec2 = mat[1];
35 vector axisVec3 = -mat[0];
36 const float addVisAng = 0; // TODO: check for good const usage
37
38 int sliceSubDiv = 16;
39 if (m_RotateMax > m_RotateMin)
40 sliceSubDiv = Math.Ceil(Math.AbsFloat(-m_RotateMax - -m_RotateMin) / 360 * 16);
41
42 CreateCircle(axisVec * m_MoveMin + pos, axisVec, 0.05, ARGB(255, 0, 255, 0), 16, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
43 CreateCircle(axisVec * m_MoveMax + pos, axisVec, 0.05, ARGB(255, 0, 255, 0), 16, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
44 if (m_RotateIsFree)
45 {
46 CreateCircle(axisVec * m_MoveMin + pos, axisVec, 0.075, ARGB(255, 0, 255, 255), 16, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
47 CreateCircle(axisVec * m_MoveMax + pos, axisVec, 0.075, ARGB(255, 0, 255, 255), 16, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
48 }
49 else
50 {
51 CreateCircleSlice(axisVec * m_MoveMin + pos, axisVec, axisVec3, -m_RotateMax + addVisAng, -m_RotateMin + addVisAng, 0.075, ARGB(255, 0, 255, 255), sliceSubDiv, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
52 CreateCircleSlice(axisVec * m_MoveMax + pos, axisVec, axisVec3, -m_RotateMax + addVisAng, -m_RotateMin + addVisAng, 0.075, ARGB(255, 0, 255, 255), sliceSubDiv, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
53 }
54 Shape.Create(ShapeType.LINE, ARGB(255, 0, 255, 0), ShapeFlags.ONCE|ShapeFlags.NOZBUFFER, axisVec * m_MoveMin + pos, axisVec * m_MoveMax + pos);
55 Shape.Create(ShapeType.LINE, ARGB(255, 0, 255, 0), ShapeFlags.ONCE|ShapeFlags.NOZBUFFER, axisVec2 * -0.05 + pos, axisVec2 * 0.05 + pos);
56 Shape.Create(ShapeType.LINE, ARGB(255, 0, 255, 0), ShapeFlags.ONCE|ShapeFlags.NOZBUFFER, axisVec3 * -0.05 + pos, axisVec3 * 0.05 + pos);
57 }
58
59 //------------------------------------------------------------------------------------------------
60 override void RotateJoint(inout vector jointMat[4])
61 {
62 vector oldJointMat[3], rotMat[3];
63 oldJointMat[0] = jointMat[0];
64 oldJointMat[1] = jointMat[1];
65 oldJointMat[2] = jointMat[2];
66 Math3D.AnglesToMatrix("-90 0 0", rotMat);
67 Math3D.MatrixMultiply3(oldJointMat, rotMat, jointMat);
68 }
69
70 //------------------------------------------------------------------------------------------------
71 override void CreateJoint(IEntity parent, IEntity child, vector jointMat1[4], vector jointMat2[4])
72 {
73 // Create the joint
74 m_Joint = PhysicsJoint.CreateSlider(parent, child, jointMat1, jointMat2, m_CollisionBlocker, -1);
75 PhysicsSliderJoint jointSlider = m_Joint;
76 jointSlider.SetLinearLimits(m_MoveMin, m_MoveMax);
77 if (m_RotateIsFree)
78 jointSlider.SetAngularLimits(1, -1);
79 else
80 jointSlider.SetAngularLimits(-m_RotateMax * Math.DEG2RAD, -m_RotateMin * Math.DEG2RAD);
81 }
82};
Shape CreateCircleSlice(vector pos, vector aroundDir, vector forwardDir, float angMin, float angMax, float radius, int color, int subdivisions, ShapeFlags flags)
Shape CreateCircle(vector pos, vector aroundDir, float radius, int color, int subdivisions, ShapeFlags flags)
Definition DebugShapes.c:91
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void IEntity(IEntitySource src, IEntity parent)
protected script Constructor
proto external void GetTransform(out vector mat[])
Definition Math.c:13
Instance of created debug visualizer.
Definition Shape.c:14
ShapeType
Definition ShapeType.c:13
ShapeFlags
Definition ShapeFlags.c:13
SCR_FieldOfViewSettings Attribute
proto int ARGB(int a, int r, int g, int b)