Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_JointConeTwistEntity.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameBase/Joints", description: "Physics joint - Cone Twist", sizeMin: "-0.05 -0.05 -0.05", sizeMax: "0.05 0.05 0.05", color: "0 0 255 255")]
3 {
4 };
5 
6 //------------------------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------------------------
12 {
13  [Attribute("0", UIWidgets.Slider, "Yaw swing range in degrees", "0 180 0.01")]
14  float m_SwingSpanYaw;
15  [Attribute("0", UIWidgets.Slider, "Pitch swing range in degrees", "0 180 0.01")]
16  float m_SwingSpanPitch;
17  [Attribute("0", UIWidgets.Slider, "Twist range in degrees (if below zero, can twist freely)", "-1 180 0.01")]
18  float m_TwistSpan;
19  [Attribute("0.5", UIWidgets.Slider, "Percentage of limits where movement is free, above this the limit is gradually enforced", "0 1 0.001")]
20  float m_Softness;
21  [Attribute("0.3", UIWidgets.Slider, "The strength with which the constraint resists limit violations", "0 1 0.001")]
22  float m_BiasFactor;
23  [Attribute("1", UIWidgets.Slider, "The lower the values, the less the constraint will fight velocities which violate the angular limits", "0 1 0.001")]
24  float m_RelaxationFactor;
25 
26  //------------------------------------------------------------------------------------------------
27 
28 
29  //------------------------------------------------------------------------------------------------
30  override void DebugDisplay()
31  {
32  vector mat[4];
33  GetTransform(mat);
34  vector pos = mat[3];
35 
36  vector axisVec = mat[2];
37  vector axisVec2 = mat[1];
38  vector axisVec3 = mat[0];
39 
40  int coneSubDiv = Math.Ceil(Math.AbsFloat(Math.Sin((m_SwingSpanYaw + m_SwingSpanPitch) / 2 * Math.DEG2RAD)) * 50);
41  int sliceSubDiv = 16;
42  if (m_TwistSpan > 0)
43  sliceSubDiv = Math.Ceil(m_TwistSpan / 360 * 16);
44 
45  CreateCone(pos, axisVec, m_SwingSpanYaw, m_SwingSpanPitch, 0.05, ARGB(255, 0, 255, 0), coneSubDiv, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
46  if (m_TwistSpan < 0)
47  CreateCircleSlice(pos, axisVec, -axisVec3, -1, 1, 0.075, ARGB(255, 0, 255, 255), sliceSubDiv, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
48  else
49  CreateCircleSlice(pos, axisVec, -axisVec3, 0, m_TwistSpan, 0.075, ARGB(255, 0, 255, 255), sliceSubDiv, ShapeFlags.ONCE|ShapeFlags.NOZBUFFER);
50  Shape.Create(ShapeType.LINE, ARGB(255, 0, 255, 0), ShapeFlags.ONCE|ShapeFlags.NOZBUFFER, axisVec * -0.05 + pos, axisVec * 0.05 + pos);
51  Shape.Create(ShapeType.LINE, ARGB(255, 0, 255, 0), ShapeFlags.ONCE|ShapeFlags.NOZBUFFER, axisVec2 * -0.05 + pos, axisVec2 * 0.05 + pos);
52  Shape.Create(ShapeType.LINE, ARGB(255, 0, 255, 0), ShapeFlags.ONCE|ShapeFlags.NOZBUFFER, axisVec3 * -0.05 + pos, axisVec3 * 0.05 + pos);
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  override void RotateJoint(inout vector jointMat[4])
57  {
58  vector oldJointMat[3], rotMat[3];
59  oldJointMat[0] = jointMat[0];
60  oldJointMat[1] = jointMat[1];
61  oldJointMat[2] = jointMat[2];
62  Math3D.AnglesToMatrix("-90 0 0", rotMat);
63  Math3D.MatrixMultiply3(oldJointMat, rotMat, jointMat);
64  }
65 
66  //------------------------------------------------------------------------------------------------
67  override void CreateJoint(IEntity parent, IEntity child, vector jointMat1[4], vector jointMat2[4])
68  {
69  // Create the joint
70  m_Joint = PhysicsJoint.CreateConeTwist(parent, child, jointMat1, jointMat2, m_CollisionBlocker, -1);
71  PhysicsConeTwistJoint jointConeTwist = m_Joint;
72  jointConeTwist.SetLimits(m_SwingSpanPitch * Math.DEG2RAD, m_SwingSpanYaw * Math.DEG2RAD, m_TwistSpan * Math.DEG2RAD, m_Softness, m_BiasFactor, m_RelaxationFactor);
73  }
74 };
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_JointConeTwistEntityClass
Definition: SCR_JointConeTwistEntity.c:2
SCR_JointConeTwistEntity
Definition: SCR_JointConeTwistEntity.c:11
SCR_JointBaseEntityClass
Definition: SCR_JointBaseEntity.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_JointBaseEntity
Definition: SCR_JointBaseEntity.c:11
CreateCircleSlice
Shape CreateCircleSlice(vector pos, vector aroundDir, vector forwardDir, float angMin, float angMax, float radius, int color, int subdivisions, ShapeFlags flags)
Definition: DebugShapes.c:165
CreateCone
Shape CreateCone(vector pos, vector aroundDir, float coneAngX, float coneAngY, float coneLength, int color, int subdivisions, ShapeFlags flags)
Definition: DebugShapes.c:30
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180