quads,
quadStrip,
lineStrip
+
+ /* ,
+ lineLoop,
+ lineStrip,
+ polygon
+ */
};
+
public class MaterialFlags { public bool doubleSided:1, translucent:1, tile:1, noFog:1, singleSideLight:1; };
public class Material : struct
{
Bitmap bumpMap;
Bitmap envMap;
MaterialFlags flags;
+ float uScale, vScale;
void Free()
{
PrimitiveGroupType type;
union
{
- struct { uint16 * indices; int nIndices; };
+ struct { union { uint16 * indices; uint * indices32; }; int nIndices; };
struct { int first, nVertices; };
};
Material material;
+
private:
void * data;
-};
+};
+
+/*
+public class PrimitiveGroupIndices16 : PrimitiveGroup
+{
+ property Array<uint16> indices
+ {
+ set { }
+ }
+}
+
+public class PrimitiveGroupIndices32 : PrimitiveGroup
+{
+ property Array<uint> indices
+ {
+ set { }
+ }
+}
+
+public class PrimitiveGroupVertexRange : PrimitiveGroup
+{
+ property int first { set { } }
+ property int nVertices { set { } }
+}
+*/
public struct PrimitiveSingle
{
PrimitiveGroupType type;
union
{
- struct { uint16 * indices; int nIndices; };
+ struct { union { uint16 * indices; uint * indices32; }; int nIndices; };
struct { int first, nVertices; };
};
Material material;
bool Allocate(MeshFeatures what, int nVertices, DisplaySystem displaySystem)
{
bool result = false;
- if((!nVertices || nVertices == nVertices) && (!this.displaySystem || this.displaySystem == displaySystem))
+ if(!this.displaySystem || this.displaySystem == displaySystem)
{
- flags |= what;
- this.nVertices = nVertices;
driver = displaySystem ? displaySystem.driver : (subclass(DisplayDriver))class(LFBDisplayDriver);
if(driver.AllocateMesh == DisplayDriver::AllocateMesh) driver = (subclass(DisplayDriver))class(LFBDisplayDriver);
- if(driver.AllocateMesh(displaySystem, this))
+ if(driver.AllocateMesh(displaySystem, this, what, nVertices))
{
+ flags |= what;
+ this.nVertices = nVertices;
if(Lock(what))
result = true;
}
FillBytes(normals, 0, nVertices * sizeof(Vector3Df));
for(group = groups.first; group; group = group.next)
{
- int nPrimitives = 0, c;
+ int c;
int offset = 0;
int strip = 0;
int nPoints, nIndex;
uint16 * indices16 = group.indices;
- uint32 * indices32 = group.indices;
+ uint32 * indices32 = group.indices32;
bool i32bit = group.type.indices32bit;
if(group.type.primitiveType == triangles)
if(group.type.primitiveType == triFan)
{
- plane.FromPointsf(vertices[group.indices[0]],
- vertices[group.indices[c]],
+ plane.FromPointsf(vertices[group.indices[0]],
+ vertices[group.indices[c]],
vertices[group.indices[c-1]]);
- planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
+ planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
normals[group.indices[0]].Add(normals[group.indices[0]], planeNormal);
numShared[group.indices[0]]++;
}
else if(group.type.primitiveType == triStrip || group.type.primitiveType == quadStrip)
{
- plane.FromPointsf(vertices[group.indices[c-1-strip]],
- vertices[group.indices[c-2+strip]],
+ plane.FromPointsf(vertices[group.indices[c-1-strip]],
+ vertices[group.indices[c-2+strip]],
vertices[group.indices[c]]);
- planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
+ planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
normals[group.indices[c-1-strip]].Add(normals[group.indices[c-1-strip]], planeNormal);
numShared[group.indices[c-1-strip]]++;
{
if(group.type.vertexRange)
{
- plane.FromPointsf(vertices[c+2],
- vertices[c+1],
+ plane.FromPointsf(vertices[c+2],
+ vertices[c+1],
vertices[c]);
- planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
+ planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
for(i = c; i<c+nIndex; i++)
{
}
else
{
- plane.FromPointsf(vertices[i32bit ? indices32[c+2] : indices16[c+2]],
- vertices[i32bit ? indices32[c+1] : indices16[c+1]],
+ plane.FromPointsf(vertices[i32bit ? indices32[c+2] : indices16[c+2]],
+ vertices[i32bit ? indices32[c+1] : indices16[c+1]],
vertices[i32bit ? indices32[c] : indices16[c]]);
- planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
+ planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
for(i = c; i<c+nIndex; i++)
{
Plane plane;
Vector3Df planeNormal;
- plane.FromPointsf(vertices[primitive->indices[2]],
- vertices[primitive->indices[1]],
+ plane.FromPointsf(vertices[primitive->indices[2]],
+ vertices[primitive->indices[1]],
vertices[primitive->indices[0]]);
- planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
+ planeNormal = { (float) plane.normal.x, (float) plane.normal.y, (float) plane.normal.z };
if(primitive->material.flags.doubleSided && plane.d < 0)
{
return result;
}
+ void * GetData()
+ {
+ return data;
+ }
+
private:
void SetMinMaxRadius(void)
float xRadius, yRadius, zRadius;
min = { MAXFLOAT, MAXFLOAT, MAXFLOAT };
- max = { MINFLOAT, MINFLOAT, MINFLOAT };
+ max = {-MAXFLOAT,-MAXFLOAT,-MAXFLOAT };
for(c = 0; c<nVertices; c++)
{
- min.x = Min(min.x, vertices[c].x);
- min.y = Min(min.y, vertices[c].y);
- min.z = Min(min.z, vertices[c].z);
- max.x = Max(max.x, vertices[c].x);
- max.y = Max(max.y, vertices[c].y);
- max.z = Max(max.z, vertices[c].z);
+ float x = vertices[c].x, y = vertices[c].y, z = vertices[c].z;
+ if(x.isNan || y.isNan || z.isNan);
+ else if(x > 1E20 || x < -1E20 || y > 1E20 || y < -1E20 || z > 1E20 || z < -1E20);
+ else
+ {
+ min.x = Min(min.x, x);
+ min.y = Min(min.y, y);
+ min.z = Min(min.z, z);
+ max.x = Max(max.x, x);
+ max.y = Max(max.y, y);
+ max.z = Max(max.z, z);
+ }
}
xRadius = Max(max.x, -min.x);
yRadius = Max(max.y, -min.y);