#include "ObjectManager.h" void InitObject(VObject * o) { o->Position.x = 0.0; o->Position.y = 0.0; o->Position.z = 0.0; o->Front.x = 0.0; o->Front.y = 0.0; o->Front.z = 1.0; o->Right.x = 1.0; o->Right.y = 0.0; o->Right.z = 0.0; o->Up.x = 0.0; o->Up.y = 1.0; o->Up.z = 0.0; o->next = NULL; o->Durability = 2; o->taggedForRemoval = 0; o->Radius = 0.0; InitModel(&o->Model); } void CleanUpObject(VObject * o) { CleanUpModel(&o->Model); } void MoveObjectToPoint(VObject * o, Vector * p) { o->Position.x = p->x; o->Position.y = p->y; o->Position.z = p->z; } void RotateObject(VObject * o, Vector * r) { #pragma unused(o, r) /* How to do this? */ } void DrawObject(VObject * o) { GLfloat matrix[16]; glPushMatrix(); matrix[0] = o->Right.x; matrix[1] = o->Right.y; matrix[2] = o->Right.z; matrix[3] = 0.0f; matrix[4] = o->Up.x; matrix[5] = o->Up.y; matrix[6] = o->Up.z; matrix[7] = 0.0f; matrix[8] = o->Front.x; matrix[9] = o->Front.y; matrix[10] = o->Front.z; matrix[11] = 0.0f; matrix[12] = 0.0f; matrix[13] = 0.0f; matrix[14] = 0.0; matrix[15] = 1.0f; glTranslatef(o->Position.x, o->Position.y, o->Position.z); glMultMatrixf(matrix); DrawModel(&o->Model); glPopMatrix(); } void CalculateRadius(VObject * o) { int wVertex; float tempRadius; o->Radius = 0.0; for (wVertex = 0; wVertex < o->Model.NumberOfVertices; wVertex++) { tempRadius = fabs((o->Model.Vertices[wVertex].x * o->Model.Vertices[wVertex].x) + (o->Model.Vertices[wVertex].y * o->Model.Vertices[wVertex].y) + (o->Model.Vertices[wVertex].z * o->Model.Vertices[wVertex].z)); if (tempRadius > o->Radius) o->Radius = tempRadius; } }