Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/graphics/importer/model.cc @ 3905

Last change on this file since 3905 was 3905, checked in by bensch, 19 years ago

orxonox/trunk: image now gets loaded with the an SDL_Surface instead of a strange pointer to a Struct that is only redundant

File size: 22.5 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
17
18#include "model.h"
19
20#include <math.h>
21#include <stdarg.h>
22
23#include "array.h"
24#include "vector.h"
25
26using namespace std;
27
28/**
29   \brief Creates a 3D-Model.
30
31   This only initializes a 3D-Model, but does not cleanup the Faces.
32*/
33Model::Model(void)
34{
35  this->initialize();
36}
37
38/**
39   \brief Creates a 3D-Model. and assigns it a Name.
40*/
41Model::Model(char* modelName)
42{
43  this->initialize();
44  this->setName(modelName);
45}
46
47/**
48   \brief deletes an Model.
49
50   Looks if any from model allocated space is still in use, and if so deleted it.
51*/
52Model::~Model(void)
53{
54  PRINTF(4)("Deleting Model ");
55  if (this->name)
56    {
57      PRINT(4)("%s\n", this->name);
58      delete []this->name;
59    }
60  else
61      PRINT(4)("\n");
62
63  PRINTF(4)("Deleting display Lists.\n");
64  Group* walker = this->firstGroup;
65  while (walker != NULL)
66    {
67      glDeleteLists (walker->listNumber, 1);
68      Group* delWalker = walker;
69      walker = walker->next;
70      delete delWalker;
71    }
72
73  PRINTF(4)("Deleting Materials.\n");
74  if (this->material)
75    delete this->material;
76}
77
78/**
79   \brief Finalizes an Object. This can be done outside of the Class.
80*/
81void Model::finalize(void)
82{
83  this->importToGL ();
84 
85  this->cleanup();
86
87  this->finalized = true;
88}
89
90/**
91   \brief Draws the Models of all Groups.
92   It does this by just calling the Lists that must have been created earlier.
93*/
94void Model::draw (void) const
95{
96  PRINTF(4)("drawing the 3D-Models\n"); 
97  Group* walker = this->firstGroup;
98  while (walker != NULL)
99    {
100      PRINTF(5)("Drawing model %s\n", walker->name);
101      glCallList (walker->listNumber);
102      walker = walker->next;
103    }
104}
105
106/**
107   \brief Draws the Model number groupNumber
108   \param groupNumber The number of the group that will be displayed.
109
110   It does this by just calling the List that must have been created earlier.
111*/
112void Model::draw (int groupNumber) const 
113{
114  if (groupNumber >= this->groupCount)
115    {
116      PRINTF(2)("You requested model number %i, but this File only contains of %i Models.\n", groupNumber-1, this->groupCount);
117      return;
118    }
119  PRINTF(4)("drawing the requested 3D-Models if found.\n"); 
120  Group* walker = this->firstGroup;
121  int counter = 0;
122  while (walker != NULL)
123    {
124      if (counter == groupNumber)
125        {
126          PRINTF(4)("Drawing model number %i named %s\n", counter, walker->name);
127          glCallList (walker->listNumber);
128          return;
129        }
130      ++counter;
131      walker = walker->next;
132    }
133  PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->name);
134  return;
135
136}
137
138/**
139   \brief Draws the Model with a specific groupName
140   \param groupName The name of the group that will be displayed.
141
142   It does this by just calling the List that must have been created earlier.
143*/
144void Model::draw (char* groupName) const
145{
146  PRINTF(4)("drawing the requested 3D-Models if found.\n"); 
147  Group* walker = this->firstGroup;
148  while (walker != NULL)
149    {
150      if (!strcmp(walker->name, groupName))
151        {
152          PRINTF(4)("Drawing model %s\n", walker->name);
153          glCallList (walker->listNumber);
154          return;
155        }
156      walker = walker->next;
157    }
158  PRINTF(2)("Model Named %s in %s not Found.\n", groupName, this->name);
159  return;
160}
161
162/**
163   \returns Count of the Models in this File
164*/
165int Model::getGroupCount (void) const
166{
167  return this->groupCount;
168}
169
170/**
171    \brief initializes the Model.
172
173    This Function initializes all the needed arrays, Lists and clientStates.
174    It also defines default values.
175*/
176bool Model::initialize (void)
177{
178  PRINTF(4)("new 3D-Model is being created\n"); 
179
180  this->name = NULL;
181  this->finalized = false;
182  // setting the start group;
183  this->firstGroup = new Group;
184  this->currentGroup = this->firstGroup;
185  this->groupCount = 0;
186 
187  this->initGroup (this->currentGroup);
188  this->scaleFactor = 1;
189  this->material = new Material();
190
191  this->vertices = new Array();
192  this->vTexture = new Array();
193  this->normals = new Array();
194
195  return true;
196}
197
198/**
199   \brief sets a name to the Model
200   \param name The name to set to this Model
201*/
202void Model::setName(const char* name)
203{
204  if (this->name) 
205    delete this->name;
206  this->name = new char[strlen(name)+1];
207  strcpy(this->name, name);
208}
209/**
210   \brief initializes a new Group model
211   \param group the group that should be initialized.
212   \todo Maybe Group should be a Class, because it does a lot of stuff
213   
214*/
215bool Model::initGroup(Group* group)
216{
217  PRINTF(4)("Adding new Group\n");
218  group->name = "";
219  group->faceMode = -1;
220  group->faceCount = 0; 
221  group->next = NULL;
222
223  group->firstFace = new Face;
224  this->initFace (group->firstFace);
225  group->currentFace = group->firstFace;
226}
227
228/**
229   \brief initializes a new Face. (sets default Values)
230   \param face The face to initialize
231*/
232bool Model::initFace (Face* face)
233{
234  face->vertexCount = 0;
235
236  face->firstElem = NULL;
237 
238  face->material = NULL;
239 
240  face->next = NULL;
241
242  return true;
243}
244
245/**
246   \brief finalizes an Model.
247   This funcion is needed, to delete all the Lists, and arrays that are no more needed because they are already imported into openGL. This will be applied at the end of the importing Process.
248*/
249bool Model::cleanup(void)
250{
251  PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
252
253  if (this->vertices)
254    delete this->vertices;
255  if (this->vTexture)
256    delete this->vTexture;
257  if (this->normals)
258    delete this->normals;
259
260  this->cleanupGroup(this->firstGroup);
261  return true; 
262}
263
264/**
265   \brief Cleans up all groups starting from group.
266   \param group the first Group to clean
267*/
268bool Model::cleanupGroup (Group* group)
269{
270  PRINTF(5)("Cleaning up group\n");
271  if (group->firstFace != NULL)
272    {
273      cleanupFace (group->firstFace);
274      delete group->firstFace;
275    }
276
277  if (group->next !=NULL)
278    cleanupGroup (group->next);
279  return true;
280}
281
282/**
283   \brief Cleans up all Faces starting from face until NULL is reached.
284   \param face the first face to clean.
285*/
286bool Model::cleanupFace (Face* face)
287{
288  PRINTF(5)("Cleaning up Face\n");
289
290  if (face->firstElem != NULL)
291    {
292      this->cleanupFaceElement(face->firstElem);
293      delete face->firstElem;
294    }
295     
296  if (face->next != NULL)
297    {
298      this->cleanupFace (face->next);
299      delete face->next;
300    }
301     
302}
303
304
305/**
306   \brief Cleans up all FaceElements starting from faceElem.
307   \param faceElem the first FaceElement to clean.
308*/
309bool Model::cleanupFaceElement(FaceElement* faceElem)
310{
311  if (faceElem->next != NULL)
312    {
313      this->cleanupFaceElement (faceElem->next);
314      delete faceElem->next;
315    }
316}
317
318/**
319   \brief parses a group String
320   \param groupString the new Group to create
321
322   This function initializes a new Group.
323   With it you should be able to import .obj-files with more than one Models inside.
324*/
325bool Model::addGroup (const char* groupString)
326{
327  PRINTF(5)("Read Group: %s.\n", groupString);
328  if (this->groupCount != 0 && this->currentGroup->faceCount>0)
329    {
330      //      finalizeGroup(currentGroup);
331      this->currentGroup = this->currentGroup->next = new Group;
332      this->initGroup(this->currentGroup);
333    }
334  // setting the group name if not default.
335  if (strcmp(groupString, "default"))
336    {
337      this->currentGroup->name = new char [strlen(groupString)+1];
338      strcpy(this->currentGroup->name, groupString);
339    }
340  ++this->groupCount;
341
342}
343
344/**
345   \brief parses a vertex-String
346   \param vertexString The String that will be parsed.
347
348   If a vertex line is found this function will inject it into the vertex-Array
349*/
350bool Model::addVertex (char* vertexString)
351{
352  float subbuffer1;
353  float subbuffer2;
354  float subbuffer3;
355  sscanf (vertexString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
356  PRINTF(5)("reading in a vertex: %f %f %f\n", &subbuffer1, &subbuffer2, &subbuffer3);
357  this->vertices->addEntry(subbuffer1*scaleFactor, subbuffer2*scaleFactor, subbuffer3*scaleFactor);
358  return true;
359}
360
361/**
362   \brief parses a vertex-String
363   \param x the X-coordinate of the Vertex to add.
364   \param y the Y-coordinate of the Vertex to add.
365   \param z the Z-coordinate of the Vertex to add.
366   
367*/
368bool Model::addVertex(float x, float y, float z)
369{
370  PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
371  this->vertices->addEntry(x*scaleFactor, y*scaleFactor, z*scaleFactor);
372  return true;
373}
374
375/**
376   \brief parses a face-string
377   \param faceString The String that will be parsed.
378
379   If a face line is found this function will add it to the glList.
380*/
381bool Model::addFace (char* faceString)
382{
383  if (this->currentGroup->faceCount >0)
384    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
385  this->initFace (this->currentGroup->currentFace);
386
387  FaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new FaceElement;
388  tmpElem->next = NULL;
389  while(strcmp (faceString, "\0"))
390    {
391      if (this->currentGroup->currentFace->vertexCount>0)
392          tmpElem = tmpElem->next = new FaceElement;
393      tmpElem->next = NULL;
394
395      char tmpValue [50];
396      int tmpLen;
397      char* vertex = NULL;
398      char* texture = NULL;
399      char* normal = NULL;
400
401      sscanf (faceString, "%s", tmpValue);
402      tmpLen = strlen(tmpValue);
403      vertex = tmpValue;
404
405      if ((texture = strstr (vertex, "/")) != NULL)
406        {
407          texture[0] = '\0';
408          texture ++;
409         
410          if ((normal = strstr (texture, "/")) !=NULL)
411            {
412              normal[0] = '\0';
413              normal ++;
414            }     
415        }
416      if (vertex)
417        tmpElem->vertexNumber = atoi(vertex)-1;
418      else
419        tmpElem->vertexNumber = -1;
420      if (texture)
421        tmpElem->texCoordNumber = atoi(texture)-1;
422      else
423        tmpElem->texCoordNumber = -1;
424      if (normal)
425        tmpElem->normalNumber = atoi(normal)-1;
426      else
427        tmpElem->normalNumber = -1;
428
429      faceString += tmpLen;
430      if (strcmp (faceString, "\0"))
431        faceString++;
432      this->currentGroup->currentFace->vertexCount++;
433    }
434
435  this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2;
436}
437
438/**
439   \brief adds a new Face
440   \param faceElemCount the number of Vertices to add to the Face.
441   \param type 0: vertex only, 1: vertex and normal, 2: vertex and Texture, 3 vertex, normal and texture
442*/
443bool Model::addFace(int faceElemCount, VERTEX_FORMAT type, ...)
444{
445   if (this->currentGroup->faceCount > 0)
446    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
447  this->initFace (this->currentGroup->currentFace);
448
449  FaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new FaceElement;
450  tmpElem->next = NULL;
451 
452  va_list itemlist;
453  va_start (itemlist, type);
454
455  for (int i = 0; i < faceElemCount; i++)
456    {
457      if (this->currentGroup->currentFace->vertexCount>0)
458          tmpElem = tmpElem->next = new FaceElement;
459      tmpElem->next = NULL;
460
461      tmpElem->vertexNumber = va_arg (itemlist, int) -1;
462      if (type & TEXCOORD)
463        tmpElem->texCoordNumber = va_arg (itemlist, int) -1;
464      if (type & NORMAL)
465        tmpElem->normalNumber = va_arg(itemlist, int) -1;
466      this->currentGroup->currentFace->vertexCount++;
467    }
468  va_end(itemlist);
469
470  this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount - 2;
471}
472
473/**
474   \brief parses a vertexNormal-String
475   \param normalString The String that will be parsed.
476
477   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
478*/
479bool Model::addVertexNormal (char* normalString)
480{
481  float subbuffer1;
482  float subbuffer2;
483  float subbuffer3;
484  sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
485  PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3);
486  this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3);
487  return true;
488}
489
490/**
491   \brief adds a VertexNormal.
492   \param x The x coordinate of the Normal.
493   \param y The y coordinate of the Normal.
494   \param z The z coordinate of the Normal.
495
496   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
497*/
498bool Model::addVertexNormal(float x, float y, float z)
499{
500  PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
501  this->normals->addEntry(x, y, z);
502}
503
504/**
505   \brief parses a vertexTextureCoordinate-String
506   \param vTextureString The String that will be parsed.
507
508   If a vertexTextureCoordinate line is found,
509   this function will inject it into the vertexTexture-Array
510*/
511bool Model::addVertexTexture (char* vTextureString)
512{
513  float subbuffer1;
514  float subbuffer2;
515  sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2);
516  PRINTF(5)("found vertex-Texture %f, %f\n", &subbuffer1, &subbuffer2);
517  this->vTexture->addEntry(subbuffer1);
518  this->vTexture->addEntry(subbuffer2);
519  return true;
520}
521
522/**
523   \brief adds a Texture Coordinate
524   \param u The u coordinate of the TextureCoordinate.
525   \param v The y coordinate of the TextureCoordinate.
526
527   If a TextureCoordinate line is found this function will inject it into the TextureCoordinate-Array
528*/
529bool Model::addVertexTexture(float u, float v)
530{
531  PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
532  this->vTexture->addEntry(u);
533  this->vTexture->addEntry(v);
534}
535
536/**
537   \brief Function that selects a material, if changed in the obj file.
538   \param matString the Material that will be set.
539*/
540bool Model::addUseMtl (const char* matString)
541{
542  /*
543  if (!this->mtlFileName)
544    {
545      PRINTF(4)("Not using new defined material, because no mtlFile found yet\n");
546      return false;
547    }
548  */     
549  if (this->currentGroup->faceCount > 0)
550    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
551  this->initFace (this->currentGroup->currentFace);
552 
553  this->currentGroup->currentFace->material = material->search(matString);
554
555  if (this->currentGroup->faceCount == 0)
556    this->currentGroup->faceCount ++;
557}
558
559/**
560   \brief Function that selects a material, if changed in the obj file.
561   \param mtl the Material that will be set.
562*/
563bool Model::addUseMtl (Material* mtl)
564{
565  if (this->currentGroup->faceCount > 0)
566    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
567  this->initFace (this->currentGroup->currentFace);
568 
569  this->currentGroup->currentFace->material = mtl;
570
571  if (this->currentGroup->faceCount == 0)
572    this->currentGroup->faceCount ++;
573}
574
575/**
576   \brief reads and includes the Faces/Materials into the openGL state Machine
577*/
578bool Model::importToGL (void)
579{
580
581  // finalize the Arrays
582  this->vertices->finalizeArray();
583  this->vTexture->finalizeArray();
584  if (normals->getCount() == 0) // vertices-Array must be built for this
585    this->buildVertexNormals();
586  this->normals->finalizeArray();
587
588  this->currentGroup = this->firstGroup;
589
590  while (this->currentGroup != NULL)
591    {
592
593      // creating a glList for the Group
594      if ((this->currentGroup->listNumber = glGenLists(1)) == 0)
595        {
596          PRINTF(2)("glList could not be created for this Model\n");
597          return false;
598        }
599      glNewList (this->currentGroup->listNumber, GL_COMPILE);
600
601      // Putting Faces to GL
602      Face* tmpFace = this->currentGroup->firstFace;
603      while (tmpFace != NULL)
604        {
605          if (tmpFace->vertexCount == 0 && tmpFace->material != NULL)
606            {
607              if (this->currentGroup->faceMode != -1)
608                glEnd();
609              this->currentGroup->faceMode = 0;
610              Material* tmpMat;
611              if (tmpFace->material != NULL)
612                {
613                  tmpFace->material->select();
614                  PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getName());
615                }
616            }
617
618          else if (tmpFace->vertexCount == 3)
619            {
620              if (this->currentGroup->faceMode != 3)
621                {
622                  if (this->currentGroup->faceMode != -1)
623                    glEnd();
624                  glBegin(GL_TRIANGLES);
625                }
626             
627              this->currentGroup->faceMode = 3;
628              PRINTF(5)("found triag.\n");
629            }
630         
631          else if (tmpFace->vertexCount == 4)
632            {
633              if (this->currentGroup->faceMode != 4)
634                {
635                  if (this->currentGroup->faceMode != -1)
636                    glEnd();
637                  glBegin(GL_QUADS);
638                }
639              this->currentGroup->faceMode = 4;
640              PRINTF(5)("found quad.\n");
641            }
642         
643          else if (tmpFace->vertexCount > 4)
644            {
645              if (this->currentGroup->faceMode != -1)
646                glEnd();
647              glBegin(GL_POLYGON);
648              PRINTF(5)("Polygon with %i faces found.", tmpFace->vertexCount);
649              this->currentGroup->faceMode = tmpFace->vertexCount;
650            }
651         
652          FaceElement* tmpElem = tmpFace->firstElem;
653          while (tmpElem != NULL)
654            {
655              //      PRINTF(2)("%s\n", tmpElem->value);
656              this->addGLElement(tmpElem);
657              tmpElem = tmpElem->next;
658            }
659          tmpFace = tmpFace->next;
660        }
661      glEnd();
662      glEndList();
663
664      this->currentGroup = this->currentGroup->next;
665    } 
666}
667
668/**
669   \brief Adds a Face-element (one vertex of a face) with all its information.
670   \param elem The FaceElement to add to the OpenGL-environment.
671
672   It does this by searching:
673   1. The Vertex itself
674   2. The VertexNormale
675   3. The VertexTextureCoordinate
676   merging this information, the face will be drawn.
677*/
678bool Model::addGLElement (FaceElement* elem)
679{
680  PRINTF(5)("importing grafical Element to openGL.\n");
681
682  if (elem->texCoordNumber != -1)
683    glTexCoord2fv(this->vTexture->getArray() + elem->texCoordNumber * 2);
684  if (elem->normalNumber != -1)
685    glNormal3fv(this->normals->getArray() + elem->normalNumber * 3);
686  if (elem->vertexNumber != -1)
687    glVertex3fv(this->vertices->getArray() + elem->vertexNumber * 3);
688
689}
690
691/**
692   \brief A routine that is able to create normals.
693
694   The algorithm does the following:
695   1. It calculates creates Vectors for each normale, and sets them to zero.
696   2. It then Walks through a) all the Groups b) all the Faces c) all the FaceElements
697   3. It searches for a points two neighbours per Face, takes Vecotrs to them calculates FaceNormals and adds it to the Points Normal.
698   4. It goes through all the normale-Points and calculates the VertexNormale and includes it in the normals-Array.
699*/
700bool Model::buildVertexNormals ()
701{
702 
703  PRINTF(4)("Normals are being calculated.\n");
704
705  Vector* normArray = new Vector [vertices->getCount()/3];
706  for (int i=0; i<vertices->getCount()/3;i++)
707    normArray[i] = Vector(.0,.0,.0);
708 
709  int firstTouch;
710  int secondTouch;
711  Vector prevV;
712  Vector nextV;
713  Vector curV;
714
715  Group* tmpGroup = firstGroup;
716  while (tmpGroup)
717    {
718      Face* tmpFace = tmpGroup->firstFace;
719      while (tmpFace)
720        {
721          if (tmpFace->firstElem)
722            {
723              FaceElement* firstElem = tmpFace->firstElem;
724              FaceElement* prevElem;
725              FaceElement* curElem = firstElem;
726              FaceElement* nextElem;
727              FaceElement* lastElem;
728              // find last Element of the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop.
729              while (curElem)
730                {
731                  prevElem = curElem;
732                  curElem = curElem->next;
733                }
734              lastElem = prevElem;
735             
736              curElem = firstElem;
737              for (int j=0; j<tmpFace->vertexCount; j++)
738                {
739                  if (!(nextElem = curElem->next))
740                    nextElem = firstElem;
741                  curElem->normalNumber = curElem->vertexNumber;
742                 
743                  curV = Vector (vertices->getArray()[curElem->vertexNumber*3], vertices->getArray()[curElem->vertexNumber*3+1], vertices->getArray()[curElem->vertexNumber*3+2]);
744                  prevV = Vector (vertices->getArray()[prevElem->vertexNumber*3], vertices->getArray()[prevElem->vertexNumber*3+1], vertices->getArray()[prevElem->vertexNumber*3+2]) - curV;
745                  nextV = Vector (vertices->getArray()[nextElem->vertexNumber*3], vertices->getArray()[nextElem->vertexNumber*3+1], vertices->getArray()[nextElem->vertexNumber*3+2]) - curV;
746                  normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
747
748                  prevElem = curElem;
749                  curElem = curElem->next;
750                }
751            }
752          tmpFace = tmpFace->next;
753        }
754      tmpGroup = tmpGroup->next;
755    }
756
757  for (int i=0; i<vertices->getCount()/3;i++)
758    {
759      normArray[i].normalize();
760      PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z);
761     
762      this->normals->addEntry(normArray[i].x, normArray[i].y, normArray[i].z);
763
764    }
765  delete []normArray; 
766 
767}
768
769
770/**
771   \brief Includes a default model
772
773   This will inject a Cube, because this is the most basic model.
774*/
775void Model::cubeModel(void)
776{
777  this->addVertex (-0.5, -0.5, 0.5);
778  this->addVertex (0.5, -0.5, 0.5);
779  this->addVertex (-0.5, 0.5, 0.5);
780  this->addVertex (0.5, 0.5, 0.5);
781  this->addVertex (-0.5, 0.5, -0.5);
782  this->addVertex (0.5, 0.5, -0.5);
783  this->addVertex (-0.5, -0.5, -0.5);
784  this->addVertex (0.5, -0.5, -0.5);
785
786  this->addVertexTexture (0.0, 0.0);
787  this->addVertexTexture (1.0, 0.0);
788  this->addVertexTexture (0.0, 1.0);
789  this->addVertexTexture (1.0, 1.0);
790  this->addVertexTexture (0.0, 2.0);
791  this->addVertexTexture (1.0, 2.0);
792  this->addVertexTexture (0.0, 3.0);
793  this->addVertexTexture (1.0, 3.0);
794  this->addVertexTexture (0.0, 4.0);
795  this->addVertexTexture (1.0, 4.0);
796  this->addVertexTexture (2.0, 0.0);
797  this->addVertexTexture (2.0, 1.0);
798  this->addVertexTexture (-1.0, 0.0);
799  this->addVertexTexture (-1.0, 1.0);
800
801  this->addVertexNormal (0.0, 0.0, 1.0);
802  this->addVertexNormal (0.0, 0.0, 1.0);
803  this->addVertexNormal (0.0, 0.0, 1.0);
804  this->addVertexNormal (0.0, 0.0, 1.0);
805  this->addVertexNormal (0.0, 1.0, 0.0);
806  this->addVertexNormal (0.0, 1.0, 0.0);
807  this->addVertexNormal (0.0, 1.0, 0.0);
808  this->addVertexNormal (0.0, 1.0, 0.0);
809  this->addVertexNormal (0.0, 0.0, -1.0);
810  this->addVertexNormal (0.0, 0.0, -1.0);
811  this->addVertexNormal (0.0, 0.0, -1.0);
812  this->addVertexNormal (0.0, 0.0, -1.0);
813  this->addVertexNormal (0.0, -1.0, 0.0);
814  this->addVertexNormal (0.0, -1.0, 0.0);
815  this->addVertexNormal (0.0, -1.0, 0.0);
816  this->addVertexNormal (0.0, -1.0, 0.0);
817  this->addVertexNormal (1.0, 0.0, 0.0);
818  this->addVertexNormal (1.0, 0.0, 0.0);
819  this->addVertexNormal (1.0, 0.0, 0.0);
820  this->addVertexNormal (1.0, 0.0, 0.0);
821  this->addVertexNormal (-1.0, 0.0, 0.0);
822  this->addVertexNormal (-1.0, 0.0, 0.0);
823  this->addVertexNormal (-1.0, 0.0, 0.0);
824  this->addVertexNormal (-1.0, 0.0, 0.0);
825
826  /* normaleLess-testingMode
827  this->addFace ("1 2 4 3");
828  this->addFace ("3 4 6 5");
829  this->addFace ("5 6 8 7");
830  this->addFace ("7 8 2 1");
831  this->addFace ("2 8 6 4");
832  this->addFace ("7 1 3 5");
833  */
834
835  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,1,1, 2,2,2, 4,4,3, 3,3,4);
836  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 3,3,5, 4,4,6, 6,6,7, 5,5,8);
837  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 5,5,9, 6,6,10, 8,8,11, 7,7,12);
838  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,7,13, 8,8,14, 2,10,15, 1,9,16);
839  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,2,17, 8,11,18, 6,12,19, 4,4,20);
840  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,13,21, 1,1,22, 3,3,23, 5,14,24);
841
842}
Note: See TracBrowser for help on using the repository browser.