public static Face MakeFace( List<Vector3> vertices, int offset, ShapeFill fill, bool reverseWind ) { List<int> indices = new List<int>(); for(int i = 0; i < vertices.Count/2; i++) { indices.Add( (vertices.Count - 1) - i + offset); indices.Add( i + offset ); } List<int> triangles = TriangleStripToTriangles( indices.ToArray(), reverseWind ); return new Face( vertices, triangles, fill ); }
public static Face MakeEdgeFace( List<Vector3> vertices, int edgeLength, int offset, ShapeFill fill, bool reverseWind = false ) { List<int> indices = new List<int>(); for( int i = 0; i < edgeLength; i++ ) { indices.Add( i + offset ); indices.Add( i + edgeLength + offset ); } indices.Add( offset ); indices.Add( edgeLength + offset ); List<int> triangles = TriangleStripToTriangles( indices.ToArray(), reverseWind ); return new Face( vertices, triangles, fill ); }
public static Material RequestMaterial( ShapeFill fill ) { ShapeMaterial cachedMaterial = null; for(int i = 0; i < shapeMaterials.Count; i++ ) { ShapeMaterial material = shapeMaterials[i]; if( material.MatchesShapeFillRequirements( fill ) ) { cachedMaterial = material; break; } } if( cachedMaterial == null ) { cachedMaterial = new ShapeMaterial( fill ); shapeMaterials.Add( cachedMaterial ); } return cachedMaterial.material; }
public ShapeMaterial( ShapeFill fill ) { this.fill = fill.Copy(); GenerateMaterial(); }
bool MatchesShapeFillRequirements( ShapeFill fill ) { return this.fill.IsEquivalent( fill ); }
public Face( List<Vector3> vertices, List<int> triangles, ShapeFill fill ) { this.vertices = vertices; this.triangles = triangles; this.fill = fill; }
public bool IsEquivalent( ShapeFill fill ) { return this.fillType == fill.fillType && this.fillTypeAdvanced == fill.fillTypeAdvanced && this.blendMode == fill.blendMode && this.isLit == fill.isLit && this.texture == fill.texture; }
public ShapeFill Copy() { ShapeFill fill = new ShapeFill(); fill.fillType = this.fillType; fill.fillTypeAdvanced = this.fillTypeAdvanced; fill.blendMode = this.blendMode; fill.isLit = this.isLit; fill.texture = this.texture; return fill; }