Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3656 in orxonox.OLD


Ignore:
Timestamp:
Mar 26, 2005, 9:02:42 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: model: sphere-model is now working

Location:
orxonox/trunk/src/lib/graphics/importer
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/importer/Makefile.am

    r3487 r3656  
    55AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib
    66AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/data
    7 AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/gaphics
     7AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics
    88AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/importer
    99AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/lang
     
    3030                  material.cc \
    3131                  texture.cc \
     32                  $(MAINSRCDIR)/lib/graphics/graphics_engine.cc \
     33                  $(MAINSRCDIR)/lib/lang/base_object.cc \
    3234                  $(MAINSRCDIR)/lib/math/vector.cc
    3335
  • orxonox/trunk/src/lib/graphics/importer/Makefile.in

    r3579 r3656  
    5555am_importer_OBJECTS = framework.$(OBJEXT) windowHandler.$(OBJEXT) \
    5656        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)
    5859importer_OBJECTS = $(am_importer_OBJECTS)
    5960importer_LDADD = $(LDADD)
     
    6162depcomp = $(SHELL) $(top_srcdir)/depcomp
    6263am__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 \
    6468@AMDEP_TRUE@    ./$(DEPDIR)/material.Po ./$(DEPDIR)/model.Po \
    6569@AMDEP_TRUE@    ./$(DEPDIR)/objModel.Po ./$(DEPDIR)/texture.Po \
     
    185189target_vendor = @target_vendor@
    186190MAINSRCDIR = ../../..
    187 AM_CXXFLAGS = -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/gaphics -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
     191AM_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
    188192AM_LDFLAGS = $(MWINDOWS)
    189193importer_SOURCES = framework.cc \
     
    194198                  material.cc \
    195199                  texture.cc \
     200                  $(MAINSRCDIR)/lib/graphics/graphics_engine.cc \
     201                  $(MAINSRCDIR)/lib/lang/base_object.cc \
    196202                  $(MAINSRCDIR)/lib/math/vector.cc
    197203
     
    271277
    272278@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@
     279@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base_object.Po@am__quote@
    273280@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/framework.Po@am__quote@
     281@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/graphics_engine.Po@am__quote@
    274282@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@
    275283@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/model.Po@am__quote@
     
    294302@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    295303@am__fastdepCXX_FALSE@  $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
     304
     305graphics_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
     313graphics_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
     321base_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
     329base_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`
    296336
    297337vector.o: $(MAINSRCDIR)/lib/math/vector.cc
  • orxonox/trunk/src/lib/graphics/importer/framework.cc

    r3479 r3656  
    7676    obj = new OBJModel(argv[1]);
    7777  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
    11980  M = Vector(wHandler.screen->w/2, wHandler.screen->h/2, 0);
    12081  rotAxis = Vector (0.0,1.0,0.0);
     
    166127      switch (event.type) {
    167128      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",
    169130                  event.motion.xrel, event.motion.yrel,
    170131                  event.motion.x, event.motion.y);
     
    205166        if (event.button.button == 4)
    206167          {
    207             PRINTF(0)("MouseWheel up\n");
     168            PRINTF(4)("MouseWheel up\n");
    208169            zoomTo *= .5;
    209170          }
    210171        else if (event.button.button == 5)
    211172          {
    212             PRINTF(2)("MouseWheel down\n");
     173            PRINTF(4)("MouseWheel down\n");
    213174            zoomTo *= 2.0;
    214175          }
     
    240201        else
    241202            {
    242               PRINTF(2)("MouseButton %d released at (%d,%d).\n",
     203              PRINTF(4)("MouseButton %d released at (%d,%d).\n",
    243204                        event.button.button, event.button.x, event.button.y);
    244205            }
  • orxonox/trunk/src/lib/graphics/importer/framework.h

    r3427 r3656  
    44#include "windowHandler.h" // Include the Whandler Basecode
    55#include "objModel.h"
     6#include "vector.h"
    67
    78class Vector;
  • orxonox/trunk/src/lib/graphics/importer/model.cc

    r3590 r3656  
    797797void Model::cubeModel(void)
    798798{
    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);
    847847
    848848  /* normaleLess-testingMode
     
    855855  */
    856856
    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*/
     871void 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
    873877  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}
    911932/**
    912933   \brief Creates a Cylinder.
     
    955976
    956977}
     978
     979
     980void Model::coneModel(float size, unsigned int detail)
     981{
     982
     983 
     984}
  • orxonox/trunk/src/lib/graphics/importer/model.h

    r3479 r3656  
    114114
    115115  void cubeModel(void);
    116   void sphereModel(void);
     116  void sphereModel(float size = 1.0, unsigned int detail = 10);
    117117  void cylinderModel(void);
     118  void coneModel(float size = 1.0, unsigned int detail = 10);
    118119};
    119120
Note: See TracChangeset for help on using the changeset viewer.