Beispiel #1
0
        //----------------------------------------------------------------------------------------------

        public virtual void RenderScenePassMultiWorld(int pass, GameTime gameTime, DiscreteDynamicsWorld world)
        {
            IndexedMatrix      m      = IndexedMatrix.Identity;
            IndexedBasisMatrix rot    = IndexedBasisMatrix.Identity;
            int            numObjects = world.GetNumCollisionObjects();
            IndexedVector3 wireColor  = new IndexedVector3(1, 0, 0);

            for (int i = 0; i < numObjects; i++)
            {
                CollisionObject colObj = world.GetCollisionObjectArray()[i];
                RigidBody       body   = RigidBody.Upcast(colObj);
                if (body != null && body.GetMotionState() != null)
                {
                    DefaultMotionState myMotionState = (DefaultMotionState)body.GetMotionState();
                    //myMotionState.m_graphicsWorldTrans.getOpenGLMatrix(m);
                    m   = myMotionState.m_graphicsWorldTrans;
                    rot = myMotionState.m_graphicsWorldTrans._basis;
                }
                else
                {
                    //colObj.getWorldTransform().getOpenGLMatrix(m);
                    m   = colObj.GetWorldTransform();
                    rot = colObj.GetWorldTransform()._basis;
                }
                wireColor = new IndexedVector3(1.0f, 1.0f, 0.5f); //wants deactivation
                if ((i & 1) != 0)
                {
                    wireColor = new IndexedVector3(0f, 0f, 1f);
                }
                ///color differently for active, sleeping, wantsdeactivation states
                if (colObj.GetActivationState() == ActivationState.ACTIVE_TAG) //active
                {
                    if ((i & 1) != 0)
                    {
                        wireColor += new IndexedVector3(1f, 0f, 0f);
                    }
                    else
                    {
                        wireColor += new IndexedVector3(.5f, 0f, 0f);
                    }
                }
                if (colObj.GetActivationState() == ActivationState.ISLAND_SLEEPING) //ISLAND_SLEEPING
                {
                    if ((i & 1) != 0)
                    {
                        wireColor += new IndexedVector3(0f, 1f, 0f);
                    }
                    else
                    {
                        wireColor += new IndexedVector3(0f, 05f, 0f);
                    }
                }

                IndexedVector3 min, max;
                world.GetBroadphase().GetBroadphaseAabb(out min, out max);

                min -= MathUtil.MAX_VECTOR;
                max += MathUtil.MAX_VECTOR;
                //		printf("aabbMin=(%f,%f,%f)\n",aabbMin.getX(),aabbMin.getY(),aabbMin.getZ());
                //		printf("aabbMax=(%f,%f,%f)\n",aabbMax.getX(),aabbMax.getY(),aabbMax.getZ());
                //		m_dynamicsWorld.getDebugDrawer().drawAabb(aabbMin,aabbMax,btVector3(1,1,1));

                switch (pass)
                {
                case 0:
                {
                    m_shapeDrawer.DrawXNA(ref m, colObj.GetCollisionShape(), ref wireColor, m_debugDraw.GetDebugMode(), ref min, ref max, ref m_lookAt, ref m_perspective);
                    break;
                }

                case 1:
                {
                    IndexedVector3 shadow = rot * m_lightDirection;
                    m_shapeDrawer.DrawShadow(ref m, ref shadow, colObj.GetCollisionShape(), ref min, ref max);
                    break;
                }

                case 2:
                {
                    IndexedVector3 adjustedWireColor = wireColor * 0.3f;
                    m_shapeDrawer.DrawXNA(ref m, colObj.GetCollisionShape(), ref adjustedWireColor, 0, ref min, ref max, ref m_lookAt, ref m_perspective);
                    break;
                }
                }
            }
        }
Beispiel #2
0
        //----------------------------------------------------------------------------------------------

        protected virtual void RenderScenePassMultiWorld(int pass, GameTime gameTime,DiscreteDynamicsWorld world)
        {
            IndexedMatrix m = IndexedMatrix.Identity;
            IndexedBasisMatrix rot = IndexedBasisMatrix.Identity;
            int numObjects = world.GetNumCollisionObjects();
            IndexedVector3 wireColor = new IndexedVector3(1, 0, 0);

            for (int i = 0; i < numObjects; i++)
            {
                CollisionObject colObj = world.GetCollisionObjectArray()[i];
                RigidBody body = RigidBody.Upcast(colObj);
                if (body != null && body.GetMotionState() != null)
                {
                    DefaultMotionState myMotionState = (DefaultMotionState)body.GetMotionState();
                    //myMotionState.m_graphicsWorldTrans.getOpenGLMatrix(m);
                    m = myMotionState.m_graphicsWorldTrans;
                    rot = myMotionState.m_graphicsWorldTrans._basis;
                }
                else
                {
                    //colObj.getWorldTransform().getOpenGLMatrix(m);
                    m = colObj.GetWorldTransform();
                    rot = colObj.GetWorldTransform()._basis;
                }
                wireColor = new IndexedVector3(1.0f, 1.0f, 0.5f); //wants deactivation
                if ((i & 1) != 0) wireColor = new IndexedVector3(0f, 0f, 1f);
                ///color differently for active, sleeping, wantsdeactivation states
                if (colObj.GetActivationState() == ActivationState.ACTIVE_TAG) //active
                {
                    if ((i & 1) != 0)
                    {
                        wireColor += new IndexedVector3(1f, 0f, 0f);
                    }
                    else
                    {
                        wireColor += new IndexedVector3(.5f, 0f, 0f);
                    }
                }
                if (colObj.GetActivationState() == ActivationState.ISLAND_SLEEPING) //ISLAND_SLEEPING
                {
                    if ((i & 1) != 0)
                    {
                        wireColor += new IndexedVector3(0f, 1f, 0f);
                    }
                    else
                    {
                        wireColor += new IndexedVector3(0f, 05f, 0f);
                    }
                }

                IndexedVector3 min, max;
                world.GetBroadphase().GetBroadphaseAabb(out min, out max);

                min -= MathUtil.MAX_VECTOR;
                max += MathUtil.MAX_VECTOR;
                //		printf("aabbMin=(%f,%f,%f)\n",aabbMin.getX(),aabbMin.getY(),aabbMin.getZ());
                //		printf("aabbMax=(%f,%f,%f)\n",aabbMax.getX(),aabbMax.getY(),aabbMax.getZ());
                //		m_dynamicsWorld.getDebugDrawer().drawAabb(aabbMin,aabbMax,btVector3(1,1,1));

                switch (pass)
                {
                    case 0:
                        {
                            m_shapeDrawer.DrawXNA(ref m, colObj.GetCollisionShape(), ref wireColor, m_debugDraw.GetDebugMode(), ref min, ref max, ref m_lookAt, ref m_perspective);
                            break;
                        }
                    case 1:
                        {
                            IndexedVector3 shadow = rot * m_lightDirection;
                            m_shapeDrawer.DrawShadow(ref m, ref shadow, colObj.GetCollisionShape(), ref min, ref max);
                            break;
                        }
                    case 2:
                        {
                            IndexedVector3 adjustedWireColor = wireColor * 0.3f;
                            m_shapeDrawer.DrawXNA(ref m, colObj.GetCollisionShape(), ref adjustedWireColor, 0, ref min, ref max, ref m_lookAt, ref m_perspective);
                            break;
                        }
                }
            }
        }