public static VertexPositionNormalTexture[] GenerateQuad(QuadOrientation orientation, Vector3 offset, float textureScaleX = 1.0f, float textureScaleY = 1.0f) { switch (orientation) { case QuadOrientation.UnitX: return(GenerateQuadUnitX(offset, textureScaleX, textureScaleY)); case QuadOrientation.UnitY: return(GenerateQuadUnitY(offset, textureScaleX, textureScaleY)); case QuadOrientation.UnitZ: return(GenerateQuadUnitZ(offset, textureScaleX, textureScaleY)); case QuadOrientation.InvUnitX: return(GenerateQuadInvUnitX(offset, textureScaleX, textureScaleY)); case QuadOrientation.InvUnitY: return(GenerateQuadInvUnitY(offset, textureScaleX, textureScaleY)); case QuadOrientation.InvUnitZ: return(GenerateQuadInvUnitZ(offset, textureScaleX, textureScaleY)); } throw new InvalidOperationException("Invalid Geometry"); }
public static PrimitiveObject MakeQuad(Transform parent, float size, Vector3 pos, QuadOrientation qo = QuadOrientation.up, bool hasCollider = true) { float halfSize = 0.5f * size; Vector3[] vertices = new Vector3[4]; if (qo == QuadOrientation.up) { vertices[0] = new Vector3(-halfSize, 0, -halfSize); vertices[1] = new Vector3(halfSize, 0, -halfSize); vertices[2] = new Vector3(-halfSize, 0, halfSize); vertices[3] = new Vector3(halfSize, 0, halfSize); } else if (qo == QuadOrientation.down) { vertices[0] = new Vector3(-halfSize, 0, -halfSize); vertices[1] = new Vector3(-halfSize, 0, halfSize); vertices[2] = new Vector3(halfSize, 0, -halfSize); vertices[3] = new Vector3(halfSize, 0, halfSize); } else if (qo == QuadOrientation.left) { vertices[0] = new Vector3(0, -halfSize, -halfSize); vertices[1] = new Vector3(0, halfSize, -halfSize); vertices[2] = new Vector3(0, -halfSize, halfSize); vertices[3] = new Vector3(0, halfSize, halfSize); } else if (qo == QuadOrientation.right) { vertices[0] = new Vector3(0, -halfSize, -halfSize); vertices[1] = new Vector3(0, -halfSize, halfSize); vertices[2] = new Vector3(0, halfSize, -halfSize); vertices[3] = new Vector3(0, halfSize, halfSize); } else if (qo == QuadOrientation.front) { vertices[0] = new Vector3(-halfSize, -halfSize, 0); vertices[1] = new Vector3(-halfSize, halfSize, 0); vertices[2] = new Vector3(halfSize, -halfSize, 0); vertices[3] = new Vector3(halfSize, halfSize, 0); } else if (qo == QuadOrientation.back) { vertices[0] = new Vector3(-halfSize, -halfSize, 0); vertices[1] = new Vector3(halfSize, -halfSize, 0); vertices[2] = new Vector3(-halfSize, halfSize, 0); vertices[3] = new Vector3(halfSize, halfSize, 0); } PrimitiveObject po = MakeRectangle(parent, vertices, pos, hasCollider); return(po); }