コード例 #1
0
        public override void ExitPhysics()
        {
            cameraSphere.Dispose();
            convexResultCallback.Dispose();

            base.ExitPhysics();
        }
コード例 #2
0
        public void Dispose()
        {
            _callback.Dispose();
            _indexVertexArrays.IndexedMeshArray[0].Dispose();
            _indexVertexArrays.Dispose();

            this.StandardCleanup();
        }
コード例 #3
0
        public void Dispose()
        {
            _callback.Dispose();
            _indexVertexArrays.IndexedMeshArray[0].Dispose();
            _indexVertexArrays.Dispose();
            if (_vertexWriter != null)
            {
                _vertexWriter.Dispose();
                _vertexWriter = null;
            }

            this.StandardCleanup();
        }
コード例 #4
0
        public void Dispose()
        {
            _callback.Dispose();
            _indexVertexArrays.IndexedMeshArray[0].Dispose();
            _indexVertexArrays.Dispose();
            _groundMesh.Dispose();
            if (_vertexWriter != null)
            {
                _vertexWriter.Dispose();
                _vertexWriter = null;
            }
            _convexcastBatch.Dispose();

            this.StandardCleanup();
        }
コード例 #5
0
        public override void OnHandleInput()
        {
            Matrix xform = ghostObject.WorldTransform;

            Vector3 forwardDir = new Vector3(xform.M31, xform.M32, xform.M33);
            //Console.Write("forwardDir={0},{1},{2}\n", forwardDir[0], forwardDir[1], forwardDir[2]);
            Vector3 upDir = new Vector3(xform.M21, xform.M22, xform.M23);

            forwardDir.Normalize();
            upDir.Normalize();
            Vector3 pos = xform.Origin;

            Vector3     walkDirection = Vector3.Zero;
            const float walkVelocity  = 1.1f * 4.0f;
            float       walkSpeed     = walkVelocity * FrameDelta * 10;// * 0.0001f;
            float       turnSpeed     = FrameDelta * 3;

            if (Input.KeysDown.Contains(Keys.Left))
            {
                Matrix orn = xform;
                orn.Row4 = new Vector4(0, 0, 0, 1);
                orn     *= Matrix.RotationAxis(upDir, -turnSpeed);
                orn.Row4 = new Vector4(pos.X, pos.Y, pos.Z, 1);
                ghostObject.WorldTransform = orn;
            }
            if (Input.KeysDown.Contains(Keys.Right))
            {
                Matrix orn = xform;
                orn.Row4 = new Vector4(0, 0, 0, 1);
                orn     *= Matrix.RotationAxis(upDir, turnSpeed);
                orn.Row4 = new Vector4(pos.X, pos.Y, pos.Z, 1);
                ghostObject.WorldTransform = orn;
            }

            if (Input.KeysDown.Contains(Keys.Up))
            {
                walkDirection += forwardDir;
            }
            if (Input.KeysDown.Contains(Keys.Down))
            {
                walkDirection -= forwardDir;
            }

            Vector3 cameraPos = pos - forwardDir * 12 + upDir * 5;

            //use the convex sweep test to find a safe position for the camera (not blocked by static geometry)
            SphereShape cameraSphere       = new SphereShape(0.2f);
            ClosestConvexResultCallback cb = new ClosestConvexResultCallback(ref pos, ref cameraPos);

            cb.CollisionFilterMask = (short)CollisionFilterGroups.StaticFilter;
            Matrix posMatrix       = Matrix.Translation(pos);
            Matrix cameraPosMatrix = Matrix.Translation(cameraPos);

            World.ConvexSweepTestRef(cameraSphere, ref posMatrix, ref cameraPosMatrix, cb);
            cameraSphere.Dispose();
            if (cb.HasHit)
            {
                cameraPos = Vector3.Lerp(pos, cameraPos, cb.ClosestHitFraction);
            }
            cb.Dispose();
            Freelook.SetEyeTarget(cameraPos, pos);

            character.SetWalkDirection(walkDirection * walkSpeed);

            base.OnHandleInput();
        }
コード例 #6
0
        public override void ExitPhysics()
        {
            callback.Dispose();

            base.ExitPhysics();
        }