Exemplo n.º 1
0
        public H_Player(Game game_, Controls control_, Vector3 center_, Vector3 size_, Quaternion theta_)
            : base(center_, size_, theta_)
        {
            //So since everything is a reference if we set the camera's position to
            //the same reference as Seen Object's Center should update in sync
            //If not, we need to update the camera during update

            //OLD
            //camera = new Camera(center, Vector3.Up, Vector3.Backward);

            camera = new CameraComponent(game_);
            PC_mediator = new Mediator_Player_Controls(control_, this);

            structure_wheel_pos = Structure_Type_e.HEALING_POOL;

            camera.Perspective(95, 1280 / 800, 2f, 3000);
            //game_.GraphicsDevice.Viewport.AspectRatio
            //DO THIS BRO
            //aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
        }
Exemplo n.º 2
0
        public virtual void render(Model model, GraphicsDeviceManager graphics, CameraComponent camera)
        {
            if (model == null)
                throw new Exception("Trying to render NULL Model!");

            /*        if (get_animator())
                    {
                        get_animator()->animate(model);
                    }
            */
            // Copy any parent transforms.
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            float modelRotation = 0.0f;

            // Draw the model. A model can have multiple meshes, so loop.
            foreach (ModelMesh mesh in model.Meshes)
            {
                // This is where the mesh orientation is set, as well
                // as our camera and projection.
                foreach (BasicEffect effect in mesh.Effects)
                {

                    //effect.PreferPerPixelLighting = true;
                    //effect.EnableDefaultLighting();
                    //effect.View = camera.ViewMatrix;
                    //effect.Projection = camera.ProjectionMatrix;
                    //effect.World = modelTransforms[mesh.ParentBone.Index] * world;

                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] *
                        Matrix.CreateScale(size) * Matrix.CreateTranslation(center);

                    effect.View = camera.ViewMatrix;
                    effect.Projection = camera.ProjectionMatrix;

                    //OLD
                    //effect.EnableDefaultLighting();

                    //effect.World = transforms[mesh.ParentBone.Index] *
                    //    Matrix.CreateScale(size)
                    //    * Matrix.CreateTranslation(center)
                    //    ;

                    //effect.View = Matrix.CreateLookAt(camera.Position,
                    //    camera.ViewDirection, camera.);

                    //effect.Projection = Matrix.CreatePerspectiveFieldOfView(
                    //    MathHelper.ToRadians(45.0f), graphics.GraphicsDevice.Viewport.AspectRatio,
                    //    1.0f, 10000.0f);

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