2019-06-22 00:18:22 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2019-07-16 23:35:21 +02:00
|
|
|
|
namespace Toolbox.Library
|
2019-06-22 00:18:22 +02:00
|
|
|
|
{
|
2019-11-16 22:41:16 +01:00
|
|
|
|
public enum STPrimitiveType
|
2019-11-09 23:36:52 +01:00
|
|
|
|
{
|
|
|
|
|
Points = 0,
|
|
|
|
|
Lines = 1,
|
|
|
|
|
LineStrips = 2,
|
|
|
|
|
Triangles = 3,
|
|
|
|
|
TrangleStrips,
|
|
|
|
|
Quads,
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-22 00:18:22 +02:00
|
|
|
|
public class STGenericPolygonGroup
|
|
|
|
|
{
|
2020-04-01 17:45:08 +02:00
|
|
|
|
public virtual STGenericMaterial Material { get; set; } = null;
|
2019-12-08 02:16:13 +01:00
|
|
|
|
|
2019-06-22 00:18:22 +02:00
|
|
|
|
public int Offset { get; set; }
|
2020-04-01 17:45:08 +02:00
|
|
|
|
public int MaterialIndex { get; set; } = -1;
|
2019-06-22 00:18:22 +02:00
|
|
|
|
public int Index { get; set; }
|
|
|
|
|
|
|
|
|
|
public List<int> faces = new List<int>();
|
|
|
|
|
|
2019-11-16 22:41:16 +01:00
|
|
|
|
public STPrimitiveType PrimativeType = STPrimitiveType.Triangles;
|
2019-11-09 23:36:52 +01:00
|
|
|
|
|
2019-06-22 00:18:22 +02:00
|
|
|
|
public int strip = 0x40;
|
|
|
|
|
public int displayFaceSize = 0;
|
|
|
|
|
|
|
|
|
|
public List<int> GetDisplayFace()
|
|
|
|
|
{
|
|
|
|
|
if ((strip >> 4) == 4)
|
|
|
|
|
{
|
|
|
|
|
displayFaceSize = faces.Count;
|
|
|
|
|
return faces;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
List<int> f = new List<int>();
|
|
|
|
|
|
|
|
|
|
int startDirection = 1;
|
|
|
|
|
int p = 0;
|
|
|
|
|
int f1 = faces[p++];
|
|
|
|
|
int f2 = faces[p++];
|
|
|
|
|
int faceDirection = startDirection;
|
|
|
|
|
int f3;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
f3 = faces[p++];
|
|
|
|
|
if (f3 == 0xFFFF)
|
|
|
|
|
{
|
|
|
|
|
f1 = faces[p++];
|
|
|
|
|
f2 = faces[p++];
|
|
|
|
|
faceDirection = startDirection;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
faceDirection *= -1;
|
|
|
|
|
if ((f1 != f2) && (f2 != f3) && (f3 != f1))
|
|
|
|
|
{
|
|
|
|
|
if (faceDirection > 0)
|
|
|
|
|
{
|
|
|
|
|
f.Add(f3);
|
|
|
|
|
f.Add(f2);
|
|
|
|
|
f.Add(f1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
f.Add(f2);
|
|
|
|
|
f.Add(f3);
|
|
|
|
|
f.Add(f1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
f1 = f2;
|
|
|
|
|
f2 = f3;
|
|
|
|
|
}
|
|
|
|
|
} while (p < faces.Count);
|
|
|
|
|
|
|
|
|
|
displayFaceSize = f.Count;
|
|
|
|
|
return f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|