├── Editor ├── Icons │ ├── uv.png │ ├── face.png │ ├── origin.png │ ├── polygon.png │ ├── vertex.png │ ├── artwork.sketch │ ├── faceIndex.png │ ├── faceNormal.png │ ├── defaultGizmo.png │ ├── facePosition.png │ ├── polygonIndex.png │ ├── vertexIndex.png │ ├── vertexNormal.png │ ├── vertexTangent.png │ └── vertexPosition.png ├── MenuCommands.cs ├── IconLoader.cs ├── TemplateEditor.cs ├── Renderers │ ├── SelectionRenderer.cs │ ├── ConnectionRenderer.cs │ ├── GridRenderer.cs │ ├── OutletRenderer.cs │ └── NodeRenderer.cs ├── GraphSelection.cs ├── GraphEvent.cs ├── ProceduralAssetEditor.cs ├── OperatorInspector.cs ├── GraphEditor.cs ├── Node.cs └── UVPreview.cs ├── Artwork ├── Graph Editor.sketch └── Architecture Diagram.sketch ├── Operators ├── Values │ ├── IntegerValue.cs │ ├── FloatValue.cs │ ├── Bounds.cs │ ├── Vector2.cs │ └── Vector3.cs ├── Conversions │ ├── IntegerToFloat.cs │ └── FloatToInteger.cs ├── Primitives │ ├── Grid.cs │ ├── Point.cs │ ├── Line.cs │ ├── Triangle.cs │ ├── Cylinder.cs │ ├── Cuboid.cs │ ├── Square.cs │ ├── Circle.cs │ └── Sphere.cs ├── Geometry │ ├── RecalculateNormals.cs │ ├── Reverse.cs │ ├── VertexNormals.cs │ ├── CircleScatter.cs │ ├── Align.cs │ ├── FlipFaces.cs │ ├── Polygonize.cs │ ├── Copy.cs │ ├── ExtractVertices.cs │ ├── ExtractFaces.cs │ ├── TransformGeometry.cs │ ├── Converge.cs │ ├── Mirror.cs │ ├── Fuse.cs │ ├── Merge.cs │ ├── Hemisphere.cs │ ├── Triangulate.cs │ ├── SplitAt.cs │ └── Bridge.cs ├── Inputs │ ├── BoolInput.cs │ ├── FloatInput.cs │ └── IntegerInput.cs ├── Math │ ├── Multiply.cs │ ├── Divide.cs │ └── Add.cs ├── Logic │ └── Switch.cs └── UV │ ├── TransformUV.cs │ ├── PlanarProjection.cs │ └── CylindricalProjection.cs ├── .gitignore ├── IOConnection.cs ├── Parameter.cs ├── IOOutlet.cs ├── README.md ├── ParameterValue.cs ├── Util ├── Orientation.cs ├── Extensions.cs └── MeshDisplay.cs ├── TemplateSerializer.cs ├── ProceduralAsset.cs ├── OperatorSerializer.cs ├── Template.cs ├── Geometry.cs └── Operator.cs /Editor/Icons/uv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/uv.png -------------------------------------------------------------------------------- /Editor/Icons/face.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/face.png -------------------------------------------------------------------------------- /Editor/Icons/origin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/origin.png -------------------------------------------------------------------------------- /Editor/Icons/polygon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/polygon.png -------------------------------------------------------------------------------- /Editor/Icons/vertex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/vertex.png -------------------------------------------------------------------------------- /Artwork/Graph Editor.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Artwork/Graph Editor.sketch -------------------------------------------------------------------------------- /Editor/Icons/artwork.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/artwork.sketch -------------------------------------------------------------------------------- /Editor/Icons/faceIndex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/faceIndex.png -------------------------------------------------------------------------------- /Editor/Icons/faceNormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/faceNormal.png -------------------------------------------------------------------------------- /Editor/Icons/defaultGizmo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/defaultGizmo.png -------------------------------------------------------------------------------- /Editor/Icons/facePosition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/facePosition.png -------------------------------------------------------------------------------- /Editor/Icons/polygonIndex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/polygonIndex.png -------------------------------------------------------------------------------- /Editor/Icons/vertexIndex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/vertexIndex.png -------------------------------------------------------------------------------- /Editor/Icons/vertexNormal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/vertexNormal.png -------------------------------------------------------------------------------- /Editor/Icons/vertexTangent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/vertexTangent.png -------------------------------------------------------------------------------- /Editor/Icons/vertexPosition.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Editor/Icons/vertexPosition.png -------------------------------------------------------------------------------- /Artwork/Architecture Diagram.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rev087/forge/HEAD/Artwork/Architecture Diagram.sketch -------------------------------------------------------------------------------- /Operators/Values/IntegerValue.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Values")] 6 | public class IntegerValue : Operator { 7 | 8 | [Input][Output] 9 | public int Integer = 0; 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Operators/Values/FloatValue.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Values", Title = "Float")] 6 | public class FloatValue : Operator { 7 | 8 | [Input][Output] 9 | public float Float = 0.0f; 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | 6 | # Autogenerated VS/MD solution and project files 7 | /*.csproj 8 | /*.unityproj 9 | /*.sln 10 | /*.suo 11 | /*.user 12 | /*.userprefs 13 | /*.pidb 14 | /*.booproj 15 | 16 | #Unity3D Generated File On Crash Reports 17 | sysinfo.txt 18 | 19 | # Unity3D Metadata 20 | *.meta -------------------------------------------------------------------------------- /Operators/Conversions/IntegerToFloat.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Conversions", Title = "Integer to Float")] 6 | public class IntegerToFloat : Operator { 7 | 8 | [Input] 9 | public int Integer = 0; 10 | 11 | [Output] 12 | public float Float { 13 | get { 14 | return Integer; 15 | } 16 | } 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Operators/Conversions/FloatToInteger.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Conversions", Title = "Float to Integer")] 6 | public class FloatToInteger : Operator { 7 | 8 | [Input] 9 | public float Float = 0f; 10 | 11 | [Output] 12 | public int Integer { 13 | get { 14 | return (int) Float; 15 | } 16 | } 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Operators/Primitives/Grid.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace Forge.Operators { 6 | 7 | public class Grid { 8 | 9 | public OrientationPreset Orientation; 10 | public Vector2 Size; 11 | public Vector2 Center; 12 | public Vector2 Cells = new Vector2(2, 2); 13 | 14 | public Geometry Output() { 15 | Geometry geo = new Geometry(); 16 | 17 | // Square cell = new Square(); 18 | 19 | return geo; 20 | } 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /IOConnection.cs: -------------------------------------------------------------------------------- 1 | namespace Forge { 2 | 3 | public struct IOConnection { 4 | public Operator From; 5 | public IOOutlet Output; 6 | public Operator To; 7 | public IOOutlet Input; 8 | 9 | public IOConnection(Operator a, IOOutlet o, Operator b, IOOutlet i) { 10 | From = a; 11 | Output = o; 12 | To = b; 13 | Input = i; 14 | } 15 | 16 | public override string ToString() { 17 | return string.Format("{0}.{1} \n{2}.{3}", From.Metadata.Title, Output, To.Metadata.Title, Input); 18 | } 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /Operators/Geometry/RecalculateNormals.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Geometry", Title = "Recalculate Normals")] 6 | class RecalculateNormals : Operator { 7 | 8 | private Geometry _geometry = Geometry.Empty; 9 | [Input] 10 | public void Input (Geometry input) { 11 | _geometry = input; 12 | } 13 | 14 | [Output] 15 | public Geometry Output() { 16 | Geometry geo = _geometry.Copy(); 17 | geo.RecalculateNormals(); 18 | return geo; 19 | } 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Operators/Values/Bounds.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Values", Title = "Bounding Box")] 6 | class Bounds : Operator { 7 | 8 | [Input] 9 | public Geometry Input = Geometry.Empty; 10 | 11 | [Input] 12 | public Axis Axis = Axis.X; 13 | 14 | [Output] 15 | public float Min { get { return Input.Min(Axis); } } 16 | 17 | [Output] 18 | public float Max { get { return Input.Max(Axis); } } 19 | 20 | [Output] 21 | public float Span { get { return Input.Span(Axis); } } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Operators/Inputs/BoolInput.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | #if UNITY_EDITOR 3 | using UnityEditor; 4 | #endif 5 | 6 | namespace Forge.Operators { 7 | 8 | [OperatorMetadata(Category = "Input", Title = "Boolean", DataType = typeof(float))] 9 | public class BoolInput : Parameter { 10 | 11 | [Input] 12 | public bool Default = false; 13 | 14 | [Output] 15 | [ParameterInput] 16 | public bool Value = false; 17 | 18 | #if UNITY_EDITOR 19 | [ParameterGUI] 20 | public object InputGUI(object intValue) { 21 | Value = (bool) EditorGUILayout.Toggle(Label, Value); 22 | return Value; 23 | } 24 | #endif 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /Operators/Math/Multiply.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Math", Title = "Multiply Integer")] 6 | public class MultiplyInteger : Operator { 7 | 8 | [Input] public int A = 1; 9 | [Input] public int B = 1; 10 | 11 | [Output] 12 | public int Output() { 13 | return A * B; 14 | } 15 | 16 | } 17 | 18 | [OperatorMetadata(Category = "Math", Title = "Multiply Float")] 19 | public class MultiplyFloat : Operator { 20 | 21 | [Input] public float A = 1.0f; 22 | [Input] public float B = 1.0f; 23 | 24 | [Output] 25 | public float Output() { 26 | return A * B; 27 | } 28 | 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /Operators/Logic/Switch.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | 4 | namespace Forge.Operators { 5 | 6 | [OperatorMetadata(Category = "Logic")] 7 | public class Switch : Operator { 8 | 9 | [Input] public bool BooleanValue = false; 10 | 11 | [Input] public Geometry TrueGeo; 12 | [Input] public Geometry FalseGeo; 13 | 14 | public Switch() {} 15 | 16 | public Switch(Geometry trueGeo, Geometry falseGeo) { 17 | TrueGeo = trueGeo; 18 | FalseGeo = falseGeo; 19 | } 20 | 21 | [Output] 22 | public Geometry Output() { 23 | if (BooleanValue) { 24 | return TrueGeo; 25 | } else { 26 | return FalseGeo; 27 | } 28 | } 29 | 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /Operators/Values/Vector2.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Values", Title = "XY to Vector2")] 6 | class XYZToVector2 : Operator { 7 | [Input] 8 | public float X = 0f; 9 | [Input] 10 | public float Y = 0f; 11 | 12 | [Output] 13 | public Vector2 Vector2() { 14 | return new Vector2(X, Y); 15 | } 16 | } 17 | 18 | [OperatorMetadata(Category = "Values", Title = "Vector2 to XY")] 19 | class Vector2ToXYZ : Operator { 20 | [Input] 21 | public Vector2 Vector = Vector2.zero; 22 | [Output] 23 | public float X { get { return Vector.x; } } 24 | [Output] 25 | public float Y { get { return Vector.y; } } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Operators/Primitives/Point.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge { 4 | 5 | [OperatorMetadata(Category = "Primitives")] 6 | public class Point : Operator { 7 | 8 | [Input] public Vector3 Position = Vector3.zero; 9 | 10 | public static Geometry At(Vector3 position) { 11 | var p = new Point(); 12 | p.Position = position; 13 | return p.Output(); 14 | } 15 | 16 | [Output] public Geometry Output() { 17 | return new Geometry() { 18 | Vertices = new Vector3[] { Position }, 19 | Normals = new Vector3[] { Vector3.zero }, 20 | Tangents = new Vector4[] { Vector4.zero }, 21 | UV = new Vector2[0], 22 | Triangles = new int[0], 23 | Polygons = new int[0] 24 | }; 25 | } 26 | 27 | } // class 28 | 29 | } // namespace -------------------------------------------------------------------------------- /Operators/Values/Vector3.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Values", Title = "XYZ to Vector3")] 6 | class XYZToVector3 : Operator { 7 | [Input] public float X = 0f; 8 | [Input] public float Y = 0f; 9 | [Input] public float Z = 0f; 10 | 11 | [Output] 12 | public Vector3 Vector3() { 13 | return new Vector3(X, Y, Z); 14 | } 15 | } 16 | 17 | [OperatorMetadata(Category = "Values", Title = "Vector3 to XYZ")] 18 | class Vector3ToXYZ : Operator { 19 | [Input] public Vector3 Vector = Vector3.zero; 20 | [Output] public float X { get { return Vector.x; } } 21 | [Output] public float Y { get { return Vector.y; } } 22 | [Output] public float Z { get { return Vector.z; } } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Operators/Inputs/FloatInput.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | #if UNITY_EDITOR 3 | using UnityEditor; 4 | #endif 5 | 6 | namespace Forge.Operators { 7 | 8 | [OperatorMetadata(Category = "Input", Title = "Float", DataType = typeof(float))] 9 | public class FloatInput : Parameter { 10 | 11 | [Input] 12 | public float Min = 0f; 13 | 14 | [Input] 15 | public float Max = 100f; 16 | 17 | [Input] 18 | public float Default = 0f; 19 | 20 | [Input] 21 | public bool DisplaySlider = true; 22 | 23 | [Output] 24 | [ParameterInput] 25 | public float Float = 0.0f; 26 | 27 | #if UNITY_EDITOR 28 | [ParameterGUI] 29 | public object InputGUI(object floatValue) { 30 | Float = EditorGUILayout.Slider(Label, floatValue == null ? Default : (float) floatValue, Min, Max); 31 | return Float; 32 | } 33 | #endif 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /Operators/Geometry/Reverse.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | 4 | namespace Forge.Operators { 5 | 6 | [OperatorMetadata(Category = "Geometry", Title = "Reverse Vertices")] 7 | public class Reverse : Operator { 8 | 9 | [Input] public Geometry Input = Geometry.Empty; 10 | 11 | [Output] 12 | public Geometry Output() { 13 | 14 | Geometry output = Input.Copy(); 15 | 16 | // Vertices 17 | System.Array.Reverse(output.Vertices); 18 | System.Array.Reverse(output.UV); 19 | System.Array.Reverse(output.Normals); 20 | System.Array.Reverse(output.Tangents); 21 | 22 | return output; 23 | } 24 | 25 | public static Geometry Process(Geometry geometry) { 26 | Reverse reverse = new Reverse(); 27 | reverse.Input = geometry; 28 | return reverse.Output(); 29 | } 30 | 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /Operators/Geometry/VertexNormals.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Geometry", Title = "Vertex Normals")] 6 | class VertexNormals : Operator { 7 | 8 | [Input] 9 | public Geometry Input = Geometry.Empty; 10 | 11 | [Input] 12 | public Vector3 Normal = Vector3.zero; 13 | 14 | [Input] 15 | public Vector4 Tangent = Vector4.zero; 16 | 17 | [Output] 18 | public Geometry Output() { 19 | Geometry geo = Input.Copy(); 20 | 21 | Vector3[] normals = new Vector3[geo.Vertices.Length]; 22 | Vector4[] tangents = new Vector4[geo.Vertices.Length]; 23 | 24 | for (int i = 0; i < geo.Vertices.Length; i++) { 25 | normals[i] = Normal; 26 | tangents[i] = Tangent; 27 | } 28 | 29 | geo.Normals = normals; 30 | geo.Tangents = tangents; 31 | 32 | return geo; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Operators/Math/Divide.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Forge.Operators { 4 | 5 | [OperatorMetadata(Category = "Math", Title = "Divide Integer")] 6 | public class DivideInteger : Operator { 7 | 8 | [Input] public int A = 1; 9 | [Input] public int B = 1; 10 | 11 | [Output] 12 | public int Output() { 13 | 14 | if (B == 0) { 15 | OperatorError = "Cannot divide by zero!"; 16 | return A; 17 | } else OperatorError = null; 18 | 19 | return A / B; 20 | } 21 | 22 | } 23 | 24 | [OperatorMetadata(Category = "Math", Title = "Divide Float")] 25 | public class DivideFloat : Operator { 26 | 27 | [Input] public float A = 1.0f; 28 | [Input] public float B = 1.0f; 29 | 30 | [Output] 31 | public float Output() { 32 | 33 | if (B == 0f) { 34 | OperatorError = "Cannot divide by zero!"; 35 | return A; 36 | } else OperatorError = null; 37 | 38 | return A / B; 39 | } 40 | 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /Editor/MenuCommands.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.IO; 4 | 5 | namespace Forge.Editor { 6 | 7 | public static class MenuCommands { 8 | 9 | [MenuItem("Assets/Create/Forge Template", false, 1)] 10 | static void CreateNewTemplate(MenuCommand menuCommand) { 11 | string path = AssetDatabase.GetAssetPath(Selection.activeObject); 12 | if (path == "") 13 | path = "Assets"; 14 | else if (Path.GetExtension (path) != "") 15 | path = path.Replace (Path.GetFileName(AssetDatabase.GetAssetPath (Selection.activeObject)), ""); 16 | 17 | string fullPath = AssetDatabase.GenerateUniqueAssetPath (path + "/New Forge Template.asset"); 18 | 19 | Template template = ScriptableObject.CreateInstance