|
From: Mike D. <o3d...@us...> - 2005-01-28 20:55:22
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22992 Modified Files: coord3d.h gravity.cpp gravity.h makefile model_loader.cpp model_loader.h object3d.h simple_sphere.cpp simple_sphere.h system_state.h x3d_loader.cpp x3d_loader.h Log Message: - dual viewpoints - various other changes Index: coord3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/coord3d.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** coord3d.h 29 Aug 2004 05:43:27 -0000 1.2 --- coord3d.h 28 Jan 2005 20:54:51 -0000 1.3 *************** *** 8,11 **** --- 8,12 ---- #include <iostream> + #include <math.h> using namespace std; Index: simple_sphere.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/simple_sphere.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** simple_sphere.h 28 Jan 2005 20:26:58 -0000 1.1 --- simple_sphere.h 28 Jan 2005 20:54:51 -0000 1.2 *************** *** 24,30 **** /* $Log$ ! Revision 1.1 2005/01/28 20:26:58 o3dozone ! - some refactoring ! - simple sphere scene object */ --- 24,30 ---- /* $Log$ ! Revision 1.2 2005/01/28 20:54:51 o3dozone ! - dual viewpoints ! - various other changes */ Index: object3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** object3d.h 28 Jan 2005 09:07:46 -0000 1.6 --- object3d.h 28 Jan 2005 20:54:51 -0000 1.7 *************** *** 10,15 **** #include "model.h" #include "coord3d.h" - #include "scene_object.h" - #include "transform.h" class Object3D { --- 10,13 ---- Index: gravity.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gravity.h 28 Jan 2005 09:07:46 -0000 1.4 --- gravity.h 28 Jan 2005 20:54:51 -0000 1.5 *************** *** 21,27 **** #include "statgraph.h" #include "statgraphrenderer.h" - #include "simple_sphere.h" ! #define MAX_OBJECTARRAY_SIZE 150 #endif --- 21,26 ---- #include "statgraph.h" #include "statgraphrenderer.h" ! #define MAX_OBJECTARRAY_SIZE 5 #endif *************** *** 29,34 **** /* $Log$ ! Revision 1.4 2005/01/28 09:07:46 o3dozone ! - many changes, including gravity and more control using the keyboard Revision 1.3 2005/01/08 07:22:49 o3dozone --- 28,34 ---- /* $Log$ ! Revision 1.5 2005/01/28 20:54:51 o3dozone ! - dual viewpoints ! - various other changes Revision 1.3 2005/01/08 07:22:49 o3dozone Index: system_state.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/system_state.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** system_state.h 28 Jan 2005 09:07:46 -0000 1.2 --- system_state.h 28 Jan 2005 20:54:51 -0000 1.3 *************** *** 35,40 **** shiftActive = false; altActive = false; - cout << "lastTick [" << lastTick << "] curTick [" << curTick << "] tickDiff [" << tickDiff << "]" << endl; }; --- 35,40 ---- shiftActive = false; altActive = false; + viewPointIndex = 0; cout << "lastTick [" << lastTick << "] curTick [" << curTick << "] tickDiff [" << tickDiff << "]" << endl; }; *************** *** 89,92 **** --- 89,93 ---- Uint32 shiftActive; Uint32 altActive; + Uint32 viewPointIndex; }; Index: model_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** model_loader.cpp 28 Jan 2005 09:07:46 -0000 1.8 --- model_loader.cpp 28 Jan 2005 20:54:51 -0000 1.9 *************** *** 9,16 **** } /* $Log$ ! Revision 1.8 2005/01/28 09:07:46 o3dozone ! - many changes, including gravity and more control using the keyboard Revision 1.7 2004/08/18 14:53:17 o3dozone --- 9,18 ---- } + /* $Log$ ! Revision 1.9 2005/01/28 20:54:51 o3dozone ! - dual viewpoints ! - various other changes Revision 1.7 2004/08/18 14:53:17 o3dozone Index: model_loader.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** model_loader.h 28 Jan 2005 09:07:46 -0000 1.4 --- model_loader.h 28 Jan 2005 20:54:51 -0000 1.5 *************** *** 1,3 **** ! // $Id$ #ifndef MODEL_LOADER_H #define MODEL_LOADER_H --- 1,3 ---- ! #ifndef MODEL_LOADER_H #define MODEL_LOADER_H *************** *** 5,10 **** --- 5,18 ---- #include <iostream> + #include <stdio.h> + #include <libxml/parser.h> + #include <libxml/tree.h> + #include "scene_object.h" + #include "mesh.h" + #include "transform.h" + #include "material.h" #include <assert.h> + #include <vector> using namespace std; *************** *** 18,25 **** }; /* $Log$ ! Revision 1.4 2005/01/28 09:07:46 o3dozone ! - many changes, including gravity and more control using the keyboard Revision 1.3 2004/07/25 10:35:59 o3dozone --- 26,35 ---- }; + /* $Log$ ! Revision 1.5 2005/01/28 20:54:51 o3dozone ! - dual viewpoints ! - various other changes Revision 1.3 2004/07/25 10:35:59 o3dozone Index: makefile =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** makefile 28 Jan 2005 09:07:46 -0000 1.7 --- makefile 28 Jan 2005 20:54:51 -0000 1.8 *************** *** 1,51 **** ! 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 -lxerces-c ! #-L/home/mdavis/software/X3DToolKit-0.6/lib -lX3DTK ! PLANE_WIN32_OBJS=spaceplane.obj ! PLANE_OBJS=spaceplane.o ! PLANE2_OBJS=spaceplane2.o ! ! GRAVITY_DEPS=gravity.dep opengl_utils.dep object3d.dep vrml_v1.dep system_state.dep statgraph.dep \ ! statgraphrenderer.dep model_loader.dep mesh.dep polygon.dep scene_object.dep transform.dep material.dep \ ! x3d_loader.dep simple_sphere.dep ! GRAVITY_OBJS=gravity.o opengl_utils.o object3d.o vrml_v1.o system_state.o statgraph.o \ ! statgraphrenderer.o model_loader.o mesh.o polygon.o scene_object.o transform.o material.o \ ! x3d_loader.o simple_sphere.o ! ! all: gravity ! @echo building all ! ! spaceplane: $(PLANE_OBJS) ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(INCDIRS) $(LIBDIRS) -o spaceplane $(PLANE_OBJS) $(SDL_LIBS) ! ! spaceplane.exe: $(PLANE_WIN32_OBJS) ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) -o spaceplane.exe $(PLANE_WIN32_OBJS) $(SDL_LIBS) ! ! universe_test: universe_test.cpp universe_test.h object3d.o ! $(CC) $(CC_OPTIONS) -o universe_test universe_test.cpp ! ! object3d_test: object3d_test.cpp object3d.o ! $(CC) $(CC_OPTIONS) -o object3d_test object3d_test.cpp ! ! gravity: $(GRAVITY_DEPS) $(GRAVITY_OBJS) ! $(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) ! ! %.dep: %.cpp %.h system_state.h model.h ! @echo building dependencies ! $(CC) $(CC_OPTIONS) -M $(SDL_FLAGS) $(CC_FLAGS) $(INCDIRS) -c $< -o $@ ! ! %.o: %.cpp %.h system_state.h model.h coord3d.h ! @echo building object file ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(CC_FLAGS) $(INCDIRS) -c $< -o $@ ! ! clean: ! rm *.o gravity spaceplane ! --- 1,49 ---- ! CC=g++ ! LIBDIRS= ! INCDIRS=-I/usr/local/include -I/usr/local/include/SDL -I/usr/include -I/usr/include/SDL \ ! -I../SDL-1.2.28 -I../SDL-1.2.8/include \ ! -I/usr/include/libxml2 -I/usr/include ! #-I/home/mdavis/software/X3DToolKit-0.6/include -I/usr/include ! CC_OPTIONS=-Wall -g -L/usr/lib/ -L /usr/lib/libxml2 -lxml2 ! SDL_FLAGS=`sdl-config --cflags` ! SDL_LIBS=`sdl-config --libs` -lSDL_image -lSDL_gfx -lSDL_net -lGL -lGLU -lglut -lxerces-c ! #-L/home/mdavis/software/X3DToolKit-0.6/lib -lX3DTK ! PLANE_WIN32_OBJS=spaceplane.obj ! PLANE_OBJS=spaceplane.o ! PLANE2_OBJS=spaceplane2.o ! ! GRAVITY_DEPS=gravity.dep opengl_utils.dep object3d.dep vrml_v1.dep system_state.dep statgraph.dep statgraphrenderer.dep model_loader.dep mesh.dep polygon.dep scene_object.dep transform.dep material.dep simple_sphere.dep x3d_loader.dep ! GRAVITY_OBJS=gravity.o opengl_utils.o object3d.o vrml_v1.o system_state.o statgraph.o statgraphrenderer.o model_loader.o mesh.o polygon.o scene_object.o transform.o material.o simple_sphere.o x3d_loader.o ! ! all: gravity ! @echo building all ! ! spaceplane: $(PLANE_OBJS) ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(INCDIRS) $(LIBDIRS) -o spaceplane $(PLANE_OBJS) $(SDL_LIBS) ! ! spaceplane.exe: $(PLANE_WIN32_OBJS) ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) -o spaceplane.exe $(PLANE_WIN32_OBJS) $(SDL_LIBS) ! ! universe_test: universe_test.cpp universe_test.h object3d.o ! $(CC) $(CC_OPTIONS) -o universe_test universe_test.cpp ! ! object3d_test: object3d_test.cpp object3d.o ! $(CC) $(CC_OPTIONS) -o object3d_test object3d_test.cpp ! ! gravity: $(GRAVITY_OBJS) ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o $@ $(GRAVITY_OBJS) ! ! gravity_static: $(GRAVITY_OBJS) ! $(CC) -static-libgcc -static $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o gravity_static $(GRAVITY_OBJS) ! ! %.dep: %.cpp %.h system_state.h model.h ! @echo building dependencies ! $(CC) $(CC_OPTIONS) -M $(SDL_FLAGS) $(CC_FLAGS) $(INCDIRS) -c $< -o $@ ! ! %.o: %.cpp %.h system_state.h model.h coord3d.h ! @echo building object file ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(CC_FLAGS) $(INCDIRS) -c $< -o $@ ! ! clean: ! rm *.o gravity spaceplane ! Index: x3d_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/x3d_loader.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** x3d_loader.cpp 28 Jan 2005 20:26:58 -0000 1.1 --- x3d_loader.cpp 28 Jan 2005 20:54:51 -0000 1.2 *************** *** 6,11 **** } SceneObject* X3DLoader::loadModel(const string filename) { ! SceneObject* sceneRoot = NULL; if((sceneRoot = _parseX3DFile(filename.c_str())) == NULL) { cout << "error parsing x3d file" << endl; --- 6,22 ---- } + X3DLoader::~X3DLoader() { + + } + SceneObject* X3DLoader::loadModel(const string filename) { ! /* ! * this initialize the library and check potential ABI mismatches ! * between the version it was compiled for and the actual shared ! * library used. ! */ ! LIBXML_TEST_VERSION ! ! SceneObject* sceneRoot = NULL; if((sceneRoot = _parseX3DFile(filename.c_str())) == NULL) { cout << "error parsing x3d file" << endl; *************** *** 18,71 **** SceneObject* X3DLoader::_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 NULL; ! } ! ! XercesDOMParser* parser = new XercesDOMParser(); ! parser->setValidationScheme(XercesDOMParser::Val_Always); // optional. ! //parser->setDoNamespaces(scene); // optional ! ! ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase(); ! parser->setErrorHandler(errHandler); ! SceneObject* sceneRoot = NULL; try { ! parser->parse(filename); ! DOMDocument* domDocument = parser->getDocument(); ! ! if(domDocument->getDocumentElement() == NULL) { ! cout << "empty document" << endl; ! return NULL; ! } else if((sceneRoot = _convertDOMNode(domDocument->getDocumentElement())) == NULL) { ! cout << "couldn't dump dom document" << endl; ! return NULL; ! } ! } catch (const XMLException& toCatch) { ! char* message = XMLString::transcode(toCatch.getMessage()); ! cout << "Exception message is [" << message << "]" << endl; ! XMLString::release(&message); ! return NULL; ! } catch (const DOMException& toCatch) { ! char* message = XMLString::transcode(toCatch.msg); ! cout << "Exception message is [" << message << "]" << endl; ! XMLString::release(&message); ! return NULL; } catch (...) { ! cout << "Unexpected Exception \n" ; ! return NULL; } ! delete parser; ! delete errHandler; return sceneRoot; } ! SceneObject* X3DLoader::_convertDOMNode(DOMNode* domNode, SceneObject* parent, long curLevel) { if(domNode == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty DOM node" << endl; --- 29,66 ---- SceneObject* X3DLoader::_parseX3DFile(const char* filename) { ! xmlDoc *doc = NULL; ! xmlNode *rootElement = NULL; SceneObject* sceneRoot = NULL; try { ! if((doc = xmlReadFile(filename, NULL, 0)) == NULL) { ! return NULL; ! } ! ! if((rootElement = xmlDocGetRootElement(doc)) == NULL) { ! xmlFreeDoc(doc); ! xmlCleanupParser(); ! return NULL; ! } ! ! if((sceneRoot = _convertDOMNode(rootElement)) == NULL) { ! cout << "couldn't dump dom document" << endl; ! xmlFreeDoc(doc); ! xmlCleanupParser(); ! return NULL; ! } } catch (...) { ! cout << "Unexpected Exception \n" ; ! xmlFreeDoc(doc); ! xmlCleanupParser(); ! return NULL; } ! xmlFreeDoc(doc); ! xmlCleanupParser(); return sceneRoot; } ! SceneObject* X3DLoader::_convertDOMNode(xmlNode* domNode, SceneObject* parent, long curLevel) { if(domNode == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty DOM node" << endl; *************** *** 80,94 **** try { ! if(domNode->getNodeType() == DOMNode::ELEMENT_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; } // find the dom node attributes ! DOMNamedNodeMap* attributes = domNode->getAttributes(); ! if(attributes != NULL) { cout << "[" << curLevel << "] dumping attributes" << endl; ! // get a scene object from the DOM Node // *** NOTE *** slightly dodgy, but handleChildren gets set in the _createSceneObjectFromDOMNode call below --- 75,90 ---- try { ! if(domNode->type == XML_ELEMENT_NODE) { ! /* ! cout << "[" << curLevel << "] node type [" << domNode->getNodeType() << "] node name [" << XMLString::transcode(domNode->getNodeName()) << "]" << endl; // value [" << domNode << "]" << endl; if(domNode->getNodeValue() != NULL) { ! cout << "[" << curLevel << "] value [" << domNode << "]" << endl; } + */ // find the dom node attributes ! if(domNode->properties != NULL) { cout << "[" << curLevel << "] dumping attributes" << endl; ! // get a scene object from the DOM Node // *** NOTE *** slightly dodgy, but handleChildren gets set in the _createSceneObjectFromDOMNode call below *************** *** 107,147 **** if(handleChildren) { // dump this element's children first ! DOMNode* curChild = domNode->getFirstChild(); ! while(curChild != NULL) { // dump the child ! SceneObject* child = _convertDOMNode(curChild, scene, curLevel + 1); if((child != NULL) && (child != scene)) { scene->addChild(child); } - - // now get the child's sibling - DOMNode* nextChild = curChild->getNextSibling(); - curChild = nextChild; } } - } /* - else { - cout << "<X3DLoader::_convertDOMNode>\tignoring scene without attributes" << endl; - scene = new SceneObject(); } - */ ! } else if(domNode->getNodeType() == DOMNode::ATTRIBUTE_NODE) { cout << "<X3DLoader::_convertDOMNode>\tignoring attribute node" << endl; ! } else if(domNode->getNodeType() == DOMNode::TEXT_NODE) { //cout << "<X3DLoader::_convertDOMNode>\tignoring text node" << endl; return NULL; } - } catch (const XMLException& toCatch) { - char* message = XMLString::transcode(toCatch.getMessage()); - cout << "Exception message is [" << message << "]" << endl; - XMLString::release(&message); - return NULL; - } catch (const DOMException& toCatch) { - char* message = XMLString::transcode(toCatch.msg); - cout << "Exception message is [" << message << "]" << endl; - XMLString::release(&message); - return NULL; } catch (...) { cout << "Unexpected Exception \n" ; --- 103,123 ---- if(handleChildren) { // dump this element's children first ! for (xmlNode *cur_node = domNode; cur_node != NULL; cur_node = cur_node->next) { // dump the child ! SceneObject* child = _convertDOMNode(cur_node, scene, curLevel + 1); if((child != NULL) && (child != scene)) { scene->addChild(child); } } } } ! } else if(domNode->type == XML_ATTRIBUTE_NODE) { cout << "<X3DLoader::_convertDOMNode>\tignoring attribute node" << endl; ! } else if(domNode->type == XML_TEXT_NODE) { //cout << "<X3DLoader::_convertDOMNode>\tignoring text node" << endl; return NULL; } } catch (...) { cout << "Unexpected Exception \n" ; *************** *** 152,174 **** } ! SceneObject* X3DLoader::_createSceneObjectFromDOMNode(DOMNode* domNode, bool& parentMustHandleChildren) { assert(domNode != NULL); ! assert(domNode->getNodeType() == DOMNode::ELEMENT_NODE); // get a usefull version of this node's name ! char* nodeName = XMLString::transcode(domNode->getNodeName()); // This is the only node we are going to handle for the moment ! if(strcmp(nodeName, "IndexedFaceSet") == 0) { // parent must ignore children, we can handle them! parentMustHandleChildren = false; return _createMesh(domNode); ! } else if(strcmp(nodeName, "Transform") == 0) { // parent must ignore children, we can handle them! //parentMustHandleChildren = false; return _createTransform(domNode); ! } else if(strcmp(nodeName, "Material") == 0) { return _createMaterial(domNode); --- 128,150 ---- } ! SceneObject* X3DLoader::_createSceneObjectFromDOMNode(xmlNode* domNode, bool& parentMustHandleChildren) { assert(domNode != NULL); ! assert(domNode->type == XML_ELEMENT_NODE); // get a usefull version of this node's name ! const xmlChar* nodeName = domNode->name; // This is the only node we are going to handle for the moment ! if(xmlStrEqual(nodeName, (const xmlChar*)"IndexedFaceSet") == 0) { // parent must ignore children, we can handle them! parentMustHandleChildren = false; return _createMesh(domNode); ! } else if(xmlStrEqual(nodeName, (const xmlChar*)"Transform") == 0) { // parent must ignore children, we can handle them! //parentMustHandleChildren = false; return _createTransform(domNode); ! } else if(xmlStrEqual(nodeName, (const xmlChar*)"Material") == 0) { return _createMaterial(domNode); *************** *** 185,189 **** } ! SceneObject* X3DLoader::_createMaterial(DOMNode* domNode) { Material* material = new Material(); --- 161,165 ---- } ! SceneObject* X3DLoader::_createMaterial(xmlNode* domNode) { Material* material = new Material(); *************** *** 205,238 **** // get the attributes (containing the coord/normal indexes) ! DOMNamedNodeMap* attributes = domNode->getAttributes(); ! if(attributes != NULL) { // get the ambientIntensity ! DOMNode* ambientIntensityNode = attributes->getNamedItem(XMLString::transcode("ambientIntensity")); ! if(ambientIntensityNode->getNodeValue() != NULL) { ! cout << "ambientIntensityNode [" << XMLString::transcode(ambientIntensityNode->getNodeValue()) << "]" << endl; } // get the ambientIntensity ! DOMNode* shininessNode = attributes->getNamedItem(XMLString::transcode("shininess")); ! if(shininessNode->getNodeValue() != NULL) { ! cout << "shininessNode [" << XMLString::transcode(shininessNode->getNodeValue()) << "]" << endl; } ! DOMNode* emissionNode = attributes->getNamedItem(XMLString::transcode("emissiveColor")); ! if(emissionNode->getNodeValue() != NULL) { ! cout << "emissionNode [" << XMLString::transcode(emissionNode->getNodeValue()) << "]" << endl; ! _convertCharToVector(emission, XMLString::transcode(emissionNode->getNodeValue())); } ! DOMNode* diffuseColorNode = attributes->getNamedItem(XMLString::transcode("diffuseColor")); ! if(diffuseColorNode->getNodeValue() != NULL) { ! cout << "diffuseColorNode [" << XMLString::transcode(diffuseColorNode->getNodeValue()) << "]" << endl; ! _convertCharToVector(diffuse, XMLString::transcode(diffuseColorNode->getNodeValue())); } ! DOMNode* specularColorNode = attributes->getNamedItem(XMLString::transcode("specularColor")); ! if(specularColorNode->getNodeValue() != NULL) { ! cout << "specularColorNode [" << XMLString::transcode(specularColorNode->getNodeValue()) << "]" << endl; ! _convertCharToVector(specular, XMLString::transcode(specularColorNode->getNodeValue())); } --- 181,213 ---- // get the attributes (containing the coord/normal indexes) ! if(domNode->properties != NULL) { // get the ambientIntensity ! const xmlChar* ambientIntensityNode = xmlGetProp(domNode, (const xmlChar*)"ambientIntensity"); ! if(ambientIntensityNode) { ! cout << "ambientIntensityNode [" << ambientIntensityNode << "]" << endl; } // get the ambientIntensity ! const xmlChar* shininessNode = xmlGetProp(domNode, (const xmlChar*)"shininess"); ! if(shininessNode) { ! cout << "shininessNode [" << shininessNode << "]" << endl; } ! const xmlChar* emissionNode = xmlGetProp(domNode, (const xmlChar*)"emissiveColor"); ! if(emissionNode) { ! cout << "emissionNode [" << emissionNode << "]" << endl; ! _convertCharToVector(emission, (const char*)emissionNode); } ! const xmlChar* diffuseColorNode = xmlGetProp(domNode, (const xmlChar*)"diffuseColor"); ! if(diffuseColorNode) { ! cout << "diffuseColorNode [" << diffuseColorNode << "]" << endl; ! _convertCharToVector(diffuse, (const char*)diffuseColorNode); } ! const xmlChar* specularColorNode = xmlGetProp(domNode, (const xmlChar*)"specularColor"); ! if(specularColorNode) { ! cout << "specularColorNode [" << specularColorNode << "]" << endl; ! _convertCharToVector(specular, (const char*)specularColorNode); } *************** *** 241,246 **** assert(specular.size() == 3); ! material->setAmbient(atof(XMLString::transcode(ambientIntensityNode->getNodeValue()))); ! material->setShininess(atof(XMLString::transcode(shininessNode->getNodeValue()))); material->setDiffuse(diffuse); material->setEmission(emission); --- 216,221 ---- assert(specular.size() == 3); ! material->setAmbient(atof((const char*)ambientIntensityNode)); ! material->setShininess(atof((const char*)shininessNode)); material->setDiffuse(diffuse); material->setEmission(emission); *************** *** 252,256 **** } ! SceneObject* X3DLoader::_createTransform(DOMNode* domNode) { Transform* transform = new Transform(); --- 227,231 ---- } ! SceneObject* X3DLoader::_createTransform(xmlNode* domNode) { Transform* transform = new Transform(); *************** *** 264,288 **** // get the attributes (containing the coord/normal indexes) ! DOMNamedNodeMap* attributes = domNode->getAttributes(); ! if(attributes != NULL) { // get the rotation ! DOMNode* rotationNode = attributes->getNamedItem(XMLString::transcode("rotation")); ! if(rotationNode->getNodeValue() != NULL) { ! cout << "rotation [" << XMLString::transcode(rotationNode->getNodeValue()) << "]" << endl; ! _convertCharToVector(rotationElements, XMLString::transcode(rotationNode->getNodeValue())); } // get the translation ! DOMNode* translationNode = attributes->getNamedItem(XMLString::transcode("translation")); ! if(translationNode->getNodeValue() != NULL) { ! cout << "translation [" << XMLString::transcode(translationNode->getNodeValue()) << "]" << endl; ! _convertCharToVector(translationElements, XMLString::transcode(translationNode->getNodeValue())); } // get the scale ! DOMNode* scaleNode = attributes->getNamedItem(XMLString::transcode("scale")); ! if(scaleNode->getNodeValue() != NULL) { ! cout << "scale [" << XMLString::transcode(scaleNode->getNodeValue()) << "]" << endl; ! _convertCharToVector(scaleElements, XMLString::transcode(scaleNode->getNodeValue())); } --- 239,262 ---- // get the attributes (containing the coord/normal indexes) ! if(domNode->properties != NULL) { // get the rotation ! xmlChar* rotationNode = xmlGetProp(domNode, (const xmlChar*)"rotation"); ! if(rotationNode) { ! cout << "rotation [" << rotationNode << "]" << endl; ! _convertCharToVector(rotationElements, (const char*)rotationNode); } // get the translation ! xmlChar* translationNode = xmlGetProp(domNode, (const xmlChar*)"translation"); ! if(translationNode) { ! cout << "translation [" << translationNode << "]" << endl; ! _convertCharToVector(translationElements, (const char*)translationNode); } // get the scale ! xmlChar* scaleNode = xmlGetProp(domNode, (const xmlChar*)"scale"); ! if(scaleNode) { ! cout << "scale [" << scaleNode << "]" << endl; ! _convertCharToVector(scaleElements, (const char*)scaleNode); } *************** *** 322,326 **** } ! SceneObject* X3DLoader::_createMesh(DOMNode* domNode) { // this is a mesh Mesh* mesh = new Mesh(); --- 296,300 ---- } ! SceneObject* X3DLoader::_createMesh(xmlNode* domNode) { // this is a mesh Mesh* mesh = new Mesh(); *************** *** 332,387 **** // get the attributes (containing the coord/normal indexes) ! DOMNamedNodeMap* attributes = domNode->getAttributes(); ! if(attributes != NULL) { // get the coord indices ! DOMNode* coordIndexesNode = attributes->getNamedItem(XMLString::transcode("coordIndex")); ! if(coordIndexesNode->getNodeValue() != NULL) { ! //cout << "coordIndexes [" << XMLString::transcode(coordIndexesNode->getNodeValue()) << "]" << endl; ! _convertCharToVector(coordIndexes, XMLString::transcode(coordIndexesNode->getNodeValue())); } // get the normal indices ! DOMNode* normalIndexesNode = attributes->getNamedItem(XMLString::transcode("normalIndex")); ! if(normalIndexesNode->getNodeValue() != NULL) { ! //cout << "normalIndexes [" << XMLString::transcode(normalIndexesNode->getNodeValue()) << "]" << endl; ! _convertCharToVector(normalIndexes, XMLString::transcode(normalIndexesNode->getNodeValue())); } } // now we need to get the coord/normal objects nodes ! DOMNode* curChild = domNode->getFirstChild(); ! while(curChild != NULL) { ! if(curChild->getNodeType() == DOMNode::ELEMENT_NODE) { ! cout << "IndexedFaceSet node type [" << domNode->getNodeType() << "] node name [" << XMLString::transcode(domNode->getNodeName()) << "]" << endl; ! char* childNodeName = XMLString::transcode(curChild->getNodeName()); // get the attributes (containing the coord/normal indexes) ! DOMNamedNodeMap* curChildAttributes = curChild->getAttributes(); ! ! if(curChildAttributes != NULL) { ! if(strcmp(childNodeName, "Coordinate") == 0) { cout << "<X3DLoader::_createSceneObjectFromDOMNode>\tgot coordinate child" << endl; // get the coord indices ! DOMNode* coordsNode = curChildAttributes->getNamedItem(XMLString::transcode("point")); ! if((coordsNode != NULL) && (coordsNode->getNodeValue() != NULL)) { ! cout << "<X3DLoader::_createSceneObjectFromDOMNode>\tgot point attribute" << endl; ! _convertCharToVector(coords, XMLString::transcode(coordsNode->getNodeValue())); } ! } else if(strcmp(childNodeName, "Normal") == 0) { cout << "<X3DLoader::_createSceneObjectFromDOMNode>\tgot normal child" << endl; // get the coord indices ! DOMNode* normalsNode = curChildAttributes->getNamedItem(XMLString::transcode("vector")); ! if((normalsNode != NULL) && (normalsNode->getNodeValue() != NULL)) { cout << "<X3DLoader::_createSceneObjectFromDOMNode>\tgot vector attribute" << endl; ! _convertCharToVector(normals, XMLString::transcode(normalsNode->getNodeValue())); } } } } - - // now get the child's sibling - DOMNode* nextChild = curChild->getNextSibling(); - curChild = nextChild; } --- 306,353 ---- // get the attributes (containing the coord/normal indexes) ! if(domNode->properties != NULL) { // get the coord indices ! xmlChar* coordIndexesNode = xmlGetProp(domNode, (const xmlChar*)"coordIndex"); ! if(coordIndexesNode) { ! //cout << "coordIndexes [" << coordIndexesNode << "]" << endl; ! _convertCharToVector(coordIndexes, (const char*)coordIndexesNode); } // get the normal indices ! xmlChar* normalIndexesNode = xmlGetProp(domNode, (const xmlChar*)"normalIndex"); ! if(normalIndexesNode) { ! //cout << "normalIndexes [" << normalIndexesNode << "]" << endl; ! _convertCharToVector(normalIndexes, (const char*)normalIndexesNode); } } // now we need to get the coord/normal objects nodes ! for (xmlNode *curChild = domNode; curChild; curChild = curChild->next) { ! if(curChild->type == XML_ELEMENT_NODE) { ! cout << "IndexedFaceSet node type [" << curChild->type << "] node name [" << (const char*)curChild->name << "]" << endl; ! const xmlChar* childNodeName = curChild->name; // get the attributes (containing the coord/normal indexes) ! if(curChild->properties != NULL) { ! if(xmlStrEqual(childNodeName, (const xmlChar*)"Coordinate") == 0) { cout << "<X3DLoader::_createSceneObjectFromDOMNode>\tgot coordinate child" << endl; // get the coord indices ! const xmlChar* coordsNode = xmlGetProp(domNode, (const xmlChar*)"point"); ! if(coordsNode) { ! cout << "<X3DLoader::_createSceneObjectFromxmlNode>\tgot point attribute" << endl; ! _convertCharToVector(coords, (const char*)coordsNode); } ! } else if(xmlStrEqual(childNodeName, (const xmlChar*)"Normal") == 0) { cout << "<X3DLoader::_createSceneObjectFromDOMNode>\tgot normal child" << endl; // get the coord indices ! const xmlChar* normalsNode = xmlGetProp(domNode, (const xmlChar*)"vector"); ! if(normalsNode) { cout << "<X3DLoader::_createSceneObjectFromDOMNode>\tgot vector attribute" << endl; ! _convertCharToVector(normals, (const char*)normalsNode); } } } } } *************** *** 523,529 **** /* $Log$ ! Revision 1.1 2005/01/28 20:26:58 o3dozone ! - some refactoring ! - simple sphere scene object */ --- 489,495 ---- /* $Log$ ! Revision 1.2 2005/01/28 20:54:51 o3dozone ! - dual viewpoints ! - various other changes */ Index: simple_sphere.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/simple_sphere.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** simple_sphere.cpp 28 Jan 2005 20:26:58 -0000 1.1 --- simple_sphere.cpp 28 Jan 2005 20:54:51 -0000 1.2 *************** *** 23,29 **** /* $Log$ ! Revision 1.1 2005/01/28 20:26:58 o3dozone ! - some refactoring ! - simple sphere scene object */ --- 23,29 ---- /* $Log$ ! Revision 1.2 2005/01/28 20:54:51 o3dozone ! - dual viewpoints ! - various other changes */ Index: x3d_loader.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/x3d_loader.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** x3d_loader.h 28 Jan 2005 20:26:58 -0000 1.1 --- x3d_loader.h 28 Jan 2005 20:54:51 -0000 1.2 *************** *** 5,15 **** #include <iostream> - #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> - #include "scene_object.h" #include "model_loader.h" --- 5,8 ---- *************** *** 20,25 **** #include <vector> - XERCES_CPP_NAMESPACE_USE - using namespace std; --- 13,16 ---- *************** *** 27,30 **** --- 18,22 ---- public: X3DLoader(); + ~X3DLoader(); virtual SceneObject* loadModel(const string filename); *************** *** 32,40 **** private: SceneObject* _parseX3DFile(const char* filename); ! SceneObject* _convertDOMNode(DOMNode* domNode, SceneObject* parent = NULL, long curLevel = 0); ! SceneObject* _createSceneObjectFromDOMNode(DOMNode* domNode, bool& parentMustHandleChildren); ! SceneObject* _createTransform(DOMNode* domNode); ! SceneObject* _createMaterial(DOMNode* domNode); ! SceneObject* _createMesh(DOMNode* domNode); bool _convertCharToVector(vector<int>& intVector, string intString); bool _convertCharToVector(vector<double>& intVector, string intString); --- 24,32 ---- private: SceneObject* _parseX3DFile(const char* filename); ! SceneObject* _convertDOMNode(xmlNode* domNode, SceneObject* parent = NULL, long curLevel = 0); ! SceneObject* _createSceneObjectFromDOMNode(xmlNode* domNode, bool& parentMustHandleChildren); ! SceneObject* _createTransform(xmlNode* domNode); ! SceneObject* _createMaterial(xmlNode* domNode); ! SceneObject* _createMesh(xmlNode* domNode); bool _convertCharToVector(vector<int>& intVector, string intString); bool _convertCharToVector(vector<double>& intVector, string intString); *************** *** 43,49 **** /* $Log$ ! Revision 1.1 2005/01/28 20:26:58 o3dozone ! - some refactoring ! - simple sphere scene object */ --- 35,41 ---- /* $Log$ ! Revision 1.2 2005/01/28 20:54:51 o3dozone ! - dual viewpoints ! - various other changes */ Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** gravity.cpp 28 Jan 2005 09:07:46 -0000 1.10 --- gravity.cpp 28 Jan 2005 20:54:51 -0000 1.11 *************** *** 6,9 **** --- 6,10 ---- #include "model_loader.h" #include "x3d_loader.h" + #include "simple_sphere.h" // BAH! Globals! *************** *** 91,96 **** --- 92,99 ---- break; case SDLK_z: + SystemStateSingleton::instance().viewPointIndex--; break; case SDLK_x: + SystemStateSingleton::instance().viewPointIndex++; break; case SDLK_h: *************** *** 425,429 **** //objectArray.resize(MAX_OBJECTARRAY_SIZE); ! RenderState renderState(640, 480); srand(time(NULL)); --- 428,432 ---- //objectArray.resize(MAX_OBJECTARRAY_SIZE); ! RenderState renderState(1024, 480); srand(time(NULL)); *************** *** 457,461 **** opengl_init(); ! reshape_screen(0, 0, renderState.screenWidth(), renderState.screenHeight()); Coord3D rotation; --- 460,474 ---- opengl_init(); ! ! int screenCentreX = renderState.screenWidth() / 2; ! int screenCentreY = renderState.screenHeight() / 2; ! ! reshape_screen(0, 0, screenCentreX, renderState.screenHeight()); ! reshape_screen(screenCentreX + 1, 0, renderState.screenWidth(), renderState.screenHeight()); ! ! Coord3D staticViewpointRotation; ! staticViewpointRotation.m_x = -90; ! Coord3D staticViewpointPosition; ! staticViewpointPosition.m_y = -5; Coord3D rotation; *************** *** 472,476 **** for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { ! objectArray.push_back(rocket); } objectArray.push_back(slugMobile); --- 485,489 ---- for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { ! objectArray.push_back(slugMobile); } objectArray.push_back(slugMobile); *************** *** 483,487 **** } - /* // disable mouse display SDL_ShowCursor(SDL_DISABLE); --- 496,499 ---- *************** *** 489,492 **** --- 501,505 ---- SDL_WM_GrabInput(SDL_GRAB_ON); + // *** NOTE *** The constructor for this object uses SDL_GetTicks (and possibly others) // so only start using this once everything has started up (SDL etc) *************** *** 494,498 **** StatGraphRenderer statGraphRenderer(&renderState); statGraphRenderer.setShape(10, 10, 60, 30); ! */ /* --- 507,511 ---- StatGraphRenderer statGraphRenderer(&renderState); statGraphRenderer.setShape(10, 10, 60, 30); ! /* *************** *** 539,542 **** --- 552,558 ---- // same position as the viewpoint paintball->getPos() = position; + paintball->getPos().m_y *= -1; + paintball->getPos().m_x *= -1; + paintball->setMass(1000000); objectArray.push_back(*paintball); *************** *** 564,568 **** } - reshape_screen(0, 0, renderState.screenWidth(), renderState.screenHeight()); // Clear the color and depth buffers. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); --- 580,583 ---- *************** *** 576,579 **** --- 591,597 ---- // statGraphRenderer.render(); + // *** screen 1 *** + reshape_screen(0, 0, screenCentreX, renderState.screenHeight()); + doLighting(lightPos, SystemStateSingleton::instance().lighting); *************** *** 594,597 **** --- 612,648 ---- //glPopMatrix(); } + + + // *** screen 2 *** + reshape_screen(screenCentreX + 1, 0, renderState.screenWidth(), renderState.screenHeight()); + doLighting(lightPos, SystemStateSingleton::instance().lighting); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + //doViewPointTransforms(staticViewpointRotation, staticViewpointPosition); + if(SystemStateSingleton::instance().viewPointIndex < 0) { + SystemStateSingleton::instance().viewPointIndex = objectArray.size() - 1; + } else if(SystemStateSingleton::instance().viewPointIndex >= objectArray.size()) { + SystemStateSingleton::instance().viewPointIndex = 0; + } + + Coord3D tempPos = objectArray[SystemStateSingleton::instance().viewPointIndex].getPos(); + tempPos.m_x *= -1; + tempPos.m_y *= -1; + + doViewPointTransforms(staticViewpointRotation, tempPos); + drawEnvironment(landscape); + drawReferenceLines(1.0, 1.0, 1.0); + + // draw objects + modelRotation++; + cerr << "objectArraySize [" << objectArray.size() << "]" << endl; + for(vector<Object3D>::iterator i = objectArray.begin(); i != objectArray.end(); i++) { + //glPushMatrix(); + // glRotatef(modelRotation * degreeToRadianRatio, 1.0, 0.0, 0.0); + (*i).draw(); + //glPopMatrix(); + } SDL_GL_SwapBuffers(); } *************** *** 608,611 **** --- 659,666 ---- /* $Log$ + Revision 1.11 2005/01/28 20:54:51 o3dozone + - dual viewpoints + - various other changes + Revision 1.10 2005/01/28 09:07:46 o3dozone - many changes, including gravity and more control using the keyboard |