Exemple #1
0
    private void GeneratePlotBores()
    {
        for (int i = 0; i < jsondata.gmfdata.data3d.bores.Length; i++)
        {
            TModelBore Bore = jsondata.gmfdata.data3d.bores[i];
            Vector3    pos  = new Vector3(Bore.y_dn, Bore.z_dn + 1.0F, Bore.x_dn);
//            Vector3 pos = new Vector3((Bore.y_dn + Bore.y_up) * 0.5F, (Bore.z_dn + Bore.z_up) * 0.5F, (Bore.x_dn + Bore.x_up) * 0.5F);

            GameObject bore = Instantiate(bore_prefab, pos, Quaternion.identity);
            bore.transform.parent = transform;
        }
    }
Exemple #2
0
    private void ScaleMesh()
    {
        float minx, maxx, miny, maxy, minz, maxz;
        float scalex = 0.02F, scaley = 0.05F, scalez = 0.02F;
        float x, y, z;

        minx = miny = minz = 1000000000.0F;
        maxx = maxy = maxz = -minx;

        for (int h = 0; h < jsondata.gmfdata.data3d.mesh.horizonts.Length; h++)
        {
            THorizontData horz = jsondata.gmfdata.data3d.mesh.horizonts[h];
            Vector3[]     vertices;

            for (int j = 0; j < 3; j++)
            {
                vertices = horz.surfaceup.vertices;
                if (j == 1)
                {
                    vertices = horz.surfacedn.vertices;
                }
                if (j == 2)
                {
                    vertices = horz.surfacesd.vertices;
                }

                for (int i = 0; i < vertices.Length; i++)
                {
                    x = vertices[i].x *= scalex;
                    y = vertices[i].y *= scaley;
                    z = vertices[i].z *= scalez;
                    if (x > maxx)
                    {
                        maxx = x;
                    }
                    if (x < minx)
                    {
                        minx = x;
                    }
                    if (y != 0.0F && y > maxy)
                    {
                        maxy = y;
                    }
                    if (y != 0.0F && y < miny)
                    {
                        miny = y;
                    }
                    if (z > maxz)
                    {
                        maxz = z;
                    }
                    if (z < minz)
                    {
                        minz = z;
                    }
                }
            }
        }

        x = -(minx + maxx) * 0.5F;
        y = -miny;
        z = -(minz + maxz) * 0.5F;

        for (int h = 0; h < jsondata.gmfdata.data3d.mesh.horizonts.Length; h++)
        {
            THorizontData horz = jsondata.gmfdata.data3d.mesh.horizonts[h];
            Vector3[]     vertices;

            for (int j = 0; j < 3; j++)
            {
                vertices = horz.surfaceup.vertices;

                if (j == 1)
                {
                    vertices = horz.surfacedn.vertices;
                }
                if (j == 2)
                {
                    vertices = horz.surfacesd.vertices;
                }

                for (int i = 0; i < vertices.Length; i++)
                {
                    vertices[i].x += x;
                    if (vertices[i].y != 0.0F)
                    {
                        vertices[i].y += y;
                    }
                    vertices[i].z += z;
                }
            }
        }

        for (int i = 0; i < jsondata.gmfdata.data3d.bores.Length; i++)
        {
            TModelBore Bore = jsondata.gmfdata.data3d.bores[i];

            jsondata.gmfdata.data3d.bores[i].x_dn *= scalex;
            jsondata.gmfdata.data3d.bores[i].x_dn += z;
            jsondata.gmfdata.data3d.bores[i].y_dn *= scalex;
            jsondata.gmfdata.data3d.bores[i].y_dn += x;
            jsondata.gmfdata.data3d.bores[i].z_dn *= scaley;
            jsondata.gmfdata.data3d.bores[i].z_dn += y;

            jsondata.gmfdata.data3d.bores[i].x_up *= scalex;
            jsondata.gmfdata.data3d.bores[i].x_up += z;
            jsondata.gmfdata.data3d.bores[i].y_up *= scalex;
            jsondata.gmfdata.data3d.bores[i].y_up += x;
            jsondata.gmfdata.data3d.bores[i].z_up *= scaley;
            jsondata.gmfdata.data3d.bores[i].z_up += y;

//            jsondata.gmfdata.data3d.bores[i] = Bore;
        }
    }