private void OnGizmoScale(ITransformable transformable, TransformationEventArgs e)
        {
            var delta = (Vector3)e.Value * transformScaleFactor;

            if (Gizmo.ActiveMode == GizmoMode.UniformScale)
            {
                if (transformable is SceneEntity entity)
                {
                    STATIC_EDITOR_MODE.ExecuteOnSelfAndChildEntities(entity, sceneEntity => sceneEntity.Scale *= 1 + ((delta.X + delta.Y + delta.Z) / 3));
                }
                else
                {
                    transformable.Scale *= 1 + ((delta.X + delta.Y + delta.Z) / 3);
                }
            }
            else
            {
                if (transformable is SceneEntity entity)
                {
                    STATIC_EDITOR_MODE.ExecuteOnSelfAndChildEntities(entity, sceneEntity => sceneEntity.Scale += delta);
                }
                else
                {
                    transformable.Scale += delta;
                }
            }
            transformable.Scale = Vector3.Clamp(transformable.Scale, Vector3.Zero, transformable.Scale);
        }
 private void OnGizmoTranslate(ITransformable transformable, TransformationEventArgs e)
 {
     transformable.Position += (Vector3)e.Value;
     if (transformable is SceneEntity entity)
     {
         STATIC_EDITOR_MODE.ExecuteOnChildEntities(entity, sceneEntity => sceneEntity.Position += (Vector3)e.Value);
     }
 }
 private void OnGizmoRotate(ITransformable transformable, TransformationEventArgs e)
 {
     Gizmo.RotationHelper(transformable, e);
     if (transformable is SceneEntity entity)
     {
         STATIC_EDITOR_MODE.ExecuteOnChildEntities(entity, sceneEntity => Gizmo.RotationHelper(sceneEntity, e));
     }
 }
예제 #4
0
        private void RemoveAsset(string path, Type assetType, string name)
        {
            if (MessageBox.Show("Really remove the asset from the project? \r\n This will remove all assets of this type in the scene.", "Remove Asset", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                if (IsValidContentFile($@"{path}\{name}", assetType))
                {
                    if (assetType == typeof(Model))
                    {
                        STATIC_EDITOR_MODE.RemoveAssetsWithModel(name);
                    }
                    else if (assetType == typeof(Texture2D))
                    {
                        STATIC_EDITOR_MODE.RemoveAssetsWithHeight(name);
                    }

                    var files = Directory.GetFiles(Path.Combine(Application.StartupPath, $@"Content\{path}"), "*.xnb", SearchOption.TopDirectoryOnly);

                    foreach (var file in files)
                    {
                        if (Path.GetFileNameWithoutExtension(file) == name)
                        {
                            try {
                                File.Delete(file);
                            }
                            catch (Exception exception) {
                                Console.WriteLine(exception);
                                throw;
                            }
                        }
                    }
                }

                RefreshAllXNBLists();

                PopulateHeirarchy();
            }
        }
예제 #5
0
        private void DeleteSceneSelected()
        {
            if (editorControl1.Gizmo.Selection.Count > 0)
            {
                var selected = new List <SceneEntity>();

                // select selection and children
                foreach (var transformable in editorControl1.Gizmo.Selection)
                {
                    if (transformable is SceneEntity entity)
                    {
                        STATIC_EDITOR_MODE.ExecuteOnSelfAndChildEntities(entity, sceneEntity => selected.Add(sceneEntity));
                    }
                }
                foreach (var entity in selected.Distinct())
                {
                    STATIC_EDITOR_MODE.RemoveEntity(entity);
                }

                editorControl1.Gizmo.Selection.Clear();
                selected = null;
                PopulateHeirarchy();
            }
        }