20 Objects *Objects::m_objects = 0;
59 if(
object >= objectList.size() )
60 reserve(
object + 1 );
63 if( objectList[
object].
object != -1 ) {
70 loadObject3DS(
object, filename, factor );
84 void Objects::loadObject3DS(
unsigned int object,
string filename,
float factor ) {
92 oi.
displayList = createDisplayList( model, factor );
95 objectList[object] = oi;
108 if(
object >= objectList.size() )
110 if( objectList[
object].
object == -1 )
113 glDeleteLists( objectList[
object].displayList, 1 );
115 objectList[object].object = -1;
116 objectList[object].displayList = 0;
117 objectList[object].view =
Vector3( 0, 0, 1 );
118 objectList[object].filename =
"";
131 if( objectCount <= objectList.size() )
134 size_t oldSize = objectList.size();
136 objectList.reserve( objectCount );
137 objectList.resize ( objectCount );
140 for(
size_t i=oldSize ; i < objectList.size(); i++ ) {
151 if( (
unsigned)
object > objectList.size() )
154 return objectList[object].displayList;
162 if( (
unsigned)
object > objectList.size() )
165 return objectList[object].view;
175 GLuint Objects::createDisplayList(
ObjectLoader3ds * model,
float factor ) {
176 GLuint list = glGenLists(1);
177 glNewList( list, GL_COMPILE );
178 glPushAttrib( GL_ALL_ATTRIB_BITS );
179 glEnable( GL_COLOR_MATERIAL );
180 glColorMaterial( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
184 glDisable( GL_TEXTURE_2D );
186 glBegin(GL_TRIANGLES);
189 for(
unsigned int f = 0; f < model->
meshList[i].totalFaces; f++) {
196 if(!pMesh || !pFace)
continue;
199 glNormal3f(pFace[f].normal.x, pFace[f].
normal.
y,
203 int material = pFace[f].
matId;
207 float color[] = {1,0,0,1};
232 glMaterialfv( GL_FRONT, GL_SPECULAR, color );
251 glNormal3f(normale.
x, normale.
y, normale.
z);
253 if(pTexCoord) glTexCoord2f(pTexCoord[pFace[f].indices[0]].tu, pTexCoord[pFace[f].indices[0]].tv);
258 if(pTexCoord) glTexCoord2f(pTexCoord[pFace[f].indices[1]].tu, pTexCoord[pFace[f].indices[1]].tv);
263 if(pTexCoord) glTexCoord2f(pTexCoord[pFace[f].indices[2]].tu, pTexCoord[pFace[f].indices[2]].tv);