|
From: Mike D. <o3d...@us...> - 2004-07-21 07:38:14
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3531 Modified Files: makefile model.h opengl_utils.cpp Log Message: - now using X3D for models Index: makefile =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** makefile 24 Jun 2004 10:45:22 -0000 1.1.1.1 --- makefile 21 Jul 2004 07:38:05 -0000 1.2 *************** *** 1,8 **** CC=g++ LIBDIRS= ! INCDIRS=-I/usr/local/include -I/usr/local/include/SDL -I/usr/include -I/usr/include/SDL CC_OPTIONS=-Wall -g SDL_FLAGS=`sdl-config --cflags` ! SDL_LIBS=`sdl-config --libs` -lSDL_image -lSDL_gfx -lSDL_net -lGL -lGLU -lglut PLANE_WIN32_OBJS=spaceplane.obj PLANE_OBJS=spaceplane.o --- 1,8 ---- CC=g++ LIBDIRS= ! INCDIRS=-I/usr/local/include -I/usr/local/include/SDL -I/usr/include -I/usr/include/SDL -I/home/mdavis/software/X3DToolKit-0.6/include -I/usr/include CC_OPTIONS=-Wall -g SDL_FLAGS=`sdl-config --cflags` ! SDL_LIBS=`sdl-config --libs` -lSDL_image -lSDL_gfx -lSDL_net -lGL -lGLU -lglut -L/home/mdavis/software/X3DToolKit-0.6/lib -lX3DTK PLANE_WIN32_OBJS=spaceplane.obj PLANE_OBJS=spaceplane.o *************** *** 24,29 **** $(CC) $(CC_OPTIONS) -o object3d_test object3d_test.cpp ! gravity: gravity.o opengl_utils.o object3d.o vrml_v1.o system_state.o model.h statgraph.o statgraphrenderer.o ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o gravity gravity.o opengl_utils.o vrml_v1.o system_state.o statgraph.o statgraphrenderer.o gravity_static: gravity.o opengl_utils.o object3d.o vrml_v1.o system_state.o model.h statgraph.o statgraphrenderer.o --- 24,29 ---- $(CC) $(CC_OPTIONS) -o object3d_test object3d_test.cpp ! gravity: gravity.o opengl_utils.o object3d.o vrml_v1.o system_state.o model.h statgraph.o statgraphrenderer.o model.o ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o gravity gravity.o opengl_utils.o vrml_v1.o system_state.o statgraph.o statgraphrenderer.o model.o gravity_static: gravity.o opengl_utils.o object3d.o vrml_v1.o system_state.o model.h statgraph.o statgraphrenderer.o Index: model.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** model.h 24 Jun 2004 10:45:23 -0000 1.1.1.1 --- model.h 21 Jul 2004 07:38:05 -0000 1.2 *************** *** 6,21 **** #include <GL/glu.h> #include <GL/glut.h> class Model { public: ! Model(const string& vrmlFilename) { ! if(!_parseVrmlFile(vrmlFilename.c_str())) { ! cout << "<Model::Model>\tcouldn't parse file [" << vrmlFilename << "]" << endl; ! throw("could not parse file"); ! } ! ! // should get normals here ! }; const Vrml::DoubleArray* getPointsArray() { --- 6,29 ---- #include <GL/glu.h> #include <GL/glut.h> + #include <X3DTK/X3D/scenegraph.h> + #include <typeinfo> + #include <xercesc/parsers/XercesDOMParser.hpp> + #include <xercesc/dom/DOM.hpp> + #include <xercesc/sax/HandlerBase.hpp> + #include <xercesc/util/XMLString.hpp> + #include <xercesc/util/PlatformUtils.hpp> + #include <xercesc/dom/DOMElement.hpp> + + XERCES_CPP_NAMESPACE_USE + + + + using namespace X3DTK; + using namespace std; class Model { public: ! Model(const string& vrmlFilename); const Vrml::DoubleArray* getPointsArray() { *************** *** 30,136 **** Vrml::DoubleArray* m_indicesArray; Vrml::Object m_rootObject; ! bool _parseVrmlFile(const char* filename) { ! string vrmlText = ""; ! ! cout << "<main>\topening vrmlFile [" << filename << "]" << endl; ! ! ifstream vrmlFile; ! vrmlFile.open(filename); ! ! if(!vrmlFile.is_open()) { ! cout << "<main>\tcouldn't open file" << endl; ! return false; ! } ! ! // get length of file: ! vrmlFile.seekg (0, ios::end); ! int fileLength = vrmlFile.tellg(); ! vrmlFile.seekg (0, ios::beg); ! ! cout << "<main>\tfile length [" << fileLength << "]" << endl; ! ! string buffer; ! while(vrmlFile.good()) { ! getline(vrmlFile, buffer); ! vrmlText += buffer; ! vrmlText += '\n'; ! ! //cout << "<main>\tgot buffer [" << buffer << "]" << endl; ! } ! ! cout << "<main>\tfinished reading" << endl; ! ! //Vrml::Object m_rootObject; ! cout << "<main>\tparsing" << endl; ! ! string::size_type parseStart = 0; ! m_rootObject.parse(vrmlText, parseStart); ! cout << "<main>\tdumping m_rootObject:" << endl; ! m_rootObject.Dump(0); ! cout << "<main>\tfinding suzanne" << endl; ! ! /* ! Vrml::Object* obj_separator = m_rootObject.findChildByType("Separator"); ! if(obj_separator == NULL) { ! cout << "<main>\tdidn't find seperator" << endl; ! return false; ! } ! */ ! ! Vrml::Object* obj_switch = m_rootObject.findChildByType("Switch"); ! if(obj_switch == NULL) { ! cout << "<main>\tdidn't find switch" << endl; ! return false; ! } ! ! Vrml::Object* obj_separator = obj_switch->findChildByType("Separator"); ! if(obj_separator == NULL) { ! cout << "<main>\tdidn't find separator" << endl; ! return false; ! } ! ! Vrml::Object* obj_coords = obj_separator->findChildByType("Coordinate3"); ! if(obj_coords == NULL) { ! cout << "<main>\tdidn't find coords" << endl; ! return false; ! } ! ! Vrml::Object* obj_point = obj_coords->findChildByType("point"); ! if(obj_point == NULL) { ! cout << "<main>\tdidn't find point" << endl; ! return false; ! } ! ! Vrml::Object* obj_faceset = obj_separator->findChildByType("IndexedFaceSet"); ! if(obj_faceset == NULL) { ! cout << "<main>\tdidn't find face set" << endl; ! return false; ! } ! ! Vrml::Object* obj_indices = obj_faceset->findChildByType("coordIndex"); ! if(obj_indices == NULL) { ! cout << "<main>\tdidn't find indices" << endl; ! return false; ! } ! ! cout << "<main>\tdumping points" << endl; ! obj_point->Dump(0); ! m_pointsArray = (Vrml::DoubleArray*)obj_point->getChildByIndex(0); ! ! /* ! for(long index = 0; index < m_pointsArray->size(); index++) { ! cout << "index [" << index << "] value [" << (*m_pointsArray)[index] << "]" << endl; ! } ! */ ! ! cout << "<main>\tdumping coord indices" << endl; ! obj_indices->Dump(0); ! m_indicesArray = (Vrml::DoubleArray*)obj_indices->getChildByIndex(0); ! ! ! return true; ! } ! }; --- 38,48 ---- Vrml::DoubleArray* m_indicesArray; Vrml::Object m_rootObject; + X3D::XercesLoader* m_x3dLoader; + X3D::Scene* m_x3dScene; ! bool _parseVrmlFile(const char* filename); ! bool _parseX3DFile(const char* filename); ! bool _dumpX3DScene(X3D::X3DNode* curNode, long curLevel = 0); ! bool _dumpDOMNode(DOMNode* domNode, long curLevel = 0); }; Index: opengl_utils.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/opengl_utils.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** opengl_utils.cpp 24 Jun 2004 16:44:06 -0000 1.2 --- opengl_utils.cpp 21 Jul 2004 07:38:05 -0000 1.3 *************** *** 134,137 **** --- 134,142 ---- pos_t& clposZ = velocity.m_z; + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POINT_SMOOTH); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // move the light around if(SystemStateSingleton::instance().lighting) { *************** *** 167,171 **** } ! glTranslatef(0, 0, -10); // call draw here --- 172,176 ---- } ! //glTranslatef(0, 0, -10); // call draw here |