Changeset 4579 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Jun 10, 2005, 2:59:14 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/importer
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/Makefile.am
r4564 r4579 9 9 md2Model.cc \ 10 10 material.cc \ 11 texture.cc \ 12 array.cc 11 texture.cc 13 12 14 13 -
orxonox/trunk/src/lib/graphics/importer/Makefile.in
r4564 r4579 56 56 am_libORXimporter_a_OBJECTS = model.$(OBJEXT) objModel.$(OBJEXT) \ 57 57 primitive_model.$(OBJEXT) md2Model.$(OBJEXT) \ 58 material.$(OBJEXT) texture.$(OBJEXT) array.$(OBJEXT)58 material.$(OBJEXT) texture.$(OBJEXT) 59 59 libORXimporter_a_OBJECTS = $(am_libORXimporter_a_OBJECTS) 60 60 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) 61 61 depcomp = $(SHELL) $(top_srcdir)/depcomp 62 62 am__depfiles_maybe = depfiles 63 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/ array.Po ./$(DEPDIR)/material.Po \63 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/material.Po \ 64 64 @AMDEP_TRUE@ ./$(DEPDIR)/md2Model.Po ./$(DEPDIR)/model.Po \ 65 65 @AMDEP_TRUE@ ./$(DEPDIR)/objModel.Po \ … … 192 192 md2Model.cc \ 193 193 material.cc \ 194 texture.cc \ 195 array.cc 194 texture.cc 196 195 197 196 noinst_HEADERS = abstract_model.h \ … … 253 252 -rm -f *.tab.c 254 253 255 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@256 254 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@ 257 255 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md2Model.Po@am__quote@ -
orxonox/trunk/src/lib/graphics/importer/array.h
r4577 r4579 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 1 16 /*! 2 17 \file array.h … … 8 23 #ifndef _ARRAY_H 9 24 #define _ARRAY_H 10 #include " glincl.h"25 #include "debug.h" 11 26 12 27 //! Array Class that handles dynamic-float arrays. 13 class Array28 template<class T> class Array 14 29 { 15 public:16 Array ();17 ~Array();30 public: 31 Array (); 32 ~Array(); 18 33 19 void initializeArray (); 20 void finalizeArray (void); 21 void addEntry (GLfloat entry); 22 void addEntry(GLfloat entry0, GLfloat entry1, GLfloat entry2); 34 void finalizeArray (void); 35 void addEntry (T entry); 36 void addEntry(T entry0, T entry1, T entry2); 23 37 24 /** \returns The array */ 25 inline const GLfloat* getArray () const { return this->array; }; 26 /** \returns The Count of entries in the Array*/ 27 inline int getCount(void)const { return this->entryCount; }; 28 void debug(void) const ; 29 private: 30 //! One entry of the Array 31 struct Entry 32 { 33 GLfloat value; //!< The value of this Entry. 34 Entry* next; //!< Pointer to the Next entry. 35 }; 38 /** \returns The array */ 39 inline const T* getArray () const { return this->array; }; 40 /** \returns The Count of entries in the Array*/ 41 inline unsigned int getCount(void)const { return this->entryCount; }; 42 void debug(void) const ; 36 43 37 GLfloat* array; //!< The array that will be produced when finalizing the Array. 38 int entryCount; //!< The count of Entries in this Array. 39 bool finalized; //!< If this variable is set to true, the Array can not be changed anymore. true if finalized, false else (initially). 40 Entry* firstEntry; //!< Pointer to the first Entry of this Array 41 Entry* currentEntry; //!< Pointer to the current Entry of this Array. The one Entry we are working with. 44 private: 45 //! One entry of the Array 46 struct Entry 47 { 48 T value; //!< The value of this Entry. 49 Entry* next; //!< Pointer to the Next entry. 50 }; 51 52 T* array; //!< The array that will be produced when finalizing the Array. 53 unsigned int entryCount; //!< The count of Entries in this Array. 54 bool finalized; //!< If this variable is set to true, the Array can not be changed anymore. true if finalized, false else (initially). 55 Entry* firstEntry; //!< Pointer to the first Entry of this Array 56 Entry* currentEntry; //!< Pointer to the current Entry of this Array. The one Entry we are working with. 57 }; 42 58 43 59 44 }; 60 /** 61 \brief creates a new Array 62 */ 63 template<class T> 64 Array<T>::Array () 65 { 66 PRINTF(4)("crating new Array\n"); 67 this->firstEntry = new Entry; 68 this->firstEntry->next =NULL; 69 this->currentEntry=firstEntry; 70 this->finalized = false; 71 this->entryCount = 0; //0 means one entry 72 } 45 73 74 /** 75 \brief deletes an Array. 76 It does this by first deleting all the array-entries, and then delete the array[] itself 77 */ 78 template<class T> 79 Array<T>::~Array() 80 { 81 PRINTF(4)("deleting array\n"); 82 Entry* walker = this->firstEntry; 83 Entry* previous; 84 while (walker) 85 { 86 previous = walker; 87 walker = walker->next; 88 delete previous; 89 } 90 if (finalized) 91 delete []this->array; 92 } 93 94 /** 95 \brief finalizes an array. 96 This Function creates the array, and makes it ready to be sent to the application. 97 */ 98 template<class T> 99 void Array<T>::finalizeArray (void) 100 { 101 PRINTF(4)("Finalizing array. Length: %i\n", entryCount); 102 // if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL) 103 if (!(this->array = new GLfloat [this->entryCount])) 104 PRINTF(1)("could not allocate %i data Blocks\n", this->entryCount); 105 Entry* walker = this->firstEntry; 106 for (int i=0; i<this->entryCount; i++) 107 { 108 this->array[i] = walker->value; 109 walker = walker->next; 110 } 111 this->finalized = true; 112 } 113 114 /** 115 \brief adds a new Entry to the Array 116 \param entry Entry to add. 117 */ 118 template<class T> 119 void Array<T>::addEntry (T entry) 120 { 121 if (!this->finalized) 122 { 123 PRINTF(5)("adding new Entry to Array: %f\n", entry); 124 125 this->currentEntry->value = entry; 126 this->currentEntry->next = new Entry; 127 this->currentEntry = currentEntry->next; 128 this->currentEntry->next = NULL; 129 ++this->entryCount; 130 } 131 else 132 PRINTF(2)("adding failed, because list has been finalized\n"); 133 } 134 135 /** 136 \brief Adds 3 entries at once (convenience) 137 */ 138 template<class T> 139 void Array<T>::addEntry (T entry0, T entry1, T entry2) 140 { 141 this->addEntry(entry0); 142 this->addEntry(entry1); 143 this->addEntry(entry2); 144 } 145 146 /** 147 \brief Simple debug info about the Array 148 */ 149 template<class T> 150 void Array<T>::debug (void) const 151 { 152 PRINT(0)("entryCount=%i, address=%p\n", this->entryCount, this->array); 153 } 46 154 #endif -
orxonox/trunk/src/lib/graphics/importer/model.cc
r4577 r4579 148 148 this->scaleFactor = 1; 149 149 150 this->vertices = new Array ();151 this->vTexture = new Array ();152 this->normals = new Array ();150 this->vertices = new Array<GLfloat>(); 151 this->vTexture = new Array<GLfloat>(); 152 this->normals = new Array<GLfloat>(); 153 153 154 154 this->materialList = new tList<Material>; … … 201 201 // this creates the display List. 202 202 this->importToDisplayList(); 203 204 203 205 204 // deletes everything we allocated. -
orxonox/trunk/src/lib/graphics/importer/model.h
r4577 r4579 14 14 15 15 // FORWARD DEFINITION // 16 class Array;17 16 class Vector; 17 template<class T> class Array; 18 18 template<class T> class tList; 19 19 … … 174 174 unsigned int normalCount; //!< A modelwide Counter for the normals. 175 175 unsigned int texCoordCount; //!< A modelwide Counter for the texCoord. 176 Array *vertices; //!< The Array that handles the Vertices.177 Array *normals; //!< The Array that handles the Normals.178 Array *vTexture; //!< The Array that handles the VertexTextureCoordinates.176 Array<GLfloat>* vertices; //!< The Array that handles the Vertices. 177 Array<GLfloat>* normals; //!< The Array that handles the Normals. 178 Array<GLfloat>* vTexture; //!< The Array that handles the VertexTextureCoordinates. 179 179 180 180 ModelGroup* firstGroup; //!< The first of all groups.
Note: See TracChangeset
for help on using the changeset viewer.