-using System;\r
-using System.Collections.Generic;\r
-using System.Text;\r
-using System.Runtime.InteropServices;\r
-\r
-namespace Tso2MqoGui\r
-{\r
- public enum PrimType\r
- {\r
- PT_LIST,\r
- PT_STRIP,\r
- PT_FAN\r
- }\r
-\r
- public unsafe struct PrimitiveGroup\r
- {\r
- public PrimType type;\r
- public uint numIndices;\r
- public ushort* indices;\r
- }\r
-\r
- public unsafe class NvTriStrip\r
- {\r
- public static ushort[] Optimize(ushort[] triangles)\r
- {\r
- fixed(ushort* p= &triangles[0])\r
- {\r
- SetStitchStrips(true);\r
-\r
- PrimitiveGroup* pg = null;\r
- ushort num = 0;\r
- bool rc = GenerateStrips(p, (uint)triangles.Length, &pg, &num, false);\r
-\r
- if(!rc) throw new Exception();\r
-\r
- try\r
- {\r
- if(num != 1) throw new Exception();\r
- if(pg[0].type != PrimType.PT_STRIP) throw new Exception();\r
-\r
- ushort[] nidx= new ushort[pg[0].numIndices];\r
-\r
- for(int i= 0; i < nidx.Length; ++i)\r
- nidx[i] = pg[0].indices[i];\r
-\r
- return nidx;\r
- } finally\r
- {\r
- DeletePrimitiveGroup(pg);\r
- }\r
- }\r
- }\r
-\r
- //[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
- [DllImport("NvTriStrip.dll")] public extern static void EnableRestart(uint _restartVal);\r
- [DllImport("NvTriStrip.dll")] public extern static void DisableRestart();\r
- [DllImport("NvTriStrip.dll")] public extern static void SetListsOnly(bool _bListsOnly);\r
- [DllImport("NvTriStrip.dll")] public extern static void SetCacheSize(uint _cacheSize);\r
- [DllImport("NvTriStrip.dll")] public extern static void SetStitchStrips(bool _bStitchStrips);\r
- [DllImport("NvTriStrip.dll")] public extern static void SetMinStripSize(uint _minStripSize);\r
- //[DllImport("NvTriStrip.dll")] public extern static void Cleanup(NvStripInfoVec& tempStrips, NvFaceInfoVec& tempFaces);\r
- [DllImport("NvTriStrip.dll")] public extern static bool SameTriangle(ushort firstTri0, ushort firstTri1, ushort firstTri2, ushort secondTri0, ushort secondTri1, ushort secondTri2);\r
- //[DllImport("NvTriStrip.dll")] public extern static bool TestTriangle(ushort v0, ushort v1, ushort v2, const std::vector<NvFaceInfo>* in_bins, const int NUMBINS);\r
- [DllImport("NvTriStrip.dll")] public extern static void DeletePrimitiveGroup(PrimitiveGroup* primGroups);\r
- [DllImport("NvTriStrip.dll")] public extern static bool GenerateStrips(ushort* in_indices, uint in_numIndices, PrimitiveGroup** primGroups, ushort* numGroups, bool validateEnabled);\r
- [DllImport("NvTriStrip.dll")] public extern static void RemapIndices(PrimitiveGroup* in_primGroups, ushort numGroups, ushort numVerts, PrimitiveGroup** remappedGroups);\r
- }\r
-}\r
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace Tso2MqoGui
+{
+ public enum PrimType
+ {
+ PT_LIST,
+ PT_STRIP,
+ PT_FAN
+ }
+
+ public unsafe struct PrimitiveGroup
+ {
+ public PrimType type;
+ public uint numIndices;
+ public ushort* indices;
+ }
+
+ public unsafe class NvTriStrip
+ {
+ public static ushort[] Optimize(ushort[] triangles)
+ {
+ fixed (ushort* p = &triangles[0])
+ {
+ SetStitchStrips(true);
+
+ PrimitiveGroup* pg = null;
+ ushort num = 0;
+ bool rc = GenerateStrips(p, (uint)triangles.Length, &pg, &num, false);
+
+ if (!rc) throw new Exception();
+
+ try
+ {
+ if (num != 1) throw new Exception();
+ if (pg[0].type != PrimType.PT_STRIP) throw new Exception();
+
+ ushort[] nidx = new ushort[pg[0].numIndices];
+
+ for (int i = 0; i < nidx.Length; ++i)
+ nidx[i] = pg[0].indices[i];
+
+ return nidx;
+ }
+ finally
+ {
+ DeletePrimitiveGroup(pg);
+ }
+ }
+ }
+
+ //[DllImport("NvTriStrip.dll")] public extern static int GetPicture(byte* file, int len, uint flag, out IntPtr pHBInfo, out IntPtr pHBm, void* lpPrgressCallback, uint lData);
+ [DllImport("NvTriStrip.dll")]
+ public extern static void EnableRestart(uint _restartVal);
+ [DllImport("NvTriStrip.dll")]
+ public extern static void DisableRestart();
+ [DllImport("NvTriStrip.dll")]
+ public extern static void SetListsOnly(bool _bListsOnly);
+ [DllImport("NvTriStrip.dll")]
+ public extern static void SetCacheSize(uint _cacheSize);
+ [DllImport("NvTriStrip.dll")]
+ public extern static void SetStitchStrips(bool _bStitchStrips);
+ [DllImport("NvTriStrip.dll")]
+ public extern static void SetMinStripSize(uint _minStripSize);
+ //[DllImport("NvTriStrip.dll")] public extern static void Cleanup(NvStripInfoVec& tempStrips, NvFaceInfoVec& tempFaces);
+ [DllImport("NvTriStrip.dll")]
+ public extern static bool SameTriangle(ushort firstTri0, ushort firstTri1, ushort firstTri2, ushort secondTri0, ushort secondTri1, ushort secondTri2);
+ //[DllImport("NvTriStrip.dll")] public extern static bool TestTriangle(ushort v0, ushort v1, ushort v2, const std::vector<NvFaceInfo>* in_bins, const int NUMBINS);
+ [DllImport("NvTriStrip.dll")]
+ public extern static void DeletePrimitiveGroup(PrimitiveGroup* primGroups);
+ [DllImport("NvTriStrip.dll")]
+ public extern static bool GenerateStrips(ushort* in_indices, uint in_numIndices, PrimitiveGroup** primGroups, ushort* numGroups, bool validateEnabled);
+ [DllImport("NvTriStrip.dll")]
+ public extern static void RemapIndices(PrimitiveGroup* in_primGroups, ushort numGroups, ushort numVerts, PrimitiveGroup** remappedGroups);
+ }
+}
\ No newline at end of file