Created
May 31, 2020 10:27
-
-
Save andybak/0870263c0c476205b6f7a471f00ee1dc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using ProceduralToolkit; | |
using ProceduralToolkit.Samples.Primitives; | |
using UnityEngine; | |
using XNode; | |
public enum PrimitiveType | |
{ | |
Dodecahedron, | |
Octahedron | |
} | |
namespace Graphmesh { | |
public class Primitive : GraphmeshNode { | |
[Input] public PrimitiveType primitive; | |
[Input] public float radius; | |
[Input] public Material material; | |
[Output] public ModelGroup output; | |
public override object GetValue(NodePort port) { | |
object o = base.GetValue(port); | |
if (o != null) return o; | |
Mesh mesh; | |
switch (GetInputValue("primitive", this.primitive)) | |
{ | |
case PrimitiveType.Dodecahedron: | |
mesh = MeshDraft.Dodecahedron(radius).ToMesh(); | |
break; | |
case PrimitiveType.Octahedron: | |
mesh = MeshDraft.Octahedron(radius).ToMesh(); | |
break; | |
default: | |
mesh = MeshDraft.Cube(radius).ToMesh(); | |
break; | |
} | |
Material material = GetInputValue("material", this.material); | |
if (mesh == null) return new ModelGroup(); | |
//Fixme: Support for more than one material | |
Model model = new Model(mesh.Copy(), new Material[] { material }); | |
return new ModelGroup() { model }; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using ProceduralToolkit; | |
using ProceduralToolkit.Samples.Primitives; | |
using UnityEngine; | |
using XNode; | |
namespace Graphmesh { | |
public class RandomPrimitive : GraphmeshNode { | |
[Input] public int index; | |
[Output] public PrimitiveType output; | |
public override object GetValue(NodePort port) { | |
// object o = base.GetValue(port); | |
// if (o != null) return o; | |
return GetInputValue<PrimitiveType>("index", (PrimitiveType)index); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment