generateVertices() публичный Метод

public generateVertices ( MeshBuilder builder, Vector3 offset, UVArea area, float v, float yCos, float ySin ) : List
builder MeshBuilder
offset Vector3
area UVArea
v float
yCos float
ySin float
Результат List
Пример #1
0
        public Mesh generateMesh()
        {
            MeshBuilder   builder        = new MeshBuilder();
            Arc           bottomOuterArc = new Arc(bottomRadius, 0, 0, 360, faces);
            Arc           topOuterArc    = new Arc(topRadius, height, 0, 360, faces);
            List <Vertex> verts1         = bottomOuterArc.generateVertices(builder, offset, outsideUV, outsideUV.v1, 1, 0);
            List <Vertex> verts2         = topOuterArc.generateVertices(builder, offset, outsideUV, outsideUV.v2, 1, 0);

            builder.generateQuads(verts1, verts2, false);
            if (bottomInnerRadius != 0 || topInnerRadius != 0)
            {
                Arc   bottomInnerArc = new Arc(bottomInnerRadius, 0, 0, 360, faces);
                Arc   topInnerArc    = new Arc(topInnerRadius, height, 0, 360, faces);
                float heightDiff     = topInnerArc.height - bottomInnerArc.height;
                float radiusDiff     = bottomInnerArc.radius - topInnerArc.radius;
                float sideRadians    = Mathf.Atan2(heightDiff, radiusDiff) - 90 * Mathf.Deg2Rad;
                float yCos           = Mathf.Cos(sideRadians);
                float ySin           = Mathf.Sin(sideRadians);
                verts1 = bottomInnerArc.generateVertices(builder, offset, insideUV, insideUV.v1, -yCos, ySin);
                verts2 = topInnerArc.generateVertices(builder, offset, insideUV, insideUV.v2, -yCos, ySin);
                builder.generateQuads(verts1, verts2, true);
            }
            builder.generateCylinderCap(offset, faces, bottomRadius, bottomInnerRadius, 0, 0, 360, bottomUV, true);
            builder.generateCylinderCap(offset, faces, topRadius, topInnerRadius, height, 0, 360, topUV, false);

            Mesh mesh = builder.buildMesh();

            mesh.name = "ProceduralCylinderMesh";
            return(mesh);
        }
Пример #2
0
        public Mesh generateMesh()
        {
            MeshBuilder builder = new MeshBuilder();
            Arc bottomOuterArc = new Arc(bottomRadius, 0, 0, 360, faces);
            Arc topOuterArc = new Arc(topRadius, height, 0, 360, faces);
            List<Vertex> verts1 = bottomOuterArc.generateVertices(builder, offset, outsideUV, outsideUV.v1, 1, 0);
            List<Vertex> verts2 = topOuterArc.generateVertices(builder, offset, outsideUV, outsideUV.v2, 1, 0);
            builder.generateQuads(verts1, verts2, false);
            if (bottomInnerRadius != 0 || topInnerRadius != 0)
            {
                Arc bottomInnerArc = new Arc(bottomInnerRadius, 0, 0, 360, faces);
                Arc topInnerArc = new Arc(topInnerRadius, height, 0, 360, faces);
                float heightDiff = topInnerArc.height - bottomInnerArc.height;
                float radiusDiff = bottomInnerArc.radius - topInnerArc.radius;
                float sideRadians = Mathf.Atan2(heightDiff, radiusDiff) - 90 * Mathf.Deg2Rad;
                float yCos = Mathf.Cos(sideRadians);
                float ySin = Mathf.Sin(sideRadians);
                verts1 = bottomInnerArc.generateVertices(builder, offset, insideUV, insideUV.v1, -yCos, ySin);
                verts2 = topInnerArc.generateVertices(builder, offset, insideUV, insideUV.v2, -yCos, ySin);
                builder.generateQuads(verts1, verts2, true);
            }
            builder.generateCylinderCap(offset, faces, bottomRadius, bottomInnerRadius, 0, 0, 360, bottomUV, true);
            builder.generateCylinderCap(offset, faces, topRadius, topInnerRadius, height, 0, 360, topUV, false);

            Mesh mesh = builder.buildMesh();
            mesh.name = "ProceduralCylinderMesh";
            return mesh;
        }
Пример #3
0
        private void generatePanelSegment(MeshBuilder builder, Vector3 pos, Arc arcA, Arc arcB, UVArea area, bool invertFaces, bool invertNormalY, bool invertNormalXZ)
        {
            float heightDiff  = arcB.height - arcA.height;
            float offset      = arcA.radius - arcB.radius;
            float sideRadians = Mathf.Atan2(heightDiff, offset) - 90 * Mathf.Deg2Rad;
            float yCos        = Mathf.Cos(sideRadians);
            float ySin        = Mathf.Sin(sideRadians);

            if (invertNormalY)
            {
                ySin *= -1;
            }
            if (invertNormalXZ)
            {
                yCos *= -1;
            }
            List <Vertex> verts1 = new List <Vertex>();
            List <Vertex> verts2 = new List <Vertex>();

            verts1.AddRange(arcA.generateVertices(builder, pos, area, area.v1, yCos, ySin));
            verts2.AddRange(arcB.generateVertices(builder, pos, area, area.v2, yCos, ySin));
            builder.generateQuads(verts1, verts2, invertFaces);
        }
Пример #4
0
 private void generatePanelSegment(MeshBuilder builder, Vector3 pos, Arc arcA, Arc arcB, UVArea area, bool invertFaces, bool invertNormalY, bool invertNormalXZ)
 {
     float heightDiff = arcB.height - arcA.height;
     float offset = arcA.radius - arcB.radius;
     float sideRadians = Mathf.Atan2(heightDiff, offset) - 90 * Mathf.Deg2Rad;
     float yCos = Mathf.Cos(sideRadians);
     float ySin = Mathf.Sin(sideRadians);
     if (invertNormalY) { ySin *= -1; }
     if (invertNormalXZ) { yCos *= -1; }
     List<Vertex> verts1 = new List<Vertex>();
     List<Vertex> verts2 = new List<Vertex>();
     verts1.AddRange(arcA.generateVertices(builder, pos, area, area.v1, yCos, ySin));
     verts2.AddRange(arcB.generateVertices(builder, pos, area, area.v2, yCos, ySin));
     builder.generateQuads(verts1, verts2, invertFaces);
 }