Beispiel #1
0
        public Player(Game game, Model model, InputState input, ChaseCamera camera)
            : base(game)
        {
            this.model = model;
            this.input = input;
            this.camera = camera;
            position = new Vector3(0, 20, 0);
            speed = 0;
            direction = Vector3.UnitZ;
            top = Vector3.UnitY;
            left = Vector3.Cross(top, direction);

            inputMode = InputState.InputMode.Advanced;
        }
Beispiel #2
0
        protected override void Initialize()
        {
            camera = new ChaseCamera(
                Vector3.Zero,
                Vector3.UnitZ,
                Vector3.UnitY,
                10,
                GraphicsDevice.DisplayMode.AspectRatio);

            random = new Random();
            input = new InputState(this);
            debug = new DebugInfoWriter(this);
            index1 = debug.AddText("camera info");
            index2 = debug.AddText("camera info");
            index3 = debug.AddText("camera info");
            index4 = debug.AddText("camera info");

            track = new Track();

            Components.Add(input);
            Components.Add(debug);

            base.Initialize();
        }
Beispiel #3
0
        private void DrawSkybox(GraphicsDevice graphicsDevice, ChaseCamera camera, Matrix world)
        {
            basicEffect.World = world;
            basicEffect.View = camera.view;
            basicEffect.Projection = camera.projection;
            basicEffect.CurrentTechnique = basicEffect.Techniques[0];

            //RasterizerState rState0 = graphicsDevice.RasterizerState;
            //RasterizerState rState1 = new RasterizerState();
            //rState1.CullMode = CullMode.None;
            //graphicsDevice.RasterizerState = rState1;
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                graphicsDevice.DrawUserPrimitives<VertexPositionColorTexture>(
                    PrimitiveType.TriangleList,
                    skybox,
                    0,
                    skybox.Length / 3
                );

            }
            //graphicsDevice.RasterizerState = rState0;
        }
Beispiel #4
0
        public void Draw(GraphicsDevice graphicsDevice, ChaseCamera camera)
        {
            //draw skybox, then flush depth buffer or some such
            //draw landscape geometry
            //draw oranment models
            //draw lens flare?

            //Matrix world = Matrix.CreateWorld(-player.position, Vector3.UnitZ, Vector3.UnitY);
            Matrix world = Matrix.Identity;

            DrawSkybox(graphicsDevice, camera, world);

            effect.Parameters["World"].SetValue(world);
            effect.Parameters["View"].SetValue(camera.view);
            effect.Parameters["Projection"].SetValue(camera.projection);

            effect.CurrentTechnique = effect.Techniques["Technique1"];

            graphicsDevice.SetVertexBuffer(vertexBuffer);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();

                graphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(
                    PrimitiveType.TriangleList,
                    indexedVertices,
                    0,   // vertex buffer offset to add to each element of the index buffer
                    indexedVertices.Length,  // number of vertices to draw
                    indices,
                    0,   // first index element to read
                    indices.Length / 3   // number of primitives to draw
                );
            }
        }