Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8700 Modified Files: makefile mesh.cpp mesh.h model.cpp model.h polygon.cpp polygon.h random_stuff.cpp scene_object.cpp scene_object.h Log Message: - mesh and associated classes now 'work' - model class now uses mesh etc Index: model.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** model.cpp 21 Jul 2004 07:41:03 -0000 1.1 --- model.cpp 21 Jul 2004 19:32:44 -0000 1.2 *************** *** 14,25 **** */ - if(!_parseX3DFile(vrmlFilename.c_str())) { - cout << "error parsing x3d file" << endl; - abort(); - } - - cout << "stopping now" << endl; - abort(); - /* if(!_parseVrmlFile(vrmlFilename.c_str())) { --- 14,17 ---- *************** *** 30,259 **** // should get normals here - } - - bool Model::_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; - } - - bool Model::_parseX3DFile(const char* filename) { - try { - XMLPlatformUtils::Initialize(); - } catch (const XMLException& toCatch) { - char* message = XMLString::transcode(toCatch.getMessage()); - cout << "Error during initialization [" << message << "]" << endl; - XMLString::release(&message); - return false; - } - XercesDOMParser* parser = new XercesDOMParser(); - parser->setValidationScheme(XercesDOMParser::Val_Always); // optional. - parser->setDoNamespaces(true); // optional - - ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase(); - parser->setErrorHandler(errHandler); - - try { - parser->parse(filename); - DOMDocument* domDocument = parser->getDocument(); - if(!_dumpDOMNode(domDocument->getDocumentElement())) { - cout << "couldn't dump dom document" << endl; - return false; - } - } catch (const XMLException& toCatch) { - char* message = XMLString::transcode(toCatch.getMessage()); - cout << "Exception message is [" << message << "]" << endl; - XMLString::release(&message); - return false; - } catch (const DOMException& toCatch) { - char* message = XMLString::transcode(toCatch.msg); - cout << "Exception message is [" << message << "]" << endl; - XMLString::release(&message); - return false; - } catch (...) { - cout << "Unexpected Exception \n" ; - return false; - } ! delete parser; ! delete errHandler; - return true; - } - - bool Model::_dumpDOMNode(DOMNode* domNode, long curLevel) { - if(domNode == NULL) { - return false; - } - - try { - if((domNode->getNodeType() == DOMNode::ELEMENT_NODE) || (domNode->getNodeType() == DOMNode::ATTRIBUTE_NODE)) { - cout << "[" << curLevel << "] node type [" << domNode->getNodeType() << "] node name [" << XMLString::transcode(domNode->getNodeName()) << "]" << endl; // value [" << XMLString::transcode(domNode->getNodeValue()) << "]" << endl; - if(domNode->getNodeValue() != NULL) { - cout << "[" << curLevel << "] value [" << XMLString::transcode(domNode->getNodeValue()) << "]" << endl; - } - - DOMNamedNodeMap* attributes = domNode->getAttributes(); - if(attributes != NULL) { - cout << "[" << curLevel << "] dumping attributes" << endl; - for(XMLSize_t index = 0; index < attributes->getLength(); index++) { - _dumpDOMNode(attributes->item(index), curLevel + 1); - } - cout << "[" << curLevel << "] dumping attributes complete" << endl; - } - } else if(domNode->getNodeType() == DOMNode::TEXT_NODE) { - return false; - } - - // dump this element's children first - DOMNode* curChild = domNode->getFirstChild(); - while(curChild != NULL) { - // dump the child - _dumpDOMNode(curChild, curLevel + 1); - - // now get the child's sibling - DOMNode* nextChild = curChild->getNextSibling(); - curChild = nextChild; - } - - } catch (const XMLException& toCatch) { - char* message = XMLString::transcode(toCatch.getMessage()); - cout << "Exception message is [" << message << "]" << endl; - XMLString::release(&message); - return false; - } catch (const DOMException& toCatch) { - char* message = XMLString::transcode(toCatch.msg); - cout << "Exception message is [" << message << "]" << endl; - XMLString::release(&message); - return false; - } catch (...) { - cout << "Unexpected Exception \n" ; - return false; - } - - return true; } - bool Model::_dumpX3DScene(X3D::X3DNode* curNode, long curLevel) { - MFAbstractNode childList = curNode->getChildList(); - /* - if(childList == NULL) { - cout << "got an empty child list at level [" << curLevel << "]" << endl; - return false; - } - */ - - //cout << "start loop at level [" << curLevel << "]" << endl; - for(MFAbstractNode::iterator i = childList.begin(); i != childList.end(); i++) { - try { - cout << "got child of type [" << typeid(*(*i)).name() << "] at level [" << curLevel << "]" << endl; - } catch(exception& e) { - cout << "got an exception at level [" << curLevel << "] what [" << e.what() << "]" << endl; - continue; - } - - _dumpX3DScene((X3D::X3DNode*)*i, curLevel + 1); - //cout << "finished with node at level [" << curLevel << "]" << endl; - } - //cout << "end loop at level [" << curLevel << "]" << endl; - - return true; - } --- 22,31 ---- // should get normals here ! ModelLoader* modelLoader = new X3DLoader(); ! SceneObject* slugMobile = modelLoader->loadModel(vrmlFilename); } Index: model.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** model.h 21 Jul 2004 07:38:05 -0000 1.2 --- model.h 21 Jul 2004 19:32:44 -0000 1.3 *************** *** 6,24 **** #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; --- 6,13 ---- #include <GL/glu.h> #include <GL/glut.h> #include <typeinfo> ! #include "model_loader.h" using namespace std; *************** *** 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); }; --- 27,30 ---- Index: random_stuff.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/random_stuff.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** random_stuff.cpp 24 Jun 2004 10:45:23 -0000 1.1.1.1 --- random_stuff.cpp 21 Jul 2004 19:32:44 -0000 1.2 *************** *** 238,240 **** --- 238,373 ---- pos_t yAngleRadians = (yAngle / (pos_t)360) * M_PI * 2; + + + bool Model::_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; + } + + bool Model::_dumpX3DScene(X3D::X3DNode* curNode, long curLevel) { + MFAbstractNode childList = curNode->getChildList(); + /* + if(childList == NULL) { + cout << "got an empty child list at level [" << curLevel << "]" << endl; + return false; + } + */ + + //cout << "start loop at level [" << curLevel << "]" << endl; + for(MFAbstractNode::iterator i = childList.begin(); i != childList.end(); i++) { + try { + cout << "got child of type [" << typeid(*(*i)).name() << "] at level [" << curLevel << "]" << endl; + } catch(exception& e) { + cout << "got an exception at level [" << curLevel << "] what [" << e.what() << "]" << endl; + continue; + } + + _dumpX3DScene((X3D::X3DNode*)*i, curLevel + 1); + //cout << "finished with node at level [" << curLevel << "]" << endl; + } + //cout << "end loop at level [" << curLevel << "]" << endl; + + return true; + } + + bool _parseVrmlFile(const char* filename); + bool _dumpX3DScene(X3D::X3DNode* curNode, long curLevel = 0); + Index: polygon.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/polygon.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** polygon.cpp 21 Jul 2004 07:41:03 -0000 1.1 --- polygon.cpp 21 Jul 2004 19:32:44 -0000 1.2 *************** *** 6,10 **** #include "polygon.h" ! PolyGon::PolyGon(SceneObject* parent) : SceneObject(parent) { --- 6,10 ---- #include "polygon.h" ! Polygon::Polygon(SceneObject* parent) : SceneObject(parent) { *************** *** 12,20 **** } Polygon::Polygon(const Polygon& rhs) { cout << "<Polygon::Polygon(copy)>\tcalled" << endl; } ! bool PolyGon::setNormal(double normal) { m_normal = normal; --- 12,24 ---- } + Polygon::~Polygon() { + } + Polygon::Polygon(const Polygon& rhs) { cout << "<Polygon::Polygon(copy)>\tcalled" << endl; } ! /* ! bool Polygon::setNormal(double normal) { m_normal = normal; *************** *** 27,33 **** --- 31,42 ---- return true; } + */ /* $Log$ + Revision 1.2 2004/07/21 19:32:44 o3dozone + - mesh and associated classes now 'work' + - model class now uses mesh etc + Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models Index: polygon.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/polygon.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** polygon.h 21 Jul 2004 07:41:03 -0000 1.1 --- polygon.h 21 Jul 2004 19:32:44 -0000 1.2 *************** *** 8,28 **** #include "scene_object.h" ! #include "coord3d.h" ! class PolyGon : public SceneObject { public: ! PolyGon(SceneObject* parent = NULL); Polygon(const Polygon& rhs); ! virtual ~PolyGon; ! bool setNormal(double normal); ! bool setCoord(Coord3D& coord); private: double m_normal; ! Coord3D m_coord; }; /* $Log$ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models --- 8,34 ---- #include "scene_object.h" ! //#include "coord3d.h" ! #include <iostream> ! ! class Polygon : public SceneObject { public: ! Polygon(SceneObject* parent = NULL); Polygon(const Polygon& rhs); ! virtual ~Polygon(); ! //bool setNormal(double normal); ! //bool setCoord(Coord3D& coord); private: double m_normal; ! //Coord3D m_coord; }; /* $Log$ + Revision 1.2 2004/07/21 19:32:44 o3dozone + - mesh and associated classes now 'work' + - model class now uses mesh etc + Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models Index: scene_object.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** scene_object.h 21 Jul 2004 07:41:03 -0000 1.1 --- scene_object.h 21 Jul 2004 19:32:44 -0000 1.2 *************** *** 19,22 **** --- 19,24 ---- bool addChild(SceneObject* child); bool draw(bool drawChildren = true); + + virtual SceneObject& operator=(const SceneObject& rhs); private: SceneObject* m_parent; *************** *** 26,29 **** --- 28,35 ---- /* $Log$ + Revision 1.2 2004/07/21 19:32:44 o3dozone + - mesh and associated classes now 'work' + - model class now uses mesh etc + Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models Index: scene_object.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** scene_object.cpp 21 Jul 2004 07:41:03 -0000 1.1 --- scene_object.cpp 21 Jul 2004 19:32:44 -0000 1.2 *************** *** 11,14 **** --- 11,18 ---- } + SceneObject::~SceneObject() + { + } + bool SceneObject::addChild(SceneObject* child) { m_children.push_back(child); *************** *** 20,25 **** --- 24,40 ---- } + SceneObject& SceneObject::operator=(const SceneObject& rhs) { + m_parent = rhs.m_parent; + m_children = rhs.m_children; + + return *this; + } + /* $Log$ + Revision 1.2 2004/07/21 19:32:44 o3dozone + - mesh and associated classes now 'work' + - model class now uses mesh etc + Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models Index: makefile =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** makefile 21 Jul 2004 07:38:05 -0000 1.2 --- makefile 21 Jul 2004 19:32:44 -0000 1.3 *************** *** 9,12 **** --- 9,15 ---- PLANE2_OBJS=spaceplane2.o + GRAVITY_DEPS= + GRAVITY_OBJS=gravity.o opengl_utils.o object3d.o vrml_v1.o system_state.o statgraph.o statgraphrenderer.o model.o model_loader.o mesh.o polygon.o scene_object.o + all: gravity @echo building all *************** *** 24,32 **** $(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 ! $(CC) -static-libgcc -static $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o gravity_static gravity.o opengl_utils.o vrml_v1.o system_state.o statgraph.o statgraphrenderer.o %.o: %.cpp %.h system_state.h model.h --- 27,35 ---- $(CC) $(CC_OPTIONS) -o object3d_test object3d_test.cpp ! gravity: $(GRAVITY_OBJS) $(GRAVITY_DEPS) ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o $@ $(GRAVITY_OBJS) ! gravity_static: $(GRAVITY_OBJS) $(GRAVITY_DEPS) ! $(CC) -static-libgcc -static $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o gravity_static $(GRAVITY_OBJS) %.o: %.cpp %.h system_state.h model.h Index: mesh.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mesh.cpp 21 Jul 2004 07:41:03 -0000 1.1 --- mesh.cpp 21 Jul 2004 19:32:44 -0000 1.2 *************** *** 12,15 **** --- 12,18 ---- } + Mesh::~Mesh() { + } + bool Mesh::addPolygon(Polygon& polygon) { m_polygons.push_back(polygon); *************** *** 18,23 **** --- 21,38 ---- } + Mesh& Mesh::operator=(const Mesh& rhs) { + SceneObject::operator=(rhs); + + //m_polygons = rhs.m_polygons; + + return *this; + } + /* $Log$ + Revision 1.2 2004/07/21 19:32:44 o3dozone + - mesh and associated classes now 'work' + - model class now uses mesh etc + Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models Index: mesh.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mesh.h 21 Jul 2004 07:41:03 -0000 1.1 --- mesh.h 21 Jul 2004 19:32:44 -0000 1.2 *************** *** 7,12 **** */ - #include "scene_object.h" #include <vector> using namespace std; --- 7,15 ---- */ #include <vector> + #include <iostream> + #include "scene_object.h" + + #include "polygon.h" using namespace std; *************** *** 15,21 **** public: Mesh(SceneObject* parent = NULL); ! virtual ~Mesh; bool addPolygon(Polygon& polygon); private: vector<Polygon> m_polygons; --- 18,26 ---- public: Mesh(SceneObject* parent = NULL); ! virtual ~Mesh(); bool addPolygon(Polygon& polygon); + + virtual Mesh& operator=(const Mesh& rhs); private: vector<Polygon> m_polygons; *************** *** 30,33 **** --- 35,42 ---- /* $Log$ + Revision 1.2 2004/07/21 19:32:44 o3dozone + - mesh and associated classes now 'work' + - model class now uses mesh etc + Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models |