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