C# Class SSTUTools.MeshBuilder

Generic mesh-building class; input each vert and triangle as created, it will take care of creating the actual mesh and calculating tangents
Show file Open project: shadowmage45/SSTULabs Class Usage Examples

Public Properties

Property Type Description
subdivision int

Public Methods

Method Description
addTriangle ( int a, int b, int c ) : void
addVertex ( Vector3 vert, Vector3 norm, Vector2 uv ) : Vertex
buildMesh ( ) : Mesh
clear ( ) : void
generateCuboid ( Vector3 size, Vector3 center, Vector2 uvStart, Vector2 uvEnd ) : void

Creates an axis-aligned cube mesh at the given center point, with the given size dimensions, from the input UV coordinates.

generateCylinderCap ( Vector3 offset, int faces, float outerRadius, float innerRadius, float height, float startAngle, float endAngle, UVArea area, bool bottomCap ) : void
generatePanelCollider ( Vector3 center, float startAngle, float endAngle, float startY, float height, float bottomRadius, float topRadius, float thickness ) : void
generateQuads ( List verts1, List verts2, bool invertFaces ) : void
generateRadialVerticesCylinderUVs ( Vector3 offset, int faces, float radius, float height, float startAngle, float endAngle, UVArea area, float uvRadius, float yCos, float ySin ) : List

Generates a ring of vertices using circular UV mapping, where the center of the ring is the center of the UV area. This would be used to generate a partial ring, such as the procedural decoupler Input radius is the radius of the actual ring, uvRadius is the radius to be used for maximal UV bounds (e.g. they will only be different on an inner-ring; where radius=ring radius, and uvRadius = outerRingRadius)

generateRadialVerticesFlatUVs ( Vector3 offset, int faces, float radius, float height, float startAngle, float endAngle, float v, UVArea area, float yCos, float ySin ) : List

Used to generate a ring of vertices with the uvMapping appropriate for a cylinder wall (increments in +x)

generateTriangle ( Vertex a, Vertex b, Vertex c, bool invertFace ) : void
generateTriangleFan ( List circ, List centers, bool invertFaces ) : void
generateTriangleFan ( List circ, Vertex cent, bool invertFaces ) : void

Private Methods

Method Description
calculateTangents ( ) : Vector4[]
getNorms ( ) : Vector3[]
getTriangles ( ) : int[]
getUVs ( ) : Vector2[]
getVerts ( ) : Vector3[]

Method Details

addTriangle() public method

public addTriangle ( int a, int b, int c ) : void
a int
b int
c int
return void

addVertex() public method

public addVertex ( Vector3 vert, Vector3 norm, Vector2 uv ) : Vertex
vert Vector3
norm Vector3
uv Vector2
return Vertex

buildMesh() public method

public buildMesh ( ) : Mesh
return UnityEngine.Mesh

clear() public method

public clear ( ) : void
return void

generateCuboid() public method

Creates an axis-aligned cube mesh at the given center point, with the given size dimensions, from the input UV coordinates.
public generateCuboid ( Vector3 size, Vector3 center, Vector2 uvStart, Vector2 uvEnd ) : void
size Vector3
center Vector3
uvStart Vector2
uvEnd Vector2
return void

generateCylinderCap() public method

public generateCylinderCap ( Vector3 offset, int faces, float outerRadius, float innerRadius, float height, float startAngle, float endAngle, UVArea area, bool bottomCap ) : void
offset Vector3
faces int
outerRadius float
innerRadius float
height float
startAngle float
endAngle float
area UVArea
bottomCap bool
return void

generatePanelCollider() public method

public generatePanelCollider ( Vector3 center, float startAngle, float endAngle, float startY, float height, float bottomRadius, float topRadius, float thickness ) : void
center Vector3
startAngle float
endAngle float
startY float
height float
bottomRadius float
topRadius float
thickness float
return void

generateQuads() public method

public generateQuads ( List verts1, List verts2, bool invertFaces ) : void
verts1 List
verts2 List
invertFaces bool
return void

generateRadialVerticesCylinderUVs() public method

Generates a ring of vertices using circular UV mapping, where the center of the ring is the center of the UV area. This would be used to generate a partial ring, such as the procedural decoupler Input radius is the radius of the actual ring, uvRadius is the radius to be used for maximal UV bounds (e.g. they will only be different on an inner-ring; where radius=ring radius, and uvRadius = outerRingRadius)
public generateRadialVerticesCylinderUVs ( Vector3 offset, int faces, float radius, float height, float startAngle, float endAngle, UVArea area, float uvRadius, float yCos, float ySin ) : List
offset Vector3
faces int
radius float
height float
startAngle float
endAngle float
area UVArea The UV area to map the UV vertex to.
uvRadius float The radius to be used for the UV area, in case it differs from the radius in use (basically scales the UV area)
yCos float Determines the x/z normal component
ySin float Used directly as the y normal component
return List

generateRadialVerticesFlatUVs() public method

Used to generate a ring of vertices with the uvMapping appropriate for a cylinder wall (increments in +x)
public generateRadialVerticesFlatUVs ( Vector3 offset, int faces, float radius, float height, float startAngle, float endAngle, float v, UVArea area, float yCos, float ySin ) : List
offset Vector3
faces int
radius float
height float
startAngle float
endAngle float
v float
area UVArea
yCos float
ySin float
return List

generateTriangle() public method

public generateTriangle ( Vertex a, Vertex b, Vertex c, bool invertFace ) : void
a Vertex
b Vertex
c Vertex
invertFace bool
return void

generateTriangleFan() public method

public generateTriangleFan ( List circ, List centers, bool invertFaces ) : void
circ List
centers List
invertFaces bool
return void

generateTriangleFan() public method

public generateTriangleFan ( List circ, Vertex cent, bool invertFaces ) : void
circ List
cent Vertex
invertFaces bool
return void

Property Details

subdivision public property

public int subdivision
return int