Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2776 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Nov 10, 2004, 2:19:31 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/importer: added minimum material importer. does nothing for the time being

Location:
orxonox/branches/importer/importer
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/importer/importer/Makefile.am

    r2755 r2776  
    66
    77bin_PROGRAMS=importer
    8 importer_SOURCES=framework.cc windowHandler.cc object.cc array.cc
     8importer_SOURCES=framework.cc windowHandler.cc object.cc array.cc material.cc
    99
    10 noinst_HEADERS=windowHandler.h object.h array.h
     10noinst_HEADERS=windowHandler.h object.h array.h material.h
    1111
    1212
  • orxonox/branches/importer/importer/Makefile.in

    r2755 r2776  
    5353PROGRAMS = $(bin_PROGRAMS)
    5454am_importer_OBJECTS = framework.$(OBJEXT) windowHandler.$(OBJEXT) \
    55         object.$(OBJEXT) array.$(OBJEXT)
     55        object.$(OBJEXT) array.$(OBJEXT) material.$(OBJEXT)
    5656importer_OBJECTS = $(am_importer_OBJECTS)
    5757importer_LDADD = $(LDADD)
     
    6060am__depfiles_maybe = depfiles
    6161@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/array.Po ./$(DEPDIR)/framework.Po \
    62 @AMDEP_TRUE@    ./$(DEPDIR)/object.Po ./$(DEPDIR)/windowHandler.Po
     62@AMDEP_TRUE@    ./$(DEPDIR)/material.Po ./$(DEPDIR)/object.Po \
     63@AMDEP_TRUE@    ./$(DEPDIR)/windowHandler.Po
    6364CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
    6465        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
     
    150151AM_CXXFLAGS = "-I/usr/X11R6/include"
    151152AM_LDFLAGS = "-L/usr/Mesa-6.0.1/lib  -L/usr/X11R6/lib -lXt -lX11" $(MWINDOWS)
    152 importer_SOURCES = framework.cc windowHandler.cc object.cc array.cc
    153 noinst_HEADERS = windowHandler.h object.h array.h
     153importer_SOURCES = framework.cc windowHandler.cc object.cc array.cc material.cc
     154noinst_HEADERS = windowHandler.h object.h array.h material.h
    154155all: all-am
    155156
     
    220221@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@
    221222@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/framework.Po@am__quote@
     223@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/material.Po@am__quote@
    222224@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object.Po@am__quote@
    223225@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/windowHandler.Po@am__quote@
  • orxonox/branches/importer/importer/array.h

    r2773 r2776  
    1 //#include "windowHandler.h"
     1#ifndef _ARRAY_H
     2#define _ARRAY_H
     3
    24#include <GL/gl.h>
    35#include <GL/glu.h>
     
    2426
    2527};
     28
     29#endif
  • orxonox/branches/importer/importer/object.cc

    r2775 r2776  
    11#include "object.h"
     2
    23Object::Object ()
    34{
     
    8081        {
    8182          readFace (Buffer+2);
     83        }
     84     
     85      else if (!strncmp(Buffer, "mtllib", 6))
     86        {
     87          readMtlLib (Buffer+7);
    8288        }
    8389
     
    173179}
    174180
     181bool Object::readMtlLib (char* mtlFile)
     182{
     183  MTL_FILE = new ifstream (mtlFile);
     184  if (!MTL_FILE->is_open())
     185    {
     186      printf ("unable to open file: %s\n", mtlFile);
     187      return false;
     188    }
     189 
     190  char Buffer[500];
     191  vertices = new Array();
     192  faces = new Array();
     193 
     194  while(!MTL_FILE->eof())
     195    {
     196      MTL_FILE->getline(Buffer, 500);
     197      //      printf("%s\n", Buffer);
     198     
     199
     200      // create new Material
     201      if (!strncmp(Buffer, "newmtl ", 2))
     202        {
     203          material = new Material(Buffer+7);
     204        }
     205      // setting a illumMode
     206      else if (!strncmp(Buffer, "illum", 5))
     207        {
     208          material->setIllum(Buffer+6);
     209        }
     210      // setting Diffuse Color
     211      else if (!strncmp(Buffer, "Kd", 2))
     212        {
     213          material->setDiffuse(Buffer+3);
     214        }
     215      // setting Ambient Color
     216      else if (!strncmp(Buffer, "Ka", 2))
     217        {
     218          material->setAmbient(Buffer+3);
     219        }
     220      // setting Specular Color
     221      else if (!strncmp(Buffer, "Ks", 2))
     222        {
     223          material->setSpecular(Buffer+3);
     224        }
     225     
     226
     227
     228    }
     229  return true;
     230}
    175231
    176232bool Object::readUseMtl (char* matString)
     
    178234  if (faceMode != -1)
    179235    glEnd();
    180   faceMode = 1;
     236  faceMode = 0;
     237  //printf ("%s\n", matString);
    181238  glColor3f((float)rand()/2000000000.0,(float)rand()/2000000000.0,(float)rand()/2000000000.0);
    182239}
     240
     241
  • orxonox/branches/importer/importer/object.h

    r2773 r2776  
    1 #ifndef OBJECT_H
    2 #define OBJECT_H
     1#ifndef _OBJECT_H
     2#define _OBJECT_H
    33
    44#include <GL/gl.h>
     
    66
    77#include "array.h"
     8#include "material.h"
    89#include <fstream.h>
    910
     
    3233  int faceMode;
    3334  bool readVertices;
     35  Material* material;
    3436
    3537  ifstream* OBJ_FILE;
     
    3941  bool readFace (char* faceString);
    4042  bool readVT (char* vtString);
    41   bool readUseMtl (char* matString);
     43  bool readMtlLib (char* matFile);
     44  bool readUseMtl (char* mtlString);
    4245
    4346  bool addGLElement (char* elementString);
Note: See TracChangeset for help on using the changeset viewer.