Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3953 in orxonox.OLD for orxonox/branches/physics/src/lib


Ignore:
Timestamp:
Apr 25, 2005, 9:29:41 AM (19 years ago)
Author:
patrick
Message:

orxonox/branches/physics: merged with trunk - with command svn merge -r 3866:HEAD

Location:
orxonox/branches/physics/src/lib
Files:
5 deleted
12 edited

Legend:

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

    r3658 r3953  
    44AM_CXXFLAGS+=-I$(MAINSRCDIR)/story_entities
    55AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib
     6AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/coord
    67AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/data
    78AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics
    89AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/importer
     10AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/gui
    911AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/lang
    1012AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/util
     
    1517AM_CXXFLAGS+=-I$(MAINSRCDIR)/glmenu
    1618AM_CXXFLAGS+=-I$(MAINSRCDIR)/ai
     19AM_CXXFLAGS+=-I$(MAINSRCDIR)/util
     20AM_CXXFLAGS+=-I$(MAINSRCDIR)/util/animation
     21AM_CXXFLAGS+=-I$(MAINSRCDIR)/util/common
    1722
    1823
     
    3439                  $(MAINSRCDIR)/lib/lang/base_object.cc \
    3540                  $(MAINSRCDIR)/lib/math/vector.cc \
    36                   $(MAINSRCDIR)/lib/util/resource_manager.cc
     41                  $(MAINSRCDIR)/util/resource_manager.cc \
     42                  $(MAINSRCDIR)/lib/graphics/text_engine.cc \
     43                  $(MAINSRCDIR)/lib/coord/p_node.cc \
     44                  $(MAINSRCDIR)/lib/coord/null_parent.cc
    3745
    3846noinst_HEADERS= framework.h \
  • orxonox/branches/physics/src/lib/graphics/importer/Makefile.in

    r3789 r3953  
    5757        array.$(OBJEXT) material.$(OBJEXT) texture.$(OBJEXT) \
    5858        graphics_engine.$(OBJEXT) base_object.$(OBJEXT) \
    59         vector.$(OBJEXT) resource_manager.$(OBJEXT)
     59        vector.$(OBJEXT) resource_manager.$(OBJEXT) \
     60        text_engine.$(OBJEXT) p_node.$(OBJEXT) null_parent.$(OBJEXT)
    6061importer_OBJECTS = $(am_importer_OBJECTS)
    6162importer_LDADD = $(LDADD)
     
    6869@AMDEP_TRUE@    ./$(DEPDIR)/graphics_engine.Po \
    6970@AMDEP_TRUE@    ./$(DEPDIR)/material.Po ./$(DEPDIR)/model.Po \
    70 @AMDEP_TRUE@    ./$(DEPDIR)/objModel.Po \
     71@AMDEP_TRUE@    ./$(DEPDIR)/null_parent.Po ./$(DEPDIR)/objModel.Po \
     72@AMDEP_TRUE@    ./$(DEPDIR)/p_node.Po \
    7173@AMDEP_TRUE@    ./$(DEPDIR)/primitive_model.Po \
    7274@AMDEP_TRUE@    ./$(DEPDIR)/resource_manager.Po \
    73 @AMDEP_TRUE@    ./$(DEPDIR)/texture.Po ./$(DEPDIR)/vector.Po \
    74 @AMDEP_TRUE@    ./$(DEPDIR)/windowHandler.Po
     75@AMDEP_TRUE@    ./$(DEPDIR)/text_engine.Po ./$(DEPDIR)/texture.Po \
     76@AMDEP_TRUE@    ./$(DEPDIR)/vector.Po ./$(DEPDIR)/windowHandler.Po
    7577CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
    7678        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
     
    194196target_vendor = @target_vendor@
    195197MAINSRCDIR = ../../..
    196 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
     198AM_CXXFLAGS = -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/coord -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/graphics -I$(MAINSRCDIR)/lib/graphics/importer -I$(MAINSRCDIR)/lib/gui -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 -I$(MAINSRCDIR)/util -I$(MAINSRCDIR)/util/animation -I$(MAINSRCDIR)/util/common
    197199AM_LDFLAGS = $(MWINDOWS)
    198200importer_SOURCES = framework.cc \
     
    207209                  $(MAINSRCDIR)/lib/lang/base_object.cc \
    208210                  $(MAINSRCDIR)/lib/math/vector.cc \
    209                   $(MAINSRCDIR)/lib/util/resource_manager.cc
     211                  $(MAINSRCDIR)/util/resource_manager.cc \
     212                  $(MAINSRCDIR)/lib/graphics/text_engine.cc \
     213                  $(MAINSRCDIR)/lib/coord/p_node.cc \
     214                  $(MAINSRCDIR)/lib/coord/null_parent.cc
    210215
    211216noinst_HEADERS = framework.h \
     
    290295@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@
    291296@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/model.Po@am__quote@
     297@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/null_parent.Po@am__quote@
    292298@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/objModel.Po@am__quote@
     299@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/p_node.Po@am__quote@
    293300@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/primitive_model.Po@am__quote@
    294301@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resource_manager.Po@am__quote@
     302@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text_engine.Po@am__quote@
    295303@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/texture.Po@am__quote@
    296304@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector.Po@am__quote@
     
    361369@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o vector.obj `if test -f '$(MAINSRCDIR)/lib/math/vector.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/math/vector.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/math/vector.cc'; fi`
    362370
    363 resource_manager.o: $(MAINSRCDIR)/lib/util/resource_manager.cc
    364 @am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT resource_manager.o -MD -MP -MF "$(DEPDIR)/resource_manager.Tpo" -c -o resource_manager.o `test -f '$(MAINSRCDIR)/lib/util/resource_manager.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/util/resource_manager.cc; \
     371resource_manager.o: $(MAINSRCDIR)/util/resource_manager.cc
     372@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT resource_manager.o -MD -MP -MF "$(DEPDIR)/resource_manager.Tpo" -c -o resource_manager.o `test -f '$(MAINSRCDIR)/util/resource_manager.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/util/resource_manager.cc; \
    365373@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/resource_manager.Tpo" "$(DEPDIR)/resource_manager.Po"; else rm -f "$(DEPDIR)/resource_manager.Tpo"; exit 1; fi
    366 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/lib/util/resource_manager.cc' object='resource_manager.o' libtool=no @AMDEPBACKSLASH@
     374@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/util/resource_manager.cc' object='resource_manager.o' libtool=no @AMDEPBACKSLASH@
    367375@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/resource_manager.Po' tmpdepfile='$(DEPDIR)/resource_manager.TPo' @AMDEPBACKSLASH@
    368376@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    369 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o resource_manager.o `test -f '$(MAINSRCDIR)/lib/util/resource_manager.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/util/resource_manager.cc
    370 
    371 resource_manager.obj: $(MAINSRCDIR)/lib/util/resource_manager.cc
    372 @am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT resource_manager.obj -MD -MP -MF "$(DEPDIR)/resource_manager.Tpo" -c -o resource_manager.obj `if test -f '$(MAINSRCDIR)/lib/util/resource_manager.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/util/resource_manager.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/util/resource_manager.cc'; fi`; \
     377@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o resource_manager.o `test -f '$(MAINSRCDIR)/util/resource_manager.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/util/resource_manager.cc
     378
     379resource_manager.obj: $(MAINSRCDIR)/util/resource_manager.cc
     380@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT resource_manager.obj -MD -MP -MF "$(DEPDIR)/resource_manager.Tpo" -c -o resource_manager.obj `if test -f '$(MAINSRCDIR)/util/resource_manager.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/util/resource_manager.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/util/resource_manager.cc'; fi`; \
    373381@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/resource_manager.Tpo" "$(DEPDIR)/resource_manager.Po"; else rm -f "$(DEPDIR)/resource_manager.Tpo"; exit 1; fi
    374 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/lib/util/resource_manager.cc' object='resource_manager.obj' libtool=no @AMDEPBACKSLASH@
     382@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/util/resource_manager.cc' object='resource_manager.obj' libtool=no @AMDEPBACKSLASH@
    375383@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/resource_manager.Po' tmpdepfile='$(DEPDIR)/resource_manager.TPo' @AMDEPBACKSLASH@
    376384@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    377 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o resource_manager.obj `if test -f '$(MAINSRCDIR)/lib/util/resource_manager.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/util/resource_manager.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/util/resource_manager.cc'; fi`
     385@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o resource_manager.obj `if test -f '$(MAINSRCDIR)/util/resource_manager.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/util/resource_manager.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/util/resource_manager.cc'; fi`
     386
     387text_engine.o: $(MAINSRCDIR)/lib/graphics/text_engine.cc
     388@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT text_engine.o -MD -MP -MF "$(DEPDIR)/text_engine.Tpo" -c -o text_engine.o `test -f '$(MAINSRCDIR)/lib/graphics/text_engine.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/graphics/text_engine.cc; \
     389@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/text_engine.Tpo" "$(DEPDIR)/text_engine.Po"; else rm -f "$(DEPDIR)/text_engine.Tpo"; exit 1; fi
     390@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/lib/graphics/text_engine.cc' object='text_engine.o' libtool=no @AMDEPBACKSLASH@
     391@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/text_engine.Po' tmpdepfile='$(DEPDIR)/text_engine.TPo' @AMDEPBACKSLASH@
     392@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     393@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o text_engine.o `test -f '$(MAINSRCDIR)/lib/graphics/text_engine.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/graphics/text_engine.cc
     394
     395text_engine.obj: $(MAINSRCDIR)/lib/graphics/text_engine.cc
     396@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT text_engine.obj -MD -MP -MF "$(DEPDIR)/text_engine.Tpo" -c -o text_engine.obj `if test -f '$(MAINSRCDIR)/lib/graphics/text_engine.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/graphics/text_engine.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/graphics/text_engine.cc'; fi`; \
     397@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/text_engine.Tpo" "$(DEPDIR)/text_engine.Po"; else rm -f "$(DEPDIR)/text_engine.Tpo"; exit 1; fi
     398@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/lib/graphics/text_engine.cc' object='text_engine.obj' libtool=no @AMDEPBACKSLASH@
     399@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/text_engine.Po' tmpdepfile='$(DEPDIR)/text_engine.TPo' @AMDEPBACKSLASH@
     400@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     401@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o text_engine.obj `if test -f '$(MAINSRCDIR)/lib/graphics/text_engine.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/graphics/text_engine.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/graphics/text_engine.cc'; fi`
     402
     403p_node.o: $(MAINSRCDIR)/lib/coord/p_node.cc
     404@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT p_node.o -MD -MP -MF "$(DEPDIR)/p_node.Tpo" -c -o p_node.o `test -f '$(MAINSRCDIR)/lib/coord/p_node.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/coord/p_node.cc; \
     405@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/p_node.Tpo" "$(DEPDIR)/p_node.Po"; else rm -f "$(DEPDIR)/p_node.Tpo"; exit 1; fi
     406@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/lib/coord/p_node.cc' object='p_node.o' libtool=no @AMDEPBACKSLASH@
     407@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/p_node.Po' tmpdepfile='$(DEPDIR)/p_node.TPo' @AMDEPBACKSLASH@
     408@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     409@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o p_node.o `test -f '$(MAINSRCDIR)/lib/coord/p_node.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/coord/p_node.cc
     410
     411p_node.obj: $(MAINSRCDIR)/lib/coord/p_node.cc
     412@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT p_node.obj -MD -MP -MF "$(DEPDIR)/p_node.Tpo" -c -o p_node.obj `if test -f '$(MAINSRCDIR)/lib/coord/p_node.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/coord/p_node.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/coord/p_node.cc'; fi`; \
     413@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/p_node.Tpo" "$(DEPDIR)/p_node.Po"; else rm -f "$(DEPDIR)/p_node.Tpo"; exit 1; fi
     414@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/lib/coord/p_node.cc' object='p_node.obj' libtool=no @AMDEPBACKSLASH@
     415@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/p_node.Po' tmpdepfile='$(DEPDIR)/p_node.TPo' @AMDEPBACKSLASH@
     416@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     417@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o p_node.obj `if test -f '$(MAINSRCDIR)/lib/coord/p_node.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/coord/p_node.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/coord/p_node.cc'; fi`
     418
     419null_parent.o: $(MAINSRCDIR)/lib/coord/null_parent.cc
     420@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT null_parent.o -MD -MP -MF "$(DEPDIR)/null_parent.Tpo" -c -o null_parent.o `test -f '$(MAINSRCDIR)/lib/coord/null_parent.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/coord/null_parent.cc; \
     421@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/null_parent.Tpo" "$(DEPDIR)/null_parent.Po"; else rm -f "$(DEPDIR)/null_parent.Tpo"; exit 1; fi
     422@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/lib/coord/null_parent.cc' object='null_parent.o' libtool=no @AMDEPBACKSLASH@
     423@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/null_parent.Po' tmpdepfile='$(DEPDIR)/null_parent.TPo' @AMDEPBACKSLASH@
     424@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     425@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o null_parent.o `test -f '$(MAINSRCDIR)/lib/coord/null_parent.cc' || echo '$(srcdir)/'`$(MAINSRCDIR)/lib/coord/null_parent.cc
     426
     427null_parent.obj: $(MAINSRCDIR)/lib/coord/null_parent.cc
     428@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT null_parent.obj -MD -MP -MF "$(DEPDIR)/null_parent.Tpo" -c -o null_parent.obj `if test -f '$(MAINSRCDIR)/lib/coord/null_parent.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/coord/null_parent.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/coord/null_parent.cc'; fi`; \
     429@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/null_parent.Tpo" "$(DEPDIR)/null_parent.Po"; else rm -f "$(DEPDIR)/null_parent.Tpo"; exit 1; fi
     430@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='$(MAINSRCDIR)/lib/coord/null_parent.cc' object='null_parent.obj' libtool=no @AMDEPBACKSLASH@
     431@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/null_parent.Po' tmpdepfile='$(DEPDIR)/null_parent.TPo' @AMDEPBACKSLASH@
     432@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     433@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o null_parent.obj `if test -f '$(MAINSRCDIR)/lib/coord/null_parent.cc'; then $(CYGPATH_W) '$(MAINSRCDIR)/lib/coord/null_parent.cc'; else $(CYGPATH_W) '$(srcdir)/$(MAINSRCDIR)/lib/coord/null_parent.cc'; fi`
    378434uninstall-info-am:
    379435
  • orxonox/branches/physics/src/lib/graphics/importer/material.cc

    r3803 r3953  
    3434   \param mtlName Name of the Material to be added to the Material List
    3535*/
    36 Material::Material (char* mtlName)
     36Material::Material (const char* mtlName)
    3737{
    3838   PRINTF(4)("initializing new Material.\n");
    39   this->nextMat = NULL;
    40   this->name ="";
     39  this->name = NULL;
    4140  this->setIllum(3);
    4241  this->setDiffuse(0,0,0);
     
    5554  this->specularTextureSet = false;
    5655
    57   if (mtlName)
    58     this->setName (mtlName);
    59   else
    60     this->setName("");
     56  this->setName(mtlName);
    6157}
    6258
     
    7167  if (this->diffuseTexture)
    7268    ResourceManager::getInstance()->unload(this->diffuseTexture);
    73   if (this->nextMat)
    74     delete this->nextMat;
    75 }
    76 
    77 /**
    78    \brief adds a new Material to the List.
    79    this Function will append a new Material to the end of a Material List.
    80    \param mtlName The name of the Material to be added.
    81 */
    82 Material* Material::addMaterial(char* mtlName)
    83 {
    84   PRINTF(4)("adding Material %s.\n", mtlName);
    85    Material* tmpMat = this;
    86   while (tmpMat->nextMat != NULL)
    87     {
    88       tmpMat = tmpMat->nextMat;
    89     }
    90   tmpMat->nextMat = new Material(mtlName);
    91   return tmpMat->nextMat;
    92  
    93 }
    94 
    95 /**
    96    \brief Search for a Material called mtlName
    97    \param mtlName the Name of the Material to search for
    98    \returns Material named mtlName if it is found. NULL otherwise.
    99 */
    100 Material* Material::search(char* mtlName)
    101 {
    102   PRINTF(5)("Searching for material %s", mtlName);
    103   Material* searcher = this;
    104   while (searcher != NULL)
    105     {
    106       PRINT(5)(".");
    107       if (!strcmp (searcher->getName(), mtlName))
    108         {
    109           PRINT(5)("found.\n");
    110           return searcher;
    111         }
    112       searcher = searcher->nextMat;
    113     }
    114   PRINT(2)("material %s not found\n", mtlName);
    115   return NULL;
    11669}
    11770
     
    168121   \param mtlName the Name of the Material to be set.
    169122*/
    170 void Material::setName (char* mtlName)
    171 {
    172   PRINTF(4)("setting Material Name to %s.\n", this->name);
    173   this->name = new char [strlen(mtlName)+1];
    174   strcpy(this->name, mtlName);
     123void Material::setName (const char* mtlName)
     124{
     125  if (this->name)
     126    delete this->name;
     127  if (mtlName)
     128    {
     129      this->name = new char [strlen(mtlName)+1];
     130      strcpy(this->name, mtlName);
     131    }
     132  else
     133    {
     134      this->name = new char[2];
     135      strcpy(this->name, "");
     136    }
    175137}
    176138
  • orxonox/branches/physics/src/lib/graphics/importer/material.h

    r3803 r3953  
    1414#endif /* HAVE_CONFIG_H */
    1515
     16#ifndef NULL
     17#define NULL 0
     18#endif
     19
    1620// FORWARD DEFINITIONS //
    1721class Texture;
     
    2226{
    2327 public:
    24   Material (char* mtlName = "");
    25   Material* addMaterial(char* mtlName);
     28  Material (const char* mtlName = NULL);
    2629  ~Material ();
    2730
    28   Material* search(char* mtlName);
    2931  bool select (void);
    3032
    31   void setName (char* mtlName);
     33  void setName (const char* mtlName);
    3234  char* getName (void);
    3335  void setIllum (int illum);
     
    7072  bool specularTextureSet;//!< Chekcs if the specular texture is Set.
    7173
    72   Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
    73 
    74 
    7574};
    7675#endif
  • orxonox/branches/physics/src/lib/graphics/importer/model.cc

    r3801 r3953  
    2323#include "array.h"
    2424#include "vector.h"
     25#include "list.h"
    2526
    2627using namespace std;
    2728
    28 /**
    29    \brief Creates a 3D-Model.
    30 
    31    This only initializes a 3D-Model, but does not cleanup the Faces.
    32 */
    33 Model::Model(void)
    34 {
    35   this->initialize();
    36 }
    37 
     29//////////////////
     30// DE-CONSTRUCT //
     31//////////////////
    3832/**
    3933   \brief Creates a 3D-Model. and assigns it a Name.
    4034*/
    41 Model::Model(char* modelName)
    42 {
    43   this->initialize();
     35Model::Model(const char* modelName, MODEL_TYPE type)
     36{
     37  PRINTF(4)("new 3D-Model is being created\n");
     38  this->name = NULL;
    4439  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 */
    52 Model::~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 */
    81 void 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 */
    94 void 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 */
    112 void 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(2)("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 */
    144 void 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 */
    165 int 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 */
    176 bool Model::initialize (void)
    177 {
    178   PRINTF(4)("new 3D-Model is being created\n");
    179 
    180   this->name = NULL;
     40  this->type = type;
     41
    18142  this->finalized = false;
    18243  // setting the start group;
     
    18748  this->initGroup (this->currentGroup);
    18849  this->scaleFactor = 1;
    189   this->material = new Material();
    19050
    19151  this->vertices = new Array();
     
    19353  this->normals = new Array();
    19454
    195   return true;
    196 }
    197 
     55  this->materialList = new tList<Material>;
     56
     57  if (this->type == MODEL_VERTEX_ARRAY)
     58    glEnableClientState(GL_VERTEX_ARRAY | GL_NORMAL_ARRAY | GL_TEXTURE_COORD_ARRAY);
     59}
     60
     61/**
     62   \brief deletes an Model.
     63
     64   Looks if any from model allocated space is still in use, and if so deleted it.
     65*/
     66Model::~Model(void)
     67{
     68  PRINTF(4)("Deleting Model ");
     69  if (this->name)
     70    {
     71      PRINT(4)("%s\n", this->name);
     72      delete []this->name;
     73    }
     74  else
     75      PRINT(4)("\n");
     76
     77  PRINTF(5)("Deleting display Lists.\n");
     78  Group* walker = this->firstGroup;
     79  while (walker != NULL)
     80    {
     81      glDeleteLists (walker->listNumber, 1);
     82      Group* delWalker = walker;
     83      walker = walker->next;
     84      delete delWalker;
     85    }
     86
     87  // deleting Arrays
     88  this->deleteArrays();
     89
     90  // deleting the MaterialList
     91  PRINTF(5)("Deleting Materials.\n");
     92  tIterator<Material>* tmpIt = this->materialList->getIterator();
     93  Material* material = tmpIt->nextElement();
     94  while(material)
     95    {
     96      delete material;
     97      material = tmpIt->nextElement();
     98    }
     99  delete tmpIt;
     100  delete materialList;
     101}
     102
     103/**
     104   \brief Finalizes an Object. This can be done outside of the Class.
     105*/
     106void Model::finalize(void)
     107{
     108  // this creates the display List.
     109  this->importToDisplayList();
     110 
     111
     112  // deletes everything we allocated.
     113  if (this->type == MODEL_DISPLAY_LIST)
     114    this->deleteArrays();
     115  this->cleanup();
     116
     117  this->finalized = true;
     118}
     119
     120//////////
     121// DRAW //
     122//////////
     123/**
     124   \brief Draws the Models of all Groups.
     125   It does this by just calling the Lists that must have been created earlier.
     126*/
     127void Model::draw (void) const
     128{
     129  PRINTF(4)("drawing the 3D-Models\n");
     130  Group* walker = this->firstGroup;
     131  while (walker != NULL)
     132    {
     133      PRINTF(5)("Drawing model %s\n", walker->name);
     134      glCallList (walker->listNumber);
     135      walker = walker->next;
     136    }
     137}
     138
     139/**
     140   \brief Draws the Model number groupNumber
     141   \param groupNumber The number of the group that will be displayed.
     142
     143   It does this by just calling the List that must have been created earlier.
     144*/
     145void Model::draw (int groupNumber) const
     146{
     147  if (groupNumber >= this->groupCount)
     148    {
     149      PRINTF(2)("You requested model number %i, but this File only contains of %i Models.\n", groupNumber-1, this->groupCount);
     150      return;
     151    }
     152  PRINTF(4)("drawing the requested 3D-Models if found.\n");
     153  Group* walker = this->firstGroup;
     154  int counter = 0;
     155  while (walker != NULL)
     156    {
     157      if (counter == groupNumber)
     158        {
     159          PRINTF(4)("Drawing model number %i named %s\n", counter, walker->name);
     160          glCallList (walker->listNumber);
     161          return;
     162        }
     163      ++counter;
     164      walker = walker->next;
     165    }
     166  PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->name);
     167  return;
     168
     169}
     170
     171/**
     172   \brief Draws the Model with a specific groupName
     173   \param groupName The name of the group that will be displayed.
     174
     175   It does this by just calling the List that must have been created earlier.
     176*/
     177void Model::draw (char* groupName) const
     178{
     179  PRINTF(4)("drawing the requested 3D-Models if found.\n");
     180  Group* walker = this->firstGroup;
     181  while (walker != NULL)
     182    {
     183      if (!strcmp(walker->name, groupName))
     184        {
     185          PRINTF(4)("Drawing model %s\n", walker->name);
     186          glCallList (walker->listNumber);
     187          return;
     188        }
     189      walker = walker->next;
     190    }
     191  PRINTF(2)("Model Named %s in %s not Found.\n", groupName, this->name);
     192  return;
     193}
     194
     195/**
     196   \returns Count of the Models in this File
     197*/
     198int Model::getGroupCount (void) const
     199{
     200  return this->groupCount;
     201}
     202
     203//////////
     204// INIT //
     205//////////
    198206/**
    199207   \brief sets a name to the Model
     
    204212  if (this->name)
    205213    delete this->name;
    206   this->name = new char[strlen(name)+1];
    207   strcpy(this->name, name);
    208 }
     214  if (name)
     215    {
     216      this->name = new char[strlen(name)+1];
     217      strcpy(this->name, name);
     218    }
     219  else
     220    this->name = NULL;
     221}
     222
    209223/**
    210224   \brief initializes a new Group model
     
    244258
    245259/**
    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 */
    249 bool Model::cleanup(void)
    250 {
    251   PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
    252 
     260   \brief deletes all the arrays
     261*/
     262bool Model::deleteArrays(void)
     263{
    253264  if (this->vertices)
    254265    delete this->vertices;
     
    257268  if (this->normals)
    258269    delete this->normals;
    259 
     270  this->vertices = NULL;
     271  this->vTexture = NULL;
     272  this->normals = NULL;
     273}
     274
     275/**
     276   \brief finalizes an Model.
     277   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.
     278*/
     279bool Model::cleanup(void)
     280{
     281  PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
    260282  this->cleanupGroup(this->firstGroup);
    261283  return true;
     
    299321      delete face->next;
    300322    }
    301      
    302 }
    303 
     323}
    304324
    305325/**
     
    316336}
    317337
     338//////////
     339// MESH //
     340//////////
     341/**
     342   \brief adds a new Material to the Material List
     343   \param material the Material to add
     344   \returns the added material
     345
     346   !! beware the Material will be deleted when the Model gets deleted
     347*/
     348Material* Model::addMaterial(Material* material)
     349{
     350  this->materialList->add(material);
     351  return material;
     352}
     353
     354/**
     355   \brief adds a new Material to the Material List
     356   \param material the name of the Material to add
     357   \returns the added material
     358*/
     359Material* Model::addMaterial(const char* materialName)
     360{
     361 
     362  Material* newMat = new Material();
     363  newMat->setName(materialName);
     364
     365  // adding material to the List of materials
     366  this->materialList->add(newMat); 
     367  return newMat;
     368}
     369
     370/**
     371   \brief finds a Material by its name and returns it
     372   \param materialName the Name of the material to search for.
     373   \returns the Material if found, NULL otherwise
     374*/
     375Material* Model::findMaterialByName(const char* materialName)
     376{
     377  tIterator<Material>* tmpIt = this->materialList->getIterator();
     378  Material* material = tmpIt->nextElement();
     379  while(material)
     380    {
     381      if (!strcmp(material->getName(), materialName))
     382        {
     383          delete tmpIt;
     384          return material;
     385        }
     386      material = tmpIt->nextElement();
     387    }
     388  delete tmpIt;
     389  return NULL;
     390}
     391
    318392/**
    319393   \brief parses a group String
     
    323397   With it you should be able to import .obj-files with more than one Models inside.
    324398*/
    325 bool Model::addGroup (char* groupString)
     399bool Model::addGroup (const char* groupString)
    326400{
    327401  PRINTF(5)("Read Group: %s.\n", groupString);
     
    339413    }
    340414  ++this->groupCount;
    341 
    342415}
    343416
     
    348421   If a vertex line is found this function will inject it into the vertex-Array
    349422*/
    350 bool Model::addVertex (char* vertexString)
     423bool Model::addVertex (const char* vertexString)
    351424{
    352425  float subbuffer1;
     
    366439   
    367440*/
    368 bool Model::addVertex(const float x, const float y, const float z)
     441bool Model::addVertex(float x, float y, float z)
    369442{
    370443  PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
     
    374447
    375448/**
     449   \brief parses a vertexNormal-String
     450   \param normalString The String that will be parsed.
     451
     452   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
     453*/
     454bool Model::addVertexNormal (const char* normalString)
     455{
     456  float subbuffer1;
     457  float subbuffer2;
     458  float subbuffer3;
     459  sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
     460  PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3);
     461  this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3);
     462  return true;
     463}
     464
     465/**
     466   \brief adds a VertexNormal.
     467   \param x The x coordinate of the Normal.
     468   \param y The y coordinate of the Normal.
     469   \param z The z coordinate of the Normal.
     470
     471   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
     472*/
     473bool Model::addVertexNormal(float x, float y, float z)
     474{
     475  PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
     476  this->normals->addEntry(x, y, z);
     477}
     478
     479/**
     480   \brief parses a vertexTextureCoordinate-String
     481   \param vTextureString The String that will be parsed.
     482
     483   If a vertexTextureCoordinate line is found,
     484   this function will inject it into the vertexTexture-Array
     485*/
     486bool Model::addVertexTexture (const char* vTextureString)
     487{
     488  float subbuffer1;
     489  float subbuffer2;
     490  sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2);
     491  PRINTF(5)("found vertex-Texture %f, %f\n", &subbuffer1, &subbuffer2);
     492  this->vTexture->addEntry(subbuffer1);
     493  this->vTexture->addEntry(subbuffer2);
     494  return true;
     495}
     496
     497/**
     498   \brief adds a Texture Coordinate
     499   \param u The u coordinate of the TextureCoordinate.
     500   \param v The y coordinate of the TextureCoordinate.
     501
     502   If a TextureCoordinate line is found this function will inject it into the TextureCoordinate-Array
     503*/
     504bool Model::addVertexTexture(float u, float v)
     505{
     506  PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
     507  this->vTexture->addEntry(u);
     508  this->vTexture->addEntry(v);
     509}
     510
     511/**
    376512   \brief parses a face-string
    377513   \param faceString The String that will be parsed.
     
    379515   If a face line is found this function will add it to the glList.
    380516*/
    381 bool Model::addFace (char* faceString)
     517bool Model::addFace (const char* faceString)
    382518{
    383519  if (this->currentGroup->faceCount >0)
     
    441577   \param type 0: vertex only, 1: vertex and normal, 2: vertex and Texture, 3 vertex, normal and texture
    442578*/
    443 bool Model::addFace(const float faceElemCount, int type, ...)
     579bool Model::addFace(int faceElemCount, VERTEX_FORMAT type, ...)
    444580{
    445581   if (this->currentGroup->faceCount > 0)
     
    472608
    473609/**
    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 */
    479 bool 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 */
    498 bool Model::addVertexNormal(const float x, const float y, const float z)
    499 {
    500   PRINTF(3)("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 */
    511 bool 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 */
    529 bool Model::addVertexTexture(const float u, const float v)
    530 {
    531   PRINTF(3)("found vertex-Texture %f, %f\n", u, v);
    532   this->vTexture->addEntry(u);
    533   this->vTexture->addEntry(v);
    534 }
    535 
    536 /**
    537610   \brief Function that selects a material, if changed in the obj file.
    538611   \param matString the Material that will be set.
    539612*/
    540 bool Model::addUseMtl (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   */     
     613bool Model::setMaterial(const char* matString)
     614{
    549615  if (this->currentGroup->faceCount > 0)
    550616    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
    551617  this->initFace (this->currentGroup->currentFace);
    552618 
    553   this->currentGroup->currentFace->material = material->search(matString);
     619  this->currentGroup->currentFace->material = this->findMaterialByName(matString);
    554620
    555621  if (this->currentGroup->faceCount == 0)
     
    561627   \param mtl the Material that will be set.
    562628*/
    563 bool Model::addUseMtl (Material* mtl)
     629bool Model::setMaterial(Material* mtl)
    564630{
    565631  if (this->currentGroup->faceCount > 0)
     
    574640
    575641/**
     642   \brief A routine that is able to create normals.
     643
     644   The algorithm does the following:
     645   1. It calculates creates Vectors for each normale, and sets them to zero.
     646   2. It then Walks through a) all the Groups b) all the Faces c) all the FaceElements
     647   3. It searches for a points two neighbours per Face, takes Vecotrs to them calculates FaceNormals and adds it to the Points Normal.
     648   4. It goes through all the normale-Points and calculates the VertexNormale and includes it in the normals-Array.
     649*/
     650bool Model::buildVertexNormals ()
     651
     652  PRINTF(4)("Normals are being calculated.\n");
     653
     654  Vector* normArray = new Vector [vertices->getCount()/3];
     655  for (int i=0; i<vertices->getCount()/3;i++)
     656    normArray[i] = Vector(.0,.0,.0);
     657 
     658  int firstTouch;
     659  int secondTouch;
     660  Vector prevV;
     661  Vector nextV;
     662  Vector curV;
     663
     664  Group* tmpGroup = firstGroup;
     665  while (tmpGroup)
     666    {
     667      Face* tmpFace = tmpGroup->firstFace;
     668      while (tmpFace)
     669        {
     670          if (tmpFace->firstElem)
     671            {
     672              FaceElement* firstElem = tmpFace->firstElem;
     673              FaceElement* prevElem;
     674              FaceElement* curElem = firstElem;
     675              FaceElement* nextElem;
     676              FaceElement* lastElem;
     677              // 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.
     678              while (curElem)
     679                {
     680                  prevElem = curElem;
     681                  curElem = curElem->next;
     682                }
     683              lastElem = prevElem;
     684             
     685              curElem = firstElem;
     686              for (int j=0; j<tmpFace->vertexCount; j++)
     687                {
     688                  if (!(nextElem = curElem->next))
     689                    nextElem = firstElem;
     690                  curElem->normalNumber = curElem->vertexNumber;
     691                 
     692                  curV = Vector (vertices->getArray()[curElem->vertexNumber*3], vertices->getArray()[curElem->vertexNumber*3+1], vertices->getArray()[curElem->vertexNumber*3+2]);
     693                  prevV = Vector (vertices->getArray()[prevElem->vertexNumber*3], vertices->getArray()[prevElem->vertexNumber*3+1], vertices->getArray()[prevElem->vertexNumber*3+2]) - curV;
     694                  nextV = Vector (vertices->getArray()[nextElem->vertexNumber*3], vertices->getArray()[nextElem->vertexNumber*3+1], vertices->getArray()[nextElem->vertexNumber*3+2]) - curV;
     695                  normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
     696
     697                  prevElem = curElem;
     698                  curElem = curElem->next;
     699                }
     700            }
     701          tmpFace = tmpFace->next;
     702        }
     703      tmpGroup = tmpGroup->next;
     704    }
     705
     706  for (int i=0; i<vertices->getCount()/3;i++)
     707    {
     708      normArray[i].normalize();
     709      PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z);
     710     
     711      this->normals->addEntry(normArray[i].x, normArray[i].y, normArray[i].z);
     712
     713    }
     714  delete []normArray;
     715}
     716
     717////////////
     718// openGL //
     719////////////
     720/**
    576721   \brief reads and includes the Faces/Materials into the openGL state Machine
    577722*/
    578 bool Model::importToGL (void)
    579 {
    580 
     723bool Model::importToDisplayList(void)
     724{
    581725  // finalize the Arrays
    582726  this->vertices->finalizeArray();
     
    667811
    668812/**
     813   \brief reads and includes the Faces/Materials into the openGL state Machine
     814*/
     815bool Model::importToVertexArray(void)
     816{
     817  // finalize the Arrays
     818  this->vertices->finalizeArray();
     819  this->vTexture->finalizeArray();
     820  if (normals->getCount() == 0) // vertices-Array must be built for this
     821    this->buildVertexNormals();
     822  this->normals->finalizeArray();
     823
     824  this->currentGroup = this->firstGroup;
     825  glVertexPointer(3, GL_FLOAT, 0, this->vertices->getArray());
     826  glNormalPointer(3, 0, this->normals->getArray());
     827  glTexCoordPointer(2, GL_FLOAT, 0, this->vTexture->getArray());
     828
     829}
     830
     831
     832
     833/**
    669834   \brief Adds a Face-element (one vertex of a face) with all its information.
    670835   \param elem The FaceElement to add to the OpenGL-environment.
     
    688853
    689854}
    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 */
    700 bool 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 
    769855
    770856/**
     
    833919  */
    834920
    835   this->addFace (4, 3, 1,1,1, 2,2,2, 4,4,3, 3,3,4);
    836   this->addFace (4, 3, 3,3,5, 4,4,6, 6,6,7, 5,5,8);
    837   this->addFace (4, 3, 5,5,9, 6,6,10, 8,8,11, 7,7,12);
    838   this->addFace (4, 3, 7,7,13, 8,8,14, 2,10,15, 1,9,16);
    839   this->addFace (4, 3, 2,2,17, 8,11,18, 6,12,19, 4,4,20);
    840   this->addFace (4, 3, 7,13,21, 1,1,22, 3,3,23, 5,14,24);
    841 
    842 }
     921  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,1,1, 2,2,2, 4,4,3, 3,3,4);
     922  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 3,3,5, 4,4,6, 6,6,7, 5,5,8);
     923  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 5,5,9, 6,6,10, 8,8,11, 7,7,12);
     924  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,7,13, 8,8,14, 2,10,15, 1,9,16);
     925  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,2,17, 8,11,18, 6,12,19, 4,4,20);
     926  this->addFace (4, VERTEX_TEXCOORD_NORMAL, 7,13,21, 1,1,22, 3,3,23, 5,14,24);
     927
     928}
  • orxonox/branches/physics/src/lib/graphics/importer/model.h

    r3801 r3953  
    88
    99#include "material.h"
     10#include "glincl.h"
    1011
    1112// FORWARD DEFINITION //
    1213class Array;
    1314class Vector;
     15template<class T> class tList;
    1416
    15 using namespace std;
     17//! an enumerator fot the different Model Types.
     18/**
     19   MODEL_DISPLAY_LIST means, that a DisplayList will be built out of the model. This model will be STATIC, meaning it cannot be changed after initialisation.
     20   MODEL_VERTEX_ARRAY means, that a VertexArray will be built out of the model. This moel will be DYNAMIX, meaning that one can change the properties from outside of the model.
     21*/
     22typedef enum MODEL_TYPE {MODEL_DISPLAY_LIST,
     23                         MODEL_VERTEX_ARRAY};
     24
    1625
    1726// definition of different modes for setting up Faces
     
    1928#define NORMAL 1       //!< If Faces are created WITH Normals (otherwise autocalculate)
    2029#define TEXCOORD 2     //!< If Faces are created WITH TextureCoordinate
     30//! an enumerator for VERTEX_FORMAT
     31typedef enum VERTEX_FORMAT {VERTEX_ONLY = VERTEX,
     32                    VERTEX_NORMAL = NORMAL,
     33                    VERTEX_TEXCOORD = TEXCOORD,
     34                    VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD};
    2135
    2236//! Class that handles 3D-Models. it can also read them in and display them.
    2337class Model
    2438{
    25  public:
    26   Model(void);
    27   Model(char* modelName);
    28   virtual ~Model(void);
    29 
    30   void setName(const char* name);
    31  
    32   void draw(void) const;
    33   void draw(int groupNumber) const;
    34   void draw(char* groupName) const;
    35   int getGroupCount() const;
    36 
    37  protected:
    38   char* name;            //!< This is the name of the Model.
    39   bool finalized;        //!< Sets the Object to be finalized.
    40  
     39 private:
     40  /////////////
     41  // structs //
     42  /////////////
    4143  //! This is the placeholder of one Vertex beloning to a Face.
    4244  struct FaceElement
     
    6466    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
    6567
    66     unsigned int listNumber;//!< The number of the GL-List this Group gets.
     68    GLubyte* indices;   //!< The indices of the Groups. Needed for vertex-arrays
     69    GLuint listNumber;  //!< The number of the GL-List this Group gets.
    6770    Face* firstFace;    //!< The first Face in this group.
    6871    Face* currentFace;  //!< The current Face in this Group (the one we are currently working with.)
     
    7376  };
    7477
     78  char* name;            //!< This is the name of the Model.
     79  MODEL_TYPE type;
     80  bool finalized;        //!< Sets the Object to be finalized.
    7581
    7682  Array* vertices;      //!< The Array that handles the Vertices.
     
    7985  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
    8086
    81  
    8287  Group* firstGroup;    //!< The first of all groups.
    8388  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
    8489  int groupCount;       //!< The Count of Groups.
    8590
    86   Material* material;   //!< Initial pointer to the Material. This can hold many materials, because Material can be added with Material::addMaterial(..)
    87   float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
     91  tList<Material>* materialList;
     92 
    8893
    89   bool initialize(void);
    9094  bool initGroup(Group* group);
    9195  bool initFace (Face* face);
     96
     97  bool buildVertexNormals(void);
     98
     99  bool importToDisplayList(void);
     100  bool addGLElement(FaceElement* elem);
     101
     102  bool importToVertexArray(void);
     103
     104  bool deleteArrays(void);
    92105  bool cleanup(void);
    93106  bool cleanupGroup(Group* group);
     
    95108  bool cleanupFaceElement(FaceElement* faceElem);
    96109
    97  public:
    98   bool addGroup(char* groupString);
    99   bool addVertex(char* vertexString);
    100   bool addVertex(const float x, const float y, const float z);
    101   bool addFace(char* faceString);
    102   bool addFace(const float faceElemCount, int type, ...);
    103   bool addVertexNormal(char* normalString);
    104   bool addVertexNormal(const float x, const float y, const float z);
    105   bool addVertexTexture(char* vTextureString);
    106   bool addVertexTexture(const float u, const float v);
    107   bool addUseMtl(char* mtlString);
    108   bool addUseMtl(Material* mtl);
    109   void finalize(void);
    110110
    111111 protected:
    112   bool importToGL(void);
    113   bool addGLElement(FaceElement* elem);
     112  float scaleFactor;    //!< The Factor with which the Model should be scaled. \todo maybe one wants to scale the Model after Initialisation
    114113
    115   bool buildVertexNormals(void);
     114  Material* findMaterialByName(const char* materialName);
    116115
    117116  void cubeModel(void);
     117
     118 public:
     119  Model(const char* modelName = NULL, MODEL_TYPE type = MODEL_DISPLAY_LIST);
     120  virtual ~Model(void);
     121
     122  void setName(const char* name);
     123  inline const char* getName() {return this->name;}
     124 
     125  void draw(void) const;
     126  void draw(int groupNumber) const;
     127  void draw(char* groupName) const;
     128  int getGroupCount() const;
     129
     130  Material* addMaterial(Material* material);
     131  Material* addMaterial(const char* materialName);
     132
     133  bool addGroup(const char* groupString);
     134  bool addVertex(const char* vertexString);
     135  bool addVertex(float x, float y, float z);
     136  bool addFace(const char* faceString);
     137  bool addFace(int faceElemCount, VERTEX_FORMAT type, ...);
     138  bool addVertexNormal(const char* normalString);
     139  bool addVertexNormal(float x, float y, float z);
     140  bool addVertexTexture(const char* vTextureString);
     141  bool addVertexTexture(float u, float v);
     142  bool setMaterial(const char* mtlString);
     143  bool setMaterial(Material* mtl);
     144  void finalize(void);
    118145};
    119146
  • orxonox/branches/physics/src/lib/graphics/importer/objModel.cc

    r3658 r3953  
    1818#include "objModel.h"
    1919
    20 #include <fstream>
     20#include <stdio.h>
     21#include <string.h>
     22#include <stdlib.h>
     23
     24#define PARSELINELENGTH 8192
    2125
    2226#include "debug.h"
     27#include "compiler.h"
    2328
    2429/**
     
    2732   \param scaling The factor that the model will be scaled with.
    2833*/
    29 OBJModel::OBJModel(char* fileName, float scaling)
     34OBJModel::OBJModel(const char* fileName, float scaling) : Model(fileName)
    3035{
    3136  this->initializeOBJ();
     
    3439  this->importFile (fileName);
    3540
    36   this->importToGL ();
    37 
    38   this->cleanup();
     41  this->finalize();
    3942}
    4043
     
    6366  this->objFileName = NULL;
    6467  this->mtlFileName = NULL;
    65 
    66   this->initialize();
    6768}
    6869
     
    7172   \param fileName The file to import
    7273*/
    73 bool OBJModel::importFile (char* fileName)
     74bool OBJModel::importFile (const char* fileName)
    7475{
    7576  PRINTF(4)("preparing to read in file: %s\n", fileName);
     
    8384  char pathSplitter='/';
    8485#endif /* __WIN32__ */
    85   char* tmpName = fileName;
     86  char* tmpName;
     87  strcpy(tmpName, fileName);
    8688  if (tmpName[0] == pathSplitter)
    8789    tmpName++;
     
    100102 
    101103  this->setName(name);
    102   if (this->material)
    103     this->material->addTexturePath(this->objPath);
     104
    104105  this->objFileName = new char[strlen(name)+1];
    105106  strcpy (this->objFileName, name);
     
    120121  strcat(fileName, this->objFileName);
    121122
    122   ifstream* OBJ_FILE = new ifstream(fileName);
    123   if (OBJ_FILE->fail())
    124     {
    125       PRINTF(1)("unable to open .OBJ file: %s\n Loading cube-Model instead.\n", fileName);
    126       cubeModel();
    127       OBJ_FILE->close();
    128       delete []fileName;
    129       delete OBJ_FILE;
     123  FILE* stream;
     124  if( (stream = fopen (fileName, "r")) == NULL)
     125    {
     126      printf("IniParser could not open %s\n", fileName);
    130127      return false;
    131128    }
    132   PRINTF(4)("Reading from opened file %s\n", fileName);
    133   char Buffer[10000];
    134   while(!OBJ_FILE->eof())
    135     {
    136       OBJ_FILE->getline(Buffer, 10000);
    137       PRINTF(5)("Read input line: %s\n", Buffer);
     129
     130  char buffer[PARSELINELENGTH];
     131  while(fgets(buffer, PARSELINELENGTH, stream))
     132    {
     133      // line termiated with \0 not \n
     134      if (buffer[strlen(buffer)-1] == '\n')
     135        buffer[strlen(buffer)-1] = '\0';
     136
     137      // case vertice
     138      if (!strncmp(buffer, "v ", 2))
     139        {
     140          this->addVertex(buffer+2);
     141        }
     142
     143      // case face
     144      else if (!strncmp(buffer, "f ", 2))
     145        {
     146          this->addFace (buffer+2);
     147        }
    138148     
    139 
    140       // case vertice
    141       if (!strncmp(Buffer, "v ", 2))
    142         {
    143           this->addVertex(Buffer+2);
    144         }
    145 
    146       // case face
    147       else if (!strncmp(Buffer, "f ", 2))
    148         {
    149           this->addFace (Buffer+2);
    150         }
    151      
    152       else if (!strncmp(Buffer, "mtllib ", 7))
    153         {
    154           this->readMtlLib (Buffer+7);
    155         }
    156 
    157       else if (!strncmp(Buffer, "usemtl ", 7))
    158         {
    159           this->addUseMtl (Buffer+7);
     149      else if (!strncmp(buffer, "mtllib ", 7))
     150        {
     151          this->readMtlLib (buffer+7);
     152        }
     153
     154      else if (!strncmp(buffer, "usemtl ", 7))
     155        {
     156          this->setMaterial (buffer+7);
    160157        }
    161158
    162159      // case VertexNormal
    163       else if (!strncmp(Buffer, "vn ", 3))
    164         {
    165           this->addVertexNormal(Buffer+3);
     160      else if (!strncmp(buffer, "vn ", 3))
     161        {
     162          this->addVertexNormal(buffer+3);
    166163        }
    167164     
    168165      // case VertexTextureCoordinate
    169       else if (!strncmp(Buffer, "vt ", 3))
    170         {
    171           this->addVertexTexture(Buffer+3);
     166      else if (!strncmp(buffer, "vt ", 3))
     167        {
     168          this->addVertexTexture(buffer+3);
    172169        }
    173170      // case group
    174       else if (!strncmp(Buffer, "g ", 2))
    175         {
    176           this->addGroup (Buffer+2);
    177         }
    178       else if (!strncmp(Buffer, "s ", 2)) //! \todo smoothing groups have to be implemented
    179         {
    180           PRINTF(2)("smoothing groups not supportet yet. line: %s\n", Buffer);
    181         }
    182     }
    183   OBJ_FILE->close();
    184   delete OBJ_FILE;
     171      else if (!strncmp(buffer, "g ", 2))
     172        {
     173          this->addGroup (buffer+2);
     174        }
     175      else if (!strncmp(buffer, "s ", 2)) //! \todo smoothing groups have to be implemented
     176        {
     177          PRINTF(2)("smoothing groups not supportet yet. line: %s\n", buffer);
     178        }
     179    }
     180  fclose (stream);
    185181  delete []fileName;
    186182  return true;
     
    196192
    197193*/
    198 bool OBJModel::readMtlLib (char* mtlFile)
     194bool OBJModel::readMtlLib (const char* mtlFile)
    199195{
    200196  this->mtlFileName = new char [strlen(mtlFile)+1];
     
    205201 
    206202
    207   PRINTF(4)("Opening mtlFile: %s\n", fileName);
    208 
    209   ifstream* MTL_FILE = new ifstream (fileName);
    210   if (MTL_FILE->fail())
    211     {
    212       PRINTF(2)("unable to open file: %s\n", fileName);
    213       MTL_FILE->close();
    214       delete []fileName;
    215       delete MTL_FILE;
     203  FILE* stream;
     204  if( (stream = fopen (fileName, "r")) == NULL)
     205    {
     206      printf("IniParser could not open %s\n", fileName);
    216207      return false;
    217208    }
    218   char Buffer[500];
    219   Material* tmpMat = material;
    220   while(!MTL_FILE->eof())
    221     {
    222       MTL_FILE->getline(Buffer, 500);
    223       PRINTF(5)("found line in mtlFile: %s\n", Buffer);
     209
     210  char buffer[PARSELINELENGTH];
     211  Material* tmpMat = NULL;
     212
     213  while(fgets(buffer, PARSELINELENGTH, stream))
     214    {
     215      PRINTF(5)("found line in mtlFile: %s\n", buffer);
     216
     217      // line termiated with \0 not \n
     218      if (buffer[strlen(buffer)-1] == '\n')
     219        buffer[strlen(buffer)-1] = '\0';
     220
     221      // create new Material
     222      if (!strncmp(buffer, "newmtl ", 7))
     223        {
     224          tmpMat = this->addMaterial(buffer+7);//tmpMat->addMaterial(buffer+7);
     225        }
     226      // setting a illumMode
     227      else if (!strncmp(buffer, "illum ", 6))
     228        {
     229          if (likely(tmpMat != NULL))
     230            tmpMat->setIllum(buffer+6);
     231
     232        }
     233      // setting Diffuse Color
     234      else if (!strncmp(buffer, "Kd ", 3))
     235        {
     236          if (likely(tmpMat != NULL))
     237            tmpMat->setDiffuse(buffer+3);
     238        }
     239      // setting Ambient Color
     240      else if (!strncmp(buffer, "Ka ", 3))
     241        {
     242          if (likely(tmpMat != NULL))
     243            tmpMat->setAmbient(buffer+3);
     244        }
     245      // setting Specular Color
     246      else if (!strncmp(buffer, "Ks ", 3))
     247        {
     248          if (likely(tmpMat != NULL))
     249            tmpMat->setSpecular(buffer+3);
     250        }
     251      // setting The Specular Shininess
     252      else if (!strncmp(buffer, "Ns ", 3))
     253        {
     254          if (likely(tmpMat != NULL))
     255            tmpMat->setShininess(buffer+3);
     256        }
     257      // setting up transparency
     258      else if (!strncmp(buffer, "d ", 2))
     259        {
     260          if (likely(tmpMat != NULL))
     261            tmpMat->setTransparency(buffer+2);
     262        }
     263      else if (!strncmp(buffer, "Tf ", 3))
     264        {
     265          if (likely(tmpMat != NULL))
     266            tmpMat->setTransparency(buffer+3);
     267        }
    224268     
    225 
    226       // create new Material
    227       if (!strncmp(Buffer, "newmtl ", 7))
    228         {
    229           tmpMat = tmpMat->addMaterial(Buffer+7);
    230           //      PRINTF(2)("%s, %p\n", tmpMat->getName(), tmpMat);
    231         }
    232       // setting a illumMode
    233       else if (!strncmp(Buffer, "illum ", 6))
    234         {
    235           tmpMat->setIllum(Buffer+6);
    236 
    237         }
    238       // setting Diffuse Color
    239       else if (!strncmp(Buffer, "Kd ", 3))
    240         {
    241           tmpMat->setDiffuse(Buffer+3);
    242         }
    243       // setting Ambient Color
    244       else if (!strncmp(Buffer, "Ka ", 3))
    245         {
    246           tmpMat->setAmbient(Buffer+3);
    247         }
    248       // setting Specular Color
    249       else if (!strncmp(Buffer, "Ks ", 3))
    250         {
    251           tmpMat->setSpecular(Buffer+3);
    252         }
    253       // setting The Specular Shininess
    254       else if (!strncmp(Buffer, "Ns ", 3))
    255         {
    256           tmpMat->setShininess(Buffer+3);
    257         }
    258       // setting up transparency
    259       else if (!strncmp(Buffer, "d ", 2))
    260         {
    261           tmpMat->setTransparency(Buffer+2);
    262         }
    263       else if (!strncmp(Buffer, "Tf ", 3))
    264         {
    265           tmpMat->setTransparency(Buffer+3);
    266         }
    267      
    268       else if (!strncmp(Buffer, "map_Kd ", 7))
    269         {
    270           tmpMat->setDiffuseMap(Buffer+7);
    271         }
    272       else if (!strncmp(Buffer, "map_Ka ", 7))
    273         {
    274           tmpMat->setAmbientMap(Buffer+7);
    275         }
    276       else if (!strncmp(Buffer, "map_Ks ", 7))
    277         {
    278           tmpMat->setSpecularMap(Buffer+7);
    279         }
    280       else if (!strncmp(Buffer, "bump ", 5))
    281         {
    282           tmpMat->setBump(Buffer+7);
     269      else if (!strncmp(buffer, "map_Kd ", 7))
     270        {
     271          if (likely(tmpMat != NULL))
     272            tmpMat->setDiffuseMap(buffer+7);
     273        }
     274      else if (!strncmp(buffer, "map_Ka ", 7))
     275        {
     276          if (likely(tmpMat != NULL))
     277            tmpMat->setAmbientMap(buffer+7);
     278        }
     279      else if (!strncmp(buffer, "map_Ks ", 7))
     280        {
     281          if (likely(tmpMat != NULL))
     282            tmpMat->setSpecularMap(buffer+7);
     283        }
     284      else if (!strncmp(buffer, "bump ", 5))
     285        {
     286          if (likely(tmpMat != NULL))
     287            tmpMat->setBump(buffer+7);
    283288        }
    284289     
    285290
    286291    }
    287   MTL_FILE->close();
     292  fclose(stream);
    288293  delete []fileName;
    289   delete MTL_FILE;
    290294  return true;
    291295}
  • orxonox/branches/physics/src/lib/graphics/importer/objModel.h

    r3655 r3953  
    1313{
    1414 public:
    15   OBJModel(char* fileName, float scaling = 1.0);
     15  OBJModel(const char* fileName, float scaling = 1.0);
    1616  virtual ~OBJModel();
    1717  void initializeOBJ(void);
     
    2424
    2525  ///// readin /////
    26   bool importFile (char* fileName);
     26  bool importFile (const char* fileName);
    2727  bool readFromObjFile (void);
    28   bool readMtlLib (char* matFile);
     28  bool readMtlLib (const char* matFile);
    2929};
    3030
  • orxonox/branches/physics/src/lib/graphics/importer/primitive_model.cc

    r3684 r3953  
    3333PrimitiveModel::PrimitiveModel(PRIMITIVE type, float size, unsigned int detail)
    3434{
    35   this->initialize();
    36 
    3735  switch (type)
    3836    {
     
    5452      break;
    5553    }
    56   this->importToGL ();
    57 
    58   this->cleanup();
     54  this->finalize();
    5955}
    6056
     
    123119            {
    124120              v1 = vertexCount+1;
    125               this->addFace(3, TEXCOORD, v1, v1, v3, v3, v4, v4);
     121              this->addFace(3, VERTEX_TEXCOORD, v1, v1, v3, v3, v4, v4);
    126122            }
    127123          else if (j == detail)
    128124            {
    129125              v3 = vertexCount+2;
    130               this->addFace(3, TEXCOORD, v1, v1, v2, v2, v3, v3);
     126              this->addFace(3, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3);
    131127            }
    132128          else
    133             this->addFace(4, TEXCOORD, v1, v1, v2, v2, v3, v3, v4, v4);
     129            this->addFace(4, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3, v4, v4);
    134130        }
    135131    }
     
    163159      p1 = 2*i+1;
    164160      p2 = 2*i+2;
    165       if (i <= detail);
    166161      p3 = 2*i+4;
    167162      p4 = 2*i+3;
    168163      // something is wrong here
    169       this->addFace(4, 0, p1, p2, p3, p4);
    170       this->addFace(3, 0, p4, p1, 2*detail+1);
    171       this->addFace(3, 0, p2, p3, 2*detail+2);
    172     }
    173   addFace(4,0, 2*detail-1, 2*detail, 2, 1);
    174   this->addFace(3, VERTEX, 1, 2*detail-1, 2*detail+1);
    175   this->addFace(3, VERTEX, 2*detail, 2, 2*detail+2);
     164      this->addFace(4, VERTEX_ONLY, p1, p2, p3, p4);
     165      this->addFace(3, VERTEX_ONLY, p4, p1, 2*detail+1);
     166      this->addFace(3, VERTEX_ONLY, p2, p3, 2*detail+2);
     167    }
     168  // caps
     169  this->addFace(4, VERTEX_ONLY, 2*detail-1, 2*detail, 2, 1);
     170  this->addFace(3, VERTEX_ONLY, 1, 2*detail-1, 2*detail+1);
     171  this->addFace(3, VERTEX_ONLY, 2*detail, 2, 2*detail+2);
    176172}
    177173
     
    207203      else
    208204        v2 = i+4;
    209       this->addFace(3, VERTEX, 1, v1, v2);
    210       this->addFace(3, VERTEX, 2, v1, v2);
     205      this->addFace(3, VERTEX_ONLY, 1, v1, v2);
     206      this->addFace(3, VERTEX_ONLY, 2, v1, v2);
    211207    }
    212208}
     
    238234        v3 = (i+1)*detail + (j+1);
    239235        v4 = i*detail + (j+1);
    240         this->addFace(4, TEXCOORD, v1, v1, v2, v2, v3, v3, v4, v4);
     236        this->addFace(4, VERTEX_TEXCOORD, v1, v1, v2, v2, v3, v3, v4, v4);
    241237      }
    242238}
  • orxonox/branches/physics/src/lib/graphics/importer/texture.cc

    r3863 r3953  
    2323   \brief Constructor for a Texture
    2424*/
    25 Texture::Texture(void)
    26 {
    27   this->pImage = new Image;
    28   this->pImage->data = NULL;
    29   this->map = NULL;
    30   this->texture = 0;
    31 }
    32 
    33 /**
    34    \brief Constructor for a Texture
    35 */
    3625Texture::Texture(const char* imageName)
    3726{
    38   this->pImage = new Image;
    39   this->pImage->data = NULL;
    40   this->map = NULL;
    4127  this->texture = 0;
    42   this->loadImage(imageName);
     28  if (imageName)
     29    this->loadImage(imageName);
    4330
    4431
     
    5037Texture::~Texture(void)
    5138{
    52   if (this->pImage->data)
    53     delete []this->pImage->data;
    54   delete pImage;
    5539  if (this->texture)
    5640    glDeleteTextures(1, &this->texture);
     
    7357/**
    7458   \brief Loads a Texture to the openGL-environment.
    75    \param pImage The Image to load to openGL
     59   \param surface the Image to load to openGL
     60   \returns The ID of the texture.
    7661*/
    77 bool Texture::loadTexToGL (Image* pImage)
     62GLuint Texture::loadTexToGL (SDL_Surface* surface)
    7863{
    7964  if (GraphicsEngine::texturesEnabled)
    8065    {
    8166      PRINTF(4)("Loading texture to OpenGL-Environment.\n");
    82       glGenTextures(1, &this->texture);
    83       glBindTexture(GL_TEXTURE_2D, this->texture);
    84       /* not Working, and not needed.
    85          glTexImage2D( GL_TEXTURE_2D, 0, 3, width,
    86          height, 0, GL_BGR,
    87          GL_UNSIGNED_BYTE, map->pixels );
    88       */
    89       gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImage->width, pImage->height, pImage->format, GL_UNSIGNED_BYTE, pImage->data);
     67
     68      GLuint texture;
     69      int w, h;
     70      SDL_Surface *image;
     71      SDL_Rect area;
     72      Uint32 saved_flags;
     73      Uint8  saved_alpha;
    9074     
    91       glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
    92       glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);     
     75      w = surface->w;
     76      h = surface->h;
     77     
     78      image = SDL_CreateRGBSurface(SDL_SWSURFACE,
     79                                   w, h,
     80                                   32,
     81#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
     82                                   0x000000FF,
     83                                   0x0000FF00,
     84                                   0x00FF0000,
     85                                   0xFF000000
     86#else
     87                                   0xFF000000,
     88                                   0x00FF0000,
     89                                   0x0000FF00,
     90                                   0x000000FF
     91#endif
     92                                   );
     93      if ( image == NULL ) {
     94        return 0;
     95      }
     96     
     97      /* Save the alpha blending attributes */
     98      saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
     99      saved_alpha = surface->format->alpha;
     100      if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
     101        SDL_SetAlpha(surface, 0, 0);
     102      }
     103     
     104      /* Copy the surface into the GL texture image */
     105      area.x = 0;
     106      area.y = 0;
     107      area.w = surface->w;
     108      area.h = surface->h;
     109      SDL_BlitSurface(surface, &area, image, &area);
     110     
     111      /* Restore the alpha blending attributes */
     112      if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
     113        SDL_SetAlpha(surface, saved_flags | SDL_OPENGL, saved_alpha);
     114      }
     115     
     116      /* Create an OpenGL texture for the image */
     117      glGenTextures(1, &texture);
     118      glBindTexture(GL_TEXTURE_2D, texture);
     119      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
     120      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
     121      /*      glTexImage2D(GL_TEXTURE_2D,
     122                   0,
     123                   GL_RGBA,
     124                   w, h,
     125                   0,
     126                   GL_RGBA,
     127                   GL_UNSIGNED_BYTE,
     128                   image->pixels);
     129      */
     130      gluBuild2DMipmaps(GL_TEXTURE_2D,
     131                        3,
     132                        w,
     133                        h,
     134                        GL_RGBA,
     135                        GL_UNSIGNED_BYTE,
     136                        image->pixels);
     137
     138      SDL_FreeSurface(image); /* No longer needed */
     139     
     140      return texture;
    93141    }
    94142}
     
    104152      if (imageName)
    105153        {
    106           this->map=IMG_Load(imageName);
    107           if(!map)
     154          SDL_Surface* tmpSurf;
     155          if (this->texture)
     156            glDeleteTextures(1, &this->texture);
     157          // load the new Image to memory
     158          tmpSurf = IMG_Load(imageName);
     159          if(!tmpSurf)
    108160            {
    109161              PRINTF(1)("IMG_Load: %s\n", IMG_GetError());
    110162              return false;
    111163            }
    112           pImage->height = map->h;
    113           pImage->width  = map->w;
    114           pImage->data   = (GLubyte*)map->pixels;
    115           pImage->bpp    = map->format->BytesPerPixel;
    116           if (pImage->bpp == 3)
    117             pImage->format = GL_RGB;
    118           else if (pImage->bpp == 4)
    119             {
    120               pImage->format = GL_RGBA;
    121               SDL_SetAlpha(this->map, 0, 0);
    122             }
    123164
    124           if( !IMG_isPNG(SDL_RWFromFile(imageName, "rb")) && !IMG_isJPG(SDL_RWFromFile(imageName, "rb")))
    125             for (int i=0;i<map->h * map->w *3;i+=3)
    126               {
    127                 GLuint temp = pImage->data[i];
    128                 pImage->data[i] = pImage->data[i+2];
    129                 pImage->data[i+2] = temp;
    130               }
    131           /* this is the real swapping algorithm */
    132           for( int i = 0 ; i < (pImage->height / 2) ; ++i )
    133             for( int j = 0 ; j < pImage->width * pImage->bpp; j += pImage->bpp )
    134               for(int k = 0; k < pImage->bpp; ++k)
    135                 swap( pImage->data[ (i * pImage->width * pImage->bpp) + j + k], pImage->data[ ( (pImage->height - i - 1) * pImage->width * pImage->bpp ) + j + k]);
     165          GLubyte* pixels = (GLubyte*)tmpSurf->pixels;
    136166         
    137           this->loadTexToGL (this->pImage);
    138           SDL_FreeSurface(map);
    139           pImage->data = NULL;
     167          /* this swaps the Mapping so lowel left will be upper left */
     168          for( int i = 0 ; i < (tmpSurf->h / 2) ; ++i )
     169            for( int j = 0 ; j < tmpSurf->w * tmpSurf->format->BytesPerPixel; j += tmpSurf->format->BytesPerPixel )
     170              for(int k = 0; k < tmpSurf->format->BytesPerPixel; ++k)
     171                swap( pixels[(i * tmpSurf->w * tmpSurf->format->BytesPerPixel) + j + k],
     172                      pixels[ ( (tmpSurf->h - i - 1) * tmpSurf->w *  tmpSurf->format->BytesPerPixel) + j + k]);
     173
     174          PRINTF(3)("loading Image %s\n", imageName);
     175          if (tmpSurf)
     176            this->texture = loadTexToGL(tmpSurf);
     177
     178         
     179          SDL_FreeSurface(tmpSurf);
     180          return true;
    140181        }
    141182      else
  • orxonox/branches/physics/src/lib/graphics/importer/texture.h

    r3863 r3953  
    2020{
    2121 private:
    22   //! Struct to handle Infos about an Image
    23   struct Image
    24   {
    25     int rowSpan;    //!< The count of the rows this Image has.
    26     GLuint width;   //!< The width of the Image.
    27     GLuint height;  //!< The height of the Image.
    28     GLuint bpp;     //!< BytesPerPixel
    29     GLenum format;  //!< The Format of the PixelData
    30     GLuint type;    //!< Type of the Image.
    31     GLubyte *data;  //!< The Image Data comes here! DANGER: uncompressed data.
    32   };
    33   Image* pImage;    //!< The data of an Image
    3422  GLuint texture;   //!< The Texture-ID of opengl from this Texture.
    35   SDL_Surface* map; //!< The map SDL initializes for this element.
    3623  char* searchTextureInPaths(const char* texName) const;
    3724  void swap(unsigned char &a, unsigned char &b);
    3825 public:
    39   Texture(void);
    40   Texture(const char* imageName);
     26  Texture(const char* imageName = NULL);
    4127  ~Texture(void);
     28
    4229  /** \returns The textureID of this texture.  */
    4330  inline GLuint getTexture(void) {return this->texture;}
    44   bool loadTexToGL (Image* pImage);
     31  GLuint loadTexToGL (SDL_Surface* surface);
    4532
    4633  bool loadImage(const char* imageName);
  • orxonox/branches/physics/src/lib/graphics/text_engine.cc

    r3845 r3953  
    3636#include "vector.h"
    3737#include "debug.h"
    38 
     38#include "list.h"
    3939
    4040////////////
Note: See TracChangeset for help on using the changeset viewer.