Exemple #1
0
        private void BoxCollideWithGround(MataliPhysicsObject baseObject, MataliPhysicsObject collidingObject)
        {
            String materialName = ((IPhysicsObject)collidingObject.UserTagObj).MaterialName;

            if (materialName.Equals("Ground"))
            {
                // Set the collision sound volume based on the contact speed
                SoundEffectInstance instance = Sound.Instance.PlaySoundEffect(bounceSound);
                // Print a text message on the screen
                Notifier.AddMessage("Contact with ground");

                // Create a 3D text to be rendered
                Text3DInfo text3d = new Text3DInfo();
                text3d.Text = "BOOM!!";
                // The larger the contact speed, the longer the 3D text will stay displayed
                text3d.Duration    = 1 * 500;
                text3d.ElapsedTime = 0;
                Vector3 contactPosition = Vector3.Zero;
                baseObject.MainWorldTransform.GetPosition(ref contactPosition);
                // Scale down the vector font since it's quite large, and display the text
                // above the contact position
                text3d.Transform = Matrix.CreateScale(0.03f) *
                                   Matrix.CreateTranslation(contactPosition + Vector3.UnitY * 4);

                // Add this 3D text to the display list
                text3ds.Add(text3d);
            }
        }
Exemple #2
0
        public void Respawn(IntPtr body)
        {
            Notifier.AddMessage("Respawned");
            Matrix mat = Matrix.CreateTranslation(0, 0, -10);

            Newton.NewtonBodySetMatrixRecursive(body, MatrixHelper.ToFloats(mat));
        }
Exemple #3
0
        private void Calibrate()
        {
            string channelSeq = "RGB";
            int    nChannles  = 3;

            captureDevice.GetImageTexture(null, ref imagePtr);

            double square_size = 22.8; // in millimeters

            if (ALVARDllBridge.alvar_calibrate_camera(cameraID, nChannles, channelSeq, channelSeq, imagePtr,
                                                      square_size, ETALON_ROWS, ETALON_COLUMNS))
            {
                if (useImageSequence)
                {
                    Notifier.AddMessage(((NullCapture)captureDevice).StaticImageFile + " succeeded");
                    successCount++;
                }
                else
                {
                    Notifier.AddMessage("Captured Image " + (captureCount + 1));
                }
                captureCount++;
            }
            else if (useImageSequence)
            {
                Notifier.AddMessage(((NullCapture)captureDevice).StaticImageFile + " failed");
            }
        }
Exemple #4
0
        public void prucall(IPhysicsObject physObj1, IPhysicsObject physObj2)
        {
            Vector3 vel  = physObj1.InitialLinearVelocity;
            Vector3 vel2 = physObj2.InitialLinearVelocity;

            Notifier.AddMessage("Aquiiiiiii");
        }
Exemple #5
0
        private void SaveAdjustments()
        {
            XmlDocument    xmlDoc         = new XmlDocument();
            XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);

            xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement);

            XmlElement xmlRootNode = xmlDoc.CreateElement("CameraAdjustments");

            xmlDoc.AppendChild(xmlRootNode);

            {
                XmlElement xmlDataNode = xmlDoc.CreateElement("LeftWidthAdjustment");
                xmlDataNode.InnerText = camWidthAdjustmentLeft.ToString();
                xmlRootNode.AppendChild(xmlDataNode);
            }

            {
                XmlElement xmlDataNode = xmlDoc.CreateElement("LeftHorizontalShiftAdjustment");
                xmlDataNode.InnerText = camHShiftAdjustmentLeft.ToString();
                xmlRootNode.AppendChild(xmlDataNode);
            }

            {
                XmlElement xmlDataNode = xmlDoc.CreateElement("LeftVerticalShiftAdjustment");
                xmlDataNode.InnerText = camVShiftAdjustmentLeft.ToString();
                xmlRootNode.AppendChild(xmlDataNode);
            }

            {
                XmlElement xmlDataNode = xmlDoc.CreateElement("RightWidthAdjustment");
                xmlDataNode.InnerText = camWidthAdjustmentRight.ToString();
                xmlRootNode.AppendChild(xmlDataNode);
            }

            {
                XmlElement xmlDataNode = xmlDoc.CreateElement("RightHorizontalShiftAdjustment");
                xmlDataNode.InnerText = camHShiftAdjustmentRight.ToString();
                xmlRootNode.AppendChild(xmlDataNode);
            }

            {
                XmlElement xmlDataNode = xmlDoc.CreateElement("RightVerticalShiftAdjustment");
                xmlDataNode.InnerText = camVShiftAdjustmentRight.ToString();
                xmlRootNode.AppendChild(xmlDataNode);
            }

            try
            {
                xmlDoc.Save(adjustmentsFilename);
                Notifier.AddMessage("Saved adjustments");
            }
            catch (Exception)
            {
                throw new GoblinException("Failed to save the adjustments: " + adjustmentsFilename);
            }
        }
Exemple #6
0
 public void CallbackBulletHitCar3(Vector3 contactPosition, Vector3 contactNormal,
                                   float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
                                   Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
 {
     // Only play sound if the collision/contact speed is above 4
     if (contactSpeed > 10.1f)
     {
         Notifier.AddMessage("Pum-Pum - VEL " + contactSpeed);
         Players[3].PlyHealth -= 2;
     }
 }
Exemple #7
0
 public void CallbackCarObst(Vector3 contactPosition, Vector3 contactNormal,
                             float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
                             Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
 {
     // Only play sound if the collision/contact speed is above 4
     if (contactSpeed > 10f)
     {
         Notifier.AddMessage("Nock-Nock - Contact with speed of " + contactSpeed);
     }
     SoundGame.CarCrash1.Play();
 }
Exemple #8
0
        public void Respawn(IntPtr body)
        {
            //IPhysicsObject prueba = (IPhysicsObject)body;
            string dato = body.GetType().ToString();

            Notifier.AddMessage("Respawned");
            Matrix mat = Matrix.CreateTranslation(StartPos) *
                         Matrix.CreateRotationX(MathHelper.ToRadians(90));

            Newton.NewtonBodySetMatrixRecursive(body, MatrixHelper.ToFloats(mat));
        }
Exemple #9
0
        private void FinalizeCalibration()
        {
            if (useImageSequence)
            {
                Notifier.AddMessage("Calibrating " + successCount + " images...");
            }
            else
            {
                Notifier.AddMessage("Calibrating...");
            }
            ALVARDllBridge.alvar_finalize_calibration(cameraID, calibrationFilename);

            Notifier.FadeOutTime = -1;
            Notifier.AddMessage("Finished calibration. Saved " + calibrationFilename);

            finalized = true;
        }
Exemple #10
0
        /// <summary>
        /// Shoot a box from the clicked mouse location
        /// </summary>
        /// <param name="near"></param>
        /// <param name="far"></param>
        private void ShootBox(Matrix globalTransform)
        {
            //Notifier.AddMessage("paddle = " + paddle);
            //Notifier.AddMessage("wall = " + wall);

            //paddleNode.Physics.PhysicsWorldTransform = Matrix.Invert(Matrix.CreateTranslation(wall));

            //paddleNode.Physics.PhysicsWorldTransform = globalTransform.Translation;
            //Notifier.AddMessage("OBJECT WORLD TRANS = "+ globalTransform.Translation);

            paddleNode.Physics.PhysicsWorldTransform = Matrix.Invert(globalTransform);
            //Notifier.AddMessage("Translation = " + globalTransform.Translation);
            //Notifier.AddMessage("Paddle Pos  = " + paddleNode.WorldTransformation.Translation);

            Notifier.AddMessage("Paddle: " + paddleNode.WorldTransformation.Translation);
            Notifier.AddMessage("Ball:" + ball.WorldTransformation.Translation);
        }
        private void CameraInitialized(object sender, Microsoft.Devices.CameraOperationCompletedEventArgs e)
        {
            cameraReady = e.Succeeded;
            if (cameraReady)
            {
                if (camera.PreviewResolution.Width != cameraWidth || camera.PreviewResolution.Height != cameraHeight)
                {
                    throw new GoblinException(cameraWidth + "x" + cameraHeight + " is not supported. The supported resolutions is: " +
                                              camera.PreviewResolution.Width + "x" + camera.PreviewResolution.Height);
                }

                luminance = new byte[cameraWidth * cameraHeight];
            }
            else
            {
                Notifier.AddMessage(e.Exception.Message);
            }
        }
Exemple #12
0
        private void CalibrateStereo()
        {
            calibrating = true;

            // get the left and right camera iamges
            leftCaptureDevice.GetImageTexture(null, ref leftImagePtr);
            rightCaptureDevice.GetImageTexture(null, ref rightImagePtr);

            markerTracker.DetectorID = 0;
            markerTracker.CameraID   = 0;
            markerTracker.ProcessImage(leftCaptureDevice, leftImagePtr);

            bool markerFoundOnLeftVideo = markerTracker.FindMarker(markerID);

            if (markerFoundOnLeftVideo)
            {
                Matrix leftEyeTransform = markerTracker.GetMarkerTransform();

                markerTracker.DetectorID = 1;
                markerTracker.CameraID   = 1;
                markerTracker.ProcessImage(rightCaptureDevice, rightImagePtr);

                bool markerFoundOnRightVideo = markerTracker.FindMarker(markerID);

                if (markerFoundOnRightVideo)
                {
                    Matrix rightEyeTransform = markerTracker.GetMarkerTransform();

                    leftEyeTransform  = Matrix.Invert(leftEyeTransform);
                    rightEyeTransform = Matrix.Invert(rightEyeTransform);

                    Matrix     relativeTransform = rightEyeTransform * Matrix.Invert(leftEyeTransform);
                    Vector3    rawScale, rawPos;
                    Quaternion rawRot;
                    relativeTransform.Decompose(out rawScale, out rawRot, out rawPos);

                    float xGap = Math.Abs(rawPos.X);
                    float yGap = Math.Abs(rawPos.Y);
                    float zGap = Math.Abs(rawPos.Z);

                    float xyRatio = yGap / xGap;
                    float xzRatio = zGap / xGap;

                    if (xyRatio < 0.2 && xzRatio < 0.2 && rawPos.Length() > EXPECTED_GAP_MIN && rawPos.Length() < EXPECTED_GAP_MAX)
                    {
                        relativeTransforms.Add(relativeTransform);

                        Console.WriteLine("Completed calculation " + (captureCount + 1));
                        Notifier.AddMessage("Completed calculation: " + (captureCount + 1) + "/" + CALIB_COUNT_MAX);

                        rawScale = Vector3Helper.QuaternionToEulerAngleVector3(rawRot);
                        rawScale = Vector3Helper.RadiansToDegrees(rawScale);
                        Console.WriteLine("Pos: " + rawPos.ToString() + ", Length: " + rawPos.Length() + ", Yaw: "
                                          + rawScale.X + ", Pitch: " + rawScale.Y + ": Roll, " + rawScale.Z);
                        Console.WriteLine();
                        captureCount++;
                    }
                    else
                    {
                        Console.WriteLine("Failed: Pos: " + rawPos.ToString() + ", Length: " + rawPos.Length());
                        Console.WriteLine();
                        Notifier.AddMessage("Failed. Try again");
                    }
                }
            }

            if (captureCount >= CALIB_COUNT_MAX)
            {
                SaveCalibration();

                Console.WriteLine("Finished calibration. Saved " + calibrationFilename);
                Notifier.AddMessage("Finished calibration!!");

                finalized = true;
            }

            calibrating = false;
        }
Exemple #13
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()
        {
            base.Initialize();
#if WINDOWS
            // Display the mouse cursor
            this.IsMouseVisible = true;
#endif

            // Initialize the GoblinXNA framework
            State.InitGoblin(graphics, Content, "");

#if WINDOWS_PHONE
            this.Activated += Sound.Instance.GameActivated;
#endif

            // Initialize the scene graph
            scene = new Scene();

            // Set the background color to CornflowerBlue color.
            // GraphicsDevice.Clear(...) is called by Scene object with this color.
            scene.BackgroundColor = Color.CornflowerBlue;

#if WINDOWS
            // We will use the Newton physics engine (http://www.newtondynamics.com)
            // for processing the physical simulation
            scene.PhysicsEngine = new NewtonPhysics();
#else
            scene.PhysicsEngine = new MataliPhysics();
#endif
            scene.PhysicsEngine.Gravity = 30;

#if WINDOWS_PHONE
            ((MataliPhysics)scene.PhysicsEngine).SimulationTimeStep = 1 / 30f;
#endif

            text3ds = new List <Text3DInfo>();

            // Set up the lights used in the scene
            CreateLights();

            // Set up the camera which defines the eye location and viewing frustum
            CreateCamera();

            // Create 3D objects
            CreateObjects();

#if WINDOWS
            // Set up physics material interaction specifications between the shooting box and the ground
            NewtonMaterial physMat = new NewtonMaterial();
            physMat.MaterialName1   = "ShootingBox";
            physMat.MaterialName2   = "Ground";
            physMat.Elasticity      = 0.7f;
            physMat.StaticFriction  = 0.8f;
            physMat.KineticFriction = 0.2f;
            // Define a callback function that will be called when the two materials contact/collide
            physMat.ContactProcessCallback = delegate(Vector3 contactPosition, Vector3 contactNormal,
                                                      float contactSpeed, float colObj1ContactTangentSpeed, float colObj2ContactTangentSpeed,
                                                      Vector3 colObj1ContactTangentDirection, Vector3 colObj2ContactTangentDirection)
            {
                if (contactSpeed > 2)
                {
                    collisionCount++;
                }

                // When a cube box collides with the ground, it can have more than 1 contact points
                // depending on the collision surface, so we only play sound and add 3D texts once
                // every four contacts to avoid multiple sound play or text addition for one surface
                // contact
                if (collisionCount >= 4)
                {
                    // Set the collision sound volume based on the contact speed
                    SoundEffectInstance instance = Sound.Instance.PlaySoundEffect(bounceSound);
                    //instance.Volume = contactSpeed / 50f;
                    // Print a text message on the screen
                    Notifier.AddMessage("Contact with speed of " + contactSpeed);

                    // Create a 3D text to be rendered
                    Text3DInfo text3d = new Text3DInfo();
                    text3d.Text = "BOOM!!";
                    // The larger the contact speed, the longer the 3D text will stay displayed
                    text3d.Duration    = contactSpeed * 500;
                    text3d.ElapsedTime = 0;
                    // Scale down the vector font since it's quite large, and display the text
                    // above the contact position
                    text3d.Transform = Matrix.CreateScale(0.03f) *
                                       Matrix.CreateTranslation(contactPosition + Vector3.UnitY * 4);

                    // Add this 3D text to the display list
                    text3ds.Add(text3d);

                    // Reset the count
                    collisionCount = 0;
                }
            };

            // Add this physics material interaction specifications to the physics engine
            ((NewtonPhysics)scene.PhysicsEngine).AddPhysicsMaterial(physMat);
#endif

            // Add a mouse click handler for shooting a box model from the mouse location
            MouseInput.Instance.MouseClickEvent += new HandleMouseClick(MouseClickHandler);

            // Show some debug information
            State.ShowFPS = true;

            // Show debugging messages on the screen
            State.ShowNotifications = true;

            // Make the debugging message fade out after 3000 ms (3 seconds)
            Notifier.FadeOutTime = 3000;
        }
Exemple #14
0
 public void oooocall()
 {
     Notifier.AddMessage("jodeerrr");
 }
Exemple #15
0
 private void ServerDisconnected()
 {
     Notifier.AddMessage("Disconnected from the server");
 }
Exemple #16
0
 private void ClientConnected(string clientIP, int portNumber)
 {
     Notifier.AddMessage("Accepted connection from " + clientIP + " at port " + portNumber);
 }
Exemple #17
0
 private void ClientDisconnected(string clientIP, int portNumber)
 {
     Notifier.AddMessage("Disconnected from " + clientIP + " at port " + portNumber);
 }
Exemple #18
0
 private void ServerConnected()
 {
     Notifier.AddMessage("Connected to the server");
 }