Exemplo n.º 1
0
            public override int ClearModel()
            {
                // delete previously added shapes, if collision shape(s) used by collision object
                if (shapes.Count > 0)
                {
                    // deletes shared pointers, so also deletes shapes if uniquely referenced
                    shapes.Clear();

                    // tell to the parent collision system to remove this from collision system,
                    // if still connected to a physical system
                    if (GetContactable() != null)
                    {
                        if (GetPhysicsItem())
                        {
                            if (GetPhysicsItem().GetSystem())
                            {
                                if (GetPhysicsItem().GetCollide())
                                {
                                    GetPhysicsItem().GetSystem().GetCollisionSystem().Remove(this);
                                }
                            }
                        }
                    }

                    // at the end, no collision shape
                    bt_collision_object.SetCollisionShape(null);
                }

                return(1);
            }
Exemplo n.º 2
0
            public ChModelBullet()
            {
                bt_collision_object = new CollisionObject();
                bt_collision_object.SetCollisionShape(null);
                bt_collision_object.SetUserPointer(this);

                shapes.Clear();
            }
Exemplo n.º 3
0
        public override void InitializeDemo()

        {
            // Setup the basic world

            SetTexturing(true);
            SetShadows(true);

            SetCameraDistance(5.0f);

            m_collisionConfiguration = new DefaultCollisionConfiguration();

            m_dispatcher = new CollisionDispatcher(m_collisionConfiguration);

            IndexedVector3 worldAabbMin = new IndexedVector3(-10000, -10000, -10000);
            IndexedVector3 worldAabbMax = new IndexedVector3(10000, 10000, 10000);

            m_broadphase = new AxisSweep3Internal(ref worldAabbMin, ref worldAabbMax, 0xfffe, 0xffff, 16384, null, true);
            //m_broadphase = new SimpleBroadphase(1000, null);
            m_constraintSolver = new SequentialImpulseConstraintSolver();

            m_dynamicsWorld = new DiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_constraintSolver, m_collisionConfiguration);
            //m_dynamicsWorld.getDispatchInfo().m_useConvexConservativeDistanceUtil = true;
            //m_dynamicsWorld.getDispatchInfo().m_convexConservativeDistanceThreshold = 0.01f;



            // Setup a big ground box
            {
                CollisionShape groundShape = new BoxShape(new IndexedVector3(200.0f, 10.0f, 200.0f));
                m_collisionShapes.Add(groundShape);
                IndexedMatrix groundTransform = IndexedMatrix.CreateTranslation(0, -10, 0);

                CollisionObject fixedGround = new CollisionObject();
                fixedGround.SetCollisionShape(groundShape);
                fixedGround.SetWorldTransform(ref groundTransform);
                fixedGround.SetUserPointer("Ground");
                m_dynamicsWorld.AddCollisionObject(fixedGround);
            }

            // Spawn one ragdoll
            IndexedVector3 startOffset = new IndexedVector3(1, 0.5f, 0);


            //string filename = @"c:\users\man\bullet\xna-ragdoll-constraints-output.txt";
            //FileStream filestream = File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.Read);
            //BulletGlobals.g_streamWriter = new StreamWriter(filestream);


            SpawnRagdoll(ref startOffset, BulletGlobals.g_streamWriter);
            //startOffset = new IndexedVector3(-1,0.5f,0);
            //spawnRagdoll(ref startOffset);

            ClientResetScene();
        }