Class MeshElement
An element whose representation is provided by a mesh.
Examples
var mesh = new Mesh();
var gridSize = 10;
for (var u = 0; u < gridSize; u += 1)
{
for (var v = 0; v < gridSize; v += 1)
{
var sinu = Math.Sin(-Math.PI + 2 * ((double)u / (double)gridSize * Math.PI));
var sinv = Math.Sin(-Math.PI + 2 * ((double)v / (double)gridSize * Math.PI));
var z = sinu + sinv;
var vertex = new Vertex(new Vector3(u, v, z), color: Colors.Mint);
mesh.AddVertex(vertex);
if (u > 0 && v > 0)
{
var index = u * gridSize + v;
var a = mesh.Vertices[index];
var b = mesh.Vertices[index - gridSize];
var c = mesh.Vertices[index - 1];
var d = mesh.Vertices[index - gridSize - 1];
var tri1 = new Triangle(a, b, c);
var tri2 = new Triangle(c, b, d);
mesh.AddTriangle(tri1);
mesh.AddTriangle(tri2);
}
}
}
mesh.ComputeNormals();
var meshElement = new MeshElement(mesh, material: new Material("Lime", Colors.Lime));
Inheritance
System.Object
MeshElement
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Elements
Assembly: Hypar.Elements.dll
Syntax
public class MeshElement : GeometricElement, INotifyPropertyChanged, ITessellate
Constructors
MeshElement()
Empty constructor for compatibility purposes. It is best to use the structured constructor with arguments, to ensure the mesh is correctly created.
Declaration
public MeshElement()
MeshElement(Mesh, Transform, Material, Representation, Boolean, Guid, String)
Construct an import mesh element.
Declaration
[JsonConstructor]
public MeshElement(Mesh mesh, Transform transform = null, Material material = null, Representation representation = null, bool isElementDefinition = false, Guid id = default(Guid), string name = null)
Parameters
Type | Name | Description |
---|---|---|
Mesh | mesh | The element's mesh. |
Transform | transform | The element's transform. |
Material | material | The element's material. |
Representation | representation | The element's representation. |
System.Boolean | isElementDefinition | Is this element a definition? |
System.Guid | id | The element's id. |
System.String | name | The element's name. |
Fields
_mesh
The mesh.
Declaration
protected Mesh _mesh
Field Value
Type | Description |
---|---|
Mesh |
Properties
Mesh
The element's mesh.
Declaration
public Mesh Mesh { get; set; }
Property Value
Type | Description |
---|---|
Mesh |
Methods
Tessellate(ref Mesh, Transform, Color)
Tessellate the element.
Declaration
public void Tessellate(ref Mesh mesh, Transform transform = null, Color color = default(Color))
Parameters
Type | Name | Description |
---|---|---|
Mesh | mesh | |
Transform | transform | |
Color | color |
Implements
System.ComponentModel.INotifyPropertyChanged