public class ObjectFormat
{
- class_data char * extension;
- class_property char * extension
+ class_data const char * extension;
+ class_property const char * extension
{
set { class_data(extension) = value; }
get { return class_data(extension); }
}
- virtual bool ::Load(Object object, char * fileName, DisplaySystem displaySystem);
+ virtual bool ::Load(Object object, const char * fileName, DisplaySystem displaySystem);
};
// TODO: Review these:
mesh.SetMinMaxRadius();
min = mesh.min;
max = mesh.max;
- volume = true;
+ volume = (max.x >= min.x && max.y >= min.y && max.z >= min.z);
}
else
{
Vector3Df point;
point.MultMatrix(points[c], child.localMatrix);
- if(point.x < this.min.x) this.min.x = point.x;
- if(point.y < this.min.y) this.min.y = point.y;
- if(point.z < this.min.z) this.min.z = point.z;
+ if(point.x < min.x) min.x = point.x;
+ if(point.y < min.y) min.y = point.y;
+ if(point.z < min.z) min.z = point.z;
- if(point.x > this.max.x) this.max.x = point.x;
- if(point.y > this.max.y) this.max.y = point.y;
- if(point.z > this.max.z) this.max.z = point.z;
+ if(point.x > max.x) max.x = point.x;
+ if(point.y > max.y) max.y = point.y;
+ if(point.z > max.z) max.z = point.z;
}
volume = true;
}
{
Object modelChild;
- name = model.name;
+ name = CopyString(model.name);
flags = model.flags;
flags.ownMesh = false;
mesh = model.mesh;
{
children.Remove(child);
child.Free(displaySystem);
+
+ // We did not do this before so as to keep transform on reloading for new DisplaySystem
+ // However since children are removed, it seems that purpose has been gone, we'd need
+ // a new mechanism to handle lost resources reloading...
+ delete child;
}
if(flags.ownMesh && mesh)
{
}
}
- bool Load(char * fileName, char * type, DisplaySystem displaySystem)
+ bool Load(const char * fileName, const char * type, DisplaySystem displaySystem)
{
char ext[MAX_EXTENSION];
subclass(ObjectFormat) format;
bool result = false;
if(!type && fileName)
- {
- type = GetExtension(fileName, ext);
- strlwr(type);
- }
+ type = strlwr(GetExtension(fileName, ext));
for(link = class(ObjectFormat).derivatives.first; link; link = link.next)
{
}
}
- Object Find(char * name)
+ Object Find(const char * name)
{
if(this && name)
{
return null;
}
- bool AddName(Object object, char * name)
+ bool AddName(Object object, const char * name)
{
- bool result;
+ bool result = false;
if(this)
{
char * newName = CopyString(name);
{
bool result = false;
- if(!children.first)
+ if(!children.first && this.flags.ownMesh)
result = true;
else
{
while(true)
{
int nIndices = 0;
- PrimitiveGroupType type;
+ PrimitiveGroupType type = (PrimitiveGroupType)-1;
Material material = null;
bool foundGroup = false;
if(newGroup.material == group.material && newGroup.type == group.type)
{
int c;
- for(c = 0; c<group.nIndices; c++)
- newGroup.indices[nIndices++] = group.indices[c] + (uint16)vertexOffset;
+ if(group.type.indices32bit)
+ for(c = 0; c<group.nIndices; c++)
+ newGroup.indices32[nIndices++] = group.indices32[c] + vertexOffset;
+ else
+ for(c = 0; c<group.nIndices; c++)
+ newGroup.indices[nIndices++] = (uint16)(group.indices[c] + vertexOffset);
}
}
vertexOffset += objectMesh.nVertices;
newGroup.type == group.type)
{
int c;
- for(c = 0; c<group.nIndices; c++)
- newGroup.indices[nIndices++] = group.indices[c] + (uint16)vertexOffset;
+ if(group.type.indices32bit)
+ for(c = 0; c<group.nIndices; c++)
+ newGroup.indices32[nIndices++] = group.indices32[c] + vertexOffset;
+ else
+ for(c = 0; c<group.nIndices; c++)
+ newGroup.indices[nIndices++] = (uint16)(group.indices[c] + vertexOffset);
}
}
vertexOffset += child.mesh.nVertices;
objectMesh.primitives[c].data = null;
*/
- for(i = 0; i<triangle->nIndices; i++)
- triangle->indices[i] += (uint16)vertexOffset;
+ if(triangle->type.indices32bit)
+ for(i = 0; i<triangle->nIndices; i++)
+ triangle->indices32[i] += vertexOffset;
+ else
+ for(i = 0; i<triangle->nIndices; i++)
+ triangle->indices[i] += (uint16)vertexOffset;
mesh.UnlockPrimitive(triangle);
}
vertexOffset += objectMesh.nVertices;
child.mesh.primitives[c].data = null;
*/
- for(i = 0; i<triangle->nIndices; i++)
- triangle->indices[i] += (uint16)vertexOffset;
+ if(triangle->type.indices32bit)
+ for(i = 0; i<triangle->nIndices; i++)
+ triangle->indices[i] += (uint16)vertexOffset;
+ else
+ for(i = 0; i<triangle->nIndices; i++)
+ triangle->indices32[i] += vertexOffset;
mesh.UnlockPrimitive(triangle);
}
vertexOffset += child.mesh.nVertices;
property Camera camera { get { return camera; } }; // Fix this with inheritance? camera inherit from Object?
property Object firstChild { get { return children.first; } };
property Object next { get { return next; } };
- property char * name { get { return name; } };
+ property const char * name { get { return name; } };
property Matrix matrix { get { value = matrix; } };
property Object cameraTarget { set { cameraTarget = value; } get { return cameraTarget; } };
property OldList * tracks { /* set { tracks = value; } */ get { return &tracks; } };
private:
Object()
{
- children.offset = (uint)&((Object)0).prev;
+ children.offset = (uint)(uintptr)&((Object)0).prev;
transform.scaling = { 1, 1, 1 };
transform.orientation = { 1,0,0,0 };
flags.transform = true;
if(flags.camera && cameraTarget)
{
- // DeterMine angle to look at target
+ // Determine angle to look at target
Vector3D position, direction;
if(flags.root || !parent)
position = transform.position;
unsigned startFrame, endFrame;
int frame;
Vector3Df pivot;
- Transform transform;
+
+ public Transform transform;
Matrix matrix;
Matrix localMatrix;
void * tag;