/*--------------------------------------------------------------------------------------------*/ public static void BuildRingMesh(MeshBuilder pMeshBuild, float pInnerRadius, float pOuterRadius, float pAngle0, float pAngle1, int pSteps) { float angleFull = pAngle1-pAngle0; float angleInc = angleFull/pSteps; float angle = pAngle0; pMeshBuild.Resize((pSteps+1)*2, pSteps*6); pMeshBuild.ResetIndices(); for ( int i = 0 ; i <= pSteps ; ++i ) { float uvx = i/(float)pSteps; pMeshBuild.AddVertex(GetRingPoint(pInnerRadius, angle)); pMeshBuild.AddVertex(GetRingPoint(pOuterRadius, angle)); pMeshBuild.AddUv(new Vector2(uvx, 0)); pMeshBuild.AddUv(new Vector2(uvx, 1)); if ( i > 0 ) { int vi = pMeshBuild.VertexIndex; pMeshBuild.AddTriangle(vi-3, vi-4, vi-2); pMeshBuild.AddTriangle(vi-1, vi-3, vi-2); } angle += angleInc; } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public static void BuildQuadMesh(MeshBuilder pMeshBuild) { const float size = 0.5f; pMeshBuild.Resize(4, 6); pMeshBuild.ResetIndices(); pMeshBuild.AddVertex(new Vector3( size, size, 0)); pMeshBuild.AddVertex(new Vector3( size, -size, 0)); pMeshBuild.AddVertex(new Vector3(-size, -size, 0)); pMeshBuild.AddVertex(new Vector3(-size, size, 0)); pMeshBuild.AddUv(new Vector2(1, 1)); pMeshBuild.AddUv(new Vector2(1, 0)); pMeshBuild.AddUv(new Vector2(0, 0)); pMeshBuild.AddUv(new Vector2(0, 1)); pMeshBuild.AddTriangle(0, 1, 2); pMeshBuild.AddTriangle(0, 2, 3); }
/*--------------------------------------------------------------------------------------------*/ public static void BuildCircleMesh(MeshBuilder pMeshBuild, float pRadius, int pSteps) { const float angleFull = (float)Math.PI*2; float angleInc = angleFull/pSteps; float angle = 0; pMeshBuild.Resize(pSteps+2, pSteps*3); pMeshBuild.AddVertex(Vector3.zero); pMeshBuild.AddUv(new Vector2(0, 0)); for ( int i = 0 ; i <= pSteps ; ++i ) { pMeshBuild.AddVertex(GetRingPoint(pRadius, angle)); pMeshBuild.AddUv(new Vector2(i/(float)pSteps, 1)); if ( i > 0 ) { int vi = pMeshBuild.VertexIndex; pMeshBuild.AddTriangle(0, vi-2, vi-1); } angle += angleInc; } }