Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: importer: no more fstream c-style code only

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