A surface which is defined by curves of some kind to form a patch, e.g. a Bezier patch.
This object will take a list of control points with various assorted data, and will subdivide it into a patch mesh. Currently only Bezier curves are supported for defining the surface, but other techniques such as NURBS would follow the same basic approach.
Ejemplo n.º 1
0
        public void InitQuake3Patches(Quake3Level q3lvl, VertexDeclaration decl)
        {
            int face;

            patchVertexCount = 0;
            patchIndexCount = 0;

            // We're just building the patch here to get a hold on the size of the mesh
            // although we'll reuse this information later
            face = q3lvl.NumFaces;

            while(face-- > 0)
            {
                InternalBspFace src = q3lvl.Faces[face];

                if(src.type == BspFaceType.Patch)
                {
                    // Seems to be some crap in the Q3 level where vertex count = 0 or num control points = 0?
                    if((src.vertCount == 0) || (src.meshCtrl[0] == 0))
                        continue;

                    PatchSurface ps = new PatchSurface();

                    // Set up control points & format.
                    // Reuse the vertex declaration.
                    // Copy control points into a buffer so we can convert their format.
                    BspVertex[] controlPoints = new BspVertex[src.vertCount];
                    TextureLightMap texLightMap;

                    for(int v = 0; v < src.vertCount; v++)
                        QuakeVertexToBspVertex(q3lvl.Vertices[src.vertStart + v], out controlPoints[v], out texLightMap);

                    // Define the surface, but don't build it yet (no vertex / index buffer)
                    ps.DefineSurface(
                        controlPoints,
                        decl,
                        src.meshCtrl[0],
                        src.meshCtrl[1]
                        );

                    // Get stats
                    patchVertexCount += ps.RequiredVertexCount;
                    patchIndexCount += ps.RequiredIndexCount;

                    // Save the surface for later
                    patches.Add(face, ps);
                }
            }
        }