private void OnValidate()
        {
            if (_characterSelect == null)
            {
                _characterSelect = GetComponentInParent <CharacterSelect>();
            }

            if (_camera == null)
            {
                _camera = FindObjectOfType <CameraWrapper>();
            }

            if (_rect == null)
            {
                _rect = _selection.GetComponent <RectTransform>();
            }

#if UNITY_EDITOR
            if (_characterResources == null)
            {
                Utils.AssetDatabase.FindObjectOfType <World.Objects.Characters.Resources>();
            }
#endif
            int i = 0;
            foreach (var res in _characterResources.Characters)
            {
                _images[i].sprite = res.Portrait;
                i++;
            }

            _bound = (_height * _characterResources.Characters.Length) / 2;
        }
Example #2
0
        void drawWithBShiftEffect(Model model, Matrix[] transforms, CameraWrapper camera)
        {
            Matrix view             = camera.View;
            Matrix projectionMatrix = camera.Projection;

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (ModelMeshPart mmPart in mesh.MeshParts)
                {
                    // mmPart.Effect = bshiftEffect;
                    Effect effect         = mmPart.Effect;
                    Matrix worldTransform = transforms[mesh.ParentBone.Index];
                    effect.Parameters["world_Mx"].SetValue(worldTransform);
                    effect.Parameters["wvp_Mx"].SetValue(worldTransform * view * projectionMatrix);

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

                    Matrix viewInverse = Matrix.Invert(view);
                    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);
                }
                mesh.Draw();
            }
        }
Example #3
0
        // InitializeCamera() opens the camera session via the canon sdk wrapper, sets the right modes and starts the live view image feed
        private bool InitializeCamera(Camera camera)
        {
            try
            {
                CameraWrapper.OpenSession(camera);
                Console.Write("Done.\nAdjusting settings...");
                CameraWrapper.SetSetting(EDSDK.PropID_Av, CameraValues.AV(Settings.Av));
                CameraWrapper.SetSetting(EDSDK.PropID_Tv, CameraValues.TV(Settings.Tv));
                CameraWrapper.SetSetting(EDSDK.PropID_ISOSpeed, CameraValues.ISO(Settings.ISO));
                CameraWrapper.SetSetting(EDSDK.PropID_WhiteBalance, (uint)Settings.WB);

                Console.Write("Done.\nStarting LiveView...");
                LiveViewUpdating = false;
                CameraWrapper.StartLiveView();

                if (CameraWrapper.IsLiveViewOn)
                {
                    Console.WriteLine("Done.");
                    return(true);
                }
                Console.WriteLine("Error!\n-> LiveView dit not start for some reason.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error!\n-> " + e.Message);
            }
            return(false);
        }
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            var directory = AssemblyDirectory;

            detector = new FaceDetectorWrapper(
                directory + "/Model/opencv_face_detector.pbtxt",
                directory + "/Model/opencv_face_detector_uint8.pb");

            cameraWrapper = new CameraWrapper();
            var size = cameraWrapper.getFrameSize();

            cameraBuffer = new ManagedImage(size);

            Task.Run(() =>
            {
                while (true)
                {
                    lock (mutex)
                    {
                        if (shouldStop)
                        {
                            break;
                        }
                        cameraWrapper.readFrame(cameraBuffer);
                        DrawDetection(cameraBuffer);
                    }
                }
            }
                     );
        }
Example #5
0
        // Start(): Program start. Starts the main application loop (message pump)
        public void Start()
        {
            if (!Initialized)
            {
                return;
            }
            Console.WriteLine("Canon EOS camera handler for StereoScopica.");
            Console.WriteLine("Exit the main program to automatically shut down this handler.");
            Console.WriteLine();

            // Only try to initialize the preferred device index at startup
            List <Camera> camList = CameraWrapper.GetCameraList();

            if (camList.Count > Settings.DeviceIndex)
            {
                Console.Write("Initializing camera #{0}...", Settings.DeviceIndex);
                if (!InitializeCamera(camList[Settings.DeviceIndex]))
                {
                    Console.WriteLine("Error!\n-> Could not initialize the camera. Try to plug in the camera(s) again.");
                }
            }
            else
            {
                Console.WriteLine("Not enough cameras plugged in. Waiting for camera #{0}.", Settings.DeviceIndex);
            }

            // Enter the main application loop to enable event processing
            Application.Run();
        }
Example #6
0
        void drawSpheresOnSingleCamera(GameTime gameTime, CameraWrapper camera)
        {
            //MainGame.graphics.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            //MainGame.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

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

            foreach (ModelMesh mesh in sphere.model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    //boxEffect = new BasicEffect(BeatShift.graphics.GraphicsDevice);
                    effect.View       = viewMatrix;
                    effect.Projection = projectionMatrix;
                    effect.World      = sphere.transforms[mesh.ParentBone.Index];

                    effect.EnableDefaultLighting();
                    effect.PreferPerPixelLighting = true;

                    effect.DiffuseColor = Color.OrangeRed.ToVector3();
                    effect.Alpha        = 0.2f;

                    MapPoint point;
                    for (int i = CurrentMapData.mapPoints.Count - 1; i >= 0; i--)//draw in reverse order so transparency works when going the right way round the track
                    {
                        point               = CurrentMapData.mapPoints[i];
                        effect.World        = Matrix.CreateScale(point.getWidth()) * Matrix.CreateTranslation(point.position);
                        effect.DiffuseColor = point.getColour();
                        mesh.Draw();
                    }
                }
            }
        }
Example #7
0
        public void DrawSkybox(GameTime gameTime, CameraWrapper camera)
        {
            BeatShift.graphics.GraphicsDevice.Viewport = camera.Viewport;

            if (!Globals.DisplaySkybox)
            {
                return;
            }

            Matrix scale = Matrix.CreateScale(7f);

            Matrix[] skyboxTransforms = new Matrix[skyboxModel.Bones.Count];
            skyboxModel.CopyAbsoluteBoneTransformsTo(skyboxTransforms);
            Matrix viewMatrix       = camera.View;
            Matrix projectionMatrix = camera.Projection;

            //Vector3 upMovement = new Vector3(0f, 50f, 0f);

            foreach (ModelMesh mesh in skyboxModel.Meshes)
            {
                foreach (BasicEffect currentEffect in mesh.Effects)
                {
                    Matrix translation = Matrix.CreateTranslation(camera.racer.shipPhysics.ShipPosition);//+upMovement);
                    currentEffect.View       = viewMatrix;
                    currentEffect.Projection = projectionMatrix;

                    currentEffect.World = scale * skyboxTransforms[mesh.ParentBone.Index] * translation;//transforms;
                }

                mesh.Draw();
            }
        }
Example #8
0
        public void Update()
        {
            if (!isCompatible)
            {
                return;
            }
            if (counter < 5)
            {
                counter += TimeWarp.fixedDeltaTime;
                return;
            }
            if (cams == null)
            {
                cams = new List <CameraWrapper>();

                Camera[] cameras = Camera.allCameras;

                foreach (Camera cam in cameras)
                {
                    try
                    {
                        CameraWrapper thisCam = new CameraWrapper();
                        thisCam.camName        = cam.name.ToString();
                        thisCam.depth          = cam.depth.ToString();
                        thisCam.farClipPlane  += cam.farClipPlane.ToString();
                        thisCam.nearClipPlane += cam.nearClipPlane.ToString();
                        // layer cull appears unused by relevant cameras.

                        /*for (int i = 0; i < cam.layerCullDistances.Length; i++)
                         *  thisCam.layerCullDistances.Add("" + cam.layerCullDistances[i]);*/

                        cams.Add(thisCam);
                    }
                    catch (Exception e)
                    {
                        Debug.Log("*RSSGUI* Exception getting camera " + cam.name + "\n" + e);
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.G) && Input.GetKey(KeyCode.LeftAlt))
            {
                GUIOpen = !GUIOpen;
                if (GUIOpen)
                {
                    afg = findAFG();
                    if (afg != null)
                    {
                        rt     = afg.waveLength.r.ToString();
                        gt     = afg.waveLength.g.ToString();
                        bt     = afg.waveLength.b.ToString();
                        at     = afg.waveLength.a.ToString();
                        ESunt  = afg.ESun.ToString();
                        Krt    = afg.Kr.ToString();
                        Kmt    = afg.Km.ToString();
                        innert = (afg.innerRadius * ScaledSpace.ScaleFactor).ToString();
                        outert = (afg.outerRadius * ScaledSpace.ScaleFactor).ToString();
                    }
                }
            }
        }
Example #9
0
        public void DrawAiHUD(CameraWrapper camera, GameTime gameTime)
        {
            String message = "AI-HUD:\nAcceleration: " + accelVal + "\n  -closerBy: " + closerBy + "\n  -cB_Fraction: " + closerByFraction + "\n\nTurn: " + turnVal + "\n  -randInaccuracy: " + randInaccuracy + "\n  -fTrack3: " + fTrack3 + "\n  -fTrack5: " + fTrack5 + "\n  -sideWalls: " + sideWalls + "\n  -frontWalls: " + frontWalls;

            BeatShift.spriteBatch.DrawString(BeatShift.newfont, message, hudPosition, Color.White, 0f, Vector2.Zero, 0.65f, SpriteEffects.None, 1);
            BeatShift.spriteBatch.DrawString(BeatShift.newfont, message, hudPosition2, Color.Black, 0f, Vector2.Zero, 0.65f, SpriteEffects.None, 1);
        }
Example #10
0
        public Video()
        {
            Camera = new CameraWrapper(0, null);
            Gender = new LibCaffeWrapper(0);
            Age    = new LibCaffeWrapper(1);
            //ANG = new LibCaffeWrapper(0);
            Gender.Predict(StartLoc + "\\m\\deploy_gender.prototxt",
                           StartLoc + "\\m\\gender_500001229.caffemodel",
                           StartLoc + "\\m\\g_mean1229.binaryproto",
                           StartLoc + "\\example_image.jpg");
            Age.Predict(StartLoc + "\\m\\deploy_age.prototxt",
                        StartLoc + "\\m\\age_net.caffemodel",
                        StartLoc + "\\m\\g_mean1229.binaryproto",
                        StartLoc + "\\example_image.jpg");

            //ANG.ANGPredict(Application.StartupPath + "\\m\\deploy_age.prototxt",
            //       Application.StartupPath + "\\m\\age_net.caffemodel",
            //       Application.StartupPath + "\\m\\g_mean1229.binaryproto",
            //       Application.StartupPath + "\\m\\deploy_gender.prototxt",
            //        Application.StartupPath + "\\m\\gender_500001229.caffemodel",
            //        Application.StartupPath + "\\m\\g_mean1229.binaryproto",
            //       Application.StartupPath + "\\example_image.jpg");
            //MessageBox.Show(Application.StartupPath);
            InitializeComponent();
            axWindowsMediaPlayer2.windowlessVideo = false;
            axWindowsMediaPlayer2.uiMode          = "none";
        }
        public override void OnValidate()
        {
            base.OnValidate();

            if (_camera == null)
            {
                _camera = FindObjectOfType <CameraWrapper>();
            }
        }
Example #12
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);
            }
        }
Example #13
0
        public void DrawGlow(GameTime gameTime, CameraWrapper camera)
        {
            BeatShift.graphics.GraphicsDevice.Viewport = camera.Viewport;

            foreach (FbxModel modelObject in modelList)
            {
                if (modelObject.mapName == currentMapName || modelObject.mapName == MapName.All)
                {
                    if (modelObject.category.Equals(ModelCategory.GlowScenery))
                    {
                        drawWithBShiftEffect(modelObject.model, modelObject.transforms, camera);
                    }
                }
            }
        }
Example #14
0
 // Disconnect camera
 private void CloseCamera()
 {
     if (!CameraWrapper.CameraSessionOpen)
     {
         return;
     }
     if (!CameraWrapper.IsLiveViewOn)
     {
         return;
     }
     // Unset Depth of Field Preview to avoid errorous states in the camera
     CameraWrapper.SetSetting(EDSDK.PropID_Evf_DepthOfFieldPreview, 0);
     LiveViewUpdating = false;
     // Don't call CloseSession() here! The SetSetting call above will result in a exception in a different thread in the CanonEDSDKWrapper
     // The wrapper will call closesession when it is needed
 }
Example #15
0
        public void Update()
        {
            if (!isCompatible)
            {
                return;
            }

            if (counter < 5)
            {
                counter += TimeWarp.fixedDeltaTime;
                return;
            }

            if (cams == null)
            {
                cams = new List <CameraWrapper>();

                Camera[] cameras = Camera.allCameras;

                foreach (Camera cam in cameras)
                {
                    try
                    {
                        var thisCam = new CameraWrapper
                        {
                            camName = cam.name,

                            depth = cam.depth.ToString()
                        };

                        thisCam.farClipPlane  += cam.farClipPlane.ToString();
                        thisCam.nearClipPlane += cam.nearClipPlane.ToString();

                        cams.Add(thisCam);
                    }
                    catch (Exception exceptionStack)
                    {
                        Debug.Log("[RealSolarSystem]: Exception getting camera " + cam.name + "\n" + exceptionStack);
                    }
                }
            }

            if (Input.GetKeyDown(KeyCode.G) && Input.GetKey(KeyCode.LeftAlt))
            {
                GUIOpen = !GUIOpen;
            }
        }
Example #16
0
 // LiveViewUpdated() is called from the canon sdk wrapper when a new image is read from the camera and is ready for processing
 // LiveViewUpdated() writes the image to the anonymous memory pipe.
 // An IO error will terminate the application.
 // Depth Of Field Preview mode is also enabled after the first received image (to avoid a black screen)
 private void LiveViewUpdated(Stream img)
 {
     // Check if first image
     if (!LiveViewUpdating)
     {
         Console.WriteLine("Received first image from camera. Enabling Depth of Field Preview.");
         // Enable Depth of Field Preview mode for auto focus
         // Enabling it now seems to work better than right after calling StartLiveView() (for some reason)
         CameraWrapper.SetSetting(EDSDK.PropID_Evf_DepthOfFieldPreview, 1);
         LiveViewUpdating = true;
     }
     if (PipeClient.IsConnected)
     {
         try
         {
             // Protocol: int32 [image length] + length amount of image data in bytes
             int written;
             int length = (int)img.Length;
             if (length <= 0)
             {
                 return;
             }
             byte[] buffer = new byte[length];
             PipeWriter.Write(length);
             while ((written = img.Read(buffer, 0, buffer.Length)) != 0)
             {
                 PipeWriter.Write(buffer, 0, written);
             }
             PipeWriter.Flush();
         }
         catch (IOException e)
         {
             Console.WriteLine("Pipe error: {0}", e.Message);
             CloseCamera();
             Application.Exit();
         }
     }
     else
     {
         Console.WriteLine("Pipe disconnected during image update, exiting...");
         CloseCamera();
         Application.Exit();
     }
 }
Example #17
0
        public void Draw(GameTime gameTime, CameraWrapper camera)
        {
            BeatShift.graphics.GraphicsDevice.Viewport = camera.Viewport;

            if (Options.DrawTrackNormals) //Draw track normals.
            {
                drawTrackNormals(gameTime, camera);
            }

            //DrawMap
            BeatShift.graphics.GraphicsDevice.BlendState = BlendState.Opaque;
            foreach (FbxModel modelObject in modelList)
            {
                if (modelObject.mapName == currentMapName || modelObject.mapName == MapName.All)
                {
                    drawModel(modelObject, gameTime, camera);
                }
            }
        }
Example #18
0
        void drawWithBasicEffect(FbxModel fbxModel, CameraWrapper camera)
        {
            Matrix viewMatrix       = camera.View;
            Matrix projectionMatrix = camera.Projection;

            foreach (ModelMesh mesh in fbxModel.model.Meshes)
            {
                foreach (BasicEffect beffect in mesh.Effects)
                {
                    beffect.View       = viewMatrix;
                    beffect.Projection = projectionMatrix;
                    beffect.World      = fbxModel.transforms[mesh.ParentBone.Index];

                    beffect.EnableDefaultLighting();
                    beffect.PreferPerPixelLighting = true;
                }
                mesh.Draw();
            }
        }
Example #19
0
        public static void drawArrow(CameraWrapper camera, Vector3 position, Vector3 D, Vector3 colour)
        {
            GraphicsDevice gDevice = BeatShift.graphics.GraphicsDevice;

            arrowVertices[0] = new VertexPositionColor(Vector3.Forward * D.Length(), Color.White);
            arrowVertexBuffer.SetData(arrowVertices);
            //arrowEffect.Alpha = 0.5f;
            //gDevice.BlendState = BlendState.AlphaBlend;
            gDevice.SetVertexBuffer(arrowVertexBuffer);
            arrowEffect.World              = Matrix.CreateWorld(position, D, Vector3.Up);
            arrowEffect.View               = camera.View;
            arrowEffect.Projection         = camera.Projection;
            arrowEffect.VertexColorEnabled = true;
            arrowEffect.DiffuseColor       = colour;
            foreach (EffectPass pass in arrowEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                gDevice.DrawUserIndexedPrimitives <VertexPositionColor>(PrimitiveType.TriangleList, arrowVertices, 0, arrowVertices.Length, arrowIndices, 0, arrowIndices.Length / 3);
            }
        }
Example #20
0
 protected virtual void Dispose(bool disposing)
 {
     if (_disposed)
     {
         return;
     }
     if (disposing && Initialized)
     {
         try {
             CameraWrapper.Dispose();
         }
         catch (Exception e)
         {
             Console.WriteLine("EDSDK shutdown error: " + e);
         }
         PipeWriter.Dispose();
         PipeClient.Dispose();
     }
     _disposed = true;
 }
Example #21
0
        // CameraAdded() iterates over the connected cameras and tries to initialize each (it can be in use)
        private void CameraAdded()
        {
            // Skip the event call if we have found our camera already
            if (CameraWrapper.CameraSessionOpen)
            {
                return;
            }

            List <Camera> camList = CameraWrapper.GetCameraList();

            Console.WriteLine("A camera was plugged in! Found {0} camera(s).", camList.Count);

            for (int i = 0; i < camList.Count; i++)
            {
                Console.Write("Trying to initialize camera {0} \"{1}\"...", i + 1, camList[i].Info.szDeviceDescription);
                if (InitializeCamera(camList[i]))
                {
                    break;
                }
            }
        }
        public void OnValidate()
        {
            if (rect == null)
            {
                rect = GetComponent <RectTransform>();
            }

            if (_camera == null)
            {
                _camera = FindObjectOfType <CameraWrapper>();
            }

            if (_anchor != null)
            {
                //_candidate.x = Mathf.Round(_anchor.position.x * 100f) / 100f;
                //_candidate.y = Mathf.Round(_anchor.position.y * 100f) / 100f;
                //_candidate.z = Mathf.Round(_anchor.position.z * 100f) / 100f;
                //_candidate = Camera.main.WorldToScreenPoint(_candidate);
                //_candidate = Utils.Vectors.Round(_candidate); // Pixel snapping
                //_candidate.z = 0;
                //rect.position = _candidate + _offset;
            }
        }
Example #23
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            ExitWrapper.Init(this);
            mGraphics.GraphicsProfile = GraphicsProfile.HiDef;

            if (Settings.Dict["Fullscreen"] == "on")
            {
                ScreenSize.CurrentSize(mGraphics);
            }
            else
            {
                mGraphics.ApplyChanges();
            }
            IsMouseVisible = false;
            mCamera        = new Camera(mGraphics)
            {
                Position = AMainMenuPage.sCameraPosition
            };
            CameraWrapper.Init(mCamera);
            Globals.GetResolution(mGraphics);
            mInputManager = new InputManager(Content);
            mInputManager.GetCam(mCamera);
            ExitWrapper.LoadInputManager(mInputManager);
            CameraWrapper.LoadInputManager(mInputManager);
            ModelManager.Initialize(mGraphics.GraphicsDevice, Content, mCamera);
            AKi.LoadInputManager(mInputManager);
            ToolBox.Initialize(mGraphics, mCamera);
            SoundManager.Init();
            mMusicManager = new MusicManager(Content, "music/background", "music/win", "music/lose");

            mSoundEffectManager = new SoundEffectManager(Content, "sounds/battering_ram", "sounds/bowman", "sounds/cavalry", "sounds/swordsman", "sounds/hero");
            AAudioMenu.Init(mSoundEffectManager, mMusicManager);
            GameState.Init(mSoundEffectManager);

            base.Initialize();
        }
Example #24
0
        void drawModel(FbxModel modelObject, GameTime gameTime, CameraWrapper camera)
        {
            //Don't draw invisible things
            if (modelObject.category == ModelCategory.InvisibleWall)
            {
                return;
            }
            if (modelObject.category == ModelCategory.GlowScenery)
            {
                return;
            }
            //Don't draw when settings turn scenery display off
            if ((!Globals.DisplayScenery) && (modelObject.category.Equals(ModelCategory.SceneryFx) || modelObject.category.Equals(ModelCategory.SceneryBasic)))
            {
                return;                                                                                                                                               //If scenery should not be displayed, don't draw scenry
            }
            //Draw both sides of track by changing cull mode
            if (modelObject.category == ModelCategory.Track)
            {
                BeatShift.graphics.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
            }


            if (modelObject.category == ModelCategory.SceneryBasic)
            {
                drawWithBasicEffect(modelObject, camera);
            }
            else
            {
                drawWithBShiftEffect(modelObject.model, modelObject.transforms, camera);
            }
            if (modelObject.category == ModelCategory.Track)
            {
                BeatShift.graphics.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
            }
        }
Example #25
0
        //this is the callback for camera
        private void WebCamCallBack(int nID, IntPtr pData)
        {
            try
            {
                int nWidth = 0, nHeight = 0, nSize = 0, nFourCC = 0;
                CameraWrapper.GetInfo(nID, ref nWidth, ref nHeight, ref nSize, ref nFourCC);
                if ((uint)nFourCC != 0xe436eb7d)//MEDIASUBTYPE_RGB24
                {
                    return;
                }

                if (pData == (IntPtr)0)
                {
                    if (m_cbCameraError != null)
                    {
                        m_cbCameraError();
                    }
                    return;
                }



                while (flagLock != 0)
                {
                    ;
                }
                //update UI
                flagLock = 1;
                camFrame = new Bitmap(nWidth, nHeight, 3 * nWidth, PixelFormat.Format24bppRgb, pData);
                if (m_bFlipCamera)
                {
                    camFrame.RotateFlip(RotateFlipType.RotateNoneFlipX);
                }

                if (m_nFrameCount == 90)
                {
                    //midImage = camFrame.Clone();
                    bool bLock = Monitor.TryEnter(m_ImageLocker, 1000);
                    if (bLock)
                    {
                        try
                        {
                            if (m_camFrame != null)
                            {
                                m_camFrame.Dispose();
                            }
                            using (m_camFrame = new Bitmap(camFrame))
                            {
                                m_camFrame.Save(StartLoc + "\\1.png", System.Drawing.Imaging.ImageFormat.Png);
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("请用管理员权限运行程序");
                        }
                        //m_camFrame = new Bitmap(camFrame);
                        //m_camFrame.Save("D:\\1.png", System.Drawing.Imaging.ImageFormat.Png);
                        Monitor.Exit(m_ImageLocker);
                    }
                    if (CheckNum == 0)
                    {
                        ManNum       = 0;
                        BabyNum      = 0;
                        ChildNum     = 0;
                        TeenNum      = 0;
                        ZhongnianNum = 0;
                        TherNum      = 0;
                    }
                    CheckNum++;
                    watch.Reset();
                    watch.Start();
                    GenderThread = new Thread(GenderPredict);
                    GenderThread.IsBackground = true;
                    GenderThread.Start();

                    AgeThread = new Thread(AgePredict);
                    AgeThread.Start();

                    if (CheckNum == 3)
                    {
                        VideoPlay();
                        //Play = new Thread(VideoPlay);
                        //Play.Start();
                        CheckNum = 0;
                    }


                    //label4.Text = GenderString;
                    //label1.Text = AgeString;
                }
                if (PicBoxVideo != null)
                {
                    PicBoxVideo.Image = camFrame;

                    //System.Console.WriteLine(PicBoxVideo.ImageLocation);
                }



                //imagedata = imageToByteArray(PicBoxVideo.Image);
                // midImage.Save("D:\\1.png");



                flagLock = 0;



                m_nFrameCount++;
                if (m_nFrameCount % m_nFramesForGCCollection == 0)
                {
                    m_nFrameCount = 0;
                    GC.Collect();
                }
            }
            catch (System.InvalidOperationException)
            {
                //do nothing
                Camera.Close();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("In WebCamCallBack " + ex.ToString());
            }
        }
Example #26
0
        public void Update()
        {
            if (counter < 5)
            {
                counter += TimeWarp.fixedDeltaTime;
                return;
            }
            if (cams == null)
            {
                cams = new List<CameraWrapper>();

                Camera[] cameras = Camera.allCameras;

                foreach (Camera cam in cameras)
                {
                    try
                    {
                        CameraWrapper thisCam = new CameraWrapper();
                        thisCam.camName = cam.name.ToString();
                        thisCam.depth = cam.depth.ToString();
                        thisCam.farClipPlane += cam.farClipPlane.ToString();
                        thisCam.nearClipPlane += cam.nearClipPlane.ToString();
                        // layer cull appears unused by relevant cameras.
                        /*for (int i = 0; i < cam.layerCullDistances.Length; i++)
                            thisCam.layerCullDistances.Add("" + cam.layerCullDistances[i]);*/

                        cams.Add(thisCam);
                    }
                    catch (Exception e)
                    {
                        Debug.Log("*RSSGUI* Exception getting camera " + cam.name + "\n" + e);
                    }
                }
            }
            if (Input.GetKeyDown(KeyCode.G) && Input.GetKey(KeyCode.LeftAlt))
            {
                GUIOpen = !GUIOpen;
                if (GUIOpen)
                {
                    afg = findAFG();
                    if (afg != null)
                    {
                        rt = afg.waveLength.r.ToString();
                        gt = afg.waveLength.g.ToString();
                        bt = afg.waveLength.b.ToString();
                        at = afg.waveLength.a.ToString();
                        ESunt = afg.ESun.ToString();
                        Krt = afg.Kr.ToString();
                        Kmt = afg.Km.ToString();
                        innert = (afg.innerRadius * ScaledSpace.ScaleFactor).ToString();
                        outert = (afg.outerRadius * ScaledSpace.ScaleFactor).ToString();
                    }
                }
            }
        }
Example #27
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));
            }
        }
Example #28
0
 public RacerHuman(RacerId rID, int shipNumber, RacerType racer_Type, int viewportIndex, Boolean hasPhysics)
     : base(rID, shipNumber, racer_Type)
 {
     cameraIndex = viewportIndex;
     localCamera = new CameraWrapper(this);
 }
Example #29
0
 public void drawSpheres(GameTime gameTime, CameraWrapper camera)
 {
     BeatShift.graphics.GraphicsDevice.Viewport = camera.Viewport;
     drawSpheresOnSingleCamera(gameTime, camera);
 }
Example #30
0
        /// <summary>
        /// Draws a heads up display on the current camera in its viewport, as long as the ship is not PlayerType.None
        /// </summary>
        public static void DrawHUD(CameraWrapper camera, Racer racer, GameTime gameTime)//(Matrix viewMatrix, Matrix projectionMatrix)
        {
            //Getting information from the GraphicsDevice might be very slow on Xbox
            int viewportHeight = camera.Viewport.Height;
            int viewportWidth  = camera.Viewport.Width;

            if (racer.racerType == RacerType.None)
            {
                return;//No HUD when just viewing ship model.
            }
            //Draw speed text //must be after mesh.draw

            int vOffset = camera.Viewport.Height - 60;

            //MainGame.graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend;//Set display states

            int bleedHeight = (int)(viewportHeight * 0.1);
            int bleedWidth  = (int)(viewportWidth * 0.1);


            if (racer.raceTiming.hasCompletedRace && GameLoop.raceComplete != true)
            {
                ////////////////////////
                ///// FINAL RESULTS ////
                ////////////////////////
                if (Race.currentRaceType.getRaceType().Equals(RaceType.LappedRace))
                {
                    //BeatShift.spriteBatch.Begin();//(SpriteSortMode.Immediate, BlendState.AlphaBlend);
                    //DrawMessage("Finished!", 325, vOffset / 2);
                    DrawMessageColour(BeatShift.newfont, "Finished!", viewportWidth / 4, viewportHeight / 2 + 40, 0.6f, Color.PapayaWhip);
                    //DrawMessage("Final Time: " + racer.raceTiming.getFinalTotalTime(), 300, vOffset / 2 + 40);
                }
                if (Race.currentRaceType.getRaceType().Equals(RaceType.EliminiationRace))
                {
                    BeatShift.spriteBatch.Draw(GameTextures.Eliminated, new Rectangle(viewportWidth / 2 - GameTextures.Eliminated.Width / 2, 3 * viewportHeight / 3, GameTextures.Eliminated.Width, GameTextures.Eliminated.Height), Color.PapayaWhip);
                    //DrawMessage("ELIMINATED!", 325, vOffset / 2);
                }
                if (Race.currentRaceType.getRaceType().Equals(RaceType.TimeTrialRace))
                {
                    //BeatShift.spriteBatch.Begin();
                    DrawMessageColour(BeatShift.newfont, "Best Lap: " + racer.raceTiming.getBestLapTime(), viewportWidth / 4, viewportHeight / 2, 0.5f, Color.PapayaWhip);
                    //DrawMessage("Best lap time: " + racer.raceTiming.getBestLapTime(), 325, vOffset / 2);
                }
            }
            else
            {
                //Draw messages to when points are given
                ////////////////////
                //// Points Msg ////
                ////////////////////
                racer.racerPoints.pointsPopupManager.Draw(new Vector2(80f, viewportHeight - 140));
                //DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(), viewportWidth - 125, 195, 0.3f, Color.Goldenrod);

                //////////////////
                //// Messages ////
                //////////////////
                racer.messagePopupManager.Draw(new Vector2(180f, viewportHeight - 140));
                //DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(),viewportWidth - 125, 195, 0.4f, Color.Goldenrod);

                /////////////////////
                ///// HUD BAR ///////
                /////////////////////
                int h = viewportWidth / (GameTextures.HudBar.Width / GameTextures.HudBar.Height);

                if (viewportWidth > 700)
                {
                    BeatShift.spriteBatch.Draw(GameTextures.HudBar, new Rectangle(0, viewportHeight - GameTextures.HudBar.Height, GameTextures.HudBar.Width, GameTextures.HudBar.Height), Color.White);
                }
                else
                {
                    BeatShift.spriteBatch.Draw(GameTextures.HudBarSmall, new Rectangle(0, viewportHeight - GameTextures.HudBarSmall.Height, GameTextures.HudBarSmall.Width, GameTextures.HudBarSmall.Height), Color.White);
                }
                ////////////////////////////
                ///// ORANGE BOOST BAR /////
                ////////////////////////////

                racer.raceTiming.previousBoost       = MathHelper.Lerp(racer.raceTiming.previousBoost, (float)racer.racingControls.getBoostValue() / 100, 0.1f);
                racer.raceTiming.previousLapProgress = MathHelper.Lerp(racer.raceTiming.previousLapProgress, (float)racer.shipPhysics.getLapPercentage() / 100, 0.05f);

                var chosenLine = (viewportWidth > 700) ? GameTextures.BoostBarLine : GameTextures.BoostBarLineSmall;
                int srcWidth   = (int)((chosenLine.Width) * racer.raceTiming.previousBoost);

                if (viewportWidth > 700)
                {
                    Rectangle orange_src2 = new Rectangle(chosenLine.Width - srcWidth, 0, chosenLine.Width, chosenLine.Height);
                    Rectangle orange_dest = new Rectangle(36, viewportHeight - chosenLine.Height, chosenLine.Width, chosenLine.Height);
                    BeatShift.spriteBatch.Draw(chosenLine, orange_dest, orange_src2, Color.White);
                }
                else
                {
                    Rectangle orange_src2 = new Rectangle(chosenLine.Width - srcWidth, 0, chosenLine.Width, chosenLine.Height);
                    Rectangle orange_dest = new Rectangle(21, viewportHeight - chosenLine.Height, chosenLine.Width, chosenLine.Height);
                    BeatShift.spriteBatch.Draw(chosenLine, orange_dest, orange_src2, Color.White);
                }

                /////////////////////////
                ///////// LEVEL /////////
                /////////////////////////

                if (viewportWidth > 700)
                {
                    DrawMessageColour(BeatShift.volterfont, "LEVEL", viewportWidth - 240, vOffset - 53, 0.5f, Color.PapayaWhip);
                    DrawMessageColour(BeatShift.volterfont, (racer.beatQueue.getLayer() + 1).ToString(), viewportWidth - 230, vOffset - 35, 1f, Color.PapayaWhip);
                }
                else
                {
                    DrawMessageColour(BeatShift.volterfont, "LEVEL", viewportWidth - 143, vOffset - 12, 0.4f, Color.PapayaWhip);
                    DrawMessageColour(BeatShift.volterfont, (racer.beatQueue.getLayer() + 1).ToString(), viewportWidth - 136, vOffset - 3, 0.8f, Color.PapayaWhip);
                }

                //////////////////////////
                /////// COMBO COUNT //////
                //////////////////////////

                //if (viewportWidth > 700)
                //{
                //    DrawMessageColour(BeatShift.volterfont, racer.beatQueue.getCombo().ToString()+"x", viewportWidth - 240, vOffset - 73, 3f, Color.Black);
                //}
                //else
                //{
                //    DrawMessageColour(BeatShift.volterfont, racer.beatQueue.getCombo().ToString() + "x", viewportWidth - 143, vOffset - 42, 2.4f, Color.Black);
                //}


                //DrawMessageColour(BeatShift.volterfont, GameDebugTools.ReflectionTracker.getTrackedAsString(), 0, 0, 1.2f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "nextWaypoint: " + racer.shipPhysics.nextWaypoint.getIndex(), 0, 50, 1.5f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "currentProgressWaypoint: " + racer.shipPhysics.currentProgressWaypoint.getIndex(), 0, 80, 1.5f, Color.Black);
                //DrawMessageColour(BeatShift.volterfont, "nearestMapPoint: " + racer.shipPhysics.nearestMapPoint.getIndex(), 0, 110, 1.5f, Color.Black);

                ////////////////////////
                /////// SPEED //////////
                ////////////////////////
                try
                {
                    racer.raceTiming.previousSpeed = MathHelper.Lerp(racer.raceTiming.previousSpeed, (Math.Abs((int)racer.shipPhysics.getForwardSpeed())), 0.05f);
                }
                catch (OverflowException e)
                {
                    racer.raceTiming.previousSpeed = 0;
                }
                racer.raceTiming.speedToDisplay = String.Format("{0:0000}", racer.raceTiming.previousSpeed);
                if (viewportWidth > 700)
                {
                    DrawMessageColour(BeatShift.volterfont, "MPH", viewportWidth - 126, vOffset - 42, 0.5f, Color.Black);
                    DrawMessageColour(BeatShift.newfont, racer.raceTiming.speedToDisplay, viewportWidth - 185, vOffset - 48, 0.4f, Color.Black);
                }
                else
                {
                    DrawMessageColour(BeatShift.volterfont, "MPH", viewportWidth - 75, vOffset - 14, 0.5f, Color.Black);
                    DrawMessageColour(BeatShift.newfont, racer.raceTiming.speedToDisplay, viewportWidth - 110, vOffset - 8, 0.4f, Color.Black);
                }

                //////////////////////////////
                /////// TOP RIGHT BOARD //////
                //////////////////////////////

                double scaleFactorHeight = (double)viewportHeight / 720;
                double scaleFactorWidth  = scaleFactorHeight;// (double)viewportWidth / 1280;

                int newBoardWidth  = (int)(GameTextures.TopRightBoard.Width * scaleFactorWidth);
                int newBoardHeight = (int)(GameTextures.TopRightBoard.Height * scaleFactorHeight);

                if (Race.currentRaceType.getRaceType().Equals(RaceType.EliminiationRace))
                {
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.EliminationBar.Width, 0, GameTextures.EliminationBar.Width, GameTextures.EliminationBar.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.EliminationBar, d, Color.White);

                        if (racer.raceTiming.currentRanking == Race.currentRacers.Count)
                        {
                            DrawMessageColour(BeatShift.newfont, "DANGER!", viewportWidth - 190, 55, 0.75f, Color.White);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, "SAFE", viewportWidth - 180, 55, 0.75f, Color.White);
                        }

                        //if (racer.raceTiming.currentRanking == 1)
                        //{
                        //    DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 160, 55, 0.75f, Color.PapayaWhip);
                        //    DrawMessageColour(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 140, 55, 0.75f, Color.PapayaWhip);
                        //}
                        //else
                        //{
                        //    DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 160, 55, 0.75f, Color.PapayaWhip);
                        //    DrawMessageColour(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 135, 55, 0.75f, Color.PapayaWhip);
                        //}
                    }
                }
                else if (Race.currentRaceType.getRaceType().Equals(RaceType.PointsRace))
                {
                    if (viewportWidth > 700)
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.PointsHUD.Width, 0, GameTextures.PointsHUD.Width, GameTextures.PointsHUD.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.PointsHUD, d, Color.White);
                    }
                    else
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.PointsHUD.Width, 0, GameTextures.PointsHUD.Width, GameTextures.PointsHUD.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.PointsHUD, d, Color.White);
                    }
                }
                else
                {
                    if (viewportWidth > 700)
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.TopRightBoard.Width, 0, GameTextures.TopRightBoard.Width, GameTextures.TopRightBoard.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.TopRightBoard, d, Color.White);
                    }
                    else
                    {
                        Rectangle d = new Rectangle(viewportWidth - GameTextures.TopRightBoardSmall.Width, 0, GameTextures.TopRightBoardSmall.Width, GameTextures.TopRightBoardSmall.Height);
                        BeatShift.spriteBatch.Draw(GameTextures.TopRightBoardSmall, d, Color.White);
                    }
                }


                //////////////////////////////
                //////// TOTAL POINTS ////////
                //////////////////////////////

                if (Race.currentRaceType.displayTotalPoints)
                {
                    DrawMessageColour(BeatShift.newfont, racer.racerPoints.getTotalPoints().ToString(), viewportWidth - GameTextures.PointsHUD.Width / 2 - 65, 65, 1f, Color.PapayaWhip);
                }

                //////////////////////////////
                ////////// TOTAL LAPS ////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentLapOutofTotalLaps)
                {
                    if (viewportWidth > 700)
                    {
                        if (racer.raceTiming.isRacing == true)
                        {
                            DrawMessageColour(BeatShift.newfont, (racer.raceTiming.currentLap + 1) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 125, 33, 0.5f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, (racer.raceTiming.currentLap) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 125, 33, 0.5f, Color.PapayaWhip);
                        }
                        DrawMessageColour(BeatShift.volterfont, "LAPS", viewportWidth - 74, 39, 1f, Color.DimGray);
                    }
                    else
                    {
                        if (racer.raceTiming.isRacing == true)
                        {
                            DrawMessageColour(BeatShift.volterfont, (racer.raceTiming.currentLap + 1) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 82, 25, 0.5f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.volterfont, (racer.raceTiming.currentLap) + "/" + Race.currentRaceType.maxLaps, viewportWidth - 82, 25, 0.5f, Color.PapayaWhip);
                        }
                        DrawMessageColour(BeatShift.volterfont, "LAPS", viewportWidth - 54, 25, 0.5f, Color.PapayaWhip);
                    }
                }

                //////////////////////////////
                ///////// CURRENT LAP ////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentLapTime)
                {
                    if (viewportWidth > 700)
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getCurrentLapTime(), viewportWidth - 125, 70, 0.4f, Color.PapayaWhip);
                    }
                    else
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getCurrentLapTime(), viewportWidth - 125, 36, 0.4f, Color.PapayaWhip);
                    }
                }
                /////////////////////////////
                ////// WRONG WAY SIGN ///////
                /////////////////////////////

                if (racer.shipPhysics.wrongWay == true)
                {
                    int newWarningWidth  = (int)(GameTextures.WrongWaySign.Width * scaleFactorWidth);
                    int newWarningHeight = (int)(GameTextures.WrongWaySign.Height * scaleFactorHeight);
                    BeatShift.spriteBatch.Draw(GameTextures.WrongWaySign, new Rectangle(viewportWidth / 2 - newWarningWidth / 2, viewportHeight / 2 - newWarningHeight / 2, newWarningWidth, newWarningHeight), Color.White);
                }

                /////////////////////////////
                ////// RESETTING SIGN ///////
                /////////////////////////////

                if (racer.isRespawning && racer.shipPhysics.millisecsLeftTillReset < 2000)
                {
                    int newWarningWidth  = (int)(GameTextures.ResettingSign.Width * scaleFactorWidth);
                    int newWarningHeight = (int)(GameTextures.ResettingSign.Height * scaleFactorHeight);
                    BeatShift.spriteBatch.Draw(GameTextures.ResettingSign, new Rectangle(viewportWidth / 2 - newWarningWidth / 2, viewportHeight / 2 - newWarningHeight / 2, newWarningWidth, newWarningHeight), Color.White);
                }

                /////////////////////////////
                ////// COUNTDOWN SIGN ///////
                /////////////////////////////

                if (Race.currentRaceType.countDownRunning)
                {
                    BeatShift.spriteBatch.Draw(Race.currentRaceType.countdownState, new Vector2(viewportWidth / 2 - Race.currentRaceType.countdownState.Width / 2, viewportHeight / 2 - Race.currentRaceType.countdownState.Height / 2), Color.White);
                }

                // Other info
                //DrawMessage("Progress: " + racer.getLapPercentage() + "%", 10, vOffset + 26);
                //DrawMessage("Accuracy: " + racer.racingControls.getLastPress(), 10, vOffset - 30);
                //DrawMessage("Dist from trac: " + racer.shipPhysics.shipRayToTrackTime, 10, vOffset - 30);
                //DrawNewMessage(" !\"#$%'()*+,-./0123456789:;<=>?@ABCDEFGHIJ", 0, 30);
                //DrawNewMessage("KLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrrstuvwxyz{|}~", 0, 90);


                //////////////////////////////
                ////////// BEST LAP //////////
                //////////////////////////////

                if (Race.currentRaceType.displayCurrentBestLap)
                {
                    if (viewportWidth > 700)
                    {
                        DrawMessageColour(BeatShift.newfont, racer.raceTiming.getBestLapTime(), viewportWidth - 125, 95, 0.4f, Color.Goldenrod);
                    }

                    //////////////////////////
                    ////////// RANK //////////
                    //////////////////////////

                    if (Race.currentRaceType.displayCurrentRank && racer.raceTiming.currentRanking == 0)
                    {
                        if (viewportWidth > 700)
                        {
                            DrawMessageColour(BeatShift.newfont, "-", viewportWidth - 190, 22, 0.75f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, "-", viewportWidth - 187, 22, 0.75f, Color.PapayaWhip);
                        }
                    }
                    else if (Race.currentRaceType.displayCurrentRank)
                    {
                        if (viewportWidth > 700)
                        {
                            DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 190, 22, 0.75f, Color.PapayaWhip);
                        }
                        else
                        {
                            DrawMessageColour(BeatShift.newfont, racer.raceTiming.currentRanking.ToString(), viewportWidth - 187, 22, 0.75f, Color.PapayaWhip);
                        }
                        //DrawMessage(BeatShift.newfont, calculateRankSuffix(racer.raceTiming.currentRanking), viewportWidth - 178 + extraSuffixOffset(racer.raceTiming.currentRanking), 26, 0.25f);
                    }
                }
            }
        }