Esempio n. 1
0
    protected void inititializeTire(string name)
    {
        var sim = GetSimulation();

        Assert.IsNotNull(sim);

        var searchName = name + "Tire";
        var tire       = sim.getRigidBody(searchName);

        Assert.IsNotNull(tire, "Unable to find RigidBody: " + searchName);

        searchName = name + "Rim";
        var rim = sim.getRigidBody(searchName);

        Assert.IsNotNull(rim, "Unable to find RigidBody: " + searchName);

        // For each tire/rim there is a LockJoint that we added in Momentum just to keep the two together.
        // We need to disable that constraint
        searchName = "Lock" + name;
        var lockJoint = sim.getLockJoint(searchName);

        Assert.IsNotNull(lockJoint, "Unable to find LockJoint: " + searchName);
        lockJoint.setEnable(false);

        // Make sure orientation of the wheel is correct
        var m = new agx.AffineMatrix4x4(new agx.Quat(new agx.Vec3(0, 0, 1),
                                                     new agx.Vec3(0, 1, 0)),
                                        new agx.Vec3());

        // Create a tire model that connects the Tire with the Rim
        var tireModel = new agxModel.TwoBodyTire(tire, 1.0, rim, 0.5, m);

        m_tireModels.Add(tireModel);
        sim.add(tireModel);
    }
Esempio n. 2
0
        protected void inititializeTire()
        {
            if (!agx.Runtime.instance().isValid() || !agx.Runtime.instance().isModuleEnabled("AgX-Tires"))
            {
                Debug.LogError("This Component requires a valid license for the AGX Dynamics module: AgX-Tires");
            }


            clearTireModel();

            if (m_rimBody == null || m_tireBody == null || m_tireBody.GetInitialized <RigidBody>() == null || m_rimBody.GetInitialized <RigidBody>() == null)
            {
                return;
            }

            var tire = m_tireBody.GetInitialized <RigidBody>().Native;
            var rim  = m_rimBody.GetInitialized <RigidBody>().Native;

            if (tire == null || rim == null)
            {
                Debug.LogWarning("Two Tire Model requires two bodies, one for the tire and one for the rim");
                return;
            }
            // Make sure orientation of the wheel is correct
            var m = new agx.AffineMatrix4x4(new agx.Quat(new agx.Vec3(0, 0, 1), new agx.Vec3(0, 1, 0)), new agx.Vec3());

            // Create a tire model that connects the Tire with the Rim
            m_tireModel = new agxModel.TwoBodyTire(tire, 1.0, rim, 0.5, m);

            GetSimulation().add(m_tireModel);
        }
Esempio n. 3
0
        private void clearTireModel()
        {
            if (m_tireModel == null)
            {
                return;
            }

            m_tireModel.getSimulation().remove(m_tireModel);
            m_tireModel = null;
        }
Esempio n. 4
0
        protected override bool Initialize()
        {
            if (!agx.Runtime.instance().isModuleEnabled("AgX-Tires"))
            {
                Debug.LogError("TwoBodyTire requires a valid license for the AGX Dynamics module: AgX-Tires", this);
                return(false);
            }

            if (TireRigidBody == null || RimRigidBody == null)
            {
                Debug.LogError("TwoBodyTire failed to initialize: Tire or Rim rigid body is null.", this);
                return(false);
            }

            var nativeTireRigidBody = TireRigidBody.GetInitialized <RigidBody>()?.Native;
            var nativeRimRigidBody  = RimRigidBody.GetInitialized <RigidBody>()?.Native;

            if (nativeTireRigidBody == null || nativeRimRigidBody == null)
            {
                Debug.LogError("TwoBodyTire failed to initialize: Tire or Rim rigid body failed to initialize.", this);
                return(false);
            }

            Native = new agxModel.TwoBodyTire(nativeTireRigidBody,
                                              TireRadius,
                                              nativeRimRigidBody,
                                              RimRadius,
                                              FindNativeTransform(TireRigidBody));
            GetSimulation().add(Native);

            if (TireRimConstraint != null)
            {
                // Disable the tire rim constraint since agx.TwoBodyTire will
                // create an additional constraint between the tire and the rim
                // with tire properties applied.
                if (TireRimConstraint.GetInitialized <Constraint>().IsEnabled)
                {
                    m_tireRimConstraintInitialState = TireRimConstraint.enabled;
                    TireRimConstraint.enabled       = false;
                }

                // The "hinge" is replacing the TireRimConstraint, take the
                // solve type from disabled rim constraint.
                Native.getHinge().setSolveType(Constraint.Convert(TireRimConstraint.SolveType));
            }

            if (Properties != null)
            {
                Properties.Register(this);
            }

            return(true);
        }
Esempio n. 5
0
        protected override bool Initialize()
        {
            if (!agx.Runtime.instance().isModuleEnabled("AgX-Tires"))
            {
                Debug.LogError("TwoBodyTire requires a valid license for the AGX Dynamics module: AgX-Tires", this);
                return(false);
            }

            if (TireRigidBody == null || RimRigidBody == null)
            {
                Debug.LogError("TwoBodyTire failed to initialize: Tire or Rim rigid body is null.", this);
                return(false);
            }

            var nativeTireRigidBody = TireRigidBody.GetInitialized <RigidBody>()?.Native;
            var nativeRimRigidBody  = RimRigidBody.GetInitialized <RigidBody>()?.Native;

            if (nativeTireRigidBody == null || nativeRimRigidBody == null)
            {
                Debug.LogError("TwoBodyTire failed to initialize: Tire or Rim rigid body failed to initialize.", this);
                return(false);
            }

            Native = new agxModel.TwoBodyTire(nativeTireRigidBody,
                                              TireRadius,
                                              nativeRimRigidBody,
                                              RimRadius,
                                              FindNativeTransform(TireRigidBody));
            GetSimulation().add(Native);

            if (TireRimConstraint != null && TireRimConstraint.GetInitialized <Constraint>().IsEnabled)
            {
                m_tireRimConstraintInitialState = TireRimConstraint.enabled;
                TireRimConstraint.enabled       = false;
            }

            if (Properties != null)
            {
                Properties.Register(this);
            }

            return(true);
        }