ModelGeometry

Description

abstract class Tinman.Engine.Models.ModelGeometry

Derived from

IModelGeometry

Abstract base class for IModelGeometry implementations.

This class provides factory methods for building instances of the IModelGeometry interface:

  • Box: axis-aligned box

  • Build: custom geometry

  • Sphere: tessellated sphere

  • Wrap: wrap terrain vertex data

Public / Constructors

Append


public static method Append → (1)

geometries in : IEnumerable<IModelGeometry>

The model geometries to concatenate.

returns → IModelGeometry

The resulting model geometry or null if geometries in is null or if it does not contain any non-null IModelGeometry objects.

Concatenates the vertices and indices of the given model geometries in.

Calling this method is equivalent to calling IModelGeometry.Append repeatedly for the elements in geometries in.

Box


public static method Box → (3)

box in : Box3D

The box coordinates.

normals opt : int32 = 0

Generate normal vectors?
> 0 : Generate normals by right-hand rule for CCW faces (see figure).
< 0 : Generate normals by right-hand rule for CW faces (see figure).
= 0 : Do not generate normals.

texCoords opt : int32 = 0

[>=0]
The texture coordinate repeat count per face. Set to 0 to disable texture coordinates.

returns → IModelGeometrySimple

The model geometry.

Builds an axis-aligned box.

The following figure shows the mapping from the given box in to the 3D model:

   121-----221
   /|      /|
  / |     / |
122-----222 |
 | 111---|-211
 | /     | /
 |/      |/
112-----212

where 111 maps to Box3D.X1, Box3D.Y1, Box3D.Z1 and 222 maps to Box3D.X2, Box3D.Y2, Box3D.Z2.

Build


public static method Build → ()

returns → ModelGeometryBuilder

The model geometry builder.

Creates a builder for IModelGeometry objects.

Capsule


public static method Capsule → (4)

length in : float64

[>=0]
The distance between A and B.

radius in : float64

[>=0]
The hemisphere radius at A and B.

segments opt : int32 = 12

[>=3]
The number of circle segments.

modulo opt : int32 = 1

[>=1]
The modulo to use for generating segment lines.

returns → IModelGeometrySimple

The model geometry.

Builds a capsule.

  ________________
 /                \     A = (0,0,0)
|  A------------B  |
 \________________/     B = (0,length,0)

   |____________|       length

                |__|    radius

Cone


public static method Cone → (4)

length in : float64

[>=0]
The distance between A and B.

radius in : float64

[>=0]
The disc radius at A.

segments opt : int32 = 12

[>=3]
The number of circle segments.

modulo opt : int32 = 1

[>=1]
The modulo to use for generating segment lines.

returns → IModelGeometrySimple

The model geometry.

Builds a cone.

     B
    /|\        A = (0,0,0)
   / | \
  /  |  \      B = (0,length,0)
 /   |   \
+----A----+

     |____|    radius

Cylinder


public static method Cylinder → (4)

length in : float64

[>=0]
The distance between A and B.

radius in : float64

[>=0]
The disc radius at A and B.

segments opt : int32 = 12

[>=3]
The number of circle segments.

modulo opt : int32 = 1

[>=1]
The modulo to use for generating segment lines.

returns → IModelGeometrySimple

The model geometry.

Builds a cylinder.

 ____________
|            |    A = (0,0,0)
A------------B
|____________|    B = (0,length,0)

Disc


public static method Disc → (2)

radius in : float64

[>=0]
The disc radius at A.

segments opt : int32 = 12

[>=3]
The number of circle segments.

returns → IModelGeometrySimple

The model geometry.

Builds a disc that is perpendicular to (0,1,0).

+--A--+    A = (0,0,0)
   |__|    radius

Dynamic


public static method Dynamic → (3)

vertices in : int32

[>0]
The vertex count.

format in : ModelVertexFormat

The vertex format.

indices opt : int32 = 0

[>=0]
The index count or 0 for none.

returns → IModelGeometryDynamic

The dynamic model geometry.

Creates an instance of IModelGeometryDynamic.

Generic


public static method Generic → (7)

length in : float64

[>=0]
The distance between A and B.

radiusA in : float64

[>=0]
The radius at A.

radiusB in : float64

[>=0]
The radius at B.

capA in : int32

The cap to build at A.

capB in : int32

The cap to build at B.

segments opt : int32 = 12

[>=3]
The number of circle segments.

modulo opt : int32 = 1

[>=1]
The modulo to use for generating segment lines.

returns → IModelGeometrySimple

The model geometry or null if empty.

Builds a 3D primitive from a generic, possibly degenerated capsule.

The point A is at (0,0,0), the point B is at (0, length in ,0):

  ________________
 /                \
|  A------------B  |    Round (cap > 0)
 \________________/

    ____________
   |            |
   A------------B       Flat  (cap = 0)
   |____________|

    ____________

   A------------B       None  (cap < 0)
    ____________


   |____________|       length

|__|            |__|    radiusA, radiusB

By choosing parameter values carefully, a variety of 3D primitives can be built with this method:

Primitive  | len = 0 | rA = 0 | rB = 0 | rA = rB | cA | cB
-----------+---------+--------+--------+---------+----+----
Capsule    |    no   |    no  |    no  |   yes   |  1 |  1
-----------+---------+--------+--------+---------+----+----
Cone       |    no   |   yes  |    no  |    no   | -1 |  0
           |    no   |    no  |   yes  |    no   |  0 | -1
-----------+---------+--------+--------+---------+----+----
Cylinder   |    no   |    no  |    no  |   yes   |  0 |  0
-----------+---------+--------+--------+---------+----+----
Disc       |   yes   |    no  |    no  |   yes   |  0 |  0
-----------+---------+--------+--------+---------+----+----
Hemisphere |   yes   |    no  |    no  |    no   |  1 |  0
           |   yes   |    no  |   yes  |   yes   |  0 |  1
-----------+---------+--------+--------+---------+----+----
Line       |    no   |   yes  |   yes  |   yes   | -1 | -1
-----------+---------+--------+--------+---------+----+----
Point      |   yes   |   yes  |   yes  |   yes   | -1 | -1
-----------+---------+--------+--------+---------+----+----
Sphere     |   yes   |    no  |    no  |   yes   |  1 |  1
-----------+---------+--------+--------+---------+----+----
Tube       |    no   |    no  |    no  |   yes   | -1 | -1

where len is length in, rA is radiusA in, rB is radiusB in, cA is capA in and cB is capB in.

Hemisphere


public static method Hemisphere → (3)

radius in : float64

[>=0]
The hemisphere radius at A.

segments opt : int32 = 12

[>=3]
The number of circle segments.

modulo opt : int32 = 1

[>=1]
The modulo to use for generating segment lines.

returns → IModelGeometrySimple

The model geometry.

Builds a hemisphere.

 _
| \     A = (0,0,0)
A  B
|_/     B = (0,radius,0)

Line


public static method Line → (1)

length in : float64

[>=0]
The distance between A and B.

returns → IModelGeometrySimple

The model geometry.

Builds a line segment.

A------------B    A = (0,0,0)
                  B = (0,length,0)

Shape


public static method Shape → (7)

shape in : IShape

[not-null]
The 2D shape.

triangles opt : bool = true

Generate triangles?

lines opt : bool = true

Generate lines

u0 opt : float64 = 0

Texture U-coordinate to map to Box2D.X1 of IShape.Bounds.

v0 opt : float64 = 0

Texture V-coordinate to map to Box2D.Y1 of IShape.Bounds.

u1 opt : float64 = 1

Texture U-coordinate to map to Box2D.X2 of IShape.Bounds.

v1 opt : float64 = 1

Texture V-coordinate to map to Box2D.Y2 of IShape.Bounds.

returns → IModelGeometrySimple

The model geometry or null if empty.

Builds a 3D shape.

The shape is in the XY-plane, having the normal vector (0,0,1). Texture coordinates are generated in the range (u0 opt, v0 opt) to ( u1 opt, v1 opt), which maps to Box2D.TopLeft resp. Box2D.BottomRight of IShape.Bounds.

The triangles of the 3D shape are obtained by first converting the given shape in to ShapeType.Mesh and then using IShape.TriangleAt.

The lines of the 3D shape are obtained by first converting the given shape in to ShapeType.Graph and then using IShape.EdgeAt.

Sphere


public static method Sphere → (3)

radius in : float64

[>=0]
The sphere radius.

segments opt : int32 = 12

[>=3]
The number of circle segments.

modulo opt : int32 = 1

[>=1]
The modulo to use for generating segment lines.

returns → IModelGeometrySimple

The model geometry.

Builds a sphere.

  ___
 /   \
|  A  |    A = (0,0,0)
 \___/

   |__|    radius

Sphere​Ico


public static method SphereIco → (5)

center in : Vec3D

The sphere center.

radius in : float64

The sphere radius. If negative, the sphere will be mirrored at center in, making the normals point inwards.

levels in : int32

[>=0]
Subdivisions to perform for faces (see IModelGeometrySimple.Triangles). Level 7 generates approximately one million triangles.

levelsEdges opt : int32 = 0

[0..levels]
Subdivisions to perform for edges (see IModelGeometrySimple.Lines). Level 7 generates approximately one million lines.

textureCoordinates opt : bool = false

Generate U and V texture coordinates?

The U-coordinate range [0..1] is mapped to longitude [-180° .. +180°].
The V-coordinate range [0..1] is mapped to latitude  [ +90° ..  -90°].

Vertex positions are mapped to geographic coordinates using the conventions of Geocentric.

returns → IModelGeometrySimple

The model geometry.

Builds a sphere by subdividing an icosahedron.

The number of triangle vertices resp. line vertices (see PrimitiveBatch.Count) can be computed from the subdivision count levels in resp. levelsEdges opt as follows:

vertices = 4 ^ levels * 60

The first eight subdivision levels produce the following triangle resp. line vertex counts:

count = 0 : vertices =      60
count = 1 : vertices =     240
count = 2 : vertices =     960
count = 3 : vertices =   3,840
count = 4 : vertices =  15,360
count = 5 : vertices =  61,440
count = 6 : vertices = 245,760
count = 7 : vertices = 983,040

Tube


public static method Tube → (4)

length in : float64

[>=0]
The distance between A and B.

radius in : float64

[>=0]
The hemisphere radius at A and B.

segments opt : int32 = 12

[>=3]
The number of circle segments.

modulo opt : int32 = 1

[>=1]
The modulo to use for generating segment lines.

returns → IModelGeometrySimple

The model geometry.

Builds a tube.

______________
                  A = (0,0,0)
A------------B
______________    B = (0,length,0)

Wrap


[Pure]
public static method Wrap → (2)

vertices in : VertexArrays

[not-null]
The vertex data to wrap.

indices opt : int32 [ ] = null

The index data to wrap or null to create non-indexed geometry.

returns → IModelGeometry

The model geometry.

Creates a new instance of ModelGeometry.

The given vertices in object and indices opt array will be referenced by the returned IModelGeometry object, no data is copied.

Logging

Logger


public static readonly attribute Logger → (ILogger)

The logger object of this class.