Esempio n. 1
0
        public void Update(GameTime gameTime)
        {
            ShipFbx ship = shipClasses[(int)currentShip];

            if (ship.isAnimated)
            {
                ship.clipPlayer.Update(gameTime, Matrix.Identity);
            }
        }
Esempio n. 2
0
        public void Draw(GameTime gameTime, CameraWrapper camera, Boolean isThisTheCamerasShip)
        {
            //TODO:
            //if playerType == PlayerType.None and this is not the camera belonging to this ship
            //Then return, we only want to draw ship selection ships to thier own camera


            Matrix viewMatrix       = camera.View;
            Matrix projectionMatrix = camera.Projection;

            BeatShift.graphics.GraphicsDevice.Viewport = camera.Viewport;

            //Set light to colour
            //shipClasses[(int)currentShip].shipRenderer.DiffuseColor = shipColour.ToVector3();
            //shipClasses[(int)currentShip].shipRenderer.DirectionalLight0.DiffuseColor = shipColour.ToVector3();

            //shipClasses[(int)currentShip].shipRenderer.View = viewMatrix;
            //shipClasses[(int)currentShip].shipRenderer.Projection = projectionMatrix;

            //world uses SRT matrix for scale rotation and translation of ship
            Matrix worldMatrix = getShipDrawOrientationMatrix();

            worldMatrix.Translation = getShipPosition();
            //shipClasses[(int)currentShip].shipRenderer.World = worldMatrix;

            if (((camera.ShouldDrawOwnShip || !isThisTheCamerasShip) && GameLoop.getCurrentState() == GameState.LocalGame) || isThisTheCamerasShip)
            {
                //Use high reflectivity when racer at lvl5
                if (parentRacer.beatQueue.getLayer() == 4)
                {
                    reflectOverride = MathHelper.Lerp(reflectOverride, 1.0f, 0.05f);
                }
                else
                {
                    reflectOverride = MathHelper.Lerp(reflectOverride, 0.0f, 0.2f);
                }

                //Draw ship using bShiftEffect.fx as instructed by the fbx file
                ShipFbx shipFbx = shipClasses[(int)currentShip];
                BeatShift.graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
                foreach (ModelMesh mesh in shipFbx.model.Meshes)
                {
                    foreach (Effect effect in mesh.Effects)
                    {
                        if (shipFbx.isAnimated)
                        {
                            effect.CurrentTechnique = effect.Techniques["SkinnedShip"];
                            effect.Parameters["Bones"].SetValue(shipFbx.Bones);
                        }

                        effect.Parameters["world_Mx"].SetValue(worldMatrix);
                        effect.Parameters["wvp_Mx"].SetValue(worldMatrix * viewMatrix * projectionMatrix);

                        //Matrix worldInverseTranspose = Matrix.Transpose(Matrix.Invert(worldTransform));
                        //effect.Parameters["wit_Mx"].SetValue(worldInverseTranspose);

                        Matrix viewInverse = Matrix.Invert(viewMatrix);
                        effect.Parameters["viewInv_Mx"].SetValue(viewInverse);


                        effect.Parameters["useAmbient"].SetValue(Globals.useAmbient);
                        effect.Parameters["useLambert"].SetValue(Globals.useLambert);
                        effect.Parameters["useSpecular"].SetValue(Globals.useSpecular);
                        effect.Parameters["drawNormals"].SetValue(Globals.drawNormals);
                        effect.Parameters["reflectOverride"].SetValue(reflectOverride);
                    }
                    mesh.Draw();
                }
            }

            //if (Options.DrawShipBoundingBoxes)
            //{

            //    BeatShift.graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend;
            //    shipPhysicsModelEffect.View = viewMatrix;
            //    shipPhysicsModelEffect.Projection = projectionMatrix;
            //    shipPhysicsModelEffect.World = worldMatrix;
            //    foreach (ModelMesh mesh in shipPhysicsModel.Meshes)
            //    {
            //        mesh.Draw();
            //    }
            //}

            if (Options.DrawShipBoundingBoxes)
            {
                foreach (D_Arrow arrow in drawArrowListRays)
                {
                    DrawVector.drawArrow(camera, arrow.pos, arrow.dir, arrow.col);
                }
                drawArrowListRays.Clear();
            }

            if (Globals.EnableParticles)
            {
                if (engineGlow != null)
                {
                    parentRacer.globalSystems.SetWorldViewProjectionMatricesForAllParticleSystems(Matrix.Identity, viewMatrix, projectionMatrix);
                    parentRacer.globalSystems.SetCameraPositionForAllParticleSystems(camera.cameraPosition());
                    parentRacer.globalSystems.DrawAllParticleSystems();
                    if (isThisTheCamerasShip && !parentRacer.raceTiming.hasCompletedRace)
                    {
                        //Draw visualizations with camera's view matrix, but with the visualization projection matrix
                        parentRacer.visualizationSystems.SetWorldViewProjectionMatricesForAllParticleSystems(Matrix.Identity, camera.VisualizationViewM, camera.VisualizationProjection);
                        parentRacer.visualizationSystems.SetCameraPositionForAllParticleSystems(camera.cameraPosition());
                        parentRacer.visualizationSystems.DrawAllParticleSystems();
                    }
                }
            }
            //if (Options.DrawCollisionPoints)
            {
                foreach (D_Arrow arrow in drawArrowListPermanent)
                {
                    DrawVector.drawArrow(camera, arrow.pos, arrow.dir, arrow.col);
                }
            }
            if (isThisTheCamerasShip && AiInputManager.testAI)
            {
                DrawVector.drawArrow(camera, getShipPosition(), aiWallRayArrow, aiWallRayHit ? new Vector3(255, 0, 0) : new Vector3(0, 0, 255));
                DrawVector.drawArrow(camera, getShipPosition(), aiFrontRayArrow, aiFrontRayHit ? new Vector3(200, 0, 50) : new Vector3(0, 50, 200));
            }
        }