Пример #1
0
        // Methods

        public override void Draw(GameTime gameTime)
        {
            Matrix[] modelTransforms = new Matrix[stage.WayPoint3D.Bones.Count];
            foreach (NavNode navNode in node)
            {
                // draw the Path markers
                foreach (ModelMesh mesh in stage.WayPoint3D.Meshes)
                {
                    stage.WayPoint3D.CopyAbsoluteBoneTransformsTo(modelTransforms);
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();
                        effect.DirectionalLight0.DiffuseColor = navNode.NodeColor;
                        effect.AmbientLightColor           = navNode.NodeColor;
                        effect.DirectionalLight0.Direction = stage.LightDirection;
                        effect.DirectionalLight0.Enabled   = true;
                        effect.View       = stage.View;
                        effect.Projection = stage.Projection;
                        effect.World      = Matrix.CreateTranslation(navNode.Translation) * modelTransforms[mesh.ParentBone.Index];
                    }
                    stage.setBlendingState(true);
                    mesh.Draw();
                    stage.setBlendingState(false);
                }
            }
        }
Пример #2
0
        public override void  Draw(GameTime gameTime)
        {
            Matrix[] modelTransforms = new Matrix[model.Bones.Count];
            foreach (Object3D obj3d in instance)
            {
                foreach (ModelMesh mesh in model.Meshes)
                {
                    model.CopyAbsoluteBoneTransformsTo(modelTransforms);
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();
                        effect.DirectionalLight0.DiffuseColor = stage.DiffuseLight;
                        effect.AmbientLightColor           = stage.AmbientLight;
                        effect.DirectionalLight0.Direction = stage.LightDirection;
                        effect.DirectionalLight0.Enabled   = true;
                        effect.View       = stage.View;
                        effect.Projection = stage.Projection;
                        effect.World      = modelTransforms[mesh.ParentBone.Index] * obj3d.Orientation;
                    }
                    mesh.Draw();
                }
                // draw the bounding sphere with blending ?
                if (stage.DrawBoundingSpheres && IsCollidable)
                {
                    foreach (ModelMesh mesh in stage.BoundingSphere3D.Meshes)
                    {
                        model.CopyAbsoluteBoneTransformsTo(modelTransforms);
                        foreach (BasicEffect effect in mesh.Effects)
                        {
                            effect.EnableDefaultLighting();
                            if (stage.Fog)
                            {
                                effect.FogColor   = Color.CornflowerBlue.ToVector3();
                                effect.FogStart   = 50;
                                effect.FogEnd     = 500;
                                effect.FogEnabled = true;
                            }
                            else
                            {
                                effect.FogEnabled = false;
                            }

                            effect.DirectionalLight0.DiffuseColor = stage.DiffuseLight;
                            effect.AmbientLightColor           = stage.AmbientLight;
                            effect.DirectionalLight0.Direction = stage.LightDirection;
                            effect.DirectionalLight0.Enabled   = true;
                            effect.View       = stage.View;
                            effect.Projection = stage.Projection;
                            effect.World      = obj3d.ObjectBoundingSphereWorld * modelTransforms[mesh.ParentBone.Index];
                        }
                        stage.setBlendingState(true);
                        mesh.Draw();
                        stage.setBlendingState(false);
                    }
                }
            }
        }