예제 #1
0
        /// <summary>
        /// Creates native shape and geometry. Assigns material to the
        /// native geometry if material is present.
        /// </summary>
        /// <returns></returns>
        protected override bool Initialize()
        {
            m_transform = transform;

            m_shape = CreateNative();

            if (m_shape == null)
            {
                return(false);
            }

            m_geometry = new agxCollide.Geometry(m_shape, GetNativeGeometryOffset());
            m_geometry.setName(name);
            m_geometry.setEnable(IsEnabled);

            if (Material != null)
            {
                m_geometry.setMaterial(m_material.GetInitialized <ShapeMaterial>().Native);
            }

            SyncNativeTransform();

            GetSimulation().add(m_geometry);

            // TODO: Add pre-synch to be able to move geometries during play?

            // Adding transform synchronization. This will be removed if this
            // shape is part of a rigid body (SetRigidBody) since our transform
            // will be updated with our parent body.
            Simulation.Instance.StepCallbacks.PostSynchronizeTransforms += OnPostSynchronizeTransformsCallback;

            return(base.Initialize());
        }
예제 #2
0
        /// <summary>
        /// Creates native shape and geometry. Assigns material to the
        /// native geometry if material is present.
        /// </summary>
        /// <returns></returns>
        protected override bool Initialize()
        {
            m_shape = CreateNative();

            if (m_shape == null)
            {
                return(false);
            }

            m_geometry = new agxCollide.Geometry(m_shape, GetNativeGeometryOffset());
            m_geometry.setName(name);
            m_geometry.setEnable(IsEnabled);

            if (Material != null)
            {
                m_geometry.setMaterial(m_material.GetInitialized <ShapeMaterial>().Native);
            }

            SyncNativeTransform();

            GetSimulation().add(m_geometry);

            // Temp hack to get "pulley property" of a RigidBody which name
            // contains the name "sheave".
            //RigidBody rbTmp = Find.FirstParentWithComponent<RigidBody>( gameObject );
            //if ( rbTmp != null && rbTmp.gameObject.name.ToLower().Contains( "sheave" ) ) {
            //  Debug.Log( "Adding pulley property to: " + gameObject.name + " from rb.name = " + rbTmp.gameObject.name );
            //  m_geometry.getPropertyContainer().addPropertyBool( "Pulley", true );
            //}

            // TODO: Add pre-synch to be able to move geometries during play?
            Simulation.Instance.StepCallbacks.PostSynchronizeTransforms += OnPostSynchronizeTransformsCallback;

            return(base.Initialize());
        }