16 float m_SwingSpanPitch;
17 [
Attribute(
"0",
UIWidgets.Slider,
"Twist range in degrees (if below zero, can twist freely)",
"-1 180 0.01")]
19 [
Attribute(
"0.5",
UIWidgets.Slider,
"Percentage of limits where movement is free, above this the limit is gradually enforced",
"0 1 0.001")]
21 [
Attribute(
"0.3",
UIWidgets.Slider,
"The strength with which the constraint resists limit violations",
"0 1 0.001")]
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;
30 override void DebugDisplay()
40 int coneSubDiv =
Math.Ceil(
Math.AbsFloat(
Math.Sin((m_SwingSpanYaw + m_SwingSpanPitch) / 2 *
Math.DEG2RAD)) * 50);
43 sliceSubDiv =
Math.Ceil(m_TwistSpan / 360 * 16);
45 CreateCone(pos, axisVec, m_SwingSpanYaw, m_SwingSpanPitch, 0.05,
ARGB(255, 0, 255, 0), coneSubDiv,
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
47 CreateCircleSlice(pos, axisVec, -axisVec3, -1, 1, 0.075,
ARGB(255, 0, 255, 255), sliceSubDiv,
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
49 CreateCircleSlice(pos, axisVec, -axisVec3, 0, m_TwistSpan, 0.075,
ARGB(255, 0, 255, 255), sliceSubDiv,
ShapeFlags.ONCE|
ShapeFlags.NOZBUFFER);
56 override void RotateJoint(inout
vector jointMat[4])
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);
70 m_Joint =
PhysicsJoint.CreateConeTwist(parent, child, jointMat1, jointMat2, m_CollisionBlocker, -1);
72 jointConeTwist.SetLimits(m_SwingSpanPitch *
Math.DEG2RAD, m_SwingSpanYaw *
Math.DEG2RAD, m_TwistSpan *
Math.DEG2RAD, m_Softness, m_BiasFactor, m_RelaxationFactor);
Shape CreateCone(vector pos, vector aroundDir, float coneAngX, float coneAngY, float coneLength, int color, int subdivisions, ShapeFlags flags)
Shape CreateCircleSlice(vector pos, vector aroundDir, vector forwardDir, float angMin, float angMax, float radius, int color, int subdivisions, ShapeFlags flags)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.