Esempio 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);
                }
            }
        }
Esempio n. 2
0
                public static PatchSurface FromBaseObject(BaseObject baseObj)
                {
                    if (baseObj == null || baseObj.NativeObject == IntPtr.Zero)
                    {
                        return(null);
                    }
                    PatchSurface obj = baseObj as  PatchSurface;

                    if (object.Equals(obj, null))
                    {
                        obj = new PatchSurface(CreatedWhenConstruct.CWC_NotToCreate);
                        obj.BindNativeObject(baseObj.NativeObject, "CPatchSurface");
                        obj.IncreaseCast();
                    }

                    return(obj);
                }
Esempio n. 3
0
        public void BuildQuake3Patches(int vertOffset, int indexOffset)
        {
            // Loop through the patches
            int currVertOffset  = vertOffset;
            int currIndexOffset = indexOffset;

            HardwareVertexBuffer vbuf = vertexData.vertexBufferBinding.GetBuffer(0);

            for (int i = 0; i < patches.Count; i++)
            {
                PatchSurface ps = (PatchSurface)patches[i];

                ps.Build(vbuf, currVertOffset, indexes, currIndexOffset);

                currVertOffset  += ps.RequiredVertexCount;
                currIndexOffset += ps.RequiredIndexCount;
            }
        }
Esempio n. 4
0
                public BaseObject Create()
                {
                    PatchSurface emptyInstance = new PatchSurface(CreatedWhenConstruct.CWC_NotToCreate);

                    return(emptyInstance);
                }
Esempio n. 5
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PatchSurface obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }