Пример #1
0
        /// <summary>
        /// Process polygon 3d commands.
        /// </summary>
        /// <param name="polydata">Data of specific polygon.</param>
        private static void Process3DCommand(byte[] polydata)
        {
            if (polydata == null)
                return;
            int commandptr = 0;
            int commandlimit = polydata.Length;
            int[] command = new int[4];
            int cur_vertex, mode, i;
            float[] vtx_state = {0.0f, 0.0f, 0.0f};
            float[] vtx_trans = {0.0f, 0.0f, 0.0f};

            cur_vertex = gCurrentVertex; // for vertex_mode
            CurrentMatrix = MatrixStack[stackID].Clone();
            while (commandptr < commandlimit)
            {
                for (i = 0; i < 4; ++i)
                {
                    if (commandptr >= commandlimit)
                        command[i] = 0xFF;
                    else
                    {
                        command[i] = polydata[commandptr];
                        commandptr++;
                    }
                }

                for (i = 0; i < 4 && commandptr < commandlimit; i++)
                {
                    switch (command[i])
                    {
                        case 0: // No Operation (for padding packed GXFIFO commands)
                            break;
                        case 0x14:
                            /*
                                  MTX_RESTORE - Restore Current Matrix from Stack (W)
                                  Sets C=[N]. The stack pointer S is not used, and is left unchanged.
                                  Parameter Bit0-4:  Stack Address (0..30) (31 causes overflow in GXSTAT.15)
                                  Parameter Bit5-31: Not used
                                */

                            stackID = Utils.Read4BytesAsInt32(polydata, commandptr) & 0x0000001F;
                            commandptr += 4;
                            CurrentMatrix = MatrixStack[stackID].Clone();

                            break;

                        case 0x1b:
                            /*
                                  MTX_SCALE - Multiply Current Matrix by Scale Matrix (W)
                                  Sets C=M*C. Parameters: 3, m[0..2] (MTX_SCALE doesn't change Vector Matrix)
                                */
                            {
                                int x, y, z;
                                x = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;
                                y = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;
                                z = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;
                                CurrentMatrix.Scale(x/SCALE_IV, y/SCALE_IV, z/SCALE_IV);
                                break;
                            }
                        case 0x20: // Directly Set Vertex Color (W)
                            {
                                int rgb, r, g, b;

                                rgb = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                if (gOptColoring)
                                {
                                    r = (rgb >> 0) & 0x1F;
                                    g = (rgb >> 5) & 0x1F;
                                    b = (rgb >> 10) & 0x1F;
                                    Gl.glColor3f(((float) r)/31.0f, ((float) g)/31.0f, ((float) b)/31.0f);
                                }
                            }
                            break;

                        case 0x21:
                            /*
                                  Set Normal Vector (W)
                                  0-9   X-Component of Normal Vector (1bit sign + 9bit fractional part)
                                  10-19 Y-Component of Normal Vector (1bit sign + 9bit fractional part)
                                  20-29 Z-Component of Normal Vector (1bit sign + 9bit fractional part)
                                  30-31 Not used
                                */
                            {
                                int xyz, x, y, z;

                                xyz = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                x = (xyz >> 0) & 0x3FF;
                                if ((x & 0x200) != 0)
                                    x |= -1024;
                                y = (xyz >> 10) & 0x3FF;
                                if ((y & 0x200) != 0) y |= -1024;
                                z = (xyz >> 20) & 0x3FF;
                                if ((z & 0x200) != 0) z |= -1024;
                                Gl.glNormal3f(((float) x)/512.0f, ((float) y)/512.0f, ((float) z)/512.0f);
                                break;
                            }
                        case 0x22:
                            /*
                                  Set Texture Coordinates (W)
                                  Parameter 1, Bit 0-15   S-Coordinate (X-Coordinate in Texture Source)
                                  Parameter 1, Bit 16-31  T-Coordinate (Y-Coordinate in Texture Source)
                                  Both values are 1bit sign + 11bit integer + 4bit fractional part.
                                  A value of 1.0 (=1 SHL 4) equals to one Texel.
                                */
                            {
                                int st, s, t;

                                st = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                s = (st >> 0) & 0xffff;
                                if ((s & 0x8000) != 0) s |= -65536;
                                t = (st >> 16) & 0xffff;
                                if ((t & 0x8000) != 0) t |= -65536;
                                Gl.glTexCoord2f(((float) s)/16.0f, ((float) t)/16.0f);
                                break;
                            }
                        case 0x23:
                            /*
                                  VTX_16 - Set Vertex XYZ Coordinates (W)
                                  Parameter 1, Bit 0-15   X-Coordinate (signed, with 12bit fractional part)
                                  Parameter 1, Bit 16-31  Y-Coordinate (signed, with 12bit fractional part)
                                  Parameter 2, Bit 0-15   Z-Coordinate (signed, with 12bit fractional part)
                                  Parameter 2, Bit 16-31  Not used
                                */
                            {
                                int parameter, x, y, z;

                                parameter = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                x = (parameter >> 0) & 0xFFFF;
                                if ((x & 0x8000) != 0) x |= -65536;
                                y = (parameter >> 16) & 0xFFFF;
                                if ((y & 0x8000) != 0) y |= -65536;

                                parameter = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;
                                z = parameter & 0xFFFF;
                                if ((z & 0x8000) != 0) z |= -65536;

                                vtx_state[0] = ((float) x)/SCALE_IV;
                                vtx_state[1] = ((float) y)/SCALE_IV;
                                vtx_state[2] = ((float) z)/SCALE_IV;
                                if (stackID != -1)
                                {
                                    vtx_trans = CurrentMatrix.MultVector(vtx_state);
                                    Gl.glVertex3fv(vtx_trans);
                                }
                                else
                                {
                                    Gl.glVertex3fv(vtx_state);
                                }

                                break;
                            }
                        case 0x24:
                            /*
                                  VTX_10 - Set Vertex XYZ Coordinates (W)
                                  Parameter 1, Bit 0-9    X-Coordinate (signed, with 6bit fractional part)
                                  Parameter 1, Bit 10-19  Y-Coordinate (signed, with 6bit fractional part)
                                  Parameter 1, Bit 20-29  Z-Coordinate (signed, with 6bit fractional part)
                                  Parameter 1, Bit 30-31  Not used
                                */
                            {
                                int xyz, x, y, z;

                                xyz = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                x = (xyz >> 0) & 0x3FF;
                                if ((x & 0x200) != 0) x |= -1024;
                                y = (xyz >> 10) & 0x3FF;
                                if ((y & 0x200) != 0) y |= -1024;
                                z = (xyz >> 20) & 0x3FF;
                                if ((z & 0x200) != 0) z |= -1024;

                                vtx_state[0] = ((float) x)/64.0f;
                                vtx_state[1] = ((float) y)/64.0f;
                                vtx_state[2] = ((float) z)/64.0f;

                                if (stackID != -1)
                                {
                                    vtx_trans = CurrentMatrix.MultVector(vtx_state);
                                    Gl.glVertex3fv(vtx_trans);
                                }
                                else
                                {
                                    Gl.glVertex3fv(vtx_state);
                                }
                                break;
                            }
                        case 0x25:
                            /*
                                  VTX_XY - Set Vertex XY Coordinates (W)
                                  Parameter 1, Bit 0-15   X-Coordinate (signed, with 12bit fractional part)
                                  Parameter 1, Bit 16-31  Y-Coordinate (signed, with 12bit fractional part)
                                */
                            {
                                int xy, x, y;

                                xy = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                x = (xy >> 0) & 0xFFFF;
                                if ((x & 0x8000) != 0) x |= -65536;
                                y = (xy >> 16) & 0xFFFF;
                                if ((y & 0x8000) != 0) y |= -65536;

                                vtx_state[0] = ((float) x)/SCALE_IV;
                                vtx_state[1] = ((float) y)/SCALE_IV;

                                if (stackID != -1)
                                {
                                    vtx_trans = CurrentMatrix.MultVector(vtx_state);
                                    Gl.glVertex3fv(vtx_trans);
                                }
                                else
                                {
                                    Gl.glVertex3fv(vtx_state);
                                }
                                break;
                            }
                        case 0x26:
                            /*
                                  VTX_XZ - Set Vertex XZ Coordinates (W)
                                  Parameter 1, Bit 0-15   X-Coordinate (signed, with 12bit fractional part)
                                  Parameter 1, Bit 16-31  Z-Coordinate (signed, with 12bit fractional part)
                                */
                            {
                                int xz, x, z;

                                xz = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                x = (xz >> 0) & 0xFFFF;
                                if ((x & 0x8000) != 0) x |= -65536;
                                z = (xz >> 16) & 0xFFFF;
                                if ((z & 0x8000) != 0) z |= -65536;

                                vtx_state[0] = ((float) x)/SCALE_IV;
                                vtx_state[2] = ((float) z)/SCALE_IV;

                                if (stackID != -1)
                                {
                                    vtx_trans = CurrentMatrix.MultVector(vtx_state);
                                    Gl.glVertex3fv(vtx_trans);
                                }
                                else
                                {
                                    Gl.glVertex3fv(vtx_state);
                                }
                                break;
                            }
                        case 0x27:
                            /*
                                  VTX_YZ - Set Vertex YZ Coordinates (W)
                                  Parameter 1, Bit 0-15   Y-Coordinate (signed, with 12bit fractional part)
                                  Parameter 1, Bit 16-31  Z-Coordinate (signed, with 12bit fractional part)
                                */
                            {
                                int yz, y, z;
                                yz = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                y = (yz >> 0) & 0xFFFF;
                                if ((y & 0x8000) != 0) y |= -65536;
                                z = (yz >> 16) & 0xFFFF;
                                if ((z & 0x8000) != 0) z |= -65536;

                                vtx_state[1] = ((float) y)/SCALE_IV;
                                vtx_state[2] = ((float) z)/SCALE_IV;

                                if (stackID != -1)
                                {
                                    vtx_trans = CurrentMatrix.MultVector(vtx_state);
                                    Gl.glVertex3fv(vtx_trans);
                                }
                                else
                                {
                                    Gl.glVertex3fv(vtx_state);
                                }
                                break;
                            }
                        case 0x28:
                            /*
                                  VTX_DIFF - Set Relative Vertex Coordinates (W)
                                  Parameter 1, Bit 0-9    X-Difference (signed, with 9bit fractional part)
                                  Parameter 1, Bit 10-19  Y-Difference (signed, with 9bit fractional part)
                                  Parameter 1, Bit 20-29  Z-Difference (signed, with 9bit fractional part)
                                  Parameter 1, Bit 30-31  Not used
                                */
                            {
                                int xyz, x, y, z;
                                xyz = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                x = (xyz >> 0) & 0x3FF;
                                if ((x & 0x200) != 0) x |= -1024;
                                y = (xyz >> 10) & 0x3FF;
                                if ((y & 0x200) != 0) y |= -1024;
                                z = (xyz >> 20) & 0x3FF;
                                if ((z & 0x200) != 0) z |= -1024;

                                vtx_state[0] += ((float) x)/SCALE_IV;
                                vtx_state[1] += ((float) y)/SCALE_IV;
                                vtx_state[2] += ((float) z)/SCALE_IV;

                                if (stackID != -1)
                                {
                                    vtx_trans = CurrentMatrix.MultVector(vtx_state);
                                    Gl.glVertex3fv(vtx_trans);
                                }
                                else
                                {
                                    Gl.glVertex3fv(vtx_state);
                                }
                                break;
                            }
                        case 0x40: // Start of Vertex List (W)
                            {
                                mode = Utils.Read4BytesAsInt32(polydata, commandptr);
                                commandptr += 4;

                                switch (mode)
                                {
                                    case 0:
                                        mode = Gl.GL_TRIANGLES;
                                        break;
                                    case 1:
                                        mode = Gl.GL_QUADS;
                                        break;
                                    case 2:
                                        mode = Gl.GL_TRIANGLE_STRIP;
                                        break;
                                    case 3:
                                        mode = Gl.GL_QUAD_STRIP;
                                        break;
                                    default:
                                        //return ;// FALSE;//throw new Exception();
                                        break;
                                }

                                Gl.glBegin(mode);
                                break;
                            }
                        case 0x41: // End of Vertex List (W)
                            Gl.glEnd();

                            // for vertex mode, display at maximum certain number of vertex-list
                            // decrease cur_vertex so that when we reach 0, stop rendering any further
                            cur_vertex--;
                            if (cur_vertex < 0 && gOptVertexMode)
                                return; //TRUE;
                            break;
                        default:
                            break;
                            //return FALSE;
                    }
                }
            }
        }
Пример #2
0
        public void RipModel(string file)
        {
            NsbmdPolygon polygon;
            int matId;
            NsbmdMaterial material;
            int num3;
            DiffuseMaterial material2;
            MeshBuilder builder;
            Model3D modeld;
            MTX44 mtx = new MTX44();
            List<MKDS_Course_Editor.Export3DTools.Group> list = new List<MKDS_Course_Editor.Export3DTools.Group>();
            List<Vector3> list2 = new List<Vector3>();
            for (int i = 0; i < (this.Model.Polygons.Count - 1); i++)
            {
                polygon = this.Model.Polygons[i];
                matId = polygon.MatId;
                material = this.Model.Materials[matId];
            }
            MTX44 mtx2 = new MTX44();
            mtx2.LoadIdentity();
            for (num3 = 0; num3 < this.Model.Objects.Count; num3++)
            {
                NsbmdObject obj2 = this.Model.Objects[num3];
                float[] transVect = obj2.TransVect;
                float[] numArray2 = loadIdentity();
                if (obj2.RestoreID != -1)
                {
                    mtx2 = MatrixStack[obj2.RestoreID];
                }
                if (obj2.StackID != -1)
                {
                    if (obj2.visible)
                    {
                        MTX44 b = new MTX44();
                        b.SetValues(obj2.materix);
                        mtx2 = mtx2.MultMatrix(b);
                    }
                    else
                    {
                        mtx2.Zero();
                    }
                    MatrixStack[obj2.StackID] = mtx2;
                    stackID = obj2.StackID;
                    float[] numArray3 = mtx2.MultVector(new float[3]);
                    list2.Add(new Vector3(numArray3[0], numArray3[1], numArray3[2]));
                }
            }
            num3 = 0;
            while (num3 < (this.Model.Polygons.Count - 1))
            {
                polygon = this.Model.Polygons[num3];
                if ((gOptTexture && !gOptWireFrame) && g_mat)
                {
                    matId = polygon.MatId;
                    if (matId == -1)
                    {
                        this.mattt.Add(new ImageBrush());
                    }
                    else
                    {
                        this.mattt.Add(this.matt[matId]);
                        material = this.Model.Materials[matId];
                    }
                }
                stackID = polygon.StackID;
                list.Add(Process3DCommandRipper(polygon.PolyData, Model.Materials[polygon.MatId], polygon.JointID, true));
                num3++;
            }
            File.Create(file).Close();
            HelixToolkit.ObjExporter exporter = new HelixToolkit.ObjExporter(file, "Created with Spiky's DS Map Editor " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            int index = 0;
            foreach (MKDS_Course_Editor.Export3DTools.Group group in list)
            {
                ImageBrush brush = new ImageBrush();
                try
                {
                    brush.ImageSource = this.mattt[index].ImageSource;
                    brush.Opacity = this.mattt[index].Opacity;
                    brush.Viewbox = this.mattt[index].Viewbox;
                    brush.ViewboxUnits = this.mattt[index].ViewboxUnits;
                    brush.Viewport = this.mattt[index].Viewport;
                    brush.ViewportUnits = this.mattt[index].ViewportUnits;
                }
                catch
                {
                }
                if (brush.ImageSource != null)
                {
                    material2 = new DiffuseMaterial(brush);
                }
                else
                {
                    material2 = new DiffuseMaterial(new SolidColorBrush());
                }
                material2.SetValue(matName, this.Model.Materials[this.Model.Polygons[index].MatId].MaterialName);
                material2.SetValue(polyName, this.Model.Polygons[index].Name);
                material2.Brush.Opacity = ((float)this.Model.Materials[this.Model.Polygons[index].MatId].Alpha) / 31f;
                material2.AmbientColor = System.Windows.Media.Color.FromArgb(this.Model.Materials[this.Model.Polygons[index].MatId].AmbientColor.A, this.Model.Materials[this.Model.Polygons[index].MatId].AmbientColor.R, this.Model.Materials[this.Model.Polygons[index].MatId].AmbientColor.G, this.Model.Materials[this.Model.Polygons[index].MatId].AmbientColor.B);
                material2.Color = System.Windows.Media.Color.FromArgb(0xff, this.Model.Materials[this.Model.Polygons[index].MatId].DiffuseColor.R, this.Model.Materials[this.Model.Polygons[index].MatId].DiffuseColor.G, this.Model.Materials[this.Model.Polygons[index].MatId].DiffuseColor.B);
                builder = new MeshBuilder();
                foreach (MKDS_Course_Editor.Export3DTools.Polygon polygon2 in group)
                {
                    IList<Point3D> list3;
                    IList<Vector3D> list4;
                    IList<System.Windows.Point> list5;
                    switch (polygon2.PolyType)
                    {
                        case PolygonType.Triangle:
                            list3 = new List<Point3D>();
                            list4 = new List<Vector3D>();
                            list5 = new List<System.Windows.Point>();
                            num3 = 0;
                            goto Label_08AB;

                        case PolygonType.Quad:
                            list3 = new List<Point3D>();
                            list4 = new List<Vector3D>();
                            list5 = new List<System.Windows.Point>();
                            num3 = 0;
                            goto Label_0C5E;

                        case PolygonType.TriangleStrip:
                            list3 = new List<Point3D>();
                            list4 = new List<Vector3D>();
                            list5 = new List<System.Windows.Point>();
                            num3 = 0;
                            goto Label_0D66;

                        case PolygonType.QuadStrip:
                            list3 = new List<Point3D>();
                            list4 = new List<Vector3D>();
                            list5 = new List<System.Windows.Point>();
                            num3 = 0;
                            goto Label_0E7C;

                        default:
                            {
                                continue;
                            }
                    }
                Label_0608:
                    list3.Add(new Point3D((double)polygon2.Vertex[num3].X, (double)polygon2.Vertex[num3].Y, (double)polygon2.Vertex[num3].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3].X, (double)polygon2.Normals[num3].Y, (double)polygon2.Normals[num3].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3].X, (double)polygon2.TexCoords[num3].Y));
                    list3.Add(new Point3D((double)polygon2.Vertex[num3 + 1].X, (double)polygon2.Vertex[num3 + 1].Y, (double)polygon2.Vertex[num3 + 1].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3 + 1].X, (double)polygon2.Normals[num3 + 1].Y, (double)polygon2.Normals[num3 + 1].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3 + 1].X, (double)polygon2.TexCoords[num3 + 1].Y));
                    list3.Add(new Point3D((double)polygon2.Vertex[num3 + 2].X, (double)polygon2.Vertex[num3 + 2].Y, (double)polygon2.Vertex[num3 + 2].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3 + 2].X, (double)polygon2.Normals[num3 + 2].Y, (double)polygon2.Normals[num3 + 2].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3 + 2].X, (double)polygon2.TexCoords[num3 + 2].Y));
                    builder.AddTriangles(list3, list4, list5);
                    list3.Clear();
                    list4.Clear();
                    list5.Clear();
                    num3 += 3;
                Label_08AB:
                    if (num3 < polygon2.Vertex.Length)
                    {
                        goto Label_0608;
                    }
                    continue;
                Label_08E4:
                    list3.Add(new Point3D((double)polygon2.Vertex[num3].X, (double)polygon2.Vertex[num3].Y, (double)polygon2.Vertex[num3].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3].X, (double)polygon2.Normals[num3].Y, (double)polygon2.Normals[num3].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3].X, (double)polygon2.TexCoords[num3].Y));
                    list3.Add(new Point3D((double)polygon2.Vertex[num3 + 1].X, (double)polygon2.Vertex[num3 + 1].Y, (double)polygon2.Vertex[num3 + 1].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3 + 1].X, (double)polygon2.Normals[num3 + 1].Y, (double)polygon2.Normals[num3 + 1].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3 + 1].X, (double)polygon2.TexCoords[num3 + 1].Y));
                    list3.Add(new Point3D((double)polygon2.Vertex[num3 + 2].X, (double)polygon2.Vertex[num3 + 2].Y, (double)polygon2.Vertex[num3 + 2].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3 + 2].X, (double)polygon2.Normals[num3 + 2].Y, (double)polygon2.Normals[num3 + 2].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3 + 2].X, (double)polygon2.TexCoords[num3 + 2].Y));
                    list3.Add(new Point3D((double)polygon2.Vertex[num3 + 3].X, (double)polygon2.Vertex[num3 + 3].Y, (double)polygon2.Vertex[num3 + 3].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3 + 3].X, (double)polygon2.Normals[num3 + 3].Y, (double)polygon2.Normals[num3 + 3].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3 + 3].X, (double)polygon2.TexCoords[num3 + 3].Y));
                    builder.AddQuads(list3, list4, list5);
                    list3.Clear();
                    list4.Clear();
                    list5.Clear();
                    num3 += 4;
                Label_0C5E:
                    if (num3 < polygon2.Vertex.Length)
                    {
                        goto Label_08E4;
                    }
                    continue;
                Label_0C97:
                    list3.Add(new Point3D((double)polygon2.Vertex[num3].X, (double)polygon2.Vertex[num3].Y, (double)polygon2.Vertex[num3].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3].X, (double)polygon2.Normals[num3].Y, (double)polygon2.Normals[num3].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3].X, (double)polygon2.TexCoords[num3].Y));
                    num3++;
                Label_0D66:
                    if (num3 < polygon2.Vertex.Length)
                    {
                        goto Label_0C97;
                    }
                    builder.AddTriangleStrip(list3, list4, list5);
                    continue;
                Label_0DAD:
                    list3.Add(new Point3D((double)polygon2.Vertex[num3].X, (double)polygon2.Vertex[num3].Y, (double)polygon2.Vertex[num3].Z));
                    list4.Add(new Vector3D((double)polygon2.Normals[num3].X, (double)polygon2.Normals[num3].Y, (double)polygon2.Normals[num3].Z));
                    list5.Add(new System.Windows.Point((double)polygon2.TexCoords[num3].X, (double)polygon2.TexCoords[num3].Y));
                    num3++;
                Label_0E7C:
                    if (num3 < polygon2.Vertex.Length)
                    {
                        goto Label_0DAD;
                    }
                    builder.AddTriangleStrip(list3, list4, list5);
                }
                modeld = new GeometryModel3D(builder.ToMesh(false), material2);
                exporter.Export(modeld);
                index++;
            }

            exporter.Close();
            this.writevertex = false;
        }