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")]
13 [
Attribute(
"0", UIWidgets.CheckBox,
"Whether may rotate freely (ignores limits)")]
15 [
Attribute(
"0", UIWidgets.Slider,
"Minimum rotate range in degrees (if minimum is higher than maximum, slider can rotate freely)",
"-180 0 0.01")]
17 [
Attribute(
"0", UIWidgets.Slider,
"Maximum rotate range in degrees (if minimum is higher than maximum, slider can rotate freely)",
"0 180 0.01")]
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")]
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")]
27 override void DebugDisplay()
33 vector axisVec = mat[2];
34 vector axisVec2 = mat[1];
35 vector axisVec3 = -mat[0];
39 if (m_RotateMax > m_RotateMin)
40 sliceSubDiv = Math.Ceil(Math.AbsFloat(-m_RotateMax - -m_RotateMin) / 360 * 16);
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);
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);
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);
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);
60 override void RotateJoint(inout vector jointMat[4])
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);
71 override void CreateJoint(IEntity parent, IEntity child, vector jointMat1[4], vector jointMat2[4])
74 m_Joint = PhysicsJoint.CreateSlider(parent, child, jointMat1, jointMat2, m_CollisionBlocker, -1);
75 PhysicsSliderJoint jointSlider = m_Joint;
76 jointSlider.SetLinearLimits(m_MoveMin, m_MoveMax);
78 jointSlider.SetAngularLimits(1, -1);
80 jointSlider.SetAngularLimits(-m_RotateMax * Math.DEG2RAD, -m_RotateMin * Math.DEG2RAD);