2 using System.Collections.Generic;
\r
4 using System.Runtime.InteropServices;
\r
15 public unsafe struct PrimitiveGroup
\r
17 public PrimType type;
\r
18 public uint numIndices;
\r
19 public ushort* indices;
\r
22 public unsafe class NvTriStrip
\r
24 public static ushort[] Optimize(ushort[] triangles)
\r
26 fixed(ushort* p= &triangles[0])
\r
28 SetStitchStrips(true);
\r
30 PrimitiveGroup* pg = null;
\r
32 bool rc = GenerateStrips(p, (uint)triangles.Length, &pg, &num, false);
\r
34 if(!rc) throw new Exception();
\r
38 if(num != 1) throw new Exception();
\r
39 if(pg[0].type != PrimType.PT_STRIP) throw new Exception();
\r
41 ushort[] nidx= new ushort[pg[0].numIndices];
\r
43 for(int i= 0; i < nidx.Length; ++i)
\r
44 nidx[i] = pg[0].indices[i];
\r
49 DeletePrimitiveGroup(pg);
\r
54 //[DllImport("NvTriStrip.dll")] public extern static int GetPicture(byte* file, int len, uint flag, out IntPtr pHBInfo, out IntPtr pHBm, void* lpPrgressCallback, uint lData);
\r
55 [DllImport("NvTriStrip.dll")] public extern static void EnableRestart(uint _restartVal);
\r
56 [DllImport("NvTriStrip.dll")] public extern static void DisableRestart();
\r
57 [DllImport("NvTriStrip.dll")] public extern static void SetListsOnly(bool _bListsOnly);
\r
58 [DllImport("NvTriStrip.dll")] public extern static void SetCacheSize(uint _cacheSize);
\r
59 [DllImport("NvTriStrip.dll")] public extern static void SetStitchStrips(bool _bStitchStrips);
\r
60 [DllImport("NvTriStrip.dll")] public extern static void SetMinStripSize(uint _minStripSize);
\r
61 //[DllImport("NvTriStrip.dll")] public extern static void Cleanup(NvStripInfoVec& tempStrips, NvFaceInfoVec& tempFaces);
\r
62 [DllImport("NvTriStrip.dll")] public extern static bool SameTriangle(ushort firstTri0, ushort firstTri1, ushort firstTri2, ushort secondTri0, ushort secondTri1, ushort secondTri2);
\r
63 //[DllImport("NvTriStrip.dll")] public extern static bool TestTriangle(ushort v0, ushort v1, ushort v2, const std::vector<NvFaceInfo>* in_bins, const int NUMBINS);
\r
64 [DllImport("NvTriStrip.dll")] public extern static void DeletePrimitiveGroup(PrimitiveGroup* primGroups);
\r
65 [DllImport("NvTriStrip.dll")] public extern static bool GenerateStrips(ushort* in_indices, uint in_numIndices, PrimitiveGroup** primGroups, ushort* numGroups, bool validateEnabled);
\r
66 [DllImport("NvTriStrip.dll")] public extern static void RemapIndices(PrimitiveGroup* in_primGroups, ushort numGroups, ushort numVerts, PrimitiveGroup** remappedGroups);
\r