예제 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            InitializeTransform();
            InitalizePhysics();

            //Set up debug drawer for rendering physics boxes.
            debugDrawer = new DebugDrawer(this, m_ThirdPersonCamera);
            debugDrawer.Enabled = true;
            Components.Add(debugDrawer);

            debugDrawerFirst = new DebugDrawer(this, m_FirstPersonCamera);
            debugDrawerFirst.Enabled = true;
            Components.Add(debugDrawerFirst);

            base.Initialize();
        }
예제 #2
0
        public virtual void Render(DebugDrawer debugDrawer, Camera cam)
        {
            foreach (ModelMesh mesh in m_GOModel.Meshes)
            {
                //This is where the mesh orientation is set
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();

                    if (m_body.CollisionSkin != null)
                        effect.World = m_GOModelTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(m_GOScale) * m_body.CollisionSkin.GetPrimitiveLocal(0).Transform.Orientation * m_body.Orientation * Matrix.CreateFromYawPitchRoll(m_GORot.X, m_GORot.Y, m_GORot.Z) * Matrix.CreateTranslation(m_body.Position);
                    else
                        effect.World = m_GOModelTransforms[mesh.ParentBone.Index] * Matrix.CreateScale(m_GOScale) * m_body.Orientation * Matrix.CreateFromYawPitchRoll(m_GORot.X, m_GORot.Y, m_GORot.Z) * Matrix.CreateTranslation(m_body.Position);

                    effect.Projection = cam.camProjectionMatrix;
                    effect.View = cam.camViewMatrix;

                    //render fog for all models.
                    effect.SpecularPower = 2;
                    effect.FogEnabled = true;
                    effect.FogColor = Color.Black.ToVector3();
                    effect.FogStart = 70;
                    effect.FogEnd = 80;

                    if (m_textured)
                    {
                        effect.TextureEnabled = true;
                    }
                    else
                    {
                        effect.TextureEnabled = false;
                    }

                }

                //Draw the mesh, will use the effects set above.
                mesh.Draw();
            }
        }