Exemplo n.º 1
0
            public static MeshData GetSidePolygon(Vector3 u, Vector3 v, float width, float front, float back, int material)
            {
                u.z = front;
                v.z = front;
                Vector3 distUV = (v - u);
                float   height = 1.0f;
                float   shift  = 0.0f;

                if (Mathf.Abs(distUV.x) > Mathf.Abs(distUV.y))
                {
                    height = width * (distUV.magnitude) / distUV.x;
                    shift  = (float)(-(double)v.x / width) * Mathf.Sign(distUV.x);
                }
                else
                {
                    height = width * (distUV.magnitude) / distUV.y;
                    shift  = v.y / width * Mathf.Sign(-distUV.y);
                }

                shift = shift - (int)(shift / width) * width;

                Vector2[] data = new Vector2[4];
                float     xmin = back, xmax = front;
                float     ymin = shift, ymax = distUV.magnitude + shift;

                data[0] = new Vector2(xmin, ymax);
                data[1] = new Vector2(xmax, ymax);
                data[2] = new Vector2(xmax, ymin);
                data[3] = new Vector2(xmin, ymin);

                /*
                 * data[0] = new Vector2(0, 1);
                 * data[1] = new Vector2(1, 1);
                 * data[2] = new Vector2(1, 0);
                 * data[3] = new Vector2(0, 0);
                 */
                MeshData tmpMeshData = EditablePolygon2D.GetMeshData(data, material, 0, width, height);

                float rotX = Mathf.Atan2(distUV.y, distUV.x) / Mathf.PI * 180;

                tmpMeshData.Move(new Vector3(0, -shift - distUV.magnitude / 2, 0));
                tmpMeshData.Rotate(new Vector3(rotX, 0, 0));
                tmpMeshData.Rotate(new Vector3(90, 0, 90));
                tmpMeshData.Move((u + v) / 2 + new Vector3(0, 0, -front));
                return(tmpMeshData);
            }
Exemplo n.º 2
0
            public MeshData GetMeshData(Vector2[] points)
            {
                float width = (additional.isAdditional ? additional.width : 1.0f);

                MeshData meshData = EditablePolygon2D.GetMeshData(points, material, zValue, width, width);

                if (make3DSetting.is3DMode)
                {
                    MeshData meshNext = new MeshData();

                    if (!make3DSetting.ignoreFront)
                    {
                        // front mesh
                        meshData.Move(new Vector3(0, 0, make3DSetting.front - zValue));
                        meshNext = MeshData.Marge(meshNext, meshData);
                    }



                    for (int i = 0; i < points.Length; i++)
                    {
                        /*
                         * Vector3 u = meshData.vertices[i];
                         * Vector3 v = meshData.vertices[(i + 1) % meshData.vertices.Count];
                         */
                        Vector3  u           = points[i];
                        Vector3  v           = points[(i + 1) % points.Length];
                        MeshData tmpMeshData = GetSidePolygon(u, v, width, make3DSetting.front, make3DSetting.back, material);
                        meshNext = MeshData.Marge(tmpMeshData, meshNext);
                    }

                    if (!make3DSetting.ignoreBack)
                    {
                        // back mesh
                        MeshData meshBack = MeshData.Marge(new MeshData(), meshData);
                        meshBack.Move(new Vector3(0, 0, make3DSetting.back - make3DSetting.front));
                        meshNext = MeshData.Marge(meshBack, meshNext);
                    }

                    meshData = meshNext;
                }
                return(meshData);
            }