コード例 #1
0
        private void MoveCameraToSelectedItem()
        {
            LevelGameObject selectedGO = objectList.SelectedItem as LevelGameObject;

            if (selectedGO == null)
            {
                MessageBox.Show(this, "Please select a game object from the list first.", "Snap game object");
                return;
            }

            GroundableEntity entityRep           = currentLevel.GetGameObjectRepresentation(selectedGO);
            Vector3          entityForwardOrient = Vector3.FORWARD * entityRep.Transform.Rotation;

            AssetLocator.MainCamera.Position = entityRep.Transform.Translation - entityForwardOrient.WithLength(PhysicsManager.ONE_METRE_SCALED * 0.2f);
            AssetLocator.MainCamera.Orient(entityForwardOrient, Vector3.UP);
        }
コード例 #2
0
        public override void ResetEntity(LevelGeometryEntity levelGeometryEntity, Material overrideMaterial = null)
        {
            base.ResetEntity(levelGeometryEntity, overrideMaterial);
            Entity             rep          = GetEntityRepresentation(levelGeometryEntity);
            PhysicsShapeHandle physicsShape = activePhysicsShapes[levelGeometryEntity];

            if (physicsShape == PhysicsShapeHandle.NULL)
            {
                return;                                                      // Some geometry is non-collidable (i.e. planes)
            }
            rep.SetPhysicsShape(physicsShape, Vector3.ZERO, LevelGeometry.GEOMETRY_MASS, forceIntransigence: true);

            if (rep is PresetMovementEntity)
            {
                foreach (LevelGameObject levelGameObject in GameObjects.Where(go => go.GroundingGeometryEntity == levelGeometryEntity))
                {
                    GroundableEntity goRep = GetGameObjectRepresentation(levelGameObject);
                    goRep.Ground((PresetMovementEntity)rep);
                }
            }
        }
コード例 #3
0
        private void SnapSelectedToCamera()
        {
            LevelGameObject selectedGO = objectList.SelectedItem as LevelGameObject;

            if (selectedGO == null)
            {
                MessageBox.Show(this, "Please select a game object from the list first.", "Snap game object");
                return;
            }

            GroundableEntity entityRep = currentLevel.GetGameObjectRepresentation(selectedGO);

            entityRep.Transform = selectedGO.Transform = selectedGO.Transform.With(
                rotation: Quaternion.FromVectorTransition(Vector3.UP, AssetLocator.MainCamera.Orientation),
                translation: AssetLocator.MainCamera.Position
                );

            if (selectedGO.GroundingGeometryEntity != null)
            {
                currentLevel.ResetGameObject(selectedGO);
            }
            UpdateSelectedObject();
        }
コード例 #4
0
        private void AdjustSelectedGOTransform(TransformAdjustmentType type, TransformAdjustmentAxis axis, bool negative)
        {
            LevelGameObject selectedGO = objectList.SelectedItem as LevelGameObject;

            if (selectedGO == null)
            {
                return;
            }
            GroundableEntity entityRep = currentLevel.GetGameObjectRepresentation(selectedGO);
            float            amount;

            switch (type)
            {
            case TransformAdjustmentType.Translation:
                amount = (float)translationAmountPicker.Value * (negative ? -1f : 1f);
                switch (axis)
                {
                case TransformAdjustmentAxis.X:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.TranslateBy(new Vector3(amount, 0f, 0f));
                    break;

                case TransformAdjustmentAxis.Y:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.TranslateBy(new Vector3(0f, amount, 0f));
                    break;

                case TransformAdjustmentAxis.Z:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.TranslateBy(new Vector3(0f, 0f, amount));
                    break;
                }
                break;

            case TransformAdjustmentType.Rotation:
                amount = MathUtils.DegToRad((float)rotationAmountPicker.Value * (negative ? -1f : 1f));
                switch (axis)
                {
                case TransformAdjustmentAxis.X:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.RotateBy(Quaternion.FromAxialRotation(Vector3.RIGHT, amount));
                    break;

                case TransformAdjustmentAxis.Y:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.RotateBy(Quaternion.FromAxialRotation(Vector3.UP, amount));
                    break;

                case TransformAdjustmentAxis.Z:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.RotateBy(Quaternion.FromAxialRotation(Vector3.FORWARD, amount));
                    break;
                }
                break;

            case TransformAdjustmentType.Scale:
                amount = (float)scalingAmountPicker.Value * (negative ? -1f : 1f);
                switch (axis)
                {
                case TransformAdjustmentAxis.X:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.With(scale: selectedGO.Transform.Scale + new Vector3(amount, 0f, 0f));
                    break;

                case TransformAdjustmentAxis.Y:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.With(scale: selectedGO.Transform.Scale + new Vector3(0f, amount, 0f));
                    break;

                case TransformAdjustmentAxis.Z:
                    entityRep.Transform = selectedGO.Transform = selectedGO.Transform.With(scale: selectedGO.Transform.Scale + new Vector3(0f, 0f, amount));
                    break;
                }
                break;
            }
            if (selectedGO.GroundingGeometryEntity != null)
            {
                currentLevel.ResetGameObject(selectedGO);
            }
            UpdateSelectedObject();
        }