Beispiel #1
0
        public HumanController()
        {
            TargetLabel = Engine.Singleton.Labeler.NewTextLabel3D("Primitive", 0.04f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 0);

            HUD     = new HUD();
            Gravity = true;

            ActualAxis = GrabOrRotateAxis.X;
        }
        public HumanController()
        {
            TargetLabel = Engine.Singleton.Labeler.NewTextLabel3D("Primitive", 0.04f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 0);

            HUD = new HUD();
            Gravity = true;

            ActualAxis = GrabOrRotateAxis.X;
        }
Beispiel #3
0
        private void HandleRotate()
        {
            RotateObject();

            User.FocusedObject.Position = PositionBefore;

            FocusedObjectRot = Vector3.ZERO;

            if (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
            {
                while (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
                {
                    Engine.Singleton.Mouse.Capture();                                   //petla, zeby nie klikal mi milion razy, tylko raz :)
                }

                switch (User.FocusedObject.GetType().ToString())
                {
                case "WorldCreator.Described":
                    (User.FocusedObject as Described).Body.MaterialGroupID = Engine.Singleton.MaterialManager.DescribedMaterialID;
                    (User.FocusedObject as Described).Body.SetForce(Vector3.ZERO);
                    (User.FocusedObject as Described).Body.Velocity = Vector3.ZERO;
                    break;

                case "WorldCreator.Character":
                    (User.FocusedObject as Character).Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;
                    (User.FocusedObject as Character).Body.SetForce(Vector3.ZERO);
                    (User.FocusedObject as Character).Body.Velocity = Vector3.ZERO;
                    break;

                case "WorldCreator.Enemy":
                    (User.FocusedObject as Enemy).Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;
                    (User.FocusedObject as Enemy).Body.SetForce(Vector3.ZERO);
                    (User.FocusedObject as Enemy).Body.Velocity = Vector3.ZERO;
                    break;
                }

                User.FocusedObject.Orientation = RotationBefore;
                SwitchState(HumanControllerState.FREE);
            }

            if (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            {
                while (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
                {
                    Engine.Singleton.Mouse.Capture();                                   //petla, zeby nie klikal mi milion razy, tylko raz :)
                }

                switch (User.FocusedObject.GetType().ToString())
                {
                case "WorldCreator.Described":
                    (User.FocusedObject as Described).Body.MaterialGroupID = Engine.Singleton.MaterialManager.DescribedMaterialID;
                    (User.FocusedObject as Described).Body.SetForce(Vector3.ZERO);
                    (User.FocusedObject as Described).Body.Velocity = Vector3.ZERO;
                    break;

                case "WorldCreator.Character":
                    (User.FocusedObject as Character).Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;
                    (User.FocusedObject as Character).Body.SetForce(Vector3.ZERO);
                    (User.FocusedObject as Character).Body.Velocity = Vector3.ZERO;
                    break;

                case "WorldCreator.Enemy":
                    (User.FocusedObject as Enemy).Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;
                    (User.FocusedObject as Enemy).Body.SetForce(Vector3.ZERO);
                    (User.FocusedObject as Enemy).Body.Velocity = Vector3.ZERO;
                    break;
                }

                SwitchState(HumanControllerState.FREE);
            }

            if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_X))
            {
                ActualAxis = GrabOrRotateAxis.X;
            }

            if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_Y))
            {
                ActualAxis = GrabOrRotateAxis.Y;
            }

            if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_Z))
            {
                ActualAxis = GrabOrRotateAxis.Z;
            }

            switch (ActualAxis)
            {
            case GrabOrRotateAxis.X:
                //FocusedObjectPos.x += -Engine.Singleton.Mouse.MouseState.X.rel * 0.01f;
                FocusedObjectRot.x += -Engine.Singleton.Mouse.MouseState.X.rel * 0.1f;
                break;

            case GrabOrRotateAxis.Y:
                FocusedObjectRot.y += -Engine.Singleton.Mouse.MouseState.X.rel * 0.1f;
                break;

            case GrabOrRotateAxis.Z:
                FocusedObjectRot.z += -Engine.Singleton.Mouse.MouseState.X.rel * 0.1f;
                break;
            }

            if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_G))
            {
                RotationBefore   = User.FocusedObject.Orientation;
                FocusedObjectPos = User.FocusedObject.Position;
                SwitchState(HumanControllerState.GRAB);
            }
        }
        private void HandleRotate()
        {
            RotateObject();

            User.FocusedObject.Position = PositionBefore;

            FocusedObjectRot = Vector3.ZERO;

            if (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
            {
                while (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
                {
                    Engine.Singleton.Mouse.Capture();               //petla, zeby nie klikal mi milion razy, tylko raz :)
                }

                switch (User.FocusedObject.GetType().ToString())
                {
                    case "WorldCreator.Described":
                        (User.FocusedObject as Described).Body.MaterialGroupID = Engine.Singleton.MaterialManager.DescribedMaterialID;
                        (User.FocusedObject as Described).Body.SetForce(Vector3.ZERO);
                        (User.FocusedObject as Described).Body.Velocity = Vector3.ZERO;
                        break;
                    case "WorldCreator.Character":
                        (User.FocusedObject as Character).Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;
                        (User.FocusedObject as Character).Body.SetForce(Vector3.ZERO);
                        (User.FocusedObject as Character).Body.Velocity = Vector3.ZERO;
                        break;
                    case "WorldCreator.Enemy":
                        (User.FocusedObject as Enemy).Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;
                        (User.FocusedObject as Enemy).Body.SetForce(Vector3.ZERO);
                        (User.FocusedObject as Enemy).Body.Velocity = Vector3.ZERO;
                        break;
                }

                User.FocusedObject.Orientation = RotationBefore;
                SwitchState(HumanControllerState.FREE);
            }

            if (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            {
                while (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
                {
                    Engine.Singleton.Mouse.Capture();               //petla, zeby nie klikal mi milion razy, tylko raz :)
                }

                switch (User.FocusedObject.GetType().ToString())
                {
                    case "WorldCreator.Described":
                        (User.FocusedObject as Described).Body.MaterialGroupID = Engine.Singleton.MaterialManager.DescribedMaterialID;
                        (User.FocusedObject as Described).Body.SetForce(Vector3.ZERO);
                        (User.FocusedObject as Described).Body.Velocity = Vector3.ZERO;
                        break;
                    case "WorldCreator.Character":
                        (User.FocusedObject as Character).Body.MaterialGroupID = Engine.Singleton.MaterialManager.CharacterMaterialID;
                        (User.FocusedObject as Character).Body.SetForce(Vector3.ZERO);
                        (User.FocusedObject as Character).Body.Velocity = Vector3.ZERO;
                        break;
                    case "WorldCreator.Enemy":
                        (User.FocusedObject as Enemy).Body.MaterialGroupID = Engine.Singleton.MaterialManager.EnemyMaterialID;
                        (User.FocusedObject as Enemy).Body.SetForce(Vector3.ZERO);
                        (User.FocusedObject as Enemy).Body.Velocity = Vector3.ZERO;
                        break;
                }

                SwitchState(HumanControllerState.FREE);
            }

            if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_X))
                ActualAxis = GrabOrRotateAxis.X;

            if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_Y))
                ActualAxis = GrabOrRotateAxis.Y;

            if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_Z))
                ActualAxis = GrabOrRotateAxis.Z;

            switch (ActualAxis)
            {
                case GrabOrRotateAxis.X:
                    //FocusedObjectPos.x += -Engine.Singleton.Mouse.MouseState.X.rel * 0.01f;
                    FocusedObjectRot.x += -Engine.Singleton.Mouse.MouseState.X.rel * 0.1f;
                    break;

                case GrabOrRotateAxis.Y:
                    FocusedObjectRot.y += -Engine.Singleton.Mouse.MouseState.X.rel * 0.1f;
                    break;

                case GrabOrRotateAxis.Z:
                    FocusedObjectRot.z += -Engine.Singleton.Mouse.MouseState.X.rel * 0.1f;
                    break;
            }

            if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_G))
            {

                RotationBefore = User.FocusedObject.Orientation;
                FocusedObjectPos = User.FocusedObject.Position;
                SwitchState(HumanControllerState.GRAB);
            }
        }