DefineSurface() public method

Sets up the surface by defining it's control points, type and initial subdivision level.
This method initializes the surface by passing it a set of control points. The type of curves to be used are also defined here, although the only supported option currently is a bezier patch. You can also specify a global subdivision level here if you like, although it is recommended that the parameter is left as AUTO_LEVEL, which means the system decides how much subdivision is required (based on the curvature of the surface).
public DefineSurface ( Array controlPointArray, Axiom.Graphics.VertexDeclaration decl, int width, int height ) : void
controlPointArray System.Array /// An array containing the vertex data which define control points of the curves /// rather than actual vertices. Note that you are expected to provide not /// just position information, but potentially normals and texture coordinates too. /// The array is internally treated as a contiguous memory buffer without any gaps between the elements. /// The format of the buffer is defined in the VertexDeclaration parameter. ///
decl Axiom.Graphics.VertexDeclaration /// VertexDeclaration describing the contents of the buffer. /// Note this declaration must _only_ draw on buffer source 0! ///
width int Specifies the width of the patch in control points.
height int Specifies the height of the patch in control points.
return void
Ejemplo n.º 1
0
        // ------------------------------------

        // ------------------------------------
        /// <summary>
        ///     Creates a new PatchMesh.
        /// </summary>
        /// <remarks>
        ///     As defined in <see cref="MeshManager.CreateBezierPatch" />.
        /// </remarks>
        public PatchMesh(string name, System.Array controlPointBuffer, VertexDeclaration declaration,
                         int width, int height, int uMaxSubdivisionLevel, int vMaxSubdivisionLevel, VisibleSide visibleSide,
                         BufferUsage vbUsage, BufferUsage ibUsage, bool vbUseShadow, bool ibUseShadow) : base(name)
        {
            vertexBufferUsage     = vbUsage;
            useVertexShadowBuffer = vbUseShadow;
            indexBufferUsage      = ibUsage;
            useIndexShadowBuffer  = ibUseShadow;

            // Init patch builder
            // define the surface
            // NB clone the declaration to make it independent
            vertexDeclaration = (VertexDeclaration)declaration.Clone();
            patchSurface.DefineSurface(controlPointBuffer, vertexDeclaration, width, height,
                                       PatchSurfaceType.Bezier, uMaxSubdivisionLevel, vMaxSubdivisionLevel, visibleSide);
        }
Ejemplo n.º 2
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);
                }
            }
        }