DHART
Loading...
Searching...
No Matches
DHARTAPI.Geometry.MeshInfo Class Reference

A collection of vertices and indices representing geometry. More...

+ Inheritance diagram for DHARTAPI.Geometry.MeshInfo:

Public Member Functions

int CalculatePresure ()
 Calculates the amount of pressure this mesh should exert on the GC. More...
 
 MeshInfo (int[] indices, float[] vertices, string name="", int id=0)
 Create an instance of MeshInfo from an array of vertices and triangle indices. More...
 
void RotateMesh (float xrot, float yrot, float zrot)
 Rotate this mesh by the desired magnitude. More...
 
void RotateMesh (Vector3D rotation)
 Rotate this mesh by the desired magnitude. More...
 
override String ToString ()
 
- Public Member Functions inherited from DHARTAPI.NativeUtils.NativeObject
void UpdatePressure (int new_pressure)
 Update the pressure of this object.
 

Public Attributes

int id = -1
 ID of the mesh.
 
string name = ""
 Name of the mesh.
 
DependentNativeArray< float > vertices
 An array of all the coordinates for every vertex in the mesh.
 
DependentNativeArray< int > indices
 An array of the indices for every triangle in the mesh.
 
- Public Attributes inherited from DHARTAPI.NativeUtils.NativeObject
int pressure
 the size of the object pointed to in unmanaged memory in bytes. Used to exert pressure on the GC. More...
 

Protected Member Functions

override bool ReleaseHandle ()
 Manually delete this mesh in Unmanaged memory. More...
 

Additional Inherited Members

- Properties inherited from DHARTAPI.NativeUtils.NativeObject
override bool IsInvalid [get]
 There is no way to invalidate this class without destroying it, so will always return false.
 

Detailed Description

A collection of vertices and indices representing geometry.

Figure 1.1: Meshinfo Internals

Stores a reference to mesh geometry in native memory. Internally, meshes are represented as a 3 by X matrix of vertices and a 3 by X matrix for indices. In the above image, the face list and vertex list are what's held in MeshInfo's Index and Vertex arrays respectively.

Invariant
Will always hold a valid mesh.

Constructor & Destructor Documentation

◆ MeshInfo()

DHARTAPI.Geometry.MeshInfo.MeshInfo ( int[]  indices,
float[]  vertices,
string  name = "",
int  id = 0 
)

Create an instance of MeshInfo from an array of vertices and triangle indices.

Parameters
indicesAn array of indices for the triangles in the mesh. Each integer should correspond to 3 values in vertices , and every 3 integers should represent a complete triangle for the mesh.
verticesVertices of the mesh. Each 3 floats represent the X,Y, and Z of a point in space
nameThe name of the mesh. Unused for now.
idThe unique identifier for this mesh. If -1, this will automatically be set
Exceptions
DHARTAPI.Exceptions.InvalidMeshExceptionThe input indices and vertices result in an invalid mesh.
Example
// These vertices/indices are directly taken from the plane OBJ in example models.
// Every 3 floats represent the x,y,z locations for a seperate vertex. It takes only
// 4 vertices to make a plane.
float[] vertices = {
-20.079360961914062f, 0.0f, 18.940643310546875f,
-20.079360961914062f, 0.0f, -18.842348098754883f,
20.140586853027344f, 0.0f, 18.940643310546875f,
20.140586853027344f, 0.0f, -18.842348098754883f
};
// Every 3 ints represent the indexes of vertices for a seperate triangle.
int[] indices = {
3, 1, 0,
2, 3, 0
};
// Construct a new meshinfo instance with these elements
A collection of vertices and indices representing geometry.
Definition: MeshInfo.cs:50
DependentNativeArray< float > vertices
An array of all the coordinates for every vertex in the mesh.
Definition: MeshInfo.cs:53
DependentNativeArray< int > indices
An array of the indices for every triangle in the mesh.
Definition: MeshInfo.cs:54
Manipulate and load geometry from disk.
Definition: CommonRotations.cs:4
Automated analysis of the built environent
Definition: CommonTypes.cs:9

References DHARTAPI.Geometry.MeshInfo.CalculatePresure(), and DHARTAPI.NativeUtils.NativeObject.UpdatePressure().

Member Function Documentation

◆ CalculatePresure()

int DHARTAPI.Geometry.MeshInfo.CalculatePresure ( )

Calculates the amount of pressure this mesh should exert on the GC.

Returns
The approximate size of this mesh in bytes.

References DHARTAPI.NativeUtils.NativeArray< T >.size.

Referenced by DHARTAPI.Geometry.MeshInfo.MeshInfo().

◆ ReleaseHandle()

override bool DHARTAPI.Geometry.MeshInfo.ReleaseHandle ( )
protected

Manually delete this mesh in Unmanaged memory.

Remarks
This is called automatically when the class is garbage collected, so don't worry about needing to manually call this. It may be advantageous to deallocate large meshes at specific times for specialized purposes where the garbage collector deleting a large mesh will cause noticable lag.
Returns
True if the handle is released successfully; otherwise, in the event of a catastrophic failure, false. In this case, it generates a releaseHandleFailed MDA Managed Debugging Assistant.
Warning
This deletes the mesh in unmanaged memory! Don't try to use this class again after calling this function!

◆ RotateMesh() [1/2]

void DHARTAPI.Geometry.MeshInfo.RotateMesh ( float  xrot,
float  yrot,
float  zrot 
)

Rotate this mesh by the desired magnitude.

Parameters
xrotPitch to rotate by in degrees.
yrotYaw to rotate by in degrees.
zrotRoll to rotate by in degrees.
Remarks
See the other overload for this function for use with CommonRotations.
Example
// These vertices/indices are directly taken from the plane OBJ in example models.
// Every 3 floats represent the x,y,z locations for a seperate vertex. It takes only
// 4 vertices to make a plane.
float[] vertices = {
-20.079360961914062f, 0.0f, 18.940643310546875f,
-20.079360961914062f, 0.0f, -18.842348098754883f,
20.140586853027344f, 0.0f, 18.940643310546875f,
20.140586853027344f, 0.0f, -18.842348098754883f
};
// Every 3 ints represent the indexes of vertices for a seperate triangle.
int[] indices = {
3, 1, 0,
2, 3, 0
};
// Construct a new meshinfo instance with these elements
// Rotate the mesh 90 degrees around the X axis
Mesh.RotateMesh(90, 0, 0);
void RotateMesh(float xrot, float yrot, float zrot)
Rotate this mesh by the desired magnitude.
Definition: MeshInfo.cs:165

◆ RotateMesh() [2/2]

void DHARTAPI.Geometry.MeshInfo.RotateMesh ( Vector3D  rotation)

Rotate this mesh by the desired magnitude.

Parameters
rotationHow far to rotate the mesh on the X,Y, and Z, axises in degrees.
See also
CommonRotations for commonly used rotations such as Yup to Zup.
Example
// These vertices/indices are directly taken from the plane OBJ in example models.
// Every 3 floats represent the x,y,z locations for a seperate vertex. It takes only
// 4 vertices to make a plane.
float[] vertices = {
-20.079360961914062f, 0.0f, 18.940643310546875f,
-20.079360961914062f, 0.0f, -18.842348098754883f,
20.140586853027344f, 0.0f, 18.940643310546875f,
20.140586853027344f, 0.0f, -18.842348098754883f
};
// Every 3 ints represent the indexes of vertices for a seperate triangle.
int[] indices = {
3, 1, 0,
2, 3, 0
};
// Construct a new meshinfo instance with these elements
// Rotate the mesh using a common rotation to convert it from yup to zup
A collection of rotations that are frequently useful in DHARTAPI.
Definition: CommonRotations.cs:7
static Vector3D Yup_To_Zup
Will rotate a mesh from Y-Up to Z-Up.
Definition: CommonRotations.cs:16

References DHARTAPI.NativeUtils.NativeArray< T >.size, and DHARTAPI.Geometry.MeshInfo.vertices.


The documentation for this class was generated from the following file: