Exemplo n.º 1
0
        protected override bool Initialize()
        {
            if (Wire == null)
            {
                Debug.LogWarning("Wire not assigned to winch. Winch invalid and ignored.", this);
                return(false);
            }

            WireRouteNode winchNode = Wire.Route.FirstOrDefault(node => node.Winch == this);

            if (winchNode == null)
            {
                Debug.LogWarning("Unable to initialize winch - no winch node assigned.", this);
                return(false);
            }

            RigidBody rb = winchNode.Parent != null?winchNode.Parent.GetInitializedComponentInParent <RigidBody>() : null;

            if (rb == null)
            {
                Native = new agxWire.WireWinchController(null, winchNode.Position.ToHandedVec3(), (winchNode.Rotation * Vector3.forward).ToHandedVec3(), PulledInLength);
            }
            else
            {
                Native = new agxWire.WireWinchController(rb.Native, winchNode.CalculateLocalPosition(rb.gameObject).ToHandedVec3(), (winchNode.CalculateLocalRotation(rb.gameObject) * Vector3.forward).ToHandedVec3());
            }

            return(true);
        }
Exemplo n.º 2
0
    // Start is called before the first frame update
    protected override bool Initialize()
    {
        // Get the winch from the wire (set in the editor)
        m_winch = mainWire.GetInitialized <Wire>().EndWinch.Native;

        if (m_winch == null)
        {
            Debug.LogWarning("No EndWinch", this);
            return(false);
        }

        // Get the native (AGX Dynamics Hinge) from the editor
        var hinge = baseHinge.GetInitialized <AGXUnity.Constraint>().Native.asHinge();

        if (hinge == null)
        {
            Debug.LogWarning("No hinge available", this);
            return(false);
        }
        m_baseHingeMotor = hinge.getMotor1D();

        // Get the native Prismatic constraint set in the editor
        var prismatic = liftPrismatic.GetInitialized <AGXUnity.Constraint>().Native.asPrismatic();

        if (prismatic == null)
        {
            Debug.LogWarning("No prismatic available", this);
            return(false);
        }
        m_liftPrismaticMotor = prismatic.getMotor1D();


        return(true);
    }
Exemplo n.º 3
0
        public void RestoreLocalDataFrom(agxWire.WireWinchController native)
        {
            if (native == null)
            {
                return;
            }

            Speed           = Convert.ToSingle(native.getSpeed());
            PulledInLength  = Convert.ToSingle(native.getPulledInWireLength());
            ForceRange      = new RangeReal(native.getForceRange());
            BrakeForceRange = new RangeReal(native.getBrakeForceRange());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add route node given native winch instance. Data will be copied from
        /// native to the created route node.
        /// </summary>
        /// <param name="nativeWinch">Native winch.</param>
        /// <param name="parent">Parent game object as in nativeWinch.getRigidBody().</param>
        /// <returns>Winch route node if added, otherwise null.</returns>
        public WireRouteNode Add(agxWire.WireWinchController nativeWinch, GameObject parent)
        {
            if (nativeWinch == null)
            {
                return(null);
            }

            var node = WireRouteNode.Create(Wire.NodeType.WinchNode, parent);

            if (!Add(node))
            {
                return(null);
            }

            node.LocalPosition = nativeWinch.getStopNode().getPosition().ToHandedVector3();
            node.LocalRotation = Quaternion.LookRotation(nativeWinch.getNormal().ToHandedVector3(), Vector3.up);

            node.Winch.RestoreLocalDataFrom(nativeWinch);

            return(node);
        }