Chunks
Moddable voxel sandbox for room-scale VR.
Public Member Functions | Public Attributes | Properties | List of all members
Chunks.Graphics.ModelGenerator Class Reference

Helper class used to procedurally generate 3D models. More...

Public Member Functions

 ModelGenerator (PrimitiveType primitiveType)
 
 ModelGenerator (float scale, PrimitiveType primitiveType)
 Constructs a new ModelGenerator with the specified vertex position scale and face primitive type. More...
 
 ModelGenerator (float scale, Vector offset, PrimitiveType primitiveType)
 Constructs a new ModelGenerator with the specified vertex position scale, offset, and face primitive type. More...
 
void Clear ()
 Removes all vertex data and face indices from the generated model. More...
 
int AddVertex (Vector position, Vector texCoords, Vector normal, Color color, Surface surface)
 
int AddVertex (Vector position, Vector texCoords, Vector normal, Vector tangent, Color color, Surface surface)
 Adds a single vertex to the generated model, returning its vertex index. More...
 
void AddQuad (Vector a, Vector b, Vector c, Vector d, Vector uvMin, Vector uvMax, Color color, Surface surface=null)
 Adds a quad face to the generated model using the given vertex positions, minimum and maximum texture coordinates, vertex color, and surface info. More...
 
void AddQuad (Vector min, Vector max, Color color, Surface surface=null)
 
void AddQuad (Vector a, Vector b, Vector c, Vector d, Vector uvA, Vector uvB, Vector uvC, Vector uvD, Color color, Surface surface)
 Adds a quad face to the generated model using the given vertex positions, texture coordinates, vertex color, and surface info. More...
 
void AddBox (Vector origin, Vector right, Vector up, Vector forward, Vector uvMin, Vector uvMax, Color color, Surface surface=null)
 Adds six quad faces in the shape of a parallelepiped defined by one corner position and three vectors for each of the edges from that corner to its neighbours. More...
 
void AddBox (Vector size, Color color, Surface surface=null)
 
void AddBox (Vector center, Vector size, Color color, Surface surface=null)
 
void AddQuadIndices (int indexA, int indexB, int indexC, int indexD)
 Adds a quad face defined by the indices of four vertices. More...
 
void AddQuad (BlockVertex a, BlockVertex b, BlockVertex c, BlockVertex d)
 Adds a quad face defined by four vertices. More...
 
void AddQuad (IntVector min, IntVector max, Face face, Surface surface)
 Adds a quad face defined as one of the faces of an axis aligned box. More...
 
void AddBox (IntVector min, IntVector max, [NotNull] Block block)
 Adds an axis aligned box with surface textures taken from a Block. More...
 
void AddBox (IntVector min, IntVector max, [NotNull] Surface surface)
 Adds an axis aligned box with the same texture on each face. More...
 
void AddBox (IntVector min, IntVector max, Surface xMinSurface, Surface xMaxSurface, Surface yMinSurface, Surface yMaxSurface, Surface zMinSurface, Surface zMaxSurface)
 Adds an axis aligned box with specified textures on each face. More...
 

Public Attributes

bool HasIndices => _indices.Count > 0
 Returns true if the model currently has any face indices. More...
 

Properties

float Scale [get, set]
 
Vector Offset [get, set]
 

Detailed Description

Helper class used to procedurally generate 3D models.

Constructor & Destructor Documentation

Chunks.Graphics.ModelGenerator.ModelGenerator ( PrimitiveType  primitiveType)
Chunks.Graphics.ModelGenerator.ModelGenerator ( float  scale,
PrimitiveType  primitiveType 
)

Constructs a new ModelGenerator with the specified vertex position scale and face primitive type.

Parameters
scaleThe amount each vertex position should be scaled by
primitiveTypeThe PrimitiveType of each face
Chunks.Graphics.ModelGenerator.ModelGenerator ( float  scale,
Vector  offset,
PrimitiveType  primitiveType 
)

Constructs a new ModelGenerator with the specified vertex position scale, offset, and face primitive type.

Parameters
scaleThe amount each vertex position should be scaled by
offsetThe amount to offset each vertex position
primitiveTypeThe PrimitiveType of each face

Member Function Documentation

void Chunks.Graphics.ModelGenerator.AddBox ( Vector  origin,
Vector  right,
Vector  up,
Vector  forward,
Vector  uvMin,
Vector  uvMax,
Color  color,
Surface  surface = null 
)

Adds six quad faces in the shape of a parallelepiped defined by one corner position and three vectors for each of the edges from that corner to its neighbours.

Parameters
originStarting corner of the box
rightVector from the origin to the first neighbouring corner
upVector from the origin to the second neighbouring corner
forwardVector from the origin to the third neighbouring corner
uvMinMinimum texture coordinate
uvMaxMaximum texture coordinate
colorFace color
surfaceFace surface info, used for texturing
void Chunks.Graphics.ModelGenerator.AddBox ( Vector  size,
Color  color,
Surface  surface = null 
)
void Chunks.Graphics.ModelGenerator.AddBox ( Vector  center,
Vector  size,
Color  color,
Surface  surface = null 
)
void Chunks.Graphics.ModelGenerator.AddBox ( IntVector  min,
IntVector  max,
[NotNull] Block  block 
)

Adds an axis aligned box with surface textures taken from a Block.

Parameters
minMinimum bounds of the box
maxMaximum bounds of the box
blockBlock type used for texturing
void Chunks.Graphics.ModelGenerator.AddBox ( IntVector  min,
IntVector  max,
[NotNull] Surface  surface 
)

Adds an axis aligned box with the same texture on each face.

Parameters
minMinimum bounds of the box
maxMaximum bounds of the box
surfaceSurface used for texturing
void Chunks.Graphics.ModelGenerator.AddBox ( IntVector  min,
IntVector  max,
Surface  xMinSurface,
Surface  xMaxSurface,
Surface  yMinSurface,
Surface  yMaxSurface,
Surface  zMinSurface,
Surface  zMaxSurface 
)

Adds an axis aligned box with specified textures on each face.

Parameters
minMinimum bounds of the box
maxMaximum bounds of the box
xMinSurfaceSurface to use for texturing the face point towards -X
xMaxSurfaceSurface to use for texturing the face point towards +X
yMinSurfaceSurface to use for texturing the face point towards -Y
yMaxSurfaceSurface to use for texturing the face point towards +Y
zMinSurfaceSurface to use for texturing the face point towards -Z
zMaxSurfaceSurface to use for texturing the face point towards +Z
void Chunks.Graphics.ModelGenerator.AddQuad ( Vector  a,
Vector  b,
Vector  c,
Vector  d,
Vector  uvMin,
Vector  uvMax,
Color  color,
Surface  surface = null 
)

Adds a quad face to the generated model using the given vertex positions, minimum and maximum texture coordinates, vertex color, and surface info.

Parameters
aFirst vertex position
bSecond vertex position
cThird vertex position
dFourth vertex position
uvMinTexture coordinate of the first vertex
uvMaxTexture coordinate of the third vertex
colorFace color
surfaceFace surface info, used for texturing
void Chunks.Graphics.ModelGenerator.AddQuad ( Vector  min,
Vector  max,
Color  color,
Surface  surface = null 
)
void Chunks.Graphics.ModelGenerator.AddQuad ( Vector  a,
Vector  b,
Vector  c,
Vector  d,
Vector  uvA,
Vector  uvB,
Vector  uvC,
Vector  uvD,
Color  color,
Surface  surface 
)

Adds a quad face to the generated model using the given vertex positions, texture coordinates, vertex color, and surface info.

Parameters
aFirst vertex position
bSecond vertex position
cThird vertex position
dFourth vertex position
uvAFirst texture coordinate
uvBSecond texture coordinate
uvCThird texture coordinate
uvDFourth texture coordinate
colorFace color
surfaceFace surface info, used for texturing
void Chunks.Graphics.ModelGenerator.AddQuad ( BlockVertex  a,
BlockVertex  b,
BlockVertex  c,
BlockVertex  d 
)

Adds a quad face defined by four vertices.

Parameters
aFirst vertex
bSecond vertex
cThird vertex
dFourth vertex
void Chunks.Graphics.ModelGenerator.AddQuad ( IntVector  min,
IntVector  max,
Face  face,
Surface  surface 
)

Adds a quad face defined as one of the faces of an axis aligned box.

Parameters
minMinimum bounds of the box the quad is a face of
maxMaximum bounds of the box the quad is a face of
faceFace of the box the quad is generated from
surfaceFace surface info, used for texturing
void Chunks.Graphics.ModelGenerator.AddQuadIndices ( int  indexA,
int  indexB,
int  indexC,
int  indexD 
)

Adds a quad face defined by the indices of four vertices.

Parameters
indexAFirst vertex index
indexBSecond vertex index
indexCThird vertex index
indexDFourth vertex index
int Chunks.Graphics.ModelGenerator.AddVertex ( Vector  position,
Vector  texCoords,
Vector  normal,
Color  color,
Surface  surface 
)
int Chunks.Graphics.ModelGenerator.AddVertex ( Vector  position,
Vector  texCoords,
Vector  normal,
Vector  tangent,
Color  color,
Surface  surface 
)

Adds a single vertex to the generated model, returning its vertex index.

Parameters
positionVertex position
texCoordsVertex texture coordinates
normalVertex normal
colorVertex color
surfaceVertex surface info, used for texturing
void Chunks.Graphics.ModelGenerator.Clear ( )

Removes all vertex data and face indices from the generated model.

Member Data Documentation

bool Chunks.Graphics.ModelGenerator.HasIndices => _indices.Count > 0

Returns true if the model currently has any face indices.

Property Documentation

Vector Chunks.Graphics.ModelGenerator.Offset
getset
float Chunks.Graphics.ModelGenerator.Scale
getset

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