Changeset 3656 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Mar 26, 2005, 9:02:42 PM (20 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/importer
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/Makefile.am
r3487 r3656 5 5 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib 6 6 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/data 7 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/g aphics7 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics 8 8 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/importer 9 9 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/lang … … 30 30 material.cc \ 31 31 texture.cc \ 32 $(MAINSRCDIR)/lib/graphics/graphics_engine.cc \ 33 $(MAINSRCDIR)/lib/lang/base_object.cc \ 32 34 $(MAINSRCDIR)/lib/math/vector.cc 33 35 -
orxonox/trunk/src/lib/graphics/importer/Makefile.in
r3579 r3656 55 55 am_importer_OBJECTS = framework.$(OBJEXT) windowHandler.$(OBJEXT) \ 56 56 model.$(OBJEXT) objModel.$(OBJEXT) array.$(OBJEXT) \ 57 material.$(OBJEXT) texture.$(OBJEXT) vector.$(OBJEXT) 57 material.$(OBJEXT) texture.$(OBJEXT) graphics_engine.$(OBJEXT) \ 58 base_object.$(OBJEXT) vector.$(OBJEXT) 58 59 importer_OBJECTS = $(am_importer_OBJECTS) 59 60 importer_LDADD = $(LDADD) … … 61 62 depcomp = $(SHELL) $(top_srcdir)/depcomp 62 63 am__depfiles_maybe = depfiles 63 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/array.Po ./$(DEPDIR)/framework.Po \ 64 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/array.Po \ 65 @AMDEP_TRUE@ ./$(DEPDIR)/base_object.Po \ 66 @AMDEP_TRUE@ ./$(DEPDIR)/framework.Po \ 67 @AMDEP_TRUE@ ./$(DEPDIR)/graphics_engine.Po \ 64 68 @AMDEP_TRUE@ ./$(DEPDIR)/material.Po ./$(DEPDIR)/model.Po \ 65 69 @AMDEP_TRUE@ ./$(DEPDIR)/objModel.Po ./$(DEPDIR)/texture.Po \ … … 185 189 target_vendor = @target_vendor@ 186 190 MAINSRCDIR = ../../.. 187 AM_CXXFLAGS = -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/g aphics -I$(MAINSRCDIR)/lib/graphics/importer -I$(MAINSRCDIR)/lib/lang -I$(MAINSRCDIR)/lib/util -I$(MAINSRCDIR)/lib/math -I$(MAINSRCDIR)/defs -I$(MAINSRCDIR)/font -I$(MAINSRCDIR)/network -I$(MAINSRCDIR)/glmenu -I$(MAINSRCDIR)/ai191 AM_CXXFLAGS = -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/graphics -I$(MAINSRCDIR)/lib/graphics/importer -I$(MAINSRCDIR)/lib/lang -I$(MAINSRCDIR)/lib/util -I$(MAINSRCDIR)/lib/math -I$(MAINSRCDIR)/defs -I$(MAINSRCDIR)/font -I$(MAINSRCDIR)/network -I$(MAINSRCDIR)/glmenu -I$(MAINSRCDIR)/ai 188 192 AM_LDFLAGS = $(MWINDOWS) 189 193 importer_SOURCES = framework.cc \ … … 194 198 material.cc \ 195 199 texture.cc \ 200 $(MAINSRCDIR)/lib/graphics/graphics_engine.cc \ 201 $(MAINSRCDIR)/lib/lang/base_object.cc \ 196 202 $(MAINSRCDIR)/lib/math/vector.cc 197 203 … … 271 277 272 278 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@ 279 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_object.Po@am__quote@ 273 280 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/framework.Po@am__quote@ 281 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/graphics_engine.Po@am__quote@ 274 282 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@ 275 283 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/model.Po@am__quote@ … … 294 302 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 295 303 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 304 305 graphics_engine.o: $(MAINSRCDIR)/lib/graphics/graphics_engine.cc 306 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT graphics_engine.o -MD -MP -MF "$(DEPDIR)/graphics_engine.Tpo" -c -o graphics_engine.o `test -f '$(MAINSRCDIR)/lib/graphics/graphics_engine.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/graphics/graphics_engine.cc; \ 307 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/graphics_engine.Tpo" "$(DEPDIR)/graphics_engine.Po"; else rm -f "$(DEPDIR)/graphics_engine.Tpo"; exit 1; fi 308 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(MAINSRCDIR)/lib/graphics/graphics_engine.cc' object='graphics_engine.o' libtool=no @AMDEPBACKSLASH@ 309 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/graphics_engine.Po' tmpdepfile='$(DEPDIR)/graphics_engine.TPo' @AMDEPBACKSLASH@ 310 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 311 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o graphics_engine.o `test -f '$(MAINSRCDIR)/lib/graphics/graphics_engine.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/graphics/graphics_engine.cc 312 313 graphics_engine.obj: $(MAINSRCDIR)/lib/graphics/graphics_engine.cc 314 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT graphics_engine.obj -MD -MP -MF "$(DEPDIR)/graphics_engine.Tpo" -c -o graphics_engine.obj `if test -f '$(MAINSRCDIR)/lib/graphics/graphics_engine.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/graphics/graphics_engine.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/graphics/graphics_engine.cc'; fi`; \ 315 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/graphics_engine.Tpo" "$(DEPDIR)/graphics_engine.Po"; else rm -f "$(DEPDIR)/graphics_engine.Tpo"; exit 1; fi 316 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(MAINSRCDIR)/lib/graphics/graphics_engine.cc' object='graphics_engine.obj' libtool=no @AMDEPBACKSLASH@ 317 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/graphics_engine.Po' tmpdepfile='$(DEPDIR)/graphics_engine.TPo' @AMDEPBACKSLASH@ 318 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 319 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o graphics_engine.obj `if test -f '$(MAINSRCDIR)/lib/graphics/graphics_engine.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/graphics/graphics_engine.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/graphics/graphics_engine.cc'; fi` 320 321 base_object.o: $(MAINSRCDIR)/lib/lang/base_object.cc 322 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base_object.o -MD -MP -MF "$(DEPDIR)/base_object.Tpo" -c -o base_object.o `test -f '$(MAINSRCDIR)/lib/lang/base_object.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/lang/base_object.cc; \ 323 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/base_object.Tpo" "$(DEPDIR)/base_object.Po"; else rm -f "$(DEPDIR)/base_object.Tpo"; exit 1; fi 324 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(MAINSRCDIR)/lib/lang/base_object.cc' object='base_object.o' libtool=no @AMDEPBACKSLASH@ 325 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/base_object.Po' tmpdepfile='$(DEPDIR)/base_object.TPo' @AMDEPBACKSLASH@ 326 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 327 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base_object.o `test -f '$(MAINSRCDIR)/lib/lang/base_object.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/lang/base_object.cc 328 329 base_object.obj: $(MAINSRCDIR)/lib/lang/base_object.cc 330 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT base_object.obj -MD -MP -MF "$(DEPDIR)/base_object.Tpo" -c -o base_object.obj `if test -f '$(MAINSRCDIR)/lib/lang/base_object.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/lang/base_object.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/lang/base_object.cc'; fi`; \ 331 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/base_object.Tpo" "$(DEPDIR)/base_object.Po"; else rm -f "$(DEPDIR)/base_object.Tpo"; exit 1; fi 332 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(MAINSRCDIR)/lib/lang/base_object.cc' object='base_object.obj' libtool=no @AMDEPBACKSLASH@ 333 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/base_object.Po' tmpdepfile='$(DEPDIR)/base_object.TPo' @AMDEPBACKSLASH@ 334 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 335 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o base_object.obj `if test -f '$(MAINSRCDIR)/lib/lang/base_object.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/lang/base_object.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/lang/base_object.cc'; fi` 296 336 297 337 vector.o: $(MAINSRCDIR)/lib/math/vector.cc -
orxonox/trunk/src/lib/graphics/importer/framework.cc
r3479 r3656 76 76 obj = new OBJModel(argv[1]); 77 77 else 78 { 79 // This is an example, of how it is possible, to create a new Model, and adding some vertex-information. 80 // This also packs everything into a DisplayList, and can be handled exactly as any other model. 81 // This is an example of a cube with Texture-Coordinates, but without explicite Vertex-Normals. (they are soft-created). 82 /* 83 obj = (OBJModel*) new Model(); 84 obj->setName("CUBE"); 85 obj->addVertex (-0.5, -0.5, 0.5); 86 obj->addVertex (0.5, -0.5, 0.5); 87 obj->addVertex (-0.5, 0.5, 0.5); 88 obj->addVertex (0.5, 0.5, 0.5); 89 obj->addVertex (-0.5, 0.5, -0.5); 90 obj->addVertex (0.5, 0.5, -0.5); 91 obj->addVertex (-0.5, -0.5, -0.5); 92 obj->addVertex (0.5, -0.5, -0.5); 93 94 obj->addVertexTexture (0.0, 0.0); 95 obj->addVertexTexture (1.0, 0.0); 96 obj->addVertexTexture (0.0, 1.0); 97 obj->addVertexTexture (1.0, 1.0); 98 obj->addVertexTexture (0.0, 2.0); 99 obj->addVertexTexture (1.0, 2.0); 100 obj->addVertexTexture (0.0, 3.0); 101 obj->addVertexTexture (1.0, 3.0); 102 obj->addVertexTexture (0.0, 4.0); 103 obj->addVertexTexture (1.0, 4.0); 104 obj->addVertexTexture (2.0, 0.0); 105 obj->addVertexTexture (2.0, 1.0); 106 obj->addVertexTexture (-1.0, 0.0); 107 obj->addVertexTexture (-1.0, 1.0); 108 109 obj->addFace ("1 2 4 3"); 110 obj->addFace ("3 4 6 5"); 111 obj->addFace ("5 6 8 7"); 112 obj->addFace ("7 8 2 1"); 113 obj->addFace ("2 8 6 4"); 114 obj->addFace ("7 1 3 5"); 115 obj->finalize(); 116 */ 117 obj = (OBJModel*) new Model(CYLINDER); 118 } 78 obj = (OBJModel*) new Model(SPHERE); 79 119 80 M = Vector(wHandler.screen->w/2, wHandler.screen->h/2, 0); 120 81 rotAxis = Vector (0.0,1.0,0.0); … … 166 127 switch (event.type) { 167 128 case SDL_MOUSEMOTION: 168 PRINTF( 3)("Mouse motion about %d,%d Pixels to (%d,%d).\n",129 PRINTF(4)("Mouse motion about %d,%d Pixels to (%d,%d).\n", 169 130 event.motion.xrel, event.motion.yrel, 170 131 event.motion.x, event.motion.y); … … 205 166 if (event.button.button == 4) 206 167 { 207 PRINTF( 0)("MouseWheel up\n");168 PRINTF(4)("MouseWheel up\n"); 208 169 zoomTo *= .5; 209 170 } 210 171 else if (event.button.button == 5) 211 172 { 212 PRINTF( 2)("MouseWheel down\n");173 PRINTF(4)("MouseWheel down\n"); 213 174 zoomTo *= 2.0; 214 175 } … … 240 201 else 241 202 { 242 PRINTF( 2)("MouseButton %d released at (%d,%d).\n",203 PRINTF(4)("MouseButton %d released at (%d,%d).\n", 243 204 event.button.button, event.button.x, event.button.y); 244 205 } -
orxonox/trunk/src/lib/graphics/importer/framework.h
r3427 r3656 4 4 #include "windowHandler.h" // Include the Whandler Basecode 5 5 #include "objModel.h" 6 #include "vector.h" 6 7 7 8 class Vector; -
orxonox/trunk/src/lib/graphics/importer/model.cc
r3590 r3656 797 797 void Model::cubeModel(void) 798 798 { 799 this->addVertex ( "-0.5 -0.5 0.5");800 this->addVertex ( "0.5 -0.5 0.5");801 this->addVertex ( "-0.5 0.5 0.5");802 this->addVertex ( "0.5 0.5 0.5");803 this->addVertex ( "-0.5 0.5 -0.5");804 this->addVertex ( "0.5 0.5 -0.5");805 this->addVertex ( "-0.5 -0.5 -0.5");806 this->addVertex ( "0.5 -0.5 -0.5");807 808 this->addVertexTexture ( "0.0 0.0");809 this->addVertexTexture ( "1.0 0.0");810 this->addVertexTexture ( "0.0 1.0");811 this->addVertexTexture ( "1.0 1.0");812 this->addVertexTexture ( "0.0 2.0");813 this->addVertexTexture ( "1.0 2.0");814 this->addVertexTexture ( "0.0 3.0");815 this->addVertexTexture ( "1.0 3.0");816 this->addVertexTexture ( "0.0 4.0");817 this->addVertexTexture ( "1.0 4.0");818 this->addVertexTexture ( "2.0 0.0");819 this->addVertexTexture ( "2.0 1.0");820 this->addVertexTexture ( "-1.0 0.0");821 this->addVertexTexture ( "-1.0 1.0");822 823 this->addVertexNormal ( "0.0 0.0 1.0");824 this->addVertexNormal ( "0.0 0.0 1.0");825 this->addVertexNormal ( "0.0 0.0 1.0");826 this->addVertexNormal ( "0.0 0.0 1.0");827 this->addVertexNormal ( "0.0 1.0 0.0");828 this->addVertexNormal ( "0.0 1.0 0.0");829 this->addVertexNormal ( "0.0 1.0 0.0");830 this->addVertexNormal ( "0.0 1.0 0.0");831 this->addVertexNormal ( "0.0 0.0 -1.0");832 this->addVertexNormal ( "0.0 0.0 -1.0");833 this->addVertexNormal ( "0.0 0.0 -1.0");834 this->addVertexNormal ( "0.0 0.0 -1.0");835 this->addVertexNormal ( "0.0 -1.0 0.0");836 this->addVertexNormal ( "0.0 -1.0 0.0");837 this->addVertexNormal ( "0.0 -1.0 0.0");838 this->addVertexNormal ( "0.0 -1.0 0.0");839 this->addVertexNormal ( "1.0 0.0 0.0");840 this->addVertexNormal ( "1.0 0.0 0.0");841 this->addVertexNormal ( "1.0 0.0 0.0");842 this->addVertexNormal ( "1.0 0.0 0.0");843 this->addVertexNormal ( "-1.0 0.0 0.0");844 this->addVertexNormal ( "-1.0 0.0 0.0");845 this->addVertexNormal ( "-1.0 0.0 0.0");846 this->addVertexNormal ( "-1.0 0.0 0.0");799 this->addVertex (-0.5, -0.5, 0.5); 800 this->addVertex (0.5, -0.5, 0.5); 801 this->addVertex (-0.5, 0.5, 0.5); 802 this->addVertex (0.5, 0.5, 0.5); 803 this->addVertex (-0.5, 0.5, -0.5); 804 this->addVertex (0.5, 0.5, -0.5); 805 this->addVertex (-0.5, -0.5, -0.5); 806 this->addVertex (0.5, -0.5, -0.5); 807 808 this->addVertexTexture (0.0, 0.0); 809 this->addVertexTexture (1.0, 0.0); 810 this->addVertexTexture (0.0, 1.0); 811 this->addVertexTexture (1.0, 1.0); 812 this->addVertexTexture (0.0, 2.0); 813 this->addVertexTexture (1.0, 2.0); 814 this->addVertexTexture (0.0, 3.0); 815 this->addVertexTexture (1.0, 3.0); 816 this->addVertexTexture (0.0, 4.0); 817 this->addVertexTexture (1.0, 4.0); 818 this->addVertexTexture (2.0, 0.0); 819 this->addVertexTexture (2.0, 1.0); 820 this->addVertexTexture (-1.0, 0.0); 821 this->addVertexTexture (-1.0, 1.0); 822 823 this->addVertexNormal (0.0, 0.0, 1.0); 824 this->addVertexNormal (0.0, 0.0, 1.0); 825 this->addVertexNormal (0.0, 0.0, 1.0); 826 this->addVertexNormal (0.0, 0.0, 1.0); 827 this->addVertexNormal (0.0, 1.0, 0.0); 828 this->addVertexNormal (0.0, 1.0, 0.0); 829 this->addVertexNormal (0.0, 1.0, 0.0); 830 this->addVertexNormal (0.0, 1.0, 0.0); 831 this->addVertexNormal (0.0, 0.0, -1.0); 832 this->addVertexNormal (0.0, 0.0, -1.0); 833 this->addVertexNormal (0.0, 0.0, -1.0); 834 this->addVertexNormal (0.0, 0.0, -1.0); 835 this->addVertexNormal (0.0, -1.0, 0.0); 836 this->addVertexNormal (0.0, -1.0, 0.0); 837 this->addVertexNormal (0.0, -1.0, 0.0); 838 this->addVertexNormal (0.0, -1.0, 0.0); 839 this->addVertexNormal (1.0, 0.0, 0.0); 840 this->addVertexNormal (1.0, 0.0, 0.0); 841 this->addVertexNormal (1.0, 0.0, 0.0); 842 this->addVertexNormal (1.0, 0.0, 0.0); 843 this->addVertexNormal (-1.0, 0.0, 0.0); 844 this->addVertexNormal (-1.0, 0.0, 0.0); 845 this->addVertexNormal (-1.0, 0.0, 0.0); 846 this->addVertexNormal (-1.0, 0.0, 0.0); 847 847 848 848 /* normaleLess-testingMode … … 855 855 */ 856 856 857 this->addFace ("1/1/1 2/2/2 4/4/3 3/3/4"); 858 this->addFace ("3/3/5 4/4/6 6/6/7 5/5/8"); 859 this->addFace ("5/5/9 6/6/10 8/8/11 7/7/12"); 860 this->addFace ("7/7/13 8/8/14 2/10/15 1/9/16"); 861 this->addFace ("2/2/17 8/11/18 6/12/19 4/4/20"); 862 this->addFace ("7/13/21 1/1/22 3/3/23 5/14/24"); 863 864 } 865 866 /** 867 \brief Builds a Sphere into the Model 868 */ 869 void Model::sphereModel() 870 { 871 int detail = 30; 872 if (detail <= 0) detail = 1; 857 this->addFace (4, 3, 1,1,1, 2,2,2, 4,4,3, 3,3,4); 858 this->addFace (4, 3, 3,3,5, 4,4,6, 6,6,7, 5,5,8); 859 this->addFace (4, 3, 5,5,9, 6,6,10, 8,8,11, 7,7,12); 860 this->addFace (4, 3, 7,7,13, 8,8,14, 2,10,15, 1,9,16); 861 this->addFace (4, 3, 2,2,17, 8,11,18, 6,12,19, 4,4,20); 862 this->addFace (4, 3, 7,13,21, 1,1,22, 3,3,23, 5,14,24); 863 864 } 865 866 /** 867 \brief Builds a Sphere into the Model. 868 \param size The radius of the Sphere. 869 \param detail The detail of the Sphere. 870 */ 871 void Model::sphereModel(float size, unsigned int detail) 872 { 873 int vertexCount = 0; 874 if (detail <= 0) 875 detail = 1; 876 // detail = 2; // make it even 873 877 float df = (float)detail; 874 for (float i = 0.0; i < df/2; i+=1.0) 875 { 876 for (float j = 0.0; j < df; j+=1.0) 877 { 878 float vz = i/df *2.0*PI - PI/2.0; 879 this->addVertex(cos(j/df*2.0*PI) * cos(vz) , 880 sin(j/df*2.0*PI) * cos(vz), 881 sin(vz)); 882 //if (j==0.0) 883 //printf ("%f %f\n", vz, sin (vz)); 884 if (i==0.0) 885 PRINTF(0)("%f, %f\n", j/df*2.0*PI, cos(j/df*PI)); 886 } 887 } 888 vertices->debug(); 889 for (int i = 0; i < detail/2; i++) 890 for (int j = 1; j < detail; j++) 891 { 892 unsigned int v1,v2,v3,v4; 893 v1 = i*detail +j; 894 895 /* if (j+1 == detail) 896 { 897 v2 = i*detail +1; 898 v3 = i*detail+detail + 1; 899 } 900 else*/ 901 { 902 v2 = i*detail +j+1; 903 v3 = i*detail+detail + j+1; 904 } 905 v4 = i*detail+detail + j; 906 //printf("%i %i %i %i\n", v1, v2, v3, v4); 907 this->addFace(4, 0, v1, v2, v3, v4); 908 } 909 } 910 878 879 // defining the Vertices 880 for (float i = 0; i < df *2.0; i+=1.0) 881 { 882 float vi = i/df *PI; 883 for (float j = -df / 2.0 +1.0; j < df / 2.0; j+=1.0 *df/(df+1.0)) 884 { 885 float vj = j/df *PI; 886 this->addVertex(size * cos(vi) * cos(vj), 887 size * sin(vj), 888 size * sin(vi) * cos(vj)); 889 this->addVertexTexture(i / (df *2.0), (j-1.0)/(df)+.5); 890 vertexCount++; 891 } 892 } 893 this->addVertex(0, -size, 0); 894 this->addVertex(0, size, 0); 895 896 // defining the binding Faces. 897 unsigned int v1, v2, v3, v4; 898 for (int i = 0; i <= detail * 2 -1; i++) 899 { 900 for (int j = 0; j <= detail; j++) 901 { 902 903 v1 = i*detail + j; 904 v4 = i*detail + (j+1); 905 906 if (i == detail*2 -1) 907 { 908 v2 = j; 909 v3 = j+1; 910 } 911 else 912 { 913 v2 = (i+1)*detail + j; 914 v3 = (i+1)*detail + (j+1); 915 } 916 917 if (j == 0) 918 { 919 v1 = vertexCount+1; 920 this->addFace(3, 2, v1, v1, v3, v3, v4, v4); 921 } 922 else if (j == detail) 923 { 924 v3 = vertexCount+2; 925 this->addFace(3, 2, v1, v1, v2, v2, v3, v3); 926 } 927 else 928 this->addFace(4, 2, v1, v1, v2, v2, v3, v3, v4, v4); 929 } 930 } 931 } 911 932 /** 912 933 \brief Creates a Cylinder. … … 955 976 956 977 } 978 979 980 void Model::coneModel(float size, unsigned int detail) 981 { 982 983 984 } -
orxonox/trunk/src/lib/graphics/importer/model.h
r3479 r3656 114 114 115 115 void cubeModel(void); 116 void sphereModel( void);116 void sphereModel(float size = 1.0, unsigned int detail = 10); 117 117 void cylinderModel(void); 118 void coneModel(float size = 1.0, unsigned int detail = 10); 118 119 }; 119 120
Note: See TracChangeset
for help on using the changeset viewer.