Beispiel #1
0
        private void RecordingButton(PressedActionArgs args)
        {
            Rigidbody rig = Owner.GetComponent <Rigidbody>();

            if (!hologramRecording && !hologramPlaying && (rig == null || rig.IsGrounded || !rig.GravityEnabled))
            {
                GameObject hologramRecording = new GameObject("HologramRecorder", Owner.LocalPosition,
                                                              Owner.LocalQuaternionRotation, Owner.LocalScale, Owner.Scene, Owner.Parent);
                hologramRecording.AddComponent(new HologramRecorder(5.0f, 100, StopRecording));
                hologramRecording.AddComponent(new Rigidbody(Owner.GetComponent <Rigidbody>()));
                Collider holCol = hologramRecording.AddNewComponent <Collider>();
                Bounding_Volumes.BoundingBox bound = (Owner.GetComponent <Collider>().bound as Bounding_Volumes.BoundingBox);
                holCol.bound = new Bounding_Volumes.BoundingBox(holCol, bound.Center, new Vector3(bound.HalfLength, bound.HalfHeight, bound.HalfWidth));
                MeshInstance mesh = Owner.GetComponent <MeshInstance>();
                if (mesh != null)
                {
                    hologramRecording.AddComponent(new MeshInstance(mesh));
                }
                if (PlayerMesh != null)
                {
                    Owner.AddComponent(PlayerMesh);
                    AnimationController contr = Owner.AddNewComponent <AnimationController>();
                    contr.BindAnimation("idle", isCrouching ? 7 : 6, true);
                    contr.PlayAnimation("idle");
                }
                Stay(null);
                if (getWeapon() != null)
                {
                    getWeapon().Owner.IsVisible = false;
                }
                player         = Owner;
                playerRotation = Owner.LocalQuaternionRotation;
                Vector3 rotation = Owner.LocalEulerRotation;
                Owner.RemoveComponent(this);
                hologramRecording.AddComponent(this);
                Owner.Scene.Camera.Parent = hologramRecording;
                rotation.Y = 0; rotation.Z = 0;
                player.LocalEulerRotation = rotation;
                this.hologramRecording    = true;
            }
        }
Beispiel #2
0
        public void DrawDebug(GameTime gameTime, GraphicsDeviceManager graphics)
        {
            short[] indexes = new short[24]
            {
                0, 1, 1, 2, 2, 3, 3, 0,
                4, 5, 5, 6, 6, 7, 7, 4,
                0, 4, 1, 5, 2, 6, 3, 7
            };

            Bounding_Volumes.BoundingBox box = (bound as Bounding_Volumes.BoundingBox);
            if (box != null)
            {
                Vector3[] corners = box.Corners();

                VertexPositionColor[] vertices = new VertexPositionColor[8];
                for (int j = 0; j < 8; ++j)
                {
                    vertices[j] = new VertexPositionColor(corners[j], Color.Green);
                }

                graphics.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, vertices, 0, 8, indexes, 0, 12);
            }
        }
Beispiel #3
0
        private float?IntersectBox(Bounding_Volumes.BoundingBox bound)
        {
            float tfirst = 0.0f, tlast = Length;

            Plane[] planes = new Plane[3]
            {
                bound.RightFace(), bound.UpFace(), bound.BackFace()
            };
            Vector3[] corners = bound.Corners();

            if (!RaySlabIntersect(Vector3.Dot(StartPosition, planes[0].Normal),
                                  Vector3.Dot(Direction, planes[0].Normal),
                                  Vector3.Dot(corners[1], planes[0].Normal),
                                  Vector3.Dot(corners[0], planes[0].Normal),
                                  ref tfirst, ref tlast))
            {
                return(null);
            }
            if (!RaySlabIntersect(Vector3.Dot(StartPosition, planes[1].Normal),
                                  Vector3.Dot(Direction, planes[1].Normal),
                                  Vector3.Dot(corners[3], planes[1].Normal),
                                  Vector3.Dot(corners[0], planes[1].Normal),
                                  ref tfirst, ref tlast))
            {
                return(null);
            }
            if (!RaySlabIntersect(Vector3.Dot(StartPosition, planes[2].Normal),
                                  Vector3.Dot(Direction, planes[2].Normal),
                                  Vector3.Dot(corners[0], planes[2].Normal),
                                  Vector3.Dot(corners[4], planes[2].Normal),
                                  ref tfirst, ref tlast))
            {
                return(null);
            }

            return(tfirst);
        }