public override void OnApplyForceAndTorque(float timestep) { if (Input.GetKey(KeyCode.UpArrow)) { body.GetBody().AddForce(force.x * body.m_mass, force.y * body.m_mass, force.z * body.m_mass); } else if (Input.GetKey(KeyCode.DownArrow)) { body.GetBody().AddForce(-force.x * body.m_mass, -force.y * body.m_mass, -force.z * body.m_mass); } }
public override void OnApplyForceAndTorque(float timestep) { if (timer > 0) { body.GetBody().AddForce(force.x, force.y, force.z); } }
public override void Create() { NewtonBody child = GetComponent <NewtonBody>(); dMatrix matrix = Utils.ToMatrix(m_posit, Quaternion.Euler(m_rotation)); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); m_joint = new dNewtonJointBallAndSocket(matrix, child.GetBody().GetBody(), otherBody); Stiffness = m_stiffness; }
public override void InitJoint() { NewtonBody child = GetComponent <NewtonBody>(); dMatrix matrix = Utils.ToMatrix(m_posit, Quaternion.Euler(m_rotation)); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); m_joint = new dNewtonJointDoubleHinge(matrix, child.GetBody().GetBody(), otherBody); Stiffness = m_stiffness; EnableLimits_0 = m_enableLimits_0; }
public override void Create() { NewtonBody child = GetComponent <NewtonBody>(); dMatrix matrix = Utils.ToMatrix(m_posit, Quaternion.Euler(m_rotation)); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); m_joint = new dNewtonJointSlider(matrix, child.GetBody().GetBody(), otherBody); Stiffness = m_stiffness; EnableLimits = m_enableLimits; SetSpringDamper = m_setSpringDamper; }
public override void Create() { NewtonBody child = GetComponent <NewtonBody>(); dMatrix matrix = Utils.ToMatrix(m_posit, Quaternion.Euler(m_rotation)); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); m_joint = new dNewtonJointSliderActuator(matrix, child.GetBody().GetBody(), otherBody); Speed = m_speed; MaxForce = m_maxForce; TargetPosition = m_targetPosition; }
public override void Create() { NewtonBody child = GetComponent <NewtonBody>(); dMatrix matrix = Utils.ToMatrix(m_posit, Quaternion.Euler(m_rotation)); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); m_joint = new dNewtonJointHingeActuator(matrix, child.GetBody().GetBody(), otherBody); TargetAngle = m_targetAngle; AngularRate = m_angularRate; MaxTorque = m_maxTorque; }
public override void Create() { NewtonBody child = GetComponent <NewtonBody>(); Matrix4x4 localMatrix = Matrix4x4.identity; localMatrix.SetTRS(m_posit, Quaternion.Euler(m_rotation), Vector3.one); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); Vector3 pin = localMatrix.GetColumn(0); dVector normal = new dVector(pin.x, pin.y, pin.z, 0.0f); dVector posit = new dVector(m_posit.x, m_posit.y, m_posit.z, 1.0f); m_joint = new dNewtonJointPlane3DOF(posit, normal, child.GetBody().GetBody(), otherBody); Stiffness = m_stiffness; }
public override void InitJoint() { if (initialized) { return; } NewtonBody child = GetComponent <NewtonBody>(); dMatrix matrix = Utils.ToMatrix(m_posit, Quaternion.Euler(m_rotation)); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); m_joint = new dNewtonJointHinge(matrix, child.GetBody().GetBody(), otherBody); Stiffness = m_stiffness; EnableLimits = m_enableLimits; SetSpringDamper = m_setSpringDamper; initialized = true; }
public override void Create() { Matrix4x4 localMatrix0 = Matrix4x4.identity; Matrix4x4 localMatrix1 = Matrix4x4.identity; localMatrix0.SetTRS(Vector3.zero, Quaternion.Euler(m_rotation), Vector3.one); localMatrix1.SetTRS(Vector3.zero, Quaternion.Euler(m_parentRotation), Vector3.one); Vector4 childPin = localMatrix0.GetColumn(0); Vector4 parentPin = localMatrix1.GetColumn(0); NewtonBody child = GetComponent <NewtonBody>(); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); dVector childPin_ = new dVector(childPin.x, childPin.y, childPin.z, 0.0f); dVector parentPin_ = new dVector(parentPin.x, parentPin.y, parentPin.z, 0.0f); m_joint = new dNewtonJointGear(m_gearRatio, childPin_, parentPin_, child.GetBody().GetBody(), otherBody); }
public override void InitJoint() { Matrix4x4 localMatrix0 = Matrix4x4.identity; Matrix4x4 localMatrix1 = Matrix4x4.identity; Matrix4x4 localMatrix2 = Matrix4x4.identity; localMatrix0.SetTRS(Vector3.zero, Quaternion.Euler(m_rotation), Vector3.one); localMatrix1.SetTRS(Vector3.zero, Quaternion.Euler(m_parentRotation), Vector3.one); localMatrix2.SetTRS(Vector3.zero, Quaternion.Euler(m_referenceRotation), Vector3.one); Vector4 childPin = localMatrix0.GetColumn(0); Vector4 parentPin = localMatrix1.GetColumn(0); Vector4 referencePin = localMatrix2.GetColumn(0); NewtonBody child = GetComponent <NewtonBody>(); IntPtr otherBody = (m_otherBody != null) ? m_otherBody.GetBody().GetBody() : new IntPtr(0); IntPtr referenceBody = (m_referenceBody != null) ? m_referenceBody.GetBody().GetBody() : new IntPtr(0); dVector dChildPin = new dVector(childPin.x, childPin.y, childPin.z, 0.0f); dVector dParentPin = new dVector(parentPin.x, parentPin.y, parentPin.z, 0.0f); dVector dReferencePin = new dVector(referencePin.x, referencePin.y, referencePin.z, 0.0f); m_joint = new dNewtonJointDifferentialGear(m_gearRatio, dChildPin, dParentPin, dReferencePin, child.GetBody().GetBody(), otherBody, referenceBody); }