Beispiel #1
0
        private static void InitPropertyDict()
        {
            //drawobj
            int count = DrawObj.GetPropertyNames().Length;

            for (int i = 0; i < count; i++)
            {
                _propertyIndexDict.Add(DrawObj.GetPropertyNames()[i], new PropertyIndex((int)DrawType.Obj, i));
            }

            //drawvector
            count = DrawVector.GetPropertyNames().Length;
            for (int i = 0; i < count; i++)
            {
                _propertyIndexDict.Add(DrawVector.GetPropertyNames()[i], new PropertyIndex((int)DrawType.Vector, i));
            }

            //drawtext
            count = DrawText.GetPropertyNames().Length;
            for (int i = 0; i < count; i++)
            {
                _propertyIndexDict.Add(DrawText.GetPropertyNames()[i], new PropertyIndex((int)DrawType.Text, i));
            }

            //todo add control:variable
        }
Beispiel #2
0
        private void InitList()
        {
            _list = new List <IPropertyExpression>();

            //drawobj
            string[] names = DrawObj.GetPropertyNames();
            int      count = names.Length;

            for (int i = 0; i < count; i++)
            {
                AddParameter(names[i]);
            }

            //drawvector
            if (_container.IsVector)
            {
                names = DrawVector.GetPropertyNames();
                count = names.Length;
                for (int i = 0; i < count; i++)
                {
                    AddParameter(names[i]);
                }
            }

            //draw child
            if (_container.PropertyNames != null)
            {
                count = _container.PropertyNames.Length;
                for (int i = 0; i < count; i++)
                {
                    AddParameter(_container.PropertyNames[i]);
                }
            }
        }
Beispiel #3
0
        void drawTrackNormals(GameTime gameTime, CameraWrapper camera)
        {
            MapPoint point;

            for (int i = CurrentMapData.mapPoints.Count - 1; i >= 0; i--)
            {
                point = CurrentMapData.mapPoints[i];

                Vector3 drawPosition = point.position;
                DrawVector.drawArrow(camera, drawPosition, point.roadSurface * 9f, yellow);
                DrawVector.drawArrow(camera, drawPosition, point.tangent * 12f, blue);
                DrawVector.drawArrow(camera, drawPosition, point.trackUp * 12f, red);
            }
        }
Beispiel #4
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));
            }
        }