diff options
| author | yum <yum.food.vr@gmail.com> | 2026-02-17 18:52:17 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-02-17 18:52:17 -0800 |
| commit | 00553b3f305d0e2217659993f237ff3da604ef85 (patch) | |
| tree | 76d048fcfb005cf7427f43bb6539d1ef59b75bf3 /Scripts/Fold/Editor/FoldEditorWindow.cs | |
| parent | 0783345c23701149b807d2063410e329ba1fbed6 (diff) | |
Fold: add plane to octahedron code
Diffstat (limited to 'Scripts/Fold/Editor/FoldEditorWindow.cs')
| -rwxr-xr-x | Scripts/Fold/Editor/FoldEditorWindow.cs | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/Scripts/Fold/Editor/FoldEditorWindow.cs b/Scripts/Fold/Editor/FoldEditorWindow.cs index e2a94e1..e8faf1f 100755 --- a/Scripts/Fold/Editor/FoldEditorWindow.cs +++ b/Scripts/Fold/Editor/FoldEditorWindow.cs @@ -205,12 +205,15 @@ public class FoldEditorWindow : EditorWindow menu.AddItem(new GUIContent("Plane to Tube"), false, () => AddOperation(new PlaneToTubeOp())); menu.AddItem(new GUIContent("Plane to Hemi-Octahedron"), false, () => AddOperation(new PlaneToHemiOctahedronOp())); menu.AddItem(new GUIContent("Hemi-Octahedron to Plane"), false, () => AddOperation(new HemiOctahedronToPlaneOp())); + menu.AddItem(new GUIContent("Plane to Octahedron"), false, () => AddOperation(new PlaneToOctahedronOp())); + menu.AddItem(new GUIContent("Octahedron to Plane"), false, () => AddOperation(new OctahedronToPlaneOp())); menu.AddSeparator(""); menu.AddItem(new GUIContent("Point Align"), false, () => AddOperation(new PointAlignOp())); menu.AddItem(new GUIContent("Axis Align"), false, () => AddOperation(new AxisAlignOp())); menu.AddSeparator(""); menu.AddItem(new GUIContent("Scale"), false, () => AddOperation(new ScaleOp())); menu.AddItem(new GUIContent("Translate"), false, () => AddOperation(new TranslateOp())); + menu.AddItem(new GUIContent("Rotate"), false, () => AddOperation(new RotateOp())); menu.AddItem(new GUIContent("Norm Conversion"), false, () => AddOperation(new NormConversionOp())); menu.AddItem(new GUIContent("Seal"), false, () => AddOperation(new SealOp())); menu.AddSeparator(""); @@ -274,6 +277,9 @@ public class FoldEditorWindow : EditorWindow FoldPipelineBuilder.Opcodes.HemiOctahedronToPlane => new HemiOctahedronToPlaneOp(slot), FoldPipelineBuilder.Opcodes.Scale => new ScaleOp(slot), FoldPipelineBuilder.Opcodes.Translate => new TranslateOp(slot), + FoldPipelineBuilder.Opcodes.PlaneToOctahedron => new PlaneToOctahedronOp(slot), + FoldPipelineBuilder.Opcodes.OctahedronToPlane => new OctahedronToPlaneOp(slot), + FoldPipelineBuilder.Opcodes.Rotate => new RotateOp(slot), FoldPipelineBuilder.Opcodes.PointAlign => new PointAlignOp(slot), FoldPipelineBuilder.Opcodes.AxisAlign => new AxisAlignOp(slot), FoldPipelineBuilder.Opcodes.NormConversion => new NormConversionOp(slot), @@ -418,6 +424,37 @@ public class TranslateOp : DeformOperation } [System.Serializable] +public class RotateOp : DeformOperation +{ + public Vector3 center = Vector3.zero; + public Vector3 axis = Vector3.up; + public float angleDeg = 90f; + public float t = 1f; + + public RotateOp() { } + public RotateOp(FoldSlot slot) + { + center = slot.vec0; + axis = slot.vec1; + angleDeg = slot.float0 * Mathf.Rad2Deg; + t = slot.float1; + } + + public override string GetDisplayName() => "Rotate"; + + public override void DrawParameters() + { + center = EditorGUILayout.Vector3Field("Center", center); + axis = EditorGUILayout.Vector3Field("Axis", axis); + angleDeg = EditorGUILayout.Slider("Angle", angleDeg, 0f, 360f); + t = EditorGUILayout.Slider("Interpolation (t)", t, 0f, 1f); + } + + public override void ApplyTo(FoldPipelineBuilder builder) => + builder.Rotate(center, axis, angleDeg * Mathf.Deg2Rad, t); +} + +[System.Serializable] public class HemiOctahedronToPlaneOp : DeformOperation { public Vector3 p = Vector3.zero; @@ -443,6 +480,56 @@ public class HemiOctahedronToPlaneOp : DeformOperation } [System.Serializable] +public class PlaneToOctahedronOp : DeformOperation +{ + public Vector3 p = Vector3.zero; + public Vector3 r = Vector3.right; + public Vector3 s = Vector3.forward; + public float t = 1f; + + public PlaneToOctahedronOp() { } + public PlaneToOctahedronOp(FoldSlot slot) { p = slot.vec0; r = slot.vec1; s = slot.vec2; t = slot.float0; } + + public override string GetDisplayName() => "Plane to Octahedron"; + + public override void DrawParameters() + { + p = EditorGUILayout.Vector3Field("Origin (p)", p); + r = EditorGUILayout.Vector3Field("R Axis", r); + s = EditorGUILayout.Vector3Field("S Axis", s); + t = EditorGUILayout.Slider("Interpolation (t)", t, 0f, 1f); + } + + public override void ApplyTo(FoldPipelineBuilder builder) => + builder.PlaneToOctahedron(p, r, s, t); +} + +[System.Serializable] +public class OctahedronToPlaneOp : DeformOperation +{ + public Vector3 p = Vector3.zero; + public Vector3 r = Vector3.right; + public Vector3 s = Vector3.forward; + public float t = 1f; + + public OctahedronToPlaneOp() { } + public OctahedronToPlaneOp(FoldSlot slot) { p = slot.vec0; r = slot.vec1; s = slot.vec2; t = slot.float0; } + + public override string GetDisplayName() => "Octahedron to Plane"; + + public override void DrawParameters() + { + p = EditorGUILayout.Vector3Field("Origin (p)", p); + r = EditorGUILayout.Vector3Field("R Axis", r); + s = EditorGUILayout.Vector3Field("S Axis", s); + t = EditorGUILayout.Slider("Interpolation (t)", t, 0f, 1f); + } + + public override void ApplyTo(FoldPipelineBuilder builder) => + builder.OctahedronToPlane(p, r, s, t); +} + +[System.Serializable] public class PointAlignOp : DeformOperation { public Vector3 po = Vector3.zero; |
