You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(10) |
Aug
(7) |
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Mike D. <o3d...@us...> - 2005-07-24 14:11:07
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28901 Modified Files: landscape.cpp landscape.h Log Message: - sinewave changes to landscape now working Index: landscape.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/landscape.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** landscape.h 9 Jul 2005 10:47:31 -0000 1.1 --- landscape.h 24 Jul 2005 14:10:50 -0000 1.2 *************** *** 14,18 **** class SineWave { public: ! SineWave(int initialSize, Coord3D startingPoint); double yValueAtPoint(const Coord3D& point); --- 14,19 ---- class SineWave { public: ! SineWave(double initialSize, int waveLength, Coord3D startingPoint); ! SineWave(const SineWave& rhs); double yValueAtPoint(const Coord3D& point); *************** *** 22,26 **** long m_totalTicks; Coord3D m_startingPoint; ! int m_initialSize; }; --- 23,28 ---- long m_totalTicks; Coord3D m_startingPoint; ! double m_initialSize; ! int m_waveLength; }; Index: landscape.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/landscape.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** landscape.cpp 9 Jul 2005 10:47:31 -0000 1.1 --- landscape.cpp 24 Jul 2005 14:10:50 -0000 1.2 *************** *** 12,21 **** _populateMesh(); ! m_waves.push_back(SineWave(100, Coord3D(10,20,30))); ! m_waves.push_back(SineWave(100, Coord3D(20,25,25))); ! m_waves.push_back(SineWave(100, Coord3D(12,15,50))); ! m_waves.push_back(SineWave(100, Coord3D(10,20,30))); ! m_waves.push_back(SineWave(100, Coord3D(10,20,30))); ! m_waves.push_back(SineWave(100, Coord3D(10,20,30))); } --- 12,21 ---- _populateMesh(); ! m_waves.push_back(SineWave(5, 5, Coord3D(10,20,30))); ! m_waves.push_back(SineWave(15, 15, Coord3D(50,25,25))); ! m_waves.push_back(SineWave(50, 4, Coord3D(12,15,50))); ! m_waves.push_back(SineWave(40, 2, Coord3D(30,23,30))); ! m_waves.push_back(SineWave(12, 23, Coord3D(90,40,30))); ! m_waves.push_back(SineWave(50, 30, Coord3D(40,60,30))); } *************** *** 82,86 **** bool LandScape::_updateWaves() { - double curDistance; Coord3D curPoint; --- 82,85 ---- *************** *** 91,95 **** --- 90,97 ---- } + int waveCount = 0; for(vector<SineWave>::iterator i = m_waves.begin(); i != m_waves.end(); i++) { + //cerr << "<LandScape::_populateMesh>\twaveCount [" << waveCount++ << "]" << endl; + i->addTicks(SystemStateSingleton::instance().tickDiff); *************** *** 99,103 **** curPoint.m_y = 0; curPoint.m_z = z; ! m_heights[x][z] += curDistance = i->yValueAtPoint(curPoint); } } --- 101,109 ---- curPoint.m_y = 0; curPoint.m_z = z; ! double height = i->yValueAtPoint(curPoint); ! // *** NOTE *** !!!!Hard-coded limiting here!!!! ! if((m_heights[x][z] < 1000) && (height < 1000)) { ! m_heights[x][z] += height; ! } } } *************** *** 119,130 **** */ ! SineWave::SineWave(int initialSize, Coord3D startingPoint) { m_initialSize = initialSize; m_startingPoint = startingPoint; } double SineWave::yValueAtPoint(const Coord3D& point) { double distance = m_startingPoint.distanceScalar(point); ! return ((m_initialSize / (distance + 1)) * sin((distance / 10) + (m_totalTicks / 500))); } --- 125,179 ---- */ ! SineWave::SineWave(double initialSize, int waveLength, Coord3D startingPoint) { m_initialSize = initialSize; m_startingPoint = startingPoint; + m_waveLength = waveLength; + m_totalTicks = 0; + } + + SineWave::SineWave(const SineWave& rhs) { + m_initialSize = rhs.m_initialSize; + m_startingPoint = rhs.m_startingPoint; + m_waveLength = rhs.m_waveLength; + m_totalTicks = 0; } double SineWave::yValueAtPoint(const Coord3D& point) { + // distance from the point of origin double distance = m_startingPoint.distanceScalar(point); ! ! const double maxTicks = 100000; ! // linear time drop off ! double timeDropOffFactor = (maxTicks - m_totalTicks) / maxTicks; ! ! //cerr << "<SineWave::yValueAtPoint>\tm_totalTicks [" << m_totalTicks << "]" << endl; ! ! // cut off after 2000 ticks ! if(m_totalTicks > maxTicks) { ! return 0; ! } ! ! // wavelength number ! double waveLengthNumber = distance / m_waveLength; ! ! const double maxWaveLengths = 10; ! // cut off after the 10th wavelength ! if(waveLengthNumber > maxWaveLengths) { ! return 0; ! } ! ! // linear drop-off from the point of origin ! double pointWaveSize = m_initialSize * ((maxWaveLengths - waveLengthNumber) / maxWaveLengths); ! // radians/unit length ! const double radiansToUnitLength = (3.14 * 2) / m_waveLength; ! // time-based alpha offset ! double timeAlphaOffset = ((double)m_totalTicks / 1000) * 10 * radiansToUnitLength; ! // this is a sine wave after all! ! double sineFactor = sin(((100 - distance) * radiansToUnitLength) + timeAlphaOffset); ! ! //cerr << "<SineWave::yValueAtPoint>\tm_totalTicks [" << m_totalTicks << "] distance [" << distance << "] timeDropOffFactor [" << timeDropOffFactor << "] pointWaveSize [" << pointWaveSize << "] waveLengthNumber [" << waveLengthNumber << "] sineFactor [" << sineFactor << "]" << endl; ! ! // combine all of the above ! return pointWaveSize * sineFactor * timeDropOffFactor; } *************** *** 141,144 **** --- 190,197 ---- /* $Log$ + Revision 1.2 2005/07/24 14:10:50 o3dozone + - sinewave changes to landscape + now working + Revision 1.1 2005/07/09 10:47:31 o3dozone - viewpoint changes |
|
From: Mike D. <o3d...@us...> - 2005-07-09 10:47:40
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29326 Modified Files: coord3d.h gravity.cpp makefile mesh.cpp mesh.h model.cpp model.h object3d.cpp object3d.h polygon.cpp polygon.h x3d_loader.cpp Added Files: Makefile.win collisions.cpp gravity.dev landscape.cpp landscape.h Log Message: - viewpoint changes - landscape added - landscape waves added - object collision with landscape added - windows dev files added Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** gravity.cpp 28 Jan 2005 20:54:51 -0000 1.11 --- gravity.cpp 9 Jul 2005 10:47:31 -0000 1.12 *************** *** 7,14 **** #include "x3d_loader.h" #include "simple_sphere.h" // BAH! Globals! const double degreeToRadianRatio = M_PI / 180; // a factor to convert between degrees and radians ! const double metersToCoordUnits = (double)1 / (double)10; // 1m = 100 coord units bool handleEvents(Coord3D& rotation, Coord3D& position, Coord3D& velocity) { --- 7,15 ---- #include "x3d_loader.h" #include "simple_sphere.h" + #include "landscape.h" // BAH! Globals! const double degreeToRadianRatio = M_PI / 180; // a factor to convert between degrees and radians ! const double metersToCoordUnits = 1; //(double)1 / (double)100; // 1m = 100 coord units bool handleEvents(Coord3D& rotation, Coord3D& position, Coord3D& velocity) { *************** *** 252,266 **** for(int i = 1; i < objectCount; i++) { Coord3D& position = objectArray[i].getPos(); ! position.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)30) - 15; ! position.m_y = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)30) - 15; ! position.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)30) - 15; - /* Coord3D& velocity = objectArray[i].getVelocity(); ! velocity.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; ! velocity.m_y = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; ! velocity.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; ! */ ! Coord3D& rotation = objectArray[i].getRotation(); rotation.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)360) - 180; --- 253,265 ---- for(int i = 1; i < objectCount; i++) { Coord3D& position = objectArray[i].getPos(); ! position.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)300) - 150; ! position.m_y = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)300); ! position.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)300) - 150; Coord3D& velocity = objectArray[i].getVelocity(); ! velocity.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)50) - 25; ! velocity.m_y = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)50) - 25; ! velocity.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)50) - 25; ! Coord3D& rotation = objectArray[i].getRotation(); rotation.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)360) - 180; *************** *** 269,273 **** double mass = (rand() / (double)RAND_MAX) * (double)1000000; ! objectArray[i].setMass(mass); //cout << "<randomiseObjects>\tposition x [" << position.m_x << "] y [" << position.m_y << "] z [" << position.m_z << "]" << endl; --- 268,272 ---- double mass = (rand() / (double)RAND_MAX) * (double)1000000; ! objectArray[i].setMass(mass); //cout << "<randomiseObjects>\tposition x [" << position.m_x << "] y [" << position.m_y << "] z [" << position.m_z << "]" << endl; *************** *** 280,283 **** --- 279,295 ---- } + void handleCollisions(vector<Object3D>& objectArray) { + long objectCount = objectArray.size(); + for(int curObjectIndex = 0; curObjectIndex < objectCount; curObjectIndex++) { + Coord3D& velocity = objectArray[curObjectIndex].getVelocity(); + Coord3D& position = objectArray[curObjectIndex].getPos(); + + if(position.m_y <= 0) { + velocity.m_y *= -0.80; + position.m_y = 0; + } + } + } + void applyGravity(vector<Object3D>& objectArray) { long objectCount = objectArray.size(); *************** *** 295,298 **** --- 307,314 ---- pos_t moveRatio = SystemStateSingleton::instance().moveRatio; + // check for object collisions + // and update object(s) position + handleCollisions(objectArray); + for(int curObjectIndex = 0; curObjectIndex < objectCount; curObjectIndex++) { // update positions according to *************** *** 302,305 **** --- 318,322 ---- position.m_y += velocity.m_y * moveRatio; position.m_z += velocity.m_z * moveRatio; + } *************** *** 392,425 **** } - void drawEnvironment(GLdouble landscape[100][100]) { - // draw the ground - GLdouble vertexX, vertexZ; - for(int x = 0; x < 99; x++) { - vertexX = (x * 10) - 500; - glBegin(GL_QUAD_STRIP); - for(int z = 0; z < 99; z++) { - if((z % 2 == 0) && (x % 2 == 0)) { - glColor3f(1.0, 0.0, 0.0); - } else { - glColor3f(0.0, 1.0, 0.0); - } - vertexZ = (z * 10) - 500; - glVertex3f(vertexX, landscape[x][z], vertexZ); - glVertex3f(vertexX + 10, landscape[x + 1][z], vertexZ); - glVertex3f(vertexX, landscape[x][z + 1], vertexZ + 10); - glVertex3f(vertexX + 10, landscape[x + 1][z + 1], vertexZ + 10); - } - glEnd(); - } - } - - void setupEnvironment(GLdouble landscape[100][100]) { - for(int x = 0; x < 100; x++) { - for(int z = 0; z < 100; z++) { - landscape[x][z] = 1.0 - (2.0 * rand()/(RAND_MAX+1.0)); - } - } - } - int main(int argc, char* argv[]) { SystemStateSingleton::instance().done = false; --- 409,412 ---- *************** *** 441,444 **** --- 428,432 ---- SceneObject* slugMobile = modelLoader->loadModel("slug_mobile.x3d"); SceneObject* rocket = modelLoader->loadModel("rocket.x3d"); + SceneObject* landscape = new LandScape(); int flags = SDL_OPENGL; // | SDL_FULLSCREEN; *************** *** 474,479 **** --- 462,472 ---- Coord3D rotation; Coord3D position; + Coord3D velocity; Coord3D lightPos; + lightPos.m_x = 0; + lightPos.m_y = 0; + lightPos.m_z = 0; + position.m_z = -15; *************** *** 481,492 **** slugMobile->makeDisplayList(); rocket->makeDisplayList(); long objectCount = 0; for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { objectArray.push_back(slugMobile); } ! objectArray.push_back(slugMobile); ! objectCount++; // randomise the object's initial position --- 474,492 ---- slugMobile->makeDisplayList(); rocket->makeDisplayList(); + //landscape->makeDisplayList(); long objectCount = 0; + //objectArray.push_back(landscape); + //objectCount++; + Object3D landScapeObject(landscape); + landScapeObject.shouldScale(false); + for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { objectArray.push_back(slugMobile); } ! ! //objectArray.push_back(slugMobile); ! //objectCount++; // randomise the object's initial position *************** *** 518,528 **** double modelRotation = 0.0; GLdouble landscape[100][100]; setupEnvironment(landscape); // now loop until we are done while(!SystemStateSingleton::instance().done) { //cerr << "frame" << endl; ! if(!handleEvents(rotation, position, lightPos)) { printf("Error in event handler!\n"); exit(-1); --- 518,530 ---- double modelRotation = 0.0; + /* GLdouble landscape[100][100]; setupEnvironment(landscape); + */ // now loop until we are done while(!SystemStateSingleton::instance().done) { //cerr << "frame" << endl; ! if(!handleEvents(rotation, position, velocity)) { printf("Error in event handler!\n"); exit(-1); *************** *** 600,609 **** doViewPointTransforms(rotation, position); ! 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(); --- 602,614 ---- doViewPointTransforms(rotation, position); ! //drawEnvironment(landscape); drawReferenceLines(1.0, 1.0, 1.0); + // draw the landscape + landScapeObject.draw(); + // draw objects modelRotation++; ! //cerr << "objectArraySize [" << objectArray.size() << "]" << endl; for(vector<Object3D>::iterator i = objectArray.begin(); i != objectArray.end(); i++) { //glPushMatrix(); *************** *** 633,642 **** 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(); --- 638,647 ---- 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(); *************** *** 659,662 **** --- 664,674 ---- /* $Log$ + Revision 1.12 2005/07/09 10:47:31 o3dozone + - viewpoint changes + - landscape added + - landscape waves added + - object collision with landscape added + - windows dev files added + Revision 1.11 2005/01/28 20:54:51 o3dozone - dual viewpoints --- NEW FILE: collisions.cpp --- // this flags which combos we've already done // *** NOTE *** This _will_ have a performance impact // It needs to be static or done a different way map<pair<int, int>, bool> doneMap; for(int curObjectIndex = 0; curObjectIndex < objectCount; curObjectIndex++) { // first, check for a collision // *** NOTE *** this is terribly inefficient right now for(int collisionObjectIndex = 0; collisionObjectIndex < objectCount; collisionObjectIndex++) { // skip my own object if(curObjectIndex == collisionObjectIndex) { continue; } else if(doneMap[pair<int, int>(curObjectIndex, collisionObjectIndex)]) { continue; } Coord3D& curPosition = objectArray[curObjectIndex].getPos(); Coord3D& collisionObjectPos = objectArray[collisionObjectIndex].getPos(); Coord3D& curObjectVelocity = objectArray[curObjectIndex].getVelocity(); Coord3D& collisionObjectVelocity = objectArray[collisionObjectIndex].getVelocity(); double curObjectG = objectArray[curObjectIndex].getG(); double collisionObjectG = objectArray[collisionObjectIndex].getG(); // collisions /* if(curPosition.distance(collisionObjectPos).length() <= 1) { cout << "<updateObjects>\tcollision between curObjectIndex [" << curObjectIndex << "] and collisionObjectIndex [" << collisionObjectIndex << "]" << endl; // *** NOTE *** we only modify the local object, because // the other object will be done later on in the main loop double massRatio = objectArray[curObjectIndex].getMass() / objectArray[collisionObjectIndex].getMass(); Coord3D resultant = curObjectVelocity + collisionObjectVelocity; curObjectVelocity = resultant; } doneMap[pair<int, int>(curObjectIndex, collisionObjectIndex)] = true; */ Coord3D posDiff = curPosition - collisionObjectPos; double posDiffSize = posDiff.length(); posDiff.normalise(); curObjectVelocity += posDiff * sqrt(posDiffSize) * -collisionObjectG; collisionObjectVelocity += posDiff * sqrt(posDiffSize) * curObjectG; } } --- NEW FILE: landscape.h --- #ifndef LANDSCAPE_H #define LANDSCAPE_H /* $Id: landscape.h,v 1.1 2005/07/09 10:47:31 o3dozone Exp $ */ #include "scene_object.h" #include "mesh.h" #include "polygon.h" #include "system_state.h" class SineWave { public: SineWave(int initialSize, Coord3D startingPoint); double yValueAtPoint(const Coord3D& point); bool addTicks(long ticks); const Coord3D& startingPoint(); private: long m_totalTicks; Coord3D m_startingPoint; int m_initialSize; }; using namespace std; class LandScape : public SceneObject { public: LandScape(SceneObject* parent = NULL); LandScape(const LandScape& rhs); virtual ~LandScape(); virtual LandScape& operator=(const LandScape& rhs); protected: virtual bool _draw(); private: Mesh m_mesh; GLdouble m_heights[100][100]; vector<SineWave> m_waves; bool _populateMesh(); bool _updateWaves(); }; #endif Index: model.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** model.cpp 21 Jul 2004 19:32:44 -0000 1.2 --- model.cpp 9 Jul 2005 10:47:31 -0000 1.3 *************** *** 24,29 **** ! ModelLoader* modelLoader = new X3DLoader(); ! SceneObject* slugMobile = modelLoader->loadModel(vrmlFilename); } --- 24,29 ---- ! //ModelLoader* modelLoader = new X3DLoader(); ! //SceneObject* slugMobile = modelLoader->loadModel(vrmlFilename); } --- NEW FILE: gravity.dev --- [Project] FileName=gravity.dev Name=Project1 UnitCount=34 Type=1 Ver=1 ObjFiles= Includes=C:\Dev-Cpp\include;C:\source\grappelmann\iconv-1.9.1.win32\include;C:\source\grappelmann\libxml2-2.6.19.win32\include;C:\source\grappelmann\zlib-1.2.2.win32\include;C:\source\grappelmann\SDL-1.2.8\include;C:\source\grappelmann\SDL-1.2.8\include\SDL;C:\source\grappelmann\spaceplane Libs=C:\Dev-Cpp\lib;C:\Dev-Cpp\mingw32\lib;C:\Dev-Cpp\bin PrivateResource= ResourceIncludes= MakeIncludes= Compiler= CppCompiler=-Ic:\\dev-cpp\\include_@@_-I"c:\\documents and settings\\administrator\\desktop\\source\\grappelmann\\spaceplane"_@@_ Linker=../libxml2-2.6.19.win32/lib/libxml2.lib_@@_-L../SDL-1.2.8/lib/_@@_-lopengl32 _@@_-lglu32 _@@_-lglut32_@@_../SDL-1.2.8/lib/SDL_win32_main.o_@@_-lSDL_@@_ IsCpp=1 Icon= ExeOutput= ObjectOutput= OverrideOutput=0 OverrideOutputName=gravity.exe HostApplication= Folders= CommandLine= UseCustomMakefile=0 CustomMakefile= IncludeVersionInfo=0 SupportXPThemes=0 CompilerSet=0 CompilerSettings=0000000000000000000000 [Unit2] FileName=gravity.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit4] FileName=mesh.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit5] FileName=model.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit6] FileName=model.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit7] FileName=object3d.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit8] FileName=mesh.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit9] FileName=polygon.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit11] FileName=opengl_utils.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit12] FileName=opengl_utils.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit13] FileName=model_loader.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit14] FileName=model_loader.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit15] FileName=x3d_loader.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit16] FileName=x3d_loader.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit17] FileName=object3d.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit18] FileName=scene_object.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit19] FileName=statgraph.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit20] FileName=statgraph.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit21] FileName=statgraphrenderer.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit23] FileName=transform.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit24] FileName=transform.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit25] FileName=simple_sphere.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit26] FileName=landscape.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit28] FileName=landscape.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit29] FileName=material.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit30] FileName=material.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit33] FileName=vrml_v1.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit35] FileName=transform.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit36] FileName=transform.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit38] FileName=vrml_v1.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit39] FileName=vrml_v1.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit40] FileName=x3d_loader.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit41] FileName=collisions.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [VersionInfo] Major=0 Minor=1 Release=1 Build=1 LanguageID=1033 CharsetID=1252 CompanyName= FileVersion= FileDescription=Developed using the Dev-C++ IDE InternalName= LegalCopyright= LegalTrademarks= OriginalFilename= ProductName= ProductVersion= AutoIncBuildNr=0 [Unit22] FileName=statgraphrenderer.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit27] FileName=simple_sphere.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit1] FileName=gravity.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit3] FileName=opengl_includes.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit10] FileName=polygon.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit31] FileName=system_state.h CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit32] FileName=system_state.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= [Unit34] FileName=vrml_v1.cpp CompileCpp=1 Folder=Project1 Compile=1 Link=1 Priority=1000 OverrideBuildCmd=0 BuildCmd= Index: coord3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/coord3d.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** coord3d.h 28 Jan 2005 20:54:51 -0000 1.3 --- coord3d.h 9 Jul 2005 10:47:31 -0000 1.4 *************** *** 126,129 **** --- 126,139 ---- }; + double distanceScalar(const Coord3D& rhs) { + Coord3D result(0, 0, 0); + + result.m_x = m_x - rhs.m_x; + result.m_y = m_y - rhs.m_y; + result.m_z = m_z - rhs.m_z; + + return sqrt(pow(result.m_x, 2) + pow(result.m_y, 2) + pow(result.m_z, 2)); + }; + void normalise() { pos_t vectorLength = length(); Index: makefile =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/makefile,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** makefile 28 Jan 2005 20:54:51 -0000 1.8 --- makefile 9 Jul 2005 10:47:31 -0000 1.9 *************** *** 13,18 **** 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 --- 13,22 ---- 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 landscape.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 landscape.o all: gravity Index: mesh.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mesh.h 23 Jul 2004 05:43:48 -0000 1.3 --- mesh.h 9 Jul 2005 10:47:31 -0000 1.4 *************** *** 9,18 **** #include <vector> #include <iostream> #include "scene_object.h" - #include "polygon.h" using namespace std; class Mesh : public SceneObject { public: --- 9,20 ---- #include <vector> #include <iostream> + #include "polygon.h" #include "scene_object.h" using namespace std; + class Polygon2; + class Mesh : public SceneObject { public: *************** *** 21,25 **** virtual ~Mesh(); ! bool addPolygon(Polygon& polygon); virtual Mesh& operator=(const Mesh& rhs); --- 23,27 ---- virtual ~Mesh(); ! bool addPolygon(Polygon2& polygon); virtual Mesh& operator=(const Mesh& rhs); *************** *** 27,31 **** virtual bool _draw(); private: ! vector<Polygon> m_polygons; /* coordIndex --- 29,33 ---- virtual bool _draw(); private: ! vector<Polygon2> m_polygons; /* coordIndex *************** *** 38,41 **** --- 40,50 ---- /* $Log$ + Revision 1.4 2005/07/09 10:47:31 o3dozone + - viewpoint changes + - landscape added + - landscape waves added + - object collision with landscape added + - windows dev files added + Revision 1.3 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays Index: object3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** object3d.h 28 Jan 2005 20:54:51 -0000 1.7 --- object3d.h 9 Jul 2005 10:47:31 -0000 1.8 *************** *** 14,18 **** public: Object3D(SceneObject* sceneObject) ! : m_sceneObject(sceneObject) { m_diameter = 100; --- 14,18 ---- public: Object3D(SceneObject* sceneObject) ! : m_sceneObject(sceneObject), m_shouldScale(true) { m_diameter = 100; *************** *** 26,29 **** --- 26,33 ---- }; + bool shouldScale(bool shouldScale) { + return (m_shouldScale = shouldScale); + } + void setPos(Coord3D newPos) { m_pos = newPos; *************** *** 84,87 **** --- 88,92 ---- double m_g; double m_diameter; + bool m_shouldScale; void _calcG(); Index: x3d_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/x3d_loader.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** x3d_loader.cpp 28 Jan 2005 20:54:51 -0000 1.2 --- x3d_loader.cpp 9 Jul 2005 10:47:31 -0000 1.3 *************** *** 363,367 **** Coord3D coord; Coord3D normal; ! Polygon* curPolygon = new Polygon(); for(vector<int>::size_type i = 0; i < normalCount; i++) { --- 363,367 ---- Coord3D coord; Coord3D normal; ! Polygon2* curPolygon = new Polygon2(); for(vector<int>::size_type i = 0; i < normalCount; i++) { *************** *** 375,379 **** delete(curPolygon); ! curPolygon = new Polygon(); } else { coordIndex = coordIndexes[i] * 3; --- 375,379 ---- delete(curPolygon); ! curPolygon = new Polygon2(); } else { coordIndex = coordIndexes[i] * 3; *************** *** 489,492 **** --- 489,499 ---- /* $Log$ + Revision 1.3 2005/07/09 10:47:31 o3dozone + - viewpoint changes + - landscape added + - landscape waves added + - object collision with landscape added + - windows dev files added + Revision 1.2 2005/01/28 20:54:51 o3dozone - dual viewpoints --- NEW FILE: Makefile.win --- # Project: Project1 # Makefile created by Dev-C++ 4.9.9.2 CPP = g++.exe CC = gcc.exe WINDRES = windres.exe RES = OBJ = gravity.o model.o mesh.o polygon.o opengl_utils.o model_loader.o x3d_loader.o object3d.o scene_object.o statgraph.o statgraphrenderer.o transform.o simple_sphere.o landscape.o material.o system_state.o vrml_v1.o $(RES) LINKOBJ = gravity.o model.o mesh.o polygon.o opengl_utils.o model_loader.o x3d_loader.o object3d.o scene_object.o statgraph.o statgraphrenderer.o transform.o simple_sphere.o landscape.o material.o system_state.o vrml_v1.o $(RES) LIBS = -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/mingw32/lib" -L"C:/Dev-Cpp/bin" ../libxml2-2.6.19.win32/lib/libxml2.lib -L../SDL-1.2.8/lib/ -lopengl32 -lglu32 -lglut32 ../SDL-1.2.8/lib/SDL_win32_main.o -lSDL INCS = -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include" -I"C:/source/grappelmann/iconv-1.9.1.win32/include" -I"C:/source/grappelmann/libxml2-2.6.19.win32/include" -I"C:/source/grappelmann/zlib-1.2.2.win32/include" -I"C:/source/grappelmann/SDL-1.2.8/include" -I"C:/source/grappelmann/SDL-1.2.8/include/SDL" -I"C:/source/grappelmann/spaceplane" CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Dev-Cpp/include" -I"C:/source/grappelmann/iconv-1.9.1.win32/include" -I"C:/source/grappelmann/libxml2-2.6.19.win32/include" -I"C:/source/grappelmann/zlib-1.2.2.win32/include" -I"C:/source/grappelmann/SDL-1.2.8/include" -I"C:/source/grappelmann/SDL-1.2.8/include/SDL" -I"C:/source/grappelmann/spaceplane" BIN = gravity.exe CXXFLAGS = $(CXXINCS) -Ic:\\dev-cpp\\include -I"c:\\documents and settings\\administrator\\desktop\\source\\grappelmann\\spaceplane" CFLAGS = $(INCS) RM = rm -f .PHONY: all all-before all-after clean clean-custom all: all-before gravity.exe all-after clean: clean-custom ${RM} $(OBJ) $(BIN) $(BIN): $(OBJ) $(CPP) $(LINKOBJ) -o "gravity.exe" $(LIBS) gravity.o: gravity.cpp $(CPP) -c gravity.cpp -o gravity.o $(CXXFLAGS) model.o: model.cpp $(CPP) -c model.cpp -o model.o $(CXXFLAGS) mesh.o: mesh.cpp $(CPP) -c mesh.cpp -o mesh.o $(CXXFLAGS) polygon.o: polygon.cpp $(CPP) -c polygon.cpp -o polygon.o $(CXXFLAGS) opengl_utils.o: opengl_utils.cpp $(CPP) -c opengl_utils.cpp -o opengl_utils.o $(CXXFLAGS) model_loader.o: model_loader.cpp $(CPP) -c model_loader.cpp -o model_loader.o $(CXXFLAGS) x3d_loader.o: x3d_loader.cpp $(CPP) -c x3d_loader.cpp -o x3d_loader.o $(CXXFLAGS) object3d.o: object3d.cpp $(CPP) -c object3d.cpp -o object3d.o $(CXXFLAGS) scene_object.o: scene_object.cpp $(CPP) -c scene_object.cpp -o scene_object.o $(CXXFLAGS) statgraph.o: statgraph.cpp $(CPP) -c statgraph.cpp -o statgraph.o $(CXXFLAGS) statgraphrenderer.o: statgraphrenderer.cpp $(CPP) -c statgraphrenderer.cpp -o statgraphrenderer.o $(CXXFLAGS) transform.o: transform.cpp $(CPP) -c transform.cpp -o transform.o $(CXXFLAGS) simple_sphere.o: simple_sphere.cpp $(CPP) -c simple_sphere.cpp -o simple_sphere.o $(CXXFLAGS) landscape.o: landscape.cpp $(CPP) -c landscape.cpp -o landscape.o $(CXXFLAGS) material.o: material.cpp $(CPP) -c material.cpp -o material.o $(CXXFLAGS) system_state.o: system_state.cpp $(CPP) -c system_state.cpp -o system_state.o $(CXXFLAGS) vrml_v1.o: vrml_v1.cpp $(CPP) -c vrml_v1.cpp -o vrml_v1.o $(CXXFLAGS) Index: object3d.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** object3d.cpp 8 Jan 2005 07:22:49 -0000 1.3 --- object3d.cpp 9 Jul 2005 10:47:31 -0000 1.4 *************** *** 14,20 **** m_transform.setRotation(m_rotation, length); ! double scale = m_mass / 1000000; ! Coord3D scaleCoords(scale, scale, scale); ! m_transform.setScale(scaleCoords); glPushMatrix(); --- 14,22 ---- m_transform.setRotation(m_rotation, length); ! if(m_shouldScale) { ! double scale = m_mass / 1000000; ! Coord3D scaleCoords(scale, scale, scale); ! m_transform.setScale(scaleCoords); ! } glPushMatrix(); Index: model.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** model.h 21 Jul 2004 19:32:44 -0000 1.3 --- model.h 9 Jul 2005 10:47:31 -0000 1.4 *************** *** 8,15 **** #include <typeinfo> - #include "model_loader.h" using namespace std; class Model { public: --- 8,16 ---- #include <typeinfo> using namespace std; + #include "model_loader.h" + class Model { public: Index: polygon.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/polygon.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** polygon.cpp 23 Jul 2004 05:43:48 -0000 1.3 --- polygon.cpp 9 Jul 2005 10:47:31 -0000 1.4 *************** *** 6,25 **** #include "polygon.h" ! Polygon::Polygon(SceneObject* parent) : SceneObject(parent) { ! //cout << "<Polygon::Polygon>\tcalled" << endl; } ! Polygon::~Polygon() { } ! Polygon::Polygon(const Polygon& rhs) { ! //cout << "<Polygon::Polygon(copy)>\tcalled" << endl; m_coords = rhs.m_coords; m_normals = rhs.m_normals; } ! bool Polygon::addNormal(Coord3D& normal) { m_normals.push_back(normal); --- 6,25 ---- #include "polygon.h" ! Polygon2::Polygon2(SceneObject* parent) : SceneObject(parent) { ! //cout << "<Polygon2::Polygon2>\tcalled" << endl; } ! Polygon2::~Polygon2() { } ! Polygon2::Polygon2(const Polygon2& rhs) { ! //cout << "<Polygon2::Polygon2(copy)>\tcalled" << endl; m_coords = rhs.m_coords; m_normals = rhs.m_normals; } ! bool Polygon2::addNormal(Coord3D& normal) { m_normals.push_back(normal); *************** *** 27,31 **** } ! bool Polygon::addCoord(Coord3D& coord) { m_coords.push_back(coord); --- 27,31 ---- } ! bool Polygon2::addCoord(Coord3D& coord) { m_coords.push_back(coord); *************** *** 33,37 **** } ! bool Polygon::_draw() { vector<Coord3D>::size_type verticeCount = m_coords.size(); --- 33,37 ---- } ! bool Polygon2::_draw() { vector<Coord3D>::size_type verticeCount = m_coords.size(); *************** *** 44,48 **** //glBegin(GL_LINES); } else { ! cout << "<Polygon::_draw>\tbad vertice count [" << verticeCount << "]" << endl; return false; } --- 44,48 ---- //glBegin(GL_LINES); } else { ! cout << "<Polygon2::_draw>\tbad vertice count [" << verticeCount << "]" << endl; return false; } *************** *** 67,70 **** --- 67,77 ---- /* $Log$ + Revision 1.4 2005/07/09 10:47:31 o3dozone + - viewpoint changes + - landscape added + - landscape waves added + - object collision with landscape added + - windows dev files added + Revision 1.3 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays Index: polygon.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/polygon.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** polygon.h 23 Jul 2004 05:43:48 -0000 1.3 --- polygon.h 9 Jul 2005 10:47:31 -0000 1.4 *************** *** 3,6 **** --- 3,8 ---- #define POLYGON_H + //#warning polygon included + /* $Id$ *************** *** 12,20 **** #include <iostream> ! class Polygon : public SceneObject { public: ! Polygon(SceneObject* parent = NULL); ! Polygon(const Polygon& rhs); ! virtual ~Polygon(); bool addNormal(Coord3D& normal); --- 14,22 ---- #include <iostream> ! class Polygon2 : public SceneObject { public: ! Polygon2(SceneObject* parent = NULL); ! Polygon2(const Polygon2& rhs); ! virtual ~Polygon2(); bool addNormal(Coord3D& normal); *************** *** 29,32 **** --- 31,41 ---- /* $Log$ + Revision 1.4 2005/07/09 10:47:31 o3dozone + - viewpoint changes + - landscape added + - landscape waves added + - object collision with landscape added + - windows dev files added + Revision 1.3 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays *************** *** 44,45 **** --- 53,55 ---- #endif + Index: mesh.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** mesh.cpp 8 Jan 2005 07:22:49 -0000 1.7 --- mesh.cpp 9 Jul 2005 10:47:31 -0000 1.8 *************** *** 21,25 **** } ! bool Mesh::addPolygon(Polygon& polygon) { m_polygons.push_back(polygon); --- 21,25 ---- } ! bool Mesh::addPolygon(Polygon2& polygon) { m_polygons.push_back(polygon); *************** *** 41,45 **** // then draw the children ! for(vector<Polygon>::iterator i = m_polygons.begin(); i != m_polygons.end(); i++) { (*i).draw(); } --- 41,45 ---- // then draw the children ! for(vector<Polygon2>::iterator i = m_polygons.begin(); i != m_polygons.end(); i++) { (*i).draw(); } *************** *** 56,59 **** --- 56,66 ---- /* $Log$ + Revision 1.8 2005/07/09 10:47:31 o3dozone + - viewpoint changes + - landscape added + - landscape waves added + - object collision with landscape added + - windows dev files added + Revision 1.7 2005/01/08 07:22:49 o3dozone - removed some debugging --- NEW FILE: landscape.cpp --- /* $Id: landscape.cpp,v 1.1 2005/07/09 10:47:31 o3dozone Exp $ */ #include "landscape.h" LandScape::LandScape(SceneObject* parent) : SceneObject(parent) { cout << "<LandScape::LandScape>\tcalled" << endl; _populateMesh(); m_waves.push_back(SineWave(100, Coord3D(10,20,30))); m_waves.push_back(SineWave(100, Coord3D(20,25,25))); m_waves.push_back(SineWave(100, Coord3D(12,15,50))); m_waves.push_back(SineWave(100, Coord3D(10,20,30))); m_waves.push_back(SineWave(100, Coord3D(10,20,30))); m_waves.push_back(SineWave(100, Coord3D(10,20,30))); } LandScape::LandScape(const LandScape& rhs) : SceneObject(rhs) { m_mesh = rhs.m_mesh; } LandScape::~LandScape() { } LandScape& LandScape::operator=(const LandScape& rhs) { SceneObject::operator=(rhs); m_mesh = rhs.m_mesh; return *this; } bool LandScape::_draw() { cout << "<LandScape::_populateMesh>\tdrawing\n"; _updateWaves(); // draw the m_heights GLdouble vertexX, vertexZ; for(int x = 0; x < 99; x++) { vertexX = (x * 10) - 500; glBegin(GL_QUAD_STRIP); for(int z = 0; z < 99; z++) { if((z % 2 == 0) && (x % 2 == 0)) { glColor3f(1.0, 0.0, 0.0); } else { glColor3f(0.0, 1.0, 0.0); } vertexZ = (z * 10) - 500; glVertex3f(vertexX, m_heights[x][z], vertexZ); glVertex3f(vertexX + 10, m_heights[x + 1][z], vertexZ); glVertex3f(vertexX, m_heights[x][z + 1], vertexZ + 10); glVertex3f(vertexX + 10, m_heights[x + 1][z + 1], vertexZ + 10); } glEnd(); } //m_mesh.draw(); return true; } bool LandScape::_populateMesh() { cout << "<LandScape::_populateMesh>\tpopulating height map\n"; // populate the height map for(int x = 0; x < 99; x++) { for(int z = 0; z < 100; z++) { m_heights[x][z] = 3.0 - (6.0 * rand()/(RAND_MAX+1.0)); } } cout << "<LandScape::_populateMesh>\tdone\n"; return true; } bool LandScape::_updateWaves() { double curDistance; Coord3D curPoint; for(int x = 0; x < 99; x++) { for(int z = 0; z < 100; z++) { m_heights[x][z] = 0.0; } } for(vector<SineWave>::iterator i = m_waves.begin(); i != m_waves.end(); i++) { i->addTicks(SystemStateSingleton::instance().tickDiff); for(int x = 0; x < 99; x++) { for(int z = 0; z < 100; z++) { curPoint.m_x = x; curPoint.m_y = 0; curPoint.m_z = z; m_heights[x][z] += curDistance = i->yValueAtPoint(curPoint); } } } } /* class SineWave { public: SineWave(int initialSize, Coord3D startingPoint); double yValueAtDistance(double distance); bool addTicks(long ticks); private: long m_totalTicks; Coord3D m_startingPoint; int m_initialSize; }; */ SineWave::SineWave(int initialSize, Coord3D startingPoint) { m_initialSize = initialSize; m_startingPoint = startingPoint; } double SineWave::yValueAtPoint(const Coord3D& point) { double distance = m_startingPoint.distanceScalar(point); return ((m_initialSize / (distance + 1)) * sin((distance / 10) + (m_totalTicks / 500))); } bool SineWave::addTicks(long ticks) { m_totalTicks += ticks; return true; } const Coord3D& SineWave::startingPoint() { return m_startingPoint; } /* $Log: landscape.cpp,v $ Revision 1.1 2005/07/09 10:47:31 o3dozone - viewpoint changes - landscape added - landscape waves added - object collision with landscape added - windows dev files added */ |
|
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 |
|
From: Mike D. <o3d...@us...> - 2005-01-28 20:27:09
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16779 Added Files: simple_sphere.cpp simple_sphere.h x3d_loader.cpp x3d_loader.h Log Message: - some refactoring - simple sphere scene object --- NEW FILE: x3d_loader.cpp --- // $Id: x3d_loader.cpp,v 1.1 2005/01/28 20:26:58 o3dozone Exp $ #include "x3d_loader.h" X3DLoader::X3DLoader() { } SceneObject* X3DLoader::loadModel(const string filename) { SceneObject* sceneRoot = NULL; if((sceneRoot = _parseX3DFile(filename.c_str())) == NULL) { cout << "error parsing x3d file" << endl; abort(); } return sceneRoot; } 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; return NULL; } // some sensible defaults if(parent == NULL) { parent = new SceneObject(); } SceneObject* scene = NULL; 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 bool handleChildren = true; scene = _createSceneObjectFromDOMNode(domNode, handleChildren); if(scene == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty scene" << endl; // *** NOTE *** This is a little 'hack', so we can avoid a scene with mostly dummy nodes scene = parent; //return NULL; } cout << "[" << curLevel << "] dumping attributes complete" << endl; 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" ; return NULL; } return scene; } 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); } /* else { SceneObject* dummy = new SceneObject(); return dummy; } */ return NULL; } SceneObject* X3DLoader::_createMaterial(DOMNode* domNode) { Material* material = new Material(); vector<double> diffuse; vector<double> emission; vector<double> specular; /* <Appearance> <Material +ambientIntensity="0.500" +diffuseColor="0.640 0.640 0.640" +emissiveColor="0.800 0.800 0.800" shininess="0.196" +specularColor="1.000 1.000 1.000" transparency="0.000"/> </Appearance> */ // 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())); } assert(diffuse.size() == 3); assert(emission.size() == 3); assert(specular.size() == 3); material->setAmbient(atof(XMLString::transcode(ambientIntensityNode->getNodeValue()))); material->setShininess(atof(XMLString::transcode(shininessNode->getNodeValue()))); material->setDiffuse(diffuse); material->setEmission(emission); material->setSpecular(specular); } return material; } SceneObject* X3DLoader::_createTransform(DOMNode* domNode) { Transform* transform = new Transform(); Coord3D rotation; double rotationSize = 0; Coord3D translation; Coord3D scale; vector<double> rotationElements; vector<double> translationElements; vector<double> scaleElements; // 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())); } assert(rotationElements.size() == 4); assert(translationElements.size() == 3); assert(scaleElements.size() == 3); int curIndex = 0; rotation.m_x = rotationElements[curIndex++]; rotation.m_y = rotationElements[curIndex++]; rotation.m_z = rotationElements[curIndex++]; rotationSize = rotationElements[curIndex++]; cout << "rotation size [" << rotationSize << "] x [" << rotation.m_x << "] y [" << rotation.m_y << "] z [" << rotation.m_z << "]" << endl; translation.m_x = translationElements[0]; translation.m_y = translationElements[1]; translation.m_z = translationElements[2]; cout << "translation x [" << translation.m_x << "] y [" << translation.m_y << "] z [" << translation.m_z << "]" << endl; scale.m_x = scaleElements[0]; scale.m_y = scaleElements[1]; scale.m_z = scaleElements[2]; cout << "scale x [" << scale.m_x << "] y [" << scale.m_y << "] z [" << scale.m_z << "]" << endl; } // <Transform rotation="1.000 0.000 0.000 1.571" scale="1.000 1.000 0.603" translation="1.429 -5.224 2.204"> transform->setTranslation(translation); transform->setRotation(rotation, rotationSize); transform->setScale(scale); return transform; } SceneObject* X3DLoader::_createMesh(DOMNode* domNode) { // this is a mesh Mesh* mesh = new Mesh(); vector<int> coordIndexes; vector<int> normalIndexes; vector<double> coords; vector<double> normals; // 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; } // now run through the coords and add them to the mesh // *** NOTE *** we make the assumption that there are the same number of normals as vertices // *** NOTE *** we need to presize the mesh vector, because it keeps on copying the polygons vector<int>::size_type normalCount = normalIndexes.size(); vector<double>::size_type coordsSize = coords.size(); vector<double>::size_type normalsSize = normals.size(); int coordIndex = 0; int normalIndex = 0; Coord3D coord; Coord3D normal; Polygon* curPolygon = new Polygon(); for(vector<int>::size_type i = 0; i < normalCount; i++) { //cout << "\tcoordIndex [" << coordIndexes[i] << "] coord x [" << coord.m_x << "] y [" << coord.m_y << "] z [" << coord.m_z << "]" << endl; //cout << "\tnormalIndex [" << normalIndexes[i] << "] normal x [" << normal.m_x << "] y [" << normal.m_y << "] z [" << normal.m_z << "]" << endl; // add to mesh and restart for next polygon // *** NOTE *** we could be reusing the polygon, but I just want to get this going if(coordIndexes[i] == -1) { mesh->addPolygon(*curPolygon); delete(curPolygon); curPolygon = new Polygon(); } else { coordIndex = coordIndexes[i] * 3; normalIndex = normalIndexes[i] * 3; //assert((coordIndex + 2) < coordsSize); //assert((normalIndex + 2) < normalsSize); if(coordIndex + 2 >= coordsSize) { cout << "coordsSize [" << coordsSize << "] coordIndex [" << coordIndex << "]" << endl; break; } if(normalIndex + 2 >= normalsSize) { cout << "normalsSize [" << normalsSize << "] normalIndex [" << normalIndex << "]" << endl; break; } coord.m_x = coords[coordIndex]; coord.m_y = coords[coordIndex + 1]; coord.m_z = coords[coordIndex + 2]; normal.m_x = normals[normalIndex]; normal.m_y = normals[normalIndex + 1]; normal.m_z = normals[normalIndex + 2]; curPolygon->addCoord(coord); curPolygon->addNormal(normal); } } // done, return return mesh; } bool X3DLoader::_convertCharToVector(vector<int>& intVector, string intString) { string piece; //cout << "###############################################" << endl; string::size_type startPos = 0; string::size_type endPos = 0; //int pieceCount = 0; while(endPos != string::npos) { endPos = intString.find(' ', startPos); if(endPos == string::npos) { break; } string::size_type pieceLength = endPos - startPos; piece = intString.substr(startPos, pieceLength); intVector.push_back(atoi(piece.c_str())); //pieceCount++; //cout << "piece [" << piece.c_str() << "] pieceCount [" << pieceCount << "]" << endl; startPos += pieceLength; while((intString[startPos] == ' ') && (startPos != string::npos)) { startPos++; } endPos = startPos; } // now push the last element onto the vector string::size_type pieceLength = intString.size() - 1 - startPos; piece = intString.substr(startPos, pieceLength); intVector.push_back(atoi(piece.c_str())); cout << "<X3DLoader::_convertCharToVector(int)>\tvector size [" << intVector.size() << "]" << endl; return true; } bool X3DLoader::_convertCharToVector(vector<double>& doubleVector, string intString) { string piece; //cout << "###############################################" << endl; string::size_type startPos = 0; string::size_type endPos = 0; //int pieceCount = 0; while(endPos != string::npos) { endPos = intString.find(' ', startPos); if(endPos == string::npos) { break; } string::size_type pieceLength = endPos - startPos; piece = intString.substr(startPos, pieceLength); doubleVector.push_back(atof(piece.c_str())); //pieceCount++; //cout << "piece [" << piece.c_str() << "] pieceCount [" << pieceCount << "]" << endl; startPos += pieceLength; while((intString[startPos] == ' ') && (startPos != string::npos)) { startPos++; } endPos = startPos; } // now push the last element onto the vector string::size_type pieceLength = intString.size() - 1 - startPos; piece = intString.substr(startPos, pieceLength); doubleVector.push_back(atof(piece.c_str())); cout << "<X3DLoader::_convertCharToVector(double)>\tvector size [" << doubleVector.size() << "]" << endl; return true; } /* $Log: x3d_loader.cpp,v $ Revision 1.1 2005/01/28 20:26:58 o3dozone - some refactoring - simple sphere scene object */ --- NEW FILE: x3d_loader.h --- // $Id: x3d_loader.h,v 1.1 2005/01/28 20:26:58 o3dozone Exp $ #ifndef X3D_LOADER_H #define X3D_LOADER_H #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" #include "mesh.h" #include "transform.h" #include "material.h" #include <assert.h> #include <vector> XERCES_CPP_NAMESPACE_USE using namespace std; class X3DLoader : public ModelLoader { public: X3DLoader(); virtual SceneObject* loadModel(const string filename); 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); }; /* $Log: x3d_loader.h,v $ Revision 1.1 2005/01/28 20:26:58 o3dozone - some refactoring - simple sphere scene object */ #endif --- NEW FILE: simple_sphere.h --- #ifndef SIMPLESPHERE_H #define SIMPLESPHERE_H /* $Id: simple_sphere.h,v 1.1 2005/01/28 20:26:58 o3dozone Exp $ */ #include "scene_object.h" #include <iostream> class SimpleSphere : public SceneObject { public: SimpleSphere(SceneObject* parent = NULL); SimpleSphere(const SimpleSphere& rhs); virtual ~SimpleSphere(); protected: virtual bool _draw(); private: }; /* $Log: simple_sphere.h,v $ Revision 1.1 2005/01/28 20:26:58 o3dozone - some refactoring - simple sphere scene object */ #endif --- NEW FILE: simple_sphere.cpp --- // $Id: simple_sphere.cpp,v 1.1 2005/01/28 20:26:58 o3dozone Exp $ #include "simple_sphere.h" SimpleSphere::SimpleSphere(SceneObject* parent) : SceneObject(parent) { } SimpleSphere::SimpleSphere(const SimpleSphere& rhs) { } SimpleSphere::~SimpleSphere() { } bool SimpleSphere::_draw() { glutSolidSphere(5, 10, 10); //glutWireSphere(GLdouble radius, GLint slices, GLint stacks); drawChildren(); return true; } /* $Log: simple_sphere.cpp,v $ Revision 1.1 2005/01/28 20:26:58 o3dozone - some refactoring - simple sphere scene object */ |
|
From: Mike D. <o3d...@us...> - 2005-01-08 07:22:58
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20632 Modified Files: gravity.cpp gravity.h mesh.cpp object3d.cpp Log Message: - removed some debugging - changes to constants Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** gravity.cpp 29 Aug 2004 05:43:27 -0000 1.8 --- gravity.cpp 8 Jan 2005 07:22:49 -0000 1.9 *************** *** 197,201 **** rotation.m_z = 0; ! double mass = (rand() / (double)RAND_MAX) * (double)1000; objectArray[0].setMass(mass); --- 197,201 ---- rotation.m_z = 0; ! double mass = (rand() / (double)RAND_MAX) * (double)500; objectArray[0].setMass(mass); *************** *** 218,222 **** rotation.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)360) - 180; ! double mass = (rand() / (double)RAND_MAX) * (double)1000000000; objectArray[i].setMass(mass); --- 218,222 ---- rotation.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)360) - 180; ! double mass = (rand() / (double)RAND_MAX) * (double)1000000; objectArray[i].setMass(mass); *************** *** 321,327 **** } ! char* vrmlFilename = argv[1]; ModelLoader* modelLoader = new X3DLoader(); ! SceneObject* slugMobile = modelLoader->loadModel(vrmlFilename); //Model monkey(vrmlFilename); --- 321,328 ---- } ! //char* vrmlFilename = argv[1]; ModelLoader* modelLoader = new X3DLoader(); ! SceneObject* slugMobile = modelLoader->loadModel("slug_mobile.x3d"); ! SceneObject* rocket = modelLoader->loadModel("rocket.x3d"); //Model monkey(vrmlFilename); *************** *** 367,372 **** for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { ! objectArray.push_back(slugMobile); } // randomise the object's initial position --- 368,376 ---- for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { ! objectArray.push_back(rocket); } + // big 'planet' + //objectArray.push_back(slugMobile); + //objectCount++; // randomise the object's initial position *************** *** 375,378 **** --- 379,393 ---- exit(-1); } + + /* + long planetIndex = objectArray.size() - 1; + //objectArray[planetIndex].setDiameter(500); + objectArray[planetIndex].setMass(1000000000); + + Coord3D& planetPosition = objectArray[planetIndex].getPos(); + planetPosition.m_x = -40; + planetPosition.m_y = 0; + planetPosition.m_z = 0; + */ /* *************** *** 392,396 **** --- 407,421 ---- glTranslatef(0.0, 0.0, -5.0); + double cosX; + double cosY; + double cosZ; + double sinX; + double sinY; + double sinZ; + GLdouble viewPointMatrix[16]; + // a factor to convert between degrees and radians + double degreeToRadianRatio = M_PI / 180; + // now loop until we are done while(!SystemStateSingleton::instance().done) { *************** *** 426,429 **** --- 451,455 ---- // statGraphRenderer.render(); + /* GLfloat light_position[] = { lightPos.m_x, lightPos.m_y, lightPos.m_z, 1.0 }; GLfloat white_light[] = { 1, 1, 1, 1.0 }; *************** *** 437,440 **** --- 463,467 ---- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient_light); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); + */ glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); *************** *** 448,458 **** // call draw here] ! glRotatef(-rotation.m_x, 1.0, 0.0, 0.0); ! glRotatef(-rotation.m_y, 0.0, 1.0, 0.0); ! glRotatef(-rotation.m_z, 0.0, 0.0, 1.0); ! glTranslatef(position.m_x, position.m_y, position.m_z); //position.m_z -= 0.1; ! glColor3f(1, 1, 1); glBegin(GL_LINES); glVertex3f(10, 0, -20); --- 475,551 ---- // call draw here] ! //glutWireSphere(10.0, 50, 50); ! ! /* ! glColor3f(0, 0, 1.0); ! glBegin(GL_LINES); ! glVertex3f(0, 0, 0); ! glVertex3f(0, 0, 10); ! glEnd(); ! */ ! ! //glRotatef(-rotation.m_z, 0.0, 0.0, 1.0); //position.m_z -= 0.1; ! glColor3f(1.0, 0, 0); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(20, 0, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 20, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 0, -40); ! glEnd(); ! ! ! double xXvalue = cos((rotation.m_y) * degreeToRadianRatio); ! double xZvalue = sin((rotation.m_y) * degreeToRadianRatio); ! double yYvalue = sin((rotation.m_x + 90) * degreeToRadianRatio); ! double yZvalue = -cos((rotation.m_x + 90) * degreeToRadianRatio); ! cout << "rotation.m_x [" << rotation.m_x << "]" << endl; ! cout << "rotation.m_y [" << rotation.m_y << "]" << endl; ! cout << "yYvalue [" << yYvalue << "]" << endl; ! cout << "yZvalue [" << yZvalue << "]" << endl; ! cout << "xXvalue [" << xXvalue << "]" << endl; ! cout << "xZvalue [" << xZvalue << "]" << endl; ! ! glRotatef(-rotation.m_x, xXvalue, 0.0, xZvalue); ! glColor3f(0, 1.0, 0); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(20, 0, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 20, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 0, -40); ! glEnd(); ! ! glRotatef(-rotation.m_y, 0.0, yYvalue, yZvalue); ! glColor3f(0, 0, 1.0); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(20, 0, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 20, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 0, -40); ! glEnd(); ! ! glColor3f(1.0, 1.0, 1.0); ! ! glTranslatef(position.m_x, position.m_y, position.m_z); ! glBegin(GL_LINES); glVertex3f(10, 0, -20); *************** *** 485,488 **** --- 578,582 ---- for(vector<Object3D>::iterator i = objectArray.begin(); i != objectArray.end(); i++) { count++; + // *** NOTE *** REMOVE comment below (*i).draw(); } *************** *** 507,510 **** --- 601,608 ---- /* $Log$ + Revision 1.9 2005/01/08 07:22:49 o3dozone + - removed some debugging + - changes to constants + Revision 1.8 2004/08/29 05:43:27 o3dozone - added gravity Index: gravity.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gravity.h 24 Jun 2004 19:46:40 -0000 1.2 --- gravity.h 8 Jan 2005 07:22:49 -0000 1.3 *************** *** 22,26 **** #include "statgraphrenderer.h" ! #define MAX_OBJECTARRAY_SIZE 200 #endif --- 22,26 ---- #include "statgraphrenderer.h" ! #define MAX_OBJECTARRAY_SIZE 5 #endif *************** *** 28,31 **** --- 28,35 ---- /* $Log$ + Revision 1.3 2005/01/08 07:22:49 o3dozone + - removed some debugging + - changes to constants + Revision 1.2 2004/06/24 19:46:40 o3dozone - added magic CVS tags Index: mesh.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** mesh.cpp 17 Aug 2004 18:21:43 -0000 1.6 --- mesh.cpp 8 Jan 2005 07:22:49 -0000 1.7 *************** *** 37,41 **** bool Mesh::_draw() { // first draw myself ! cout << "<Mesh::_draw>\tI'm a star!" << endl; // then draw the children --- 37,41 ---- bool Mesh::_draw() { // first draw myself ! //cout << "<Mesh::_draw>\tI'm a star!" << endl; // then draw the children *************** *** 56,59 **** --- 56,63 ---- /* $Log$ + Revision 1.7 2005/01/08 07:22:49 o3dozone + - removed some debugging + - changes to constants + Revision 1.6 2004/08/17 18:21:43 o3dozone Index: object3d.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** object3d.cpp 29 Aug 2004 05:43:27 -0000 1.2 --- object3d.cpp 8 Jan 2005 07:22:49 -0000 1.3 *************** *** 14,18 **** m_transform.setRotation(m_rotation, length); ! double scale = m_mass / 1000000000; Coord3D scaleCoords(scale, scale, scale); m_transform.setScale(scaleCoords); --- 14,18 ---- m_transform.setRotation(m_rotation, length); ! double scale = m_mass / 1000000; Coord3D scaleCoords(scale, scale, scale); m_transform.setScale(scaleCoords); |
|
From: Mike D. <o3d...@us...> - 2004-08-29 05:44:44
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17990 Added Files: rocket.blend rocket.x3d Log Message: - basic rocket model --- NEW FILE: rocket.x3d --- <?xml version="1.0" ?> <!--This file was authored with Blender (http://www.blender.org/)--> <!--Exported using the X3DExporter, written by Adrian Cheater (http://www.bitbucket.ca/~acheater/blender)--> <!DOCTYPE X3D> <X3D Profile="Interchange"> <Scene> <Transform rotation="0.901 -0.043 0.432 2.523" scale="1.000 1.000 1.000" translation="0.774 -0.042 0.234"> <Shape> <IndexedFaceSet coordIndex="7 8 9 10 -1 6 7 10 11 -1 5 6 11 12 -1 4 5 12 13 -1 4 3 14 13 -1 2 3 14 15 -1 2 1 16 15 -1 1 0 17 16 -1 16 17 18 19 -1 15 16 19 20 -1 15 14 21 20 -1 13 14 21 22 -1 13 12 23 22 -1 12 11 24 23 -1 11 10 25 24 -1 10 9 26 25 -1 25 26 27 28 -1 24 25 28 29 -1 23 24 29 30 -1 22 23 30 31 -1 22 21 32 31 -1 20 21 32 33 -1 20 19 34 33 -1 19 18 35 34 -1 34 35 36 37 -1 33 34 37 38 -1 33 32 39 38 -1 31 32 39 40 -1 31 30 41 40 -1 30 29 42 41 -1 29 28 43 42 -1 28 27 44 43 -1 43 44 45 46 -1 42 43 46 47 -1 41 42 47 48 -1 40 41 48 49 -1 40 39 50 49 -1 38 39 50 51 -1 38 37 52 51 -1 37 36 53 52 -1 52 53 54 55 -1 51 52 55 56 -1 51 50 57 56 -1 49 50 57 58 -1 49 48 59 58 -1 48 47 60 59 -1 47 46 61 60 -1 46 45 62 61 -1 61 62 63 64 -1 60 61 64 65 -1 59 60 65 66 -1 58 59 66 67 -1 58 57 68 67 -1 56 57 68 69 -1 56 55 70 69 -1 55 54 71 70 -1 70 71 72 73 -1 69 70 73 74 -1 69 68 75 74 -1 67 68 75 76 -1 67 66 77 76 -1 66 65 78 77 -1 65 64 79 78 -1 64 63 80 79 -1 79 80 81 82 -1 78 79 82 83 -1 77 78 83 84 -1 76 77 84 85 -1 76 75 86 85 -1 74 75 86 87 -1 74 73 88 87 -1 73 72 89 88 -1 88 89 90 91 -1 87 88 91 92 -1 87 86 93 92 -1 85 86 93 94 -1 85 84 95 94 -1 84 83 96 95 -1 83 82 97 96 -1 82 81 98 97 -1 97 98 99 100 -1 96 97 100 101 -1 95 96 101 102 -1 94 95 102 103 -1 94 93 104 103 -1 92 93 104 105 -1 92 91 106 105 -1 91 90 107 106 -1 106 107 108 109 -1 105 106 109 110 -1 105 104 111 110 -1 103 104 111 112 -1 103 102 113 112 -1 102 101 114 113 -1 101 100 115 114 -1 100 99 116 115 -1 " normalIndex="0 1 2 3 -1 4 5 6 7 -1 8 9 10 11 -1 12 13 14 15 -1 16 17 18 19 -1 20 21 22 23 -1 24 25 26 27 -1 28 29 30 31 -1 32 33 34 35 -1 36 37 38 39 -1 40 41 42 43 -1 44 45 46 47 -1 48 49 50 51 -1 52 53 54 55 -1 56 57 58 59 -1 60 61 62 63 -1 64 65 66 67 -1 68 69 70 71 -1 72 73 74 75 -1 76 77 78 79 -1 80 81 82 83 -1 84 85 86 87 -1 88 89 90 91 -1 92 93 94 95 -1 96 97 98 99 -1 100 101 102 103 -1 104 105 106 107 -1 108 109 110 111 -1 112 113 114 115 -1 116 117 118 119 -1 120 121 122 123 -1 124 125 126 127 -1 128 129 130 131 -1 132 133 134 135 -1 136 137 138 139 -1 140 141 142 143 -1 144 145 146 147 -1 148 149 150 151 -1 152 153 154 155 -1 156 157 158 159 -1 160 161 162 163 -1 164 165 166 167 -1 168 169 170 171 -1 172 173 174 175 -1 176 177 178 179 -1 180 181 182 183 -1 184 185 186 187 -1 188 189 190 191 -1 192 193 194 195 -1 196 197 198 199 -1 200 201 202 203 -1 204 205 206 207 -1 208 209 210 211 -1 212 213 214 215 -1 216 217 218 219 -1 220 221 222 223 -1 224 225 226 227 -1 228 229 230 231 -1 232 233 234 235 -1 236 237 238 239 -1 240 241 242 243 -1 244 245 246 247 -1 248 249 250 251 -1 252 253 254 255 -1 256 257 258 259 -1 260 261 262 263 -1 264 265 266 267 -1 268 269 270 271 -1 272 273 274 275 -1 276 277 278 279 -1 280 281 282 283 -1 284 285 286 287 -1 288 289 290 291 -1 292 293 294 295 -1 296 297 298 299 -1 300 301 302 303 -1 304 305 306 307 -1 308 309 310 311 -1 312 313 314 315 -1 316 317 318 319 -1 320 321 322 323 -1 324 325 326 327 -1 328 329 330 331 -1 332 333 334 335 -1 336 337 338 339 -1 340 341 342 343 -1 344 345 346 347 -1 348 349 350 351 -1 352 353 354 355 -1 356 357 358 359 -1 360 361 362 363 -1 364 365 366 367 -1 368 369 370 371 -1 372 373 374 375 -1 376 377 378 379 -1 380 381 382 383 -1 " solid="false"> <Coordinate point="0.000 -0.939 -0.000 -0.805 -0.927 -0.000 -0.739 -0.258 -0.000 -0.427 1.218 0.000 -0.548 1.896 0.000 -0.551 2.974 0.000 -0.327 3.487 0.000 -0.184 4.357 0.000 0.000 4.465 0.000 0.000 4.465 0.000 -0.159 4.357 -0.092 -0.283 3.487 -0.163 -0.477 2.974 -0.275 -0.475 1.896 -0.274 -0.370 1.218 -0.214 -0.640 -0.258 -0.369 -0.697 -0.927 -0.403 0.000 -0.939 0.000 0.000 -0.939 0.000 -0.403 -0.927 -0.697 -0.369 -0.258 -0.640 -0.214 1.218 -0.370 -0.274 1.896 -0.475 -0.275 2.974 -0.477 -0.163 3.487 -0.283 -0.092 4.357 -0.159 0.000 4.465 0.000 0.000 4.465 0.000 0.000 4.357 -0.184 0.000 3.487 -0.327 0.000 2.974 -0.551 0.000 1.896 -0.548 0.000 1.218 -0.427 0.000 -0.258 -0.739 -0.000 -0.927 -0.805 -0.000 -0.939 0.000 -0.000 -0.939 0.000 0.403 -0.927 -0.697 0.369 -0.258 -0.640 0.214 1.218 -0.370 0.274 1.896 -0.475 0.275 2.974 -0.477 0.163 3.487 -0.283 0.092 4.357 -0.159 -0.000 4.465 0.000 -0.000 4.465 0.000 0.159 4.357 -0.092 0.283 3.487 -0.163 0.477 2.974 -0.275 0.475 1.896 -0.274 0.370 1.218 -0.214 0.640 -0.258 -0.369 0.697 -0.927 -0.403 -0.000 -0.939 -0.000 -0.000 -0.939 -0.000 0.805 -0.927 -0.000 0.739 -0.258 0.000 0.427 1.218 0.000 0.548 1.896 0.000 0.551 2.974 0.000 0.327 3.487 0.000 0.184 4.357 0.000 -0.000 4.465 0.000 -0.000 4.465 -0.000 0.159 4.357 0.092 0.283 3.487 0.163 0.477 2.974 0.275 0.475 1.896 0.274 0.370 1.218 0.214 0.640 -0.258 0.369 0.697 -0.927 0.403 -0.000 -0.939 -0.000 -0.000 -0.939 -0.000 0.403 -0.927 0.697 0.369 -0.258 0.640 0.214 1.218 0.370 0.274 1.896 0.475 0.275 2.974 0.477 0.163 3.487 0.283 0.092 4.357 0.159 -0.000 4.465 -0.000 -0.000 4.465 -0.000 -0.000 4.357 0.184 -0.000 3.487 0.327 -0.000 2.974 0.551 -0.000 1.896 0.548 -0.000 1.218 0.427 -0.000 -0.258 0.739 -0.000 -0.927 0.805 0.000 -0.939 -0.000 0.000 -0.939 -0.000 -0.403 -0.927 0.697 -0.369 -0.258 0.640 -0.214 1.218 0.370 -0.274 1.896 0.475 -0.275 2.974 0.477 -0.163 3.487 0.283 -0.092 4.357 0.159 0.000 4.465 -0.000 0.000 4.465 -0.000 -0.159 4.357 0.092 -0.283 3.487 0.163 -0.477 2.974 0.275 -0.475 1.896 0.274 -0.370 1.218 0.214 -0.640 -0.258 0.369 -0.697 -0.927 0.403 0.000 -0.939 -0.000 0.000 -0.939 -0.000 -0.805 -0.927 -0.000 -0.739 -0.258 -0.000 -0.427 1.218 0.000 -0.548 1.896 0.000 -0.551 2.974 0.000 -0.327 3.487 0.000 -0.184 4.357 0.000 0.000 4.465 0.000 "/> <Normal vector="-0.824 0.522 -0.221 -0.501 0.855 -0.134 -0.435 0.863 -0.257 -0.731 0.536 -0.422 -0.927 0.280 -0.248 -0.824 0.522 -0.221 -0.731 0.536 -0.422 -0.829 0.289 -0.479 -0.948 0.190 -0.254 -0.927 0.280 -0.248 -0.829 0.289 -0.479 -0.849 0.197 -0.490 -0.962 -0.085 -0.258 -0.948 0.190 -0.254 -0.849 0.197 -0.490 -0.863 -0.088 -0.498 -0.962 -0.085 -0.258 0.966 -0.016 0.259 0.866 -0.016 0.500 -0.863 -0.088 -0.498 -0.956 0.146 -0.256 0.966 -0.016 0.259 0.866 -0.016 0.500 -0.856 0.151 -0.494 -0.956 0.146 -0.256 0.697 -0.692 0.187 0.615 -0.705 0.355 -0.856 0.151 -0.494 0.697 -0.692 0.187 0.015 1.000 0.004 0.013 1.000 0.007 0.615 -0.705 0.355 0.615 -0.705 0.355 0.013 1.000 0.007 0.008 1.000 0.013 -0.355 0.705 -0.615 -0.856 0.151 -0.494 0.615 -0.705 0.355 -0.355 0.705 -0.615 0.494 -0.151 0.856 -0.856 0.151 -0.494 0.866 -0.016 0.500 -0.500 0.016 -0.866 0.494 -0.151 0.856 -0.863 -0.088 -0.498 0.866 -0.016 0.500 -0.500 0.016 -0.866 0.498 0.088 0.863 -0.863 -0.088 -0.498 -0.849 0.197 -0.490 -0.490 0.197 -0.849 0.498 0.088 0.863 -0.849 0.197 -0.490 -0.829 0.289 -0.479 -0.479 0.289 -0.829 -0.490 0.197 -0.849 -0.829 0.289 -0.479 -0.731 0.536 -0.422 -0.422 0.536 -0.731 -0.479 0.289 -0.829 -0.731 0.536 -0.422 -0.435 0.863 -0.257 -0.249 0.863 -0.440 -0.422 0.536 -0.731 -0.422 0.536 -0.731 -0.249 0.863 -0.440 0.004 0.863 -0.505 0.000 0.536 -0.845 -0.479 0.289 -0.829 -0.422 0.536 -0.731 0.000 0.536 -0.845 0.000 0.289 -0.957 -0.490 0.197 -0.849 -0.479 0.289 -0.829 0.000 0.289 -0.957 0.000 0.197 -0.980 0.498 0.088 0.863 -0.490 0.197 -0.849 0.000 0.197 -0.980 0.000 -0.088 -0.996 0.498 0.088 0.863 -0.500 0.016 -0.866 0.000 -0.016 1.000 0.000 -0.088 -0.996 0.494 -0.151 0.856 -0.500 0.016 -0.866 0.000 -0.016 1.000 0.000 0.151 -0.988 0.494 -0.151 0.856 -0.355 0.705 -0.615 0.000 -0.705 0.710 0.000 0.151 -0.988 -0.355 0.705 -0.615 0.008 1.000 0.013 0.001 1.000 0.015 0.000 -0.705 0.710 0.000 -0.705 0.710 0.001 1.000 0.015 -0.007 1.000 0.013 0.355 0.705 -0.615 0.000 0.151 -0.988 0.000 -0.705 0.710 0.355 0.705 -0.615 -0.494 -0.151 0.856 0.000 0.151 -0.988 0.000 -0.016 1.000 0.500 0.016 -0.866 -0.494 -0.151 0.856 0.000 -0.088 -0.996 0.000 -0.016 1.000 0.500 0.016 -0.866 -0.498 0.088 0.863 0.000 -0.088 -0.996 0.000 0.197 -0.980 0.490 0.197 -0.849 -0.498 0.088 0.863 0.000 0.197 -0.980 0.000 0.289 -0.957 0.479 0.289 -0.829 0.490 0.197 -0.849 0.000 0.289 -0.957 0.000 0.536 -0.845 0.422 0.536 -0.731 0.479 0.289 -0.829 0.000 0.536 -0.845 0.004 0.863 -0.505 0.257 0.863 -0.435 0.422 0.536 -0.731 0.422 0.536 -0.731 0.257 0.863 -0.435 0.440 0.863 -0.249 0.731 0.536 -0.422 0.479 0.289 -0.829 0.422 0.536 -0.731 0.731 0.536 -0.422 0.829 0.289 -0.479 0.490 0.197 -0.849 0.479 0.289 -0.829 0.829 0.289 -0.479 0.849 0.197 -0.490 -0.498 0.088 0.863 0.490 0.197 -0.849 0.849 0.197 -0.490 0.863 -0.088 -0.498 -0.498 0.088 0.863 0.500 0.016 -0.866 -0.866 -0.016 0.500 0.863 -0.088 -0.498 -0.494 -0.151 0.856 0.500 0.016 -0.866 -0.866 -0.016 0.500 0.856 0.151 -0.494 -0.494 -0.151 0.856 0.355 0.705 -0.615 -0.615 -0.705 0.355 0.856 0.151 -0.494 0.355 0.705 -0.615 -0.007 1.000 0.013 -0.013 1.000 0.008 -0.615 -0.705 0.355 -0.615 -0.705 0.355 -0.013 1.000 0.008 -0.015 1.000 0.001 0.710 0.705 0.000 0.856 0.151 -0.494 -0.615 -0.705 0.355 0.710 0.705 0.000 -0.988 -0.151 0.000 0.856 0.151 -0.494 -0.866 -0.016 0.500 1.000 0.016 0.000 -0.988 -0.151 0.000 0.863 -0.088 -0.498 -0.866 -0.016 0.500 1.000 0.016 0.000 -0.996 0.088 0.000 0.863 -0.088 -0.498 0.849 0.197 -0.490 0.980 0.197 0.000 -0.996 0.088 0.000 0.849 0.197 -0.490 0.829 0.289 -0.479 0.957 0.289 0.000 0.980 0.197 0.000 0.829 0.289 -0.479 0.731 0.536 -0.422 0.845 0.536 0.000 0.957 0.289 0.000 0.731 0.536 -0.422 0.440 0.863 -0.249 0.505 0.863 0.004 0.845 0.536 0.000 0.845 0.536 0.000 0.505 0.863 0.004 0.435 0.863 0.257 0.731 0.536 0.422 0.957 0.289 0.000 0.845 0.536 0.000 0.731 0.536 0.422 0.829 0.289 0.479 0.980 0.197 0.000 0.957 0.289 0.000 0.829 0.289 0.479 0.849 0.197 0.490 -0.996 0.088 0.000 0.980 0.197 0.000 0.849 0.197 0.490 0.863 -0.088 0.498 -0.996 0.088 0.000 1.000 0.016 0.000 -0.866 -0.016 -0.500 0.863 -0.088 0.498 -0.988 -0.151 0.000 1.000 0.016 0.000 -0.866 -0.016 -0.500 0.856 0.151 0.494 -0.988 -0.151 0.000 0.710 0.705 0.000 -0.615 -0.705 -0.355 0.856 0.151 0.494 0.710 0.705 0.000 -0.015 1.000 0.001 -0.013 1.000 -0.007 -0.615 -0.705 -0.355 -0.615 -0.705 -0.355 -0.013 1.000 -0.007 -0.008 1.000 -0.013 0.355 0.705 0.615 0.856 0.151 0.494 -0.615 -0.705 -0.355 0.355 0.705 0.615 -0.494 -0.151 -0.856 0.856 0.151 0.494 -0.866 -0.016 -0.500 0.500 0.016 0.866 -0.494 -0.151 -0.856 0.863 -0.088 0.498 -0.866 -0.016 -0.500 0.500 0.016 0.866 -0.498 0.088 -0.863 0.863 -0.088 0.498 0.849 0.197 0.490 0.490 0.197 0.849 -0.498 0.088 -0.863 0.849 0.197 0.490 0.829 0.289 0.479 0.479 0.289 0.829 0.490 0.197 0.849 0.829 0.289 0.479 0.731 0.536 0.422 0.422 0.536 0.731 0.479 0.289 0.829 0.731 0.536 0.422 0.435 0.863 0.257 0.249 0.863 0.440 0.422 0.536 0.731 0.422 0.536 0.731 0.249 0.863 0.440 -0.004 0.863 0.505 0.000 0.536 0.845 0.479 0.289 0.829 0.422 0.536 0.731 0.000 0.536 0.845 0.000 0.289 0.957 0.490 0.197 0.849 0.479 0.289 0.829 0.000 0.289 0.957 0.000 0.197 0.980 -0.498 0.088 -0.863 0.490 0.197 0.849 0.000 0.197 0.980 0.000 -0.088 0.996 -0.498 0.088 -0.863 0.500 0.016 0.866 0.000 -0.016 -1.000 0.000 -0.088 0.996 -0.494 -0.151 -0.856 0.500 0.016 0.866 0.000 -0.016 -1.000 0.000 0.151 0.988 -0.494 -0.151 -0.856 0.355 0.705 0.615 0.000 -0.705 -0.710 0.000 0.151 0.988 0.355 0.705 0.615 -0.008 1.000 -0.013 -0.001 1.000 -0.015 0.000 -0.705 -0.710 0.000 -0.705 -0.710 -0.001 1.000 -0.015 0.007 1.000 -0.013 -0.355 0.705 0.615 0.000 0.151 0.988 0.000 -0.705 -0.710 -0.355 0.705 0.615 0.494 -0.151 -0.856 0.000 0.151 0.988 0.000 -0.016 -1.000 -0.500 0.016 0.866 0.494 -0.151 -0.856 0.000 -0.088 0.996 0.000 -0.016 -1.000 -0.500 0.016 0.866 0.498 0.088 -0.863 0.000 -0.088 0.996 0.000 0.197 0.980 -0.490 0.197 0.849 0.498 0.088 -0.863 0.000 0.197 0.980 0.000 0.289 0.957 -0.479 0.289 0.829 -0.490 0.197 0.849 0.000 0.289 0.957 0.000 0.536 0.845 -0.422 0.536 0.731 -0.479 0.289 0.829 0.000 0.536 0.845 -0.004 0.863 0.505 -0.257 0.863 0.435 -0.422 0.536 0.731 -0.422 0.536 0.731 -0.257 0.863 0.435 -0.440 0.863 0.249 -0.731 0.536 0.422 -0.479 0.289 0.829 -0.422 0.536 0.731 -0.731 0.536 0.422 -0.829 0.289 0.479 -0.490 0.197 0.849 -0.479 0.289 0.829 -0.829 0.289 0.479 -0.849 0.197 0.490 0.498 0.088 -0.863 -0.490 0.197 0.849 -0.849 0.197 0.490 -0.863 -0.088 0.498 0.498 0.088 -0.863 -0.500 0.016 0.866 0.866 -0.016 -0.500 -0.863 -0.088 0.498 0.494 -0.151 -0.856 -0.500 0.016 0.866 0.866 -0.016 -0.500 -0.856 0.151 0.494 0.494 -0.151 -0.856 -0.355 0.705 0.615 0.615 -0.705 -0.355 -0.856 0.151 0.494 -0.355 0.705 0.615 0.007 1.000 -0.013 0.013 1.000 -0.008 0.615 -0.705 -0.355 0.615 -0.705 -0.355 0.013 1.000 -0.008 0.015 1.000 -0.004 -0.697 0.692 0.187 -0.856 0.151 0.494 0.615 -0.705 -0.355 -0.697 0.692 0.187 0.956 -0.146 -0.256 -0.856 0.151 0.494 0.866 -0.016 -0.500 -0.966 0.016 0.259 0.956 -0.146 -0.256 -0.863 -0.088 0.498 0.866 -0.016 -0.500 -0.966 0.016 0.259 0.962 0.085 -0.258 -0.863 -0.088 0.498 -0.849 0.197 0.490 -0.948 0.190 0.254 0.962 0.085 -0.258 -0.849 0.197 0.490 -0.829 0.289 0.479 -0.927 0.280 0.248 -0.948 0.190 0.254 -0.829 0.289 0.479 -0.731 0.536 0.422 -0.824 0.522 0.221 -0.927 0.280 0.248 -0.731 0.536 0.422 -0.440 0.863 0.249 -0.501 0.855 0.134 -0.824 0.522 0.221 "/> </IndexedFaceSet> </Shape> </Transform> <NavigationInfo headlight="true" type="EXAMINE ANY"/> </Scene> </X3D> --- NEW FILE: rocket.blend --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17728 Modified Files: coord3d.h gravity.cpp makefile object3d.cpp object3d.h opengl_utils.cpp opengl_utils.h scene_object.cpp transform.cpp Log Message: - added gravity - fixed object movement updates - various model parsing updates work - updated coord3d operators - scaling now has a sensible default - transforms done in correct order - other debugging removed/added Index: transform.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/transform.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** transform.cpp 17 Aug 2004 18:21:43 -0000 1.3 --- transform.cpp 29 Aug 2004 05:43:27 -0000 1.4 *************** *** 10,13 **** --- 10,16 ---- : SceneObject(parent), m_rotationSize(0) { + m_scale.m_x = 1; + m_scale.m_y = 1; + m_scale.m_z = 1; } *************** *** 25,29 **** m_translation = translation; ! cout << "<Transform::_draw>\ttranslation x [" << m_translation.m_x << "] y [" << m_translation.m_y << "] z [" << m_translation.m_z << "]" << endl; return true; } --- 28,32 ---- m_translation = translation; ! //cout << "<Transform::setTranslation>\ttranslation x [" << m_translation.m_x << "] y [" << m_translation.m_y << "] z [" << m_translation.m_z << "]" << endl; return true; } *************** *** 48,61 **** glMatrixMode(GL_MODELVIEW); ! cout << "<Transform::_draw>\trotation size [" << m_rotationSize << "] x [" << m_rotation.m_x << "] y [" << m_rotation.m_y << "] z [" << m_rotation.m_z << "]" << endl; ! cout << "<Transform::_draw>\ttranslation x [" << m_translation.m_x << "] y [" << m_translation.m_y << "] z [" << m_translation.m_z << "]" << endl; ! cout << "<Transform::_draw>\tscale x [" << m_scale.m_x << "] y [" << m_scale.m_y << "] z [" << m_scale.m_z << "]" << endl; glTranslatef(m_translation.m_x, m_translation.m_y, m_translation.m_z); glRotatef(m_rotationSize, m_rotation.m_x, m_rotation.m_y, m_rotation.m_z); glScalef(m_scale.m_x, m_scale.m_y, m_scale.m_z); - //glTranslatef(m_translation.m_z, m_translation.m_x, m_translation.m_y); ! cout << "drawing children" << endl; //debugging //if((m_scale.m_x == 1.0) && (m_scale.m_y == 1.0) && (m_scale.m_z == 1.0)) { --- 51,63 ---- glMatrixMode(GL_MODELVIEW); ! //cout << "<Transform::_draw>\trotation size [" << m_rotationSize << "] x [" << m_rotation.m_x << "] y [" << m_rotation.m_y << "] z [" << m_rotation.m_z << "]" << endl; ! //cout << "<Transform::_draw>\ttranslation x [" << m_translation.m_x << "] y [" << m_translation.m_y << "] z [" << m_translation.m_z << "]" << endl; ! //cout << "<Transform::_draw>\tscale x [" << m_scale.m_x << "] y [" << m_scale.m_y << "] z [" << m_scale.m_z << "]" << endl; glTranslatef(m_translation.m_x, m_translation.m_y, m_translation.m_z); glRotatef(m_rotationSize, m_rotation.m_x, m_rotation.m_y, m_rotation.m_z); glScalef(m_scale.m_x, m_scale.m_y, m_scale.m_z); ! //cout << "drawing children" << endl; //debugging //if((m_scale.m_x == 1.0) && (m_scale.m_y == 1.0) && (m_scale.m_z == 1.0)) { *************** *** 63,67 **** //} ! cout << "done" << endl; return true; --- 65,69 ---- //} ! //cout << "done" << endl; return true; *************** *** 70,73 **** --- 72,84 ---- /* $Log$ + Revision 1.4 2004/08/29 05:43:27 o3dozone + - added gravity + - fixed object movement updates + - various model parsing updates work + - updated coord3d operators + - scaling now has a sensible default + - transforms done in correct order + - other debugging removed/added + Revision 1.3 2004/08/17 18:21:43 o3dozone Index: object3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** object3d.h 17 Aug 2004 18:21:43 -0000 1.4 --- object3d.h 29 Aug 2004 05:43:27 -0000 1.5 *************** *** 15,19 **** Object3D(SceneObject* sceneObject) : m_sceneObject(sceneObject) ! {}; bool willIntersect(const Object3D& rhs, Coord3D& intersectPoint); --- 15,22 ---- Object3D(SceneObject* sceneObject) : m_sceneObject(sceneObject) ! { ! m_diameter = 100; ! _calcG(); ! }; bool willIntersect(const Object3D& rhs, Coord3D& intersectPoint); *************** *** 50,59 **** --- 53,78 ---- */ + bool draw(); + void setMass(double mass) { m_mass = mass; + _calcG(); }; double getMass() { return m_mass; }; + + void setDiameter(double diameter) { + m_diameter = diameter; + _calcG(); + }; + double getDiameter() { + return m_diameter; + }; + + double getG() { + return m_g; + }; + private: Coord3D m_pos; *************** *** 61,65 **** --- 80,89 ---- Coord3D m_rotation; SceneObject* m_sceneObject; + Transform m_transform; double m_mass; + double m_g; + double m_diameter; + + void _calcG(); }; Index: object3d.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** object3d.cpp 24 Jun 2004 10:45:24 -0000 1.1.1.1 --- object3d.cpp 29 Aug 2004 05:43:27 -0000 1.2 *************** *** 5,8 **** --- 5,35 ---- }; + bool Object3D::draw() { + //cout << "<Object3D::draw>\tsetTranslation" << endl; + //cout << "<Object3D::draw>\tm_pos x [" << m_pos.m_x << "] y [" << m_pos.m_y << "] z [" << m_pos.m_z << "]" << endl; + m_transform.setTranslation(m_pos); + double length = m_rotation.length(); + m_rotation.normalise(); + + m_transform.setRotation(m_rotation, length); + + double scale = m_mass / 1000000000; + Coord3D scaleCoords(scale, scale, scale); + m_transform.setScale(scaleCoords); + + glPushMatrix(); + + //cout << "<Object3D::draw>\ttransform draw" << endl; + m_transform.draw(); + //cout << "<Object3D::draw>\tsceneobject draw" << endl; + m_sceneObject->draw(); + //cout << "<Object3D::draw>\tdone" << endl; + + glPopMatrix(); + + return true; + }; + + bool Object3D::willIntersect(const Object3D& rhs, Coord3D& intersectPoint) { bool willIntersect = false; *************** *** 57,58 **** --- 84,94 ---- }; + // gravity + // G = 6.67 x 10-11 N?m2/kg2 + // g = G(M/r^2) + void Object3D::_calcG() { + double radius = m_diameter / 2; + m_g = 6.67e-11 * m_mass / (radius * radius); + }; + + Index: scene_object.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** scene_object.cpp 18 Aug 2004 14:53:17 -0000 1.6 --- scene_object.cpp 29 Aug 2004 05:43:27 -0000 1.7 *************** *** 38,44 **** if(!m_displayListCreated) { if(_makeDisplayList()) { m_displayListCreated = true; } else { ! cout << "drawing" <<endl; draw(); } --- 38,45 ---- if(!m_displayListCreated) { if(_makeDisplayList()) { + cout << "creating display list" <<endl; m_displayListCreated = true; } else { ! //cout << "drawing" <<endl; draw(); } *************** *** 113,116 **** --- 114,126 ---- /* $Log$ + Revision 1.7 2004/08/29 05:43:27 o3dozone + - added gravity + - fixed object movement updates + - various model parsing updates work + - updated coord3d operators + - scaling now has a sensible default + - transforms done in correct order + - other debugging removed/added + Revision 1.6 2004/08/18 14:53:17 o3dozone - fixed material problems Index: coord3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/coord3d.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** coord3d.h 23 Jul 2004 05:45:06 -0000 1.1 --- coord3d.h 29 Aug 2004 05:43:27 -0000 1.2 *************** *** 68,71 **** --- 68,79 ---- }; + Coord3D operator+=(const Coord3D& rhs) { + m_x += rhs.m_x; + m_y += rhs.m_y; + m_z += rhs.m_z; + + return(*this); + }; + Coord3D operator+(const Coord3D& rhs) const { return((Coord3D)(*this) + rhs); Index: opengl_utils.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/opengl_utils.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** opengl_utils.h 23 Jul 2004 05:43:48 -0000 1.2 --- opengl_utils.h 29 Aug 2004 05:43:27 -0000 1.3 *************** *** 16,21 **** void opengl_init(); void reshape_screen(GLint widthOrigin, GLint heightOrigin, GLint width, GLint height); ! void draw_screen(Object3D& viewPoint, vector<Object3D>& objectArray, long objectCount); ! void drawModel(Vrml::DoubleArray* pointsArray, Vrml::DoubleArray* indicesArray); /* int loadTexture(GLint* textureName, char* textureFilename */ --- 16,21 ---- void opengl_init(); void reshape_screen(GLint widthOrigin, GLint heightOrigin, GLint width, GLint height); ! //void draw_screen(Object3D& viewPoint, vector<Object3D>& objectArray, long objectCount); ! //void drawModel(Vrml::DoubleArray* pointsArray, Vrml::DoubleArray* indicesArray); /* int loadTexture(GLint* textureName, char* textureFilename */ Index: makefile =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** makefile 9 Aug 2004 07:50:54 -0000 1.5 --- makefile 29 Aug 2004 05:43:27 -0000 1.6 *************** *** 11,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_loader.o mesh.o polygon.o scene_object.o transform.o material.o --- 11,15 ---- 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 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 *************** *** 29,33 **** $(CC) $(CC_OPTIONS) -o object3d_test object3d_test.cpp ! gravity: $(GRAVITY_OBJS) $(GRAVITY_DEPS) $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o $@ $(GRAVITY_OBJS) --- 29,33 ---- $(CC) $(CC_OPTIONS) -o object3d_test object3d_test.cpp ! gravity: $(GRAVITY_DEPS) $(GRAVITY_OBJS) $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o $@ $(GRAVITY_OBJS) *************** *** 35,44 **** $(CC) -static-libgcc -static $(CC_OPTIONS) $(SDL_FLAGS) $(SDL_LIBS) -o gravity_static $(GRAVITY_OBJS) ! %.o: %.cpp %.h system_state.h model.h ! $(CC) $(CC_OPTIONS) $(SDL_FLAGS) $(CC_FLAGS) $(INCDIRS) -c $< -o $@ ! ! %.obj: %.cpp %.h ! $(CC) $(CC_OPTIONS) -Dmain=SDL_main -DHAVE_OPENGL $(SDL_FLAGS) $(CC_FLAGS) -c $< -o $@ clean: --- 35,45 ---- $(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: Index: opengl_utils.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/opengl_utils.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** opengl_utils.cpp 21 Jul 2004 07:38:05 -0000 1.3 --- opengl_utils.cpp 29 Aug 2004 05:43:27 -0000 1.4 *************** *** 116,121 **** }; void draw_screen(Object3D& viewPoint, vector<Object3D>& objectArray, long objectCount) { ! /* Our angle of rotation. */ Coord3D& rotation = viewPoint.getRotation(); Coord3D& position = viewPoint.getPos(); --- 116,122 ---- }; + /* void draw_screen(Object3D& viewPoint, vector<Object3D>& objectArray, long objectCount) { ! // Our angle of rotation. Coord3D& rotation = viewPoint.getRotation(); Coord3D& position = viewPoint.getPos(); *************** *** 163,167 **** } ! /* We don't want to modify the projection matrix. */ glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); --- 164,168 ---- } ! // We don't want to modify the projection matrix. glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); *************** *** 235,238 **** --- 236,240 ---- } + */ Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gravity.cpp 17 Aug 2004 18:21:43 -0000 1.7 --- gravity.cpp 29 Aug 2004 05:43:27 -0000 1.8 *************** *** 190,194 **** velocity.m_x = 0; velocity.m_y = 0; ! velocity.m_z = 1; Coord3D& rotation = objectArray[0].getRotation(); --- 190,194 ---- velocity.m_x = 0; velocity.m_y = 0; ! velocity.m_z = 0; Coord3D& rotation = objectArray[0].getRotation(); *************** *** 202,214 **** for(int i = 1; i < objectCount; i++) { Coord3D& position = objectArray[i].getPos(); ! position.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)100) - 50; ! position.m_y = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)100) - 50; ! position.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)100) - 50; Coord3D& velocity = objectArray[i].getVelocity(); velocity.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; velocity.m_y = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; velocity.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; ! Coord3D& rotation = objectArray[i].getRotation(); rotation.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)360) - 180; --- 202,216 ---- for(int i = 1; i < objectCount; i++) { Coord3D& position = objectArray[i].getPos(); ! position.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)30) - 15; ! position.m_y = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)30) - 15; ! position.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)30) - 15; + /* Coord3D& velocity = objectArray[i].getVelocity(); velocity.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; velocity.m_y = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; velocity.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)5) - 2.5; ! */ ! Coord3D& rotation = objectArray[i].getRotation(); rotation.m_x = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)360) - 180; *************** *** 216,221 **** rotation.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)360) - 180; ! double mass = (rand() / (double)RAND_MAX) * (double)1000; objectArray[i].setMass(mass); } --- 218,228 ---- rotation.m_z = (pos_t)((pos_t) (rand() / (pos_t)RAND_MAX) * (pos_t)360) - 180; ! double mass = (rand() / (double)RAND_MAX) * (double)1000000000; objectArray[i].setMass(mass); + + //cout << "<randomiseObjects>\tposition x [" << position.m_x << "] y [" << position.m_y << "] z [" << position.m_z << "]" << endl; + //cout << "<randomiseObjects>\tvelocity x [" << velocity.m_x << "] y [" << velocity.m_y << "] z [" << velocity.m_z << "]" << endl; + //cout << "<randomiseObjects>\trotation x [" << rotation.m_x << "] y [" << rotation.m_y << "] z [" << rotation.m_z << "]" << endl; + //cout << "<randomiseObjects>\tmass [" << mass << "]" << endl; } *************** *** 237,241 **** // first, check for a collision // *** NOTE *** this is terribly inefficient right now - /* for(int collisionObjectIndex = 0; collisionObjectIndex < objectCount; collisionObjectIndex++) { // skip my own object --- 244,247 ---- *************** *** 250,254 **** --- 256,264 ---- Coord3D& curObjectVelocity = objectArray[curObjectIndex].getVelocity(); Coord3D& collisionObjectVelocity = objectArray[collisionObjectIndex].getVelocity(); + double curObjectG = objectArray[curObjectIndex].getG(); + double collisionObjectG = objectArray[collisionObjectIndex].getG(); + // collisions + /* if(curPosition.distance(collisionObjectPos).length() <= 1) { cout << "<updateObjects>\tcollision between curObjectIndex [" << curObjectIndex << "] and collisionObjectIndex [" << collisionObjectIndex << "]" << endl; *************** *** 261,267 **** doneMap[pair<int, int>(curObjectIndex, collisionObjectIndex)] = true; } - */ Coord3D& position = objectArray[curObjectIndex].getPos(); Coord3D& velocity = objectArray[curObjectIndex].getVelocity(); --- 271,285 ---- doneMap[pair<int, int>(curObjectIndex, collisionObjectIndex)] = true; + */ + + Coord3D posDiff = curPosition - collisionObjectPos; + double posDiffSize = posDiff.length(); + posDiff.normalise(); + + curObjectVelocity += posDiff * sqrt(posDiffSize) * -collisionObjectG; + collisionObjectVelocity += posDiff * sqrt(posDiffSize) * curObjectG; } + // update positions according to Coord3D& position = objectArray[curObjectIndex].getPos(); Coord3D& velocity = objectArray[curObjectIndex].getVelocity(); *************** *** 352,356 **** } - // randomise the object's initial position if(!randomiseObjects(objectArray, objectCount)) { --- 370,373 ---- *************** *** 358,362 **** exit(-1); } ! /* // disable mouse display --- 375,379 ---- exit(-1); } ! /* // disable mouse display *************** *** 370,375 **** StatGraphRenderer statGraphRenderer(&renderState); statGraphRenderer.setShape(10, 10, 60, 30); ! ! */ --- 387,391 ---- StatGraphRenderer statGraphRenderer(&renderState); statGraphRenderer.setShape(10, 10, 60, 30); ! */ *************** *** 424,475 **** glLoadIdentity( ); ! glColor3f(0.2, 0.2, 0.2); ! if(0 && SystemStateSingleton::instance().showGrid) { ! glutWireSphere(10.0, 50, 50); ! } ! ! //glTranslatef(0, 0, -10); ! // call draw here] ! glRotatef(-rotation.m_x, 1.0, 0.0, 0.0); ! glRotatef(-rotation.m_y, 0.0, 1.0, 0.0); ! glRotatef(-rotation.m_z, 0.0, 0.0, 1.0); ! glTranslatef(position.m_x, position.m_y, position.m_z); ! //position.m_z -= 0.1; ! ! glColor3f(1, 1, 1); ! glBegin(GL_LINES); ! glVertex3f(10, 0, -20); ! glVertex3f(-10, 0, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 10, -20); ! glVertex3f(0, -10, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 0, -10); ! glEnd(); ! ! glBegin(GL_LINES); ! glVertex3f(10, 20, -20); ! glVertex3f(-10, 20, 20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 20, -20); ! glVertex3f(0, -20, 20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 20, -20); ! glVertex3f(0, 20, 20); ! glEnd(); ! ! slugMobile->draw(); SDL_GL_SwapBuffers(); //printf("drawing screen\n"); ! sleep(1); } --- 440,496 ---- glLoadIdentity( ); ! glColor3f(0.2, 0.2, 0.2); ! if(0 && SystemStateSingleton::instance().showGrid) { ! glutWireSphere(10.0, 50, 50); ! } ! //glTranslatef(0, 0, -10); ! // call draw here] ! ! glRotatef(-rotation.m_x, 1.0, 0.0, 0.0); ! glRotatef(-rotation.m_y, 0.0, 1.0, 0.0); ! glRotatef(-rotation.m_z, 0.0, 0.0, 1.0); ! glTranslatef(position.m_x, position.m_y, position.m_z); ! //position.m_z -= 0.1; ! ! glColor3f(1, 1, 1); ! glBegin(GL_LINES); ! glVertex3f(10, 0, -20); ! glVertex3f(-10, 0, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 10, -20); ! glVertex3f(0, -10, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 0, -10); ! glEnd(); ! ! glBegin(GL_LINES); ! glVertex3f(10, 20, -20); ! glVertex3f(-10, 20, 20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 20, -20); ! glVertex3f(0, -20, 20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 20, -20); ! glVertex3f(0, 20, 20); ! glEnd(); ! //slugMobile->draw(); ! long count = 0; ! for(vector<Object3D>::iterator i = objectArray.begin(); i != objectArray.end(); i++) { ! count++; ! (*i).draw(); ! } ! //cout << "draw count [" << count << "]" << endl; SDL_GL_SwapBuffers(); //printf("drawing screen\n"); ! //sleep(1); } *************** *** 486,489 **** --- 507,519 ---- /* $Log$ + Revision 1.8 2004/08/29 05:43:27 o3dozone + - added gravity + - fixed object movement updates + - various model parsing updates work + - updated coord3d operators + - scaling now has a sensible default + - transforms done in correct order + - other debugging removed/added + Revision 1.7 2004/08/17 18:21:43 o3dozone |
|
From: Mike D. <o3d...@us...> - 2004-08-18 14:53:29
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27856 Modified Files: material.cpp model_loader.cpp scene_object.cpp scene_object.h Log Message: - fixed material problems Index: scene_object.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** scene_object.cpp 17 Aug 2004 18:21:43 -0000 1.5 --- scene_object.cpp 18 Aug 2004 14:53:17 -0000 1.6 *************** *** 5,8 **** --- 5,9 ---- #include "scene_object.h" + #include "material.h" SceneObject::SceneObject(SceneObject* parent) *************** *** 15,21 **** } bool SceneObject::addChild(SceneObject* child) { m_children.push_back(child); ! return true; } --- 16,33 ---- } + bool SceneObject::addChild(Material* child) { + cerr << "<SceneObject::addChild>\tmaterial add called, adding to front" << endl; + m_children.insert(m_children.begin(), (SceneObject*)child); + + return true; + } + bool SceneObject::addChild(SceneObject* child) { + if(dynamic_cast<Material*>(child) != NULL) { + cerr << "<SceneObject::addChild>\tmaterial add called, adding to front" << endl; + m_children.insert(m_children.begin(), (SceneObject*)child); + } else { m_children.push_back(child); ! } return true; } *************** *** 101,104 **** --- 113,119 ---- /* $Log$ + Revision 1.6 2004/08/18 14:53:17 o3dozone + - fixed material problems + Revision 1.5 2004/08/17 18:21:43 o3dozone Index: scene_object.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** scene_object.h 25 Jul 2004 10:35:59 -0000 1.4 --- scene_object.h 18 Aug 2004 14:53:17 -0000 1.5 *************** *** 13,16 **** --- 13,19 ---- #include "opengl_includes.h" + // avoid the nasty circular dependencies for now + class Material; + using namespace std; *************** *** 20,23 **** --- 23,27 ---- virtual ~SceneObject(); + bool addChild(Material* child); bool addChild(SceneObject* child); bool makeDisplayList(); *************** *** 39,42 **** --- 43,49 ---- /* $Log$ + Revision 1.5 2004/08/18 14:53:17 o3dozone + - fixed material problems + Revision 1.4 2004/07/25 10:35:59 o3dozone - added material and transform nodes Index: material.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/material.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** material.cpp 17 Aug 2004 18:21:43 -0000 1.2 --- material.cpp 18 Aug 2004 14:53:17 -0000 1.3 *************** *** 54,58 **** GLfloat mat_diffuse[] = { m_diffuse[0], m_diffuse[1], m_diffuse[2], 1.0 }; GLfloat mat_emission[] = { m_emission[0], m_emission[1], m_emission[2], 1.0 }; ! /* glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); --- 54,58 ---- GLfloat mat_diffuse[] = { m_diffuse[0], m_diffuse[1], m_diffuse[2], 1.0 }; GLfloat mat_emission[] = { m_emission[0], m_emission[1], m_emission[2], 1.0 }; ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); *************** *** 60,65 **** glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); ! */ ! drawChildren(); --- 60,64 ---- glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); ! drawChildren(); *************** *** 69,72 **** --- 68,74 ---- /* $Log$ + Revision 1.3 2004/08/18 14:53:17 o3dozone + - fixed material problems + Revision 1.2 2004/08/17 18:21:43 o3dozone Index: model_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** model_loader.cpp 15 Aug 2004 21:07:35 -0000 1.6 --- model_loader.cpp 18 Aug 2004 14:53:17 -0000 1.7 *************** *** 297,304 **** assert(scaleElements.size() == 3); ! rotation.m_x = rotationElements[0]; ! rotation.m_y = rotationElements[1]; ! rotation.m_z = rotationElements[2]; ! rotationSize = rotationElements[3]; cout << "rotation size [" << rotationSize << "] x [" << rotation.m_x << "] y [" << rotation.m_y << "] z [" << rotation.m_z << "]" << endl; --- 297,305 ---- assert(scaleElements.size() == 3); ! int curIndex = 0; ! rotation.m_x = rotationElements[curIndex++]; ! rotation.m_y = rotationElements[curIndex++]; ! rotation.m_z = rotationElements[curIndex++]; ! rotationSize = rotationElements[curIndex++]; cout << "rotation size [" << rotationSize << "] x [" << rotation.m_x << "] y [" << rotation.m_y << "] z [" << rotation.m_z << "]" << endl; *************** *** 528,531 **** --- 529,535 ---- /* $Log$ + Revision 1.7 2004/08/18 14:53:17 o3dozone + - fixed material problems + Revision 1.6 2004/08/15 21:07:35 o3dozone - added scale operation |
|
From: Mike D. <o3d...@us...> - 2004-08-17 19:49:56
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10780 Modified Files: gravity.cpp material.cpp mesh.cpp object3d.h scene_object.cpp transform.cpp Log Message: - various small changes - fixed rotation radian -> degree changes Index: transform.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/transform.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** transform.cpp 15 Aug 2004 21:07:35 -0000 1.2 --- transform.cpp 17 Aug 2004 18:21:43 -0000 1.3 *************** *** 1,8 **** /* ! $Id */ #include "transform.h" Transform::Transform(SceneObject* parent) --- 1,9 ---- /* ! $Id$ */ #include "transform.h" + #include <math.h> Transform::Transform(SceneObject* parent) *************** *** 32,35 **** --- 33,39 ---- m_rotationSize = rotationSize; + // convert rotationSize from radians to degrees + m_rotationSize = rotationSize * (360 / M_PI); + return true; } *************** *** 48,56 **** cout << "<Transform::_draw>\tscale x [" << m_scale.m_x << "] y [" << m_scale.m_y << "] z [" << m_scale.m_z << "]" << endl; glRotatef(m_rotationSize, m_rotation.m_x, m_rotation.m_y, m_rotation.m_z); ! //glTranslatef(m_translation.m_x, m_translation.m_y, m_translation.m_z); ! //glScalef(m_scale.m_x, m_scale.m_y, m_scale.m_z); ! drawChildren(); return true; --- 52,67 ---- cout << "<Transform::_draw>\tscale x [" << m_scale.m_x << "] y [" << m_scale.m_y << "] z [" << m_scale.m_z << "]" << endl; + glTranslatef(m_translation.m_x, m_translation.m_y, m_translation.m_z); glRotatef(m_rotationSize, m_rotation.m_x, m_rotation.m_y, m_rotation.m_z); ! glScalef(m_scale.m_x, m_scale.m_y, m_scale.m_z); ! //glTranslatef(m_translation.m_z, m_translation.m_x, m_translation.m_y); ! cout << "drawing children" << endl; ! //debugging ! //if((m_scale.m_x == 1.0) && (m_scale.m_y == 1.0) && (m_scale.m_z == 1.0)) { ! drawChildren(); ! //} ! ! cout << "done" << endl; return true; *************** *** 59,62 **** --- 70,78 ---- /* $Log$ + Revision 1.3 2004/08/17 18:21:43 o3dozone + + - various small changes + - fixed rotation radian -> degree changes + Revision 1.2 2004/08/15 21:07:35 o3dozone - added scale operation Index: object3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** object3d.h 15 Aug 2004 21:07:35 -0000 1.3 --- object3d.h 17 Aug 2004 18:21:43 -0000 1.4 *************** *** 44,50 **** --- 44,52 ---- }; + /* ModelDrawer* getModelDrawer() { return m_modelDrawer; }; + */ void setMass(double mass) { Index: scene_object.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** scene_object.cpp 25 Jul 2004 10:35:59 -0000 1.4 --- scene_object.cpp 17 Aug 2004 18:21:43 -0000 1.5 *************** *** 55,63 **** bool SceneObject::drawChildren() { - glPushMatrix(); for(vector<SceneObject*>::iterator i = m_children.begin(); i != m_children.end(); i++) { (*i)->draw(); - } glPopMatrix(); return true; --- 55,63 ---- bool SceneObject::drawChildren() { for(vector<SceneObject*>::iterator i = m_children.begin(); i != m_children.end(); i++) { + glPushMatrix(); (*i)->draw(); glPopMatrix(); + } return true; *************** *** 101,104 **** --- 101,109 ---- /* $Log$ + Revision 1.5 2004/08/17 18:21:43 o3dozone + + - various small changes + - fixed rotation radian -> degree changes + Revision 1.4 2004/07/25 10:35:59 o3dozone - added material and transform nodes Index: mesh.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** mesh.cpp 15 Aug 2004 21:07:35 -0000 1.5 --- mesh.cpp 17 Aug 2004 18:21:43 -0000 1.6 *************** *** 40,50 **** // then draw the children ! /* for(vector<Polygon>::iterator i = m_polygons.begin(); i != m_polygons.end(); i++) { (*i).draw(); } - */ ! glutSolidSphere(0.5, 10, 10); // draw any sub nodes --- 40,50 ---- // then draw the children ! for(vector<Polygon>::iterator i = m_polygons.begin(); i != m_polygons.end(); i++) { (*i).draw(); } ! ! //glutSolidSphere(0.5, 10, 10); // draw any sub nodes *************** *** 56,59 **** --- 56,64 ---- /* $Log$ + Revision 1.6 2004/08/17 18:21:43 o3dozone + + - various small changes + - fixed rotation radian -> degree changes + Revision 1.5 2004/08/15 21:07:35 o3dozone - added scale operation Index: material.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/material.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** material.cpp 25 Jul 2004 10:37:12 -0000 1.1 --- material.cpp 17 Aug 2004 18:21:43 -0000 1.2 *************** *** 54,57 **** --- 54,58 ---- GLfloat mat_diffuse[] = { m_diffuse[0], m_diffuse[1], m_diffuse[2], 1.0 }; GLfloat mat_emission[] = { m_emission[0], m_emission[1], m_emission[2], 1.0 }; + /* glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); *************** *** 59,62 **** --- 60,64 ---- glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); + */ drawChildren(); *************** *** 67,70 **** --- 69,77 ---- /* $Log$ + Revision 1.2 2004/08/17 18:21:43 o3dozone + + - various small changes + - fixed rotation radian -> degree changes + Revision 1.1 2004/07/25 10:37:12 o3dozone - added material and transform nodes Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gravity.cpp 15 Aug 2004 21:07:34 -0000 1.6 --- gravity.cpp 17 Aug 2004 18:21:43 -0000 1.7 *************** *** 336,339 **** --- 336,341 ---- Coord3D lightPos; + position.m_z = -15; + slugMobile->makeDisplayList(); *************** *** 344,348 **** //objectArray.push_back(Object3D(&monkeyDrawer)); //Object3D& viewPoint = objectArray[0]; ! //long objectCount = 0; for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { --- 346,350 ---- //objectArray.push_back(Object3D(&monkeyDrawer)); //Object3D& viewPoint = objectArray[0]; ! long objectCount = 0; for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { *************** *** 372,378 **** --- 374,383 ---- + glTranslatef(0.0, 0.0, -5.0); + // now loop until we are done while(!SystemStateSingleton::instance().done) { + cerr << "frame" << endl; if(!handleEvents(rotation, position, lightPos)) { printf("Error in event handler!\n"); *************** *** 466,470 **** //printf("drawing screen\n"); ! //sleep(1); } --- 471,475 ---- //printf("drawing screen\n"); ! sleep(1); } *************** *** 481,484 **** --- 486,494 ---- /* $Log$ + Revision 1.7 2004/08/17 18:21:43 o3dozone + + - various small changes + - fixed rotation radian -> degree changes + Revision 1.6 2004/08/15 21:07:34 o3dozone - added scale operation |
|
From: Mike D. <o3d...@us...> - 2004-08-15 21:07:45
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25139 Modified Files: gravity.cpp mesh.cpp model_loader.cpp object3d.h transform.cpp transform.h Log Message: - added scale operation - debugging for transform Index: transform.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/transform.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** transform.cpp 25 Jul 2004 10:37:12 -0000 1.1 --- transform.cpp 15 Aug 2004 21:07:35 -0000 1.2 *************** *** 15,18 **** --- 15,19 ---- m_rotation = rhs.m_rotation; m_rotationSize = rhs.m_rotationSize; + m_scale = rhs.m_scale; } *************** *** 23,26 **** --- 24,28 ---- m_translation = translation; + cout << "<Transform::_draw>\ttranslation x [" << m_translation.m_x << "] y [" << m_translation.m_y << "] z [" << m_translation.m_z << "]" << endl; return true; } *************** *** 33,42 **** } bool Transform::_draw() { cout << "<Transform::_draw>\trotation size [" << m_rotationSize << "] x [" << m_rotation.m_x << "] y [" << m_rotation.m_y << "] z [" << m_rotation.m_z << "]" << endl; cout << "<Transform::_draw>\ttranslation x [" << m_translation.m_x << "] y [" << m_translation.m_y << "] z [" << m_translation.m_z << "]" << endl; glRotatef(m_rotationSize, m_rotation.m_x, m_rotation.m_y, m_rotation.m_z); ! glTranslatef(m_translation.m_x, m_translation.m_y, m_translation.m_z); drawChildren(); --- 35,54 ---- } + bool Transform::setScale(Coord3D& scale) { + m_scale = scale; + + return true; + } + bool Transform::_draw() { + glMatrixMode(GL_MODELVIEW); + cout << "<Transform::_draw>\trotation size [" << m_rotationSize << "] x [" << m_rotation.m_x << "] y [" << m_rotation.m_y << "] z [" << m_rotation.m_z << "]" << endl; cout << "<Transform::_draw>\ttranslation x [" << m_translation.m_x << "] y [" << m_translation.m_y << "] z [" << m_translation.m_z << "]" << endl; + cout << "<Transform::_draw>\tscale x [" << m_scale.m_x << "] y [" << m_scale.m_y << "] z [" << m_scale.m_z << "]" << endl; glRotatef(m_rotationSize, m_rotation.m_x, m_rotation.m_y, m_rotation.m_z); ! //glTranslatef(m_translation.m_x, m_translation.m_y, m_translation.m_z); ! //glScalef(m_scale.m_x, m_scale.m_y, m_scale.m_z); drawChildren(); *************** *** 47,50 **** --- 59,66 ---- /* $Log$ + Revision 1.2 2004/08/15 21:07:35 o3dozone + - added scale operation + - debugging for transform + Revision 1.1 2004/07/25 10:37:12 o3dozone - added material and transform nodes Index: object3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** object3d.h 23 Jul 2004 05:43:48 -0000 1.2 --- object3d.h 15 Aug 2004 21:07:35 -0000 1.3 *************** *** 13,18 **** class Object3D { public: ! Object3D(ModelDrawer* modelDrawer) ! : m_modelDrawer(modelDrawer) {}; --- 13,18 ---- class Object3D { public: ! Object3D(SceneObject* sceneObject) ! : m_sceneObject(sceneObject) {}; *************** *** 58,62 **** Coord3D m_velocity; Coord3D m_rotation; ! ModelDrawer* m_modelDrawer; double m_mass; }; --- 58,62 ---- Coord3D m_velocity; Coord3D m_rotation; ! SceneObject* m_sceneObject; double m_mass; }; Index: transform.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/transform.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** transform.h 25 Jul 2004 10:37:12 -0000 1.1 --- transform.h 15 Aug 2004 21:07:35 -0000 1.2 *************** *** 20,23 **** --- 20,24 ---- bool setTranslation(Coord3D& translation); bool setRotation(Coord3D& rotation, double rotationSize); + bool setScale(Coord3D& scale); protected: virtual bool _draw(); *************** *** 25,28 **** --- 26,30 ---- Coord3D m_translation; Coord3D m_rotation; + Coord3D m_scale; double m_rotationSize; }; *************** *** 30,33 **** --- 32,39 ---- /* $Log$ + Revision 1.2 2004/08/15 21:07:35 o3dozone + - added scale operation + - debugging for transform + Revision 1.1 2004/07/25 10:37:12 o3dozone - added material and transform nodes Index: mesh.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** mesh.cpp 25 Jul 2004 10:35:59 -0000 1.4 --- mesh.cpp 15 Aug 2004 21:07:35 -0000 1.5 *************** *** 40,49 **** // then draw the children for(vector<Polygon>::iterator i = m_polygons.begin(); i != m_polygons.end(); i++) { (*i).draw(); } // draw any sub nodes ! drawChildren(); return true; --- 40,53 ---- // then draw the children + /* for(vector<Polygon>::iterator i = m_polygons.begin(); i != m_polygons.end(); i++) { (*i).draw(); } + */ + + glutSolidSphere(0.5, 10, 10); // draw any sub nodes ! //drawChildren(); return true; *************** *** 52,55 **** --- 56,63 ---- /* $Log$ + Revision 1.5 2004/08/15 21:07:35 o3dozone + - added scale operation + - debugging for transform + Revision 1.4 2004/07/25 10:35:59 o3dozone - added material and transform nodes Index: model_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** model_loader.cpp 8 Aug 2004 13:26:13 -0000 1.5 --- model_loader.cpp 15 Aug 2004 21:07:35 -0000 1.6 *************** *** 264,269 **** --- 264,271 ---- double rotationSize = 0; Coord3D translation; + Coord3D scale; vector<double> rotationElements; vector<double> translationElements; + vector<double> scaleElements; // get the attributes (containing the coord/normal indexes) *************** *** 284,289 **** --- 286,299 ---- } + // 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())); + } + assert(rotationElements.size() == 4); assert(translationElements.size() == 3); + assert(scaleElements.size() == 3); rotation.m_x = rotationElements[0]; *************** *** 299,302 **** --- 309,318 ---- cout << "translation x [" << translation.m_x << "] y [" << translation.m_y << "] z [" << translation.m_z << "]" << endl; + + scale.m_x = scaleElements[0]; + scale.m_y = scaleElements[1]; + scale.m_z = scaleElements[2]; + + cout << "scale x [" << scale.m_x << "] y [" << scale.m_y << "] z [" << scale.m_z << "]" << endl; } *************** *** 305,308 **** --- 321,325 ---- transform->setTranslation(translation); transform->setRotation(rotation, rotationSize); + transform->setScale(scale); return transform; *************** *** 502,506 **** piece = intString.substr(startPos, pieceLength); ! doubleVector.push_back(atoi(piece.c_str())); cout << "<X3DLoader::_convertCharToVector(double)>\tvector size [" << doubleVector.size() << "]" << endl; --- 519,523 ---- piece = intString.substr(startPos, pieceLength); ! doubleVector.push_back(atof(piece.c_str())); cout << "<X3DLoader::_convertCharToVector(double)>\tvector size [" << doubleVector.size() << "]" << endl; *************** *** 511,514 **** --- 528,535 ---- /* $Log$ + Revision 1.6 2004/08/15 21:07:35 o3dozone + - added scale operation + - debugging for transform + Revision 1.5 2004/08/08 13:26:13 o3dozone - now loads x3d files Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gravity.cpp 25 Jul 2004 10:35:59 -0000 1.5 --- gravity.cpp 15 Aug 2004 21:07:34 -0000 1.6 *************** *** 346,356 **** //long objectCount = 0; - /* for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { ! objectArray.push_back(&monkeyDrawer); } - */ ! /* // randomise the object's initial position if(!randomiseObjects(objectArray, objectCount)) { --- 346,354 ---- //long objectCount = 0; for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { ! objectArray.push_back(slugMobile); } ! // randomise the object's initial position if(!randomiseObjects(objectArray, objectCount)) { *************** *** 358,363 **** exit(-1); } ! */ ! /* // disable mouse display --- 356,360 ---- exit(-1); } ! /* // disable mouse display *************** *** 391,400 **** } - /* if(!updateObjects(objectArray, objectCount, SystemStateSingleton::instance().tickDiff)) { printf("Couldn't update objects\n"); exit(-1); } - */ reshape_screen(0, 0, renderState.screenWidth(), renderState.screenHeight()); --- 388,395 ---- *************** *** 421,426 **** glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient_light); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); ! glMatrixMode( GL_MODELVIEW ); ! glLoadIdentity( ); glColor3f(0.2, 0.2, 0.2); --- 416,421 ---- glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient_light); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); ! glMatrixMode( GL_MODELVIEW ); ! glLoadIdentity( ); glColor3f(0.2, 0.2, 0.2); *************** *** 486,489 **** --- 481,488 ---- /* $Log$ + Revision 1.6 2004/08/15 21:07:34 o3dozone + - added scale operation + - debugging for transform + Revision 1.5 2004/07/25 10:35:59 o3dozone - added material and transform nodes |
|
From: Mike D. <o3d...@us...> - 2004-08-09 07:51:04
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10865 Modified Files: makefile Log Message: - removed x3dtk references Index: makefile =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** makefile 25 Jul 2004 10:35:59 -0000 1.4 --- makefile 9 Aug 2004 07:50:54 -0000 1.5 *************** *** 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 --- 1,10 ---- 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 *************** *** 10,14 **** 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 transform.o material.o all: gravity --- 12,16 ---- GRAVITY_DEPS= ! 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 all: gravity |
|
From: Mike D. <o3d...@us...> - 2004-08-08 13:26:21
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20265 Modified Files: model_loader.cpp Log Message: - now loads x3d files Index: model_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** model_loader.cpp 25 Jul 2004 10:35:59 -0000 1.4 --- model_loader.cpp 8 Aug 2004 13:26:13 -0000 1.5 *************** *** 292,298 **** --- 292,302 ---- rotationSize = rotationElements[3]; + cout << "rotation size [" << rotationSize << "] x [" << rotation.m_x << "] y [" << rotation.m_y << "] z [" << rotation.m_z << "]" << endl; + translation.m_x = translationElements[0]; translation.m_y = translationElements[1]; translation.m_z = translationElements[2]; + + cout << "translation x [" << translation.m_x << "] y [" << translation.m_y << "] z [" << translation.m_z << "]" << endl; } *************** *** 507,510 **** --- 511,517 ---- /* $Log$ + Revision 1.5 2004/08/08 13:26:13 o3dozone + - now loads x3d files + Revision 1.4 2004/07/25 10:35:59 o3dozone - added material and transform nodes |
|
From: Mike D. <o3d...@us...> - 2004-07-25 10:37:20
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17386 Added Files: material.cpp material.h transform.cpp transform.h Log Message: - added material and transform nodes --- NEW FILE: transform.cpp --- /* $Id */ #include "transform.h" Transform::Transform(SceneObject* parent) : SceneObject(parent), m_rotationSize(0) { } Transform::Transform(const Transform& rhs) { m_translation = rhs.m_translation; m_rotation = rhs.m_rotation; m_rotationSize = rhs.m_rotationSize; } Transform::~Transform() { } bool Transform::setTranslation(Coord3D& translation) { m_translation = translation; return true; } bool Transform::setRotation(Coord3D& rotation, double rotationSize) { m_rotation = rotation; m_rotationSize = rotationSize; return true; } bool Transform::_draw() { cout << "<Transform::_draw>\trotation size [" << m_rotationSize << "] x [" << m_rotation.m_x << "] y [" << m_rotation.m_y << "] z [" << m_rotation.m_z << "]" << endl; cout << "<Transform::_draw>\ttranslation x [" << m_translation.m_x << "] y [" << m_translation.m_y << "] z [" << m_translation.m_z << "]" << endl; glRotatef(m_rotationSize, m_rotation.m_x, m_rotation.m_y, m_rotation.m_z); glTranslatef(m_translation.m_x, m_translation.m_y, m_translation.m_z); drawChildren(); return true; } /* $Log: transform.cpp,v $ Revision 1.1 2004/07/25 10:37:12 o3dozone - added material and transform nodes */ --- NEW FILE: material.cpp --- /* $Id */ #include "material.h" Material::Material(SceneObject* parent) : SceneObject(parent) { } Material::Material(const Material& rhs) { } Material::~Material() { } bool Material::setDiffuse(vector<double>& diffuse) { m_diffuse = diffuse; return true; } bool Material::setEmission(vector<double>& emission) { m_emission = emission; return true; } bool Material::setShininess(double shininess) { m_shininess = shininess; return true; } bool Material::setSpecular(vector<double>& specular) { m_specular = specular; return true; } bool Material::setAmbient(double ambient) { m_ambient = ambient; return true; } bool Material::_draw() { GLfloat mat_specular[] = { m_specular[0], m_specular[1], m_specular[2], 1.0 }; GLfloat mat_shininess[] = { m_shininess }; GLfloat mat_ambient[] = { m_ambient, m_ambient, m_ambient, 1.0 }; GLfloat mat_diffuse[] = { m_diffuse[0], m_diffuse[1], m_diffuse[2], 1.0 }; GLfloat mat_emission[] = { m_emission[0], m_emission[1], m_emission[2], 1.0 }; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); drawChildren(); return true; } /* $Log: material.cpp,v $ Revision 1.1 2004/07/25 10:37:12 o3dozone - added material and transform nodes */ --- NEW FILE: transform.h --- #ifndef TRANSFORM_H #define TRANSFORM_H /* $Id: transform.h,v 1.1 2004/07/25 10:37:12 o3dozone Exp $ */ #include "scene_object.h" #include "coord3d.h" #include <iostream> class Transform : public SceneObject { public: Transform(SceneObject* parent = NULL); Transform(const Transform& rhs); virtual ~Transform(); bool setTranslation(Coord3D& translation); bool setRotation(Coord3D& rotation, double rotationSize); protected: virtual bool _draw(); private: Coord3D m_translation; Coord3D m_rotation; double m_rotationSize; }; /* $Log: transform.h,v $ Revision 1.1 2004/07/25 10:37:12 o3dozone - added material and transform nodes */ #endif --- NEW FILE: material.h --- #ifndef MATERIAL_H #define MATERIAL_H /* $Id: material.h,v 1.1 2004/07/25 10:37:12 o3dozone Exp $ */ /* <Appearance> <Material ambientIntensity="0.500" diffuseColor="0.640 0.640 0.640" emissiveColor="0.800 0.800 0.800" shininess="0.196" specularColor="1.000 1.000 1.000" transparency="0.000"/> </Appearance> */ #include "scene_object.h" #include <iostream> class Material : public SceneObject { public: Material(SceneObject* parent = NULL); Material(const Material& rhs); virtual ~Material(); bool setDiffuse(vector<double>& diffuse); bool setEmission(vector<double>& emission); bool setShininess(double shininess); bool setSpecular(vector<double>& specular); bool setAmbient(double ambient); protected: virtual bool _draw(); private: vector<double> m_diffuse; vector<double> m_emission; double m_shininess; vector<double> m_specular; double m_ambient; }; /* $Log: material.h,v $ Revision 1.1 2004/07/25 10:37:12 o3dozone - added material and transform nodes */ #endif |
|
From: Mike D. <o3d...@us...> - 2004-07-25 10:36:09
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17203 Modified Files: gravity.cpp makefile mesh.cpp model_loader.cpp model_loader.h scene_object.cpp scene_object.h Log Message: - added material and transform nodes - fixed a few small bugs Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gravity.cpp 23 Jul 2004 05:43:48 -0000 1.4 --- gravity.cpp 25 Jul 2004 10:35:59 -0000 1.5 *************** *** 146,153 **** */ if(SystemStateSingleton::instance().middleButtonPressed) { ! clposZ++; //xAngle += 5; } else { ! cposZ++; //yAngle += 5; } --- 146,153 ---- */ if(SystemStateSingleton::instance().middleButtonPressed) { ! cposZ++; //xAngle += 5; } else { ! clposZ++; //yAngle += 5; } *************** *** 306,310 **** ModelLoader* modelLoader = new X3DLoader(); SceneObject* slugMobile = modelLoader->loadModel(vrmlFilename); - slugMobile->makeDisplayList(); //Model monkey(vrmlFilename); --- 306,309 ---- *************** *** 337,340 **** --- 336,340 ---- Coord3D lightPos; + slugMobile->makeDisplayList(); //ModelDrawer monkeyDrawer(&monkey); *************** *** 411,422 **** GLfloat light_position[] = { lightPos.m_x, lightPos.m_y, lightPos.m_z, 1.0 }; ! GLfloat mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; ! GLfloat mat_shininess[] = { 20.0 }; ! GLfloat mat_ambient[] = { 0.8, 0.8, 0.8, 1.0 }; ! GLfloat white_light[] = { 0.8, 0.8, 0.8, 1.0 }; ! GLfloat ambient_light[] = { 0.5, 0.5, 0.5, 1.0 }; ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); ! glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light); --- 411,416 ---- GLfloat light_position[] = { lightPos.m_x, lightPos.m_y, lightPos.m_z, 1.0 }; ! GLfloat white_light[] = { 1, 1, 1, 1.0 }; ! GLfloat ambient_light[] = { 1, 1, 1, 1.0 }; glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light); *************** *** 442,446 **** glRotatef(-rotation.m_z, 0.0, 0.0, 1.0); glTranslatef(position.m_x, position.m_y, position.m_z); ! position.m_z -= 0.1; glColor3f(1, 1, 1); --- 436,440 ---- glRotatef(-rotation.m_z, 0.0, 0.0, 1.0); glTranslatef(position.m_x, position.m_y, position.m_z); ! //position.m_z -= 0.1; glColor3f(1, 1, 1); *************** *** 492,495 **** --- 486,493 ---- /* $Log$ + Revision 1.5 2004/07/25 10:35:59 o3dozone + - added material and transform nodes + - fixed a few small bugs + Revision 1.4 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays Index: scene_object.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** scene_object.cpp 23 Jul 2004 05:43:48 -0000 1.3 --- scene_object.cpp 25 Jul 2004 10:35:59 -0000 1.4 *************** *** 28,31 **** --- 28,32 ---- m_displayListCreated = true; } else { + cout << "drawing" <<endl; draw(); } *************** *** 42,45 **** --- 43,47 ---- // draw if there is no display list if(!m_displayListCreated) { + //cout << "trying to draw" << endl; _draw(); // otherwise call the display list *************** *** 52,60 **** } ! bool SceneObject::_draw() { ! // then the children for(vector<SceneObject*>::iterator i = m_children.begin(); i != m_children.end(); i++) { (*i)->draw(); } return true; --- 54,70 ---- } ! bool SceneObject::drawChildren() { ! glPushMatrix(); for(vector<SceneObject*>::iterator i = m_children.begin(); i != m_children.end(); i++) { (*i)->draw(); } + glPopMatrix(); + + return true; + } + + bool SceneObject::_draw() { + // then the children + drawChildren(); return true; *************** *** 91,94 **** --- 101,108 ---- /* $Log$ + Revision 1.4 2004/07/25 10:35:59 o3dozone + - added material and transform nodes + - fixed a few small bugs + Revision 1.3 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays Index: mesh.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mesh.cpp 23 Jul 2004 05:43:48 -0000 1.3 --- mesh.cpp 25 Jul 2004 10:35:59 -0000 1.4 *************** *** 37,40 **** --- 37,41 ---- bool Mesh::_draw() { // first draw myself + cout << "<Mesh::_draw>\tI'm a star!" << endl; // then draw the children *************** *** 42,45 **** --- 43,49 ---- (*i).draw(); } + + // draw any sub nodes + drawChildren(); return true; *************** *** 48,51 **** --- 52,59 ---- /* $Log$ + Revision 1.4 2004/07/25 10:35:59 o3dozone + - added material and transform nodes + - fixed a few small bugs + Revision 1.3 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays Index: model_loader.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** model_loader.h 23 Jul 2004 05:43:48 -0000 1.2 --- model_loader.h 25 Jul 2004 10:35:59 -0000 1.3 *************** *** 14,17 **** --- 14,19 ---- #include "scene_object.h" #include "mesh.h" + #include "transform.h" + #include "material.h" #include <assert.h> #include <vector> *************** *** 39,42 **** --- 41,47 ---- 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); *************** *** 45,48 **** --- 50,57 ---- /* $Log$ + Revision 1.3 2004/07/25 10:35:59 o3dozone + - added material and transform nodes + - fixed a few small bugs + Revision 1.2 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays Index: makefile =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** makefile 21 Jul 2004 19:32:44 -0000 1.3 --- makefile 25 Jul 2004 10:35:59 -0000 1.4 *************** *** 10,14 **** 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 --- 10,14 ---- 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 transform.o material.o all: gravity Index: scene_object.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** scene_object.h 23 Jul 2004 05:43:48 -0000 1.3 --- scene_object.h 25 Jul 2004 10:35:59 -0000 1.4 *************** *** 23,26 **** --- 23,27 ---- bool makeDisplayList(); virtual bool draw(); + bool drawChildren(); virtual SceneObject& operator=(const SceneObject& rhs); *************** *** 38,41 **** --- 39,46 ---- /* $Log$ + Revision 1.4 2004/07/25 10:35:59 o3dozone + - added material and transform nodes + - fixed a few small bugs + Revision 1.3 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays Index: model_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** model_loader.cpp 23 Jul 2004 05:43:48 -0000 1.3 --- model_loader.cpp 25 Jul 2004 10:35:59 -0000 1.4 *************** *** 170,298 **** parentMustHandleChildren = false; ! // this is a mesh ! Mesh* mesh = new Mesh(); ! vector<int> coordIndexes; ! vector<int> normalIndexes; ! vector<double> coords; ! vector<double> normals; ! // 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; } ! // now run through the coords and add them to the mesh ! // *** NOTE *** we make the assumption that there are the same number of normals as vertices ! // *** NOTE *** we need to presize the mesh vector, because it keeps on copying the polygons ! vector<int>::size_type normalCount = normalIndexes.size(); ! vector<double>::size_type coordsSize = coords.size(); ! vector<double>::size_type normalsSize = normals.size(); ! int coordIndex = 0; ! int normalIndex = 0; ! Coord3D coord; ! Coord3D normal; ! Polygon* curPolygon = new Polygon(); ! for(vector<int>::size_type i = 0; i < normalCount; i++) { ! ! //cout << "\tcoordIndex [" << coordIndexes[i] << "] coord x [" << coord.m_x << "] y [" << coord.m_y << "] z [" << coord.m_z << "]" << endl; ! //cout << "\tnormalIndex [" << normalIndexes[i] << "] normal x [" << normal.m_x << "] y [" << normal.m_y << "] z [" << normal.m_z << "]" << endl; ! // add to mesh and restart for next polygon ! // *** NOTE *** we could be reusing the polygon, but I just want to get this going ! if(coordIndexes[i] == -1) { ! mesh->addPolygon(*curPolygon); ! ! delete(curPolygon); ! curPolygon = new Polygon(); ! } else { ! coordIndex = coordIndexes[i] * 3; ! normalIndex = normalIndexes[i] * 3; ! ! //assert((coordIndex + 2) < coordsSize); ! //assert((normalIndex + 2) < normalsSize); ! if(coordIndex + 2 >= coordsSize) { ! cout << "coordsSize [" << coordsSize << "] coordIndex [" << coordIndex << "]" << endl; ! break; ! } ! if(normalIndex + 2 >= normalsSize) { ! cout << "normalsSize [" << normalsSize << "] normalIndex [" << normalIndex << "]" << endl; ! break; ! } ! coord.m_x = coords[coordIndex]; ! coord.m_y = coords[coordIndex + 1]; ! coord.m_z = coords[coordIndex + 2]; ! normal.m_x = normals[normalIndex]; ! normal.m_y = normals[normalIndex + 1]; ! normal.m_z = normals[normalIndex + 2]; ! curPolygon->addCoord(coord); ! curPolygon->addNormal(normal); ! } } ! // done, return ! return mesh; ! } ! ! /* ! else { ! SceneObject* dummy = new SceneObject(); ! return dummy; } - */ ! return NULL; } --- 170,425 ---- 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); ! } ! /* ! else { ! SceneObject* dummy = new SceneObject(); ! return dummy; ! } ! */ ! ! return NULL; ! } ! ! SceneObject* X3DLoader::_createMaterial(DOMNode* domNode) { ! Material* material = new Material(); ! ! vector<double> diffuse; ! vector<double> emission; ! vector<double> specular; ! ! /* ! <Appearance> ! <Material ! +ambientIntensity="0.500" ! +diffuseColor="0.640 0.640 0.640" ! +emissiveColor="0.800 0.800 0.800" ! shininess="0.196" ! +specularColor="1.000 1.000 1.000" ! transparency="0.000"/> ! </Appearance> ! */ ! ! // 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())); ! } ! assert(diffuse.size() == 3); ! assert(emission.size() == 3); ! assert(specular.size() == 3); ! ! material->setAmbient(atof(XMLString::transcode(ambientIntensityNode->getNodeValue()))); ! material->setShininess(atof(XMLString::transcode(shininessNode->getNodeValue()))); ! material->setDiffuse(diffuse); ! material->setEmission(emission); ! material->setSpecular(specular); ! } ! ! return material; ! ! } ! ! SceneObject* X3DLoader::_createTransform(DOMNode* domNode) { ! Transform* transform = new Transform(); ! ! Coord3D rotation; ! double rotationSize = 0; ! Coord3D translation; ! vector<double> rotationElements; ! vector<double> translationElements; ! ! // 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())); ! } ! ! assert(rotationElements.size() == 4); ! assert(translationElements.size() == 3); ! ! rotation.m_x = rotationElements[0]; ! rotation.m_y = rotationElements[1]; ! rotation.m_z = rotationElements[2]; ! rotationSize = rotationElements[3]; ! ! translation.m_x = translationElements[0]; ! translation.m_y = translationElements[1]; ! translation.m_z = translationElements[2]; ! } ! ! // <Transform rotation="1.000 0.000 0.000 1.571" scale="1.000 1.000 0.603" translation="1.429 -5.224 2.204"> ! ! transform->setTranslation(translation); ! transform->setRotation(rotation, rotationSize); ! ! return transform; ! ! } ! ! SceneObject* X3DLoader::_createMesh(DOMNode* domNode) { ! // this is a mesh ! Mesh* mesh = new Mesh(); ! ! vector<int> coordIndexes; ! vector<int> normalIndexes; ! vector<double> coords; ! vector<double> normals; ! ! // 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; ! } ! ! // now run through the coords and add them to the mesh ! // *** NOTE *** we make the assumption that there are the same number of normals as vertices ! // *** NOTE *** we need to presize the mesh vector, because it keeps on copying the polygons ! vector<int>::size_type normalCount = normalIndexes.size(); ! vector<double>::size_type coordsSize = coords.size(); ! vector<double>::size_type normalsSize = normals.size(); ! ! int coordIndex = 0; ! int normalIndex = 0; ! Coord3D coord; ! Coord3D normal; ! Polygon* curPolygon = new Polygon(); ! for(vector<int>::size_type i = 0; i < normalCount; i++) { ! //cout << "\tcoordIndex [" << coordIndexes[i] << "] coord x [" << coord.m_x << "] y [" << coord.m_y << "] z [" << coord.m_z << "]" << endl; ! //cout << "\tnormalIndex [" << normalIndexes[i] << "] normal x [" << normal.m_x << "] y [" << normal.m_y << "] z [" << normal.m_z << "]" << endl; ! // add to mesh and restart for next polygon ! // *** NOTE *** we could be reusing the polygon, but I just want to get this going ! if(coordIndexes[i] == -1) { ! mesh->addPolygon(*curPolygon); ! delete(curPolygon); ! curPolygon = new Polygon(); ! } else { ! coordIndex = coordIndexes[i] * 3; ! normalIndex = normalIndexes[i] * 3; ! ! //assert((coordIndex + 2) < coordsSize); ! //assert((normalIndex + 2) < normalsSize); ! if(coordIndex + 2 >= coordsSize) { ! cout << "coordsSize [" << coordsSize << "] coordIndex [" << coordIndex << "]" << endl; ! break; ! } ! if(normalIndex + 2 >= normalsSize) { ! cout << "normalsSize [" << normalsSize << "] normalIndex [" << normalIndex << "]" << endl; ! break; } + coord.m_x = coords[coordIndex]; + coord.m_y = coords[coordIndex + 1]; + coord.m_z = coords[coordIndex + 2]; + normal.m_x = normals[normalIndex]; + normal.m_y = normals[normalIndex + 1]; + normal.m_z = normals[normalIndex + 2]; ! curPolygon->addCoord(coord); ! curPolygon->addNormal(normal); ! } } ! // done, return ! return mesh; } *************** *** 326,329 **** --- 453,462 ---- endPos = startPos; } + + // now push the last element onto the vector + string::size_type pieceLength = intString.size() - 1 - startPos; + piece = intString.substr(startPos, pieceLength); + + intVector.push_back(atoi(piece.c_str())); cout << "<X3DLoader::_convertCharToVector(int)>\tvector size [" << intVector.size() << "]" << endl; *************** *** 332,336 **** } ! bool X3DLoader::_convertCharToVector(vector<double>& intVector, string intString) { string piece; --- 465,469 ---- } ! bool X3DLoader::_convertCharToVector(vector<double>& doubleVector, string intString) { string piece; *************** *** 348,352 **** piece = intString.substr(startPos, pieceLength); ! intVector.push_back(atof(piece.c_str())); //pieceCount++; --- 481,485 ---- piece = intString.substr(startPos, pieceLength); ! doubleVector.push_back(atof(piece.c_str())); //pieceCount++; *************** *** 361,365 **** } ! cout << "<X3DLoader::_convertCharToVector(double)>\tvector size [" << intVector.size() << "]" << endl; return true; --- 494,504 ---- } ! // now push the last element onto the vector ! string::size_type pieceLength = intString.size() - 1 - startPos; ! piece = intString.substr(startPos, pieceLength); ! ! doubleVector.push_back(atoi(piece.c_str())); ! ! cout << "<X3DLoader::_convertCharToVector(double)>\tvector size [" << doubleVector.size() << "]" << endl; return true; *************** *** 368,371 **** --- 507,514 ---- /* $Log$ + Revision 1.4 2004/07/25 10:35:59 o3dozone + - added material and transform nodes + - fixed a few small bugs + Revision 1.3 2004/07/23 05:43:48 o3dozone - now correctly parses x3d vertice arrays |
|
From: Mike D. <o3d...@us...> - 2004-07-23 05:45:14
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9950 Added Files: coord3d.h opengl_includes.h Log Message: - split out these files to make the include tree more sensible --- NEW FILE: coord3d.h --- /* $Id: coord3d.h,v 1.1 2004/07/23 05:45:06 o3dozone Exp $ */ #ifndef COORD3D_H #define COORD3D_H #include <iostream> using namespace std; typedef long double pos_t; struct Coord3D { Coord3D() : m_x(0), m_y(0), m_z(0) {}; Coord3D(pos_t x, pos_t y, pos_t z) : m_x(x), m_y(y), m_z(z) {}; Coord3D(const Coord3D& rhs) : m_x(rhs.m_x), m_y(rhs.m_y), m_z(rhs.m_z) {}; bool isZero() { if(m_x == 0 && m_y == 0 && m_z == 0) { return true; } else { return false; } }; bool operator==(const Coord3D& rhs) { if((m_x == rhs.m_x) && (m_y == rhs.m_y) && (m_z == rhs.m_z)) { return true; } else { return false; } }; bool operator==(const Coord3D& rhs) const { return((Coord3D)(*this) == rhs); }; Coord3D& operator=(const Coord3D& rhs) { m_x = rhs.m_x; m_y = rhs.m_y; m_z = rhs.m_z; return(*this); }; Coord3D operator*(long double rhs) const { return((Coord3D)(*this) * rhs); }; Coord3D operator*(long double rhs) { Coord3D result(0, 0, 0); result.m_x = m_x * rhs; result.m_y = m_y * rhs; result.m_z = m_z * rhs; return result; }; Coord3D operator+(const Coord3D& rhs) const { return((Coord3D)(*this) + rhs); }; Coord3D operator+(const Coord3D& rhs) { Coord3D result(0, 0, 0); result.m_x = m_x + rhs.m_x; result.m_y = m_y + rhs.m_y; result.m_z = m_z + rhs.m_z; return result; }; Coord3D operator-(const Coord3D& rhs) const { return((Coord3D)(*this) + rhs); }; Coord3D operator-(const Coord3D& rhs) { Coord3D result(0, 0, 0); result.m_x = m_x - rhs.m_x; result.m_y = m_y - rhs.m_y; result.m_z = m_z - rhs.m_z; return result; }; Coord3D crossProduct(const Coord3D& rhs) { Coord3D result(0, 0, 0); //(aybz - azby)i+ (azbx - axbz)j+ (axby - aybx)k; result.m_x = m_y * rhs.m_z - m_z * rhs.m_y; result.m_y = m_z * rhs.m_x - m_x * rhs.m_z; result.m_z = m_x * rhs.m_y - m_y * rhs.m_x; return result; }; Coord3D distance(const Coord3D& rhs) { Coord3D result(0, 0, 0); result.m_x = m_x - rhs.m_x; result.m_y = m_y - rhs.m_y; result.m_z = m_z - rhs.m_z; return result; }; void normalise() { pos_t vectorLength = length(); if(vectorLength != 0) { m_x /= vectorLength; m_y /= vectorLength; m_z /= vectorLength; } else { m_x = 0; m_y = 0; m_z = 0; } }; bool isParallel(const Coord3D& rhs, bool& sameDirection) { pos_t x = m_x / rhs.m_x; pos_t y = m_y / rhs.m_y; pos_t z = m_z / rhs.m_z; //cout << "<::isParallel>\tx [" << x << "] y [" << y << "] z [" << z << "]" << endl; /* if((m_x == rhs.m_x) && (m_x == 0)) { cout << "x is zero" << endl; } else if((m_y == rhs.m_y) && (m_y == 0)) { cout << "y is zero" << endl; } else if((m_z == rhs.m_z) && (m_z == 0)) { cout << "z is zero" << endl; } */ sameDirection = true; if((!((m_x == rhs.m_x) && (m_x == 0))) && (!((m_y == rhs.m_y) && (m_y == 0))) && (x != y)) { cout << "1" << endl; return false; } else if((!((m_x == rhs.m_x) && (m_x == 0))) && (!((m_z == rhs.m_z) && (m_z == 0))) && (x != z)) { cout << "2" << endl; return false; } else if((!((m_z == rhs.m_z) && (m_z == 0))) && (!((m_y == rhs.m_y) && (m_y == 0))) && (z != y)) { cout << "3" << endl; return false; } else { //cout << "parallel" << endl; if((x < 0) || (y < 0) || (z < 0)) { //cout << "\topposite direction" << endl; sameDirection = false; } return true; } }; pos_t length() const { return (pos_t)sqrt(m_x * m_x + m_y * m_y + m_z * m_z); } pos_t length() { return (pos_t)sqrt(m_x * m_x + m_y * m_y + m_z * m_z); } pos_t m_x; pos_t m_y; pos_t m_z; }; Coord3D operator*(long double lhs, const Coord3D& rhs); #endif --- NEW FILE: opengl_includes.h --- /* $Id: opengl_includes.h,v 1.1 2004/07/23 05:45:06 o3dozone Exp $ */ #include <SDL.h> #include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> /* $Log: opengl_includes.h,v $ Revision 1.1 2004/07/23 05:45:06 o3dozone - split out these files to make the include tree more sensible */ |
|
From: Mike D. <o3d...@us...> - 2004-07-23 05:44:11
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9810 Modified Files: gravity.cpp mesh.cpp mesh.h model_loader.cpp model_loader.h object3d.h opengl_utils.h polygon.cpp polygon.h scene_object.cpp scene_object.h Log Message: - now correctly parses x3d vertice arrays - does *not* parse transforms etc Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gravity.cpp 24 Jun 2004 19:46:40 -0000 1.3 --- gravity.cpp 23 Jul 2004 05:43:48 -0000 1.4 *************** *** 4,26 **** #include "gravity.h" ! ! ! /* ! DxfReader::DxfReader() { ! }; ! ! void DxfReader::addVertex(const DL_VertexData& data) { ! cout << "<DxfReader::addVertex>\tx [" << data.x << "] y [" << data.y << "] z [" << data.z << "] bulge [" << data.bulge << "]" << endl; ! }; ! */ ! bool handleEvents(Object3D& viewPoint, vector<Object3D>& objectArray, long objectCount) { ! ! /* Our angle of rotation. */ ! Coord3D& rotation = viewPoint.getRotation(); ! Coord3D& position = viewPoint.getPos(); ! Coord3D& velocity = viewPoint.getVelocity(); pos_t& xAngle = rotation.m_x; --- 4,12 ---- #include "gravity.h" ! #include "model_loader.h" ! bool handleEvents(Coord3D& rotation, Coord3D& position, Coord3D& velocity) { pos_t& xAngle = rotation.m_x; *************** *** 113,124 **** } if(SystemStateSingleton::instance().rightButtonPressed) { ! clposX += (double)event.motion.xrel / (double)5; ! clposY += (double)event.motion.yrel / (double)5; } if(SystemStateSingleton::instance().middleButtonPressed) { ! /* ! xAngle += (double)event.motion.yrel / (double)5; ! yAngle += (double)event.motion.xrel / (double)5; ! */ } //cout << "cposX [" << cposX << "] cposY [" << cposY << "] cposZ [" << cposZ << "]" << endl; --- 99,108 ---- } if(SystemStateSingleton::instance().rightButtonPressed) { ! cposX += (double)event.motion.xrel / (double)5; ! cposY += (double)event.motion.yrel / (double)5; } if(SystemStateSingleton::instance().middleButtonPressed) { ! clposX += (double)event.motion.yrel / (double)5; ! clposY += (double)event.motion.xrel / (double)5; } //cout << "cposX [" << cposX << "] cposY [" << cposY << "] cposZ [" << cposZ << "]" << endl; *************** *** 162,170 **** */ if(SystemStateSingleton::instance().middleButtonPressed) { - cposZ++; - //yAngle += 5; - } else { clposZ++; //xAngle += 5; } break; --- 146,154 ---- */ if(SystemStateSingleton::instance().middleButtonPressed) { clposZ++; //xAngle += 5; + } else { + cposZ++; + //yAngle += 5; } break; *************** *** 320,324 **** char* vrmlFilename = argv[1]; ! Model monkey(vrmlFilename); int flags = SDL_OPENGL; // | SDL_FULLSCREEN; --- 304,314 ---- char* vrmlFilename = argv[1]; ! ModelLoader* modelLoader = new X3DLoader(); ! SceneObject* slugMobile = modelLoader->loadModel(vrmlFilename); ! slugMobile->makeDisplayList(); ! ! //Model monkey(vrmlFilename); ! ! int flags = SDL_OPENGL; // | SDL_FULLSCREEN; *************** *** 339,366 **** atexit(SDL_Quit); - //float ratio = (float) width / (float) height; - opengl_init(); reshape_screen(0, 0, renderState.screenWidth(), renderState.screenHeight()); - /* bool done = false; ! GLint halfHeight = height / 2; ! GLint halfWidth = width / 2; ! */ ! ! ModelDrawer monkeyDrawer(&monkey); //GLuint monkeyDisplayListId = makeDisplayListFromModel(&monkey); //cout << "got monkeyDisplayListId [" << monkeyDisplayListId << "]" << endl; ! objectArray.push_back(Object3D(&monkeyDrawer)); ! Object3D& viewPoint = objectArray[0]; ! long objectCount = 0; for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { objectArray.push_back(&monkeyDrawer); } // randomise the object's initial position if(!randomiseObjects(objectArray, objectCount)) { --- 329,356 ---- atexit(SDL_Quit); opengl_init(); reshape_screen(0, 0, renderState.screenWidth(), renderState.screenHeight()); bool done = false; + Coord3D rotation; + Coord3D position; + Coord3D lightPos; ! ! //ModelDrawer monkeyDrawer(&monkey); //GLuint monkeyDisplayListId = makeDisplayListFromModel(&monkey); //cout << "got monkeyDisplayListId [" << monkeyDisplayListId << "]" << endl; ! //objectArray.push_back(Object3D(&monkeyDrawer)); ! //Object3D& viewPoint = objectArray[0]; ! //long objectCount = 0; + /* for(; objectCount < MAX_OBJECTARRAY_SIZE; objectCount++) { objectArray.push_back(&monkeyDrawer); } + */ + /* // randomise the object's initial position if(!randomiseObjects(objectArray, objectCount)) { *************** *** 368,372 **** --- 358,364 ---- exit(-1); } + */ + /* // disable mouse display SDL_ShowCursor(SDL_DISABLE); *************** *** 380,386 **** statGraphRenderer.setShape(10, 10, 60, 30); // now loop until we are done while(!SystemStateSingleton::instance().done) { ! if(!handleEvents(viewPoint, objectArray, objectCount)) { printf("Error in event handler!\n"); exit(-1); --- 372,382 ---- statGraphRenderer.setShape(10, 10, 60, 30); + */ + + + // now loop until we are done while(!SystemStateSingleton::instance().done) { ! if(!handleEvents(rotation, position, lightPos)) { printf("Error in event handler!\n"); exit(-1); *************** *** 395,405 **** } if(!updateObjects(objectArray, objectCount, SystemStateSingleton::instance().tickDiff)) { printf("Couldn't update objects\n"); exit(-1); } reshape_screen(0, 0, renderState.screenWidth(), renderState.screenHeight()); ! /* Clear the color and depth buffers. */ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //reshape_screen(halfWidth, 0, halfWidth, height); --- 391,403 ---- } + /* if(!updateObjects(objectArray, objectCount, SystemStateSingleton::instance().tickDiff)) { printf("Couldn't update objects\n"); exit(-1); } + */ reshape_screen(0, 0, renderState.screenWidth(), renderState.screenHeight()); ! // Clear the color and depth buffers. glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //reshape_screen(halfWidth, 0, halfWidth, height); *************** *** 407,414 **** //cout << "<main>\tmonkeyDisplayListId [" << monkeyDisplayListId << "]" << endl; ! draw_screen(viewPoint, objectArray, objectCount); //reshape_screen(0, 0, halfWidth, height); //draw_screen(cposX + 10, cposY + 10, cposZ + 2, clposX, clposY, clposZ, xAngle, yAngle, zAngle); ! statGraphRenderer.render(); SDL_GL_SwapBuffers(); --- 405,476 ---- //cout << "<main>\tmonkeyDisplayListId [" << monkeyDisplayListId << "]" << endl; ! // draw_screen(viewPoint, objectArray, objectCount); //reshape_screen(0, 0, halfWidth, height); //draw_screen(cposX + 10, cposY + 10, cposZ + 2, clposX, clposY, clposZ, xAngle, yAngle, zAngle); ! // statGraphRenderer.render(); ! ! GLfloat light_position[] = { lightPos.m_x, lightPos.m_y, lightPos.m_z, 1.0 }; ! GLfloat mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; ! GLfloat mat_shininess[] = { 20.0 }; ! GLfloat mat_ambient[] = { 0.8, 0.8, 0.8, 1.0 }; ! GLfloat white_light[] = { 0.8, 0.8, 0.8, 1.0 }; ! GLfloat ambient_light[] = { 0.5, 0.5, 0.5, 1.0 }; ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); ! glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light); ! glLightfv(GL_LIGHT0, GL_SPECULAR, white_light); ! glEnable(GL_LIGHT0); ! ! glEnable(GL_LIGHTING); ! glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient_light); ! glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); ! glMatrixMode( GL_MODELVIEW ); ! glLoadIdentity( ); ! ! glColor3f(0.2, 0.2, 0.2); ! if(0 && SystemStateSingleton::instance().showGrid) { ! glutWireSphere(10.0, 50, 50); ! } ! ! //glTranslatef(0, 0, -10); ! // call draw here] ! ! glRotatef(-rotation.m_x, 1.0, 0.0, 0.0); ! glRotatef(-rotation.m_y, 0.0, 1.0, 0.0); ! glRotatef(-rotation.m_z, 0.0, 0.0, 1.0); ! glTranslatef(position.m_x, position.m_y, position.m_z); ! position.m_z -= 0.1; ! ! glColor3f(1, 1, 1); ! glBegin(GL_LINES); ! glVertex3f(10, 0, -20); ! glVertex3f(-10, 0, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 10, -20); ! glVertex3f(0, -10, -20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 0, -20); ! glVertex3f(0, 0, -10); ! glEnd(); ! ! glBegin(GL_LINES); ! glVertex3f(10, 20, -20); ! glVertex3f(-10, 20, 20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 20, -20); ! glVertex3f(0, -20, 20); ! glEnd(); ! glBegin(GL_LINES); ! glVertex3f(0, 20, -20); ! glVertex3f(0, 20, 20); ! glEnd(); ! ! ! slugMobile->draw(); SDL_GL_SwapBuffers(); *************** *** 430,433 **** --- 492,499 ---- /* $Log$ + Revision 1.4 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.3 2004/06/24 19:46:40 o3dozone - added magic CVS tags Index: opengl_utils.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/opengl_utils.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** opengl_utils.h 24 Jun 2004 10:45:23 -0000 1.1.1.1 --- opengl_utils.h 23 Jul 2004 05:43:48 -0000 1.2 *************** *** 4,11 **** #include <stdlib.h> ! #include <SDL.h> ! #include <GL/gl.h> ! #include <GL/glu.h> ! #include <GL/glut.h> #include "object3d.h" --- 4,8 ---- #include <stdlib.h> ! #include "opengl_includes.h" #include "object3d.h" Index: scene_object.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** scene_object.cpp 21 Jul 2004 19:32:44 -0000 1.2 --- scene_object.cpp 23 Jul 2004 05:43:48 -0000 1.3 *************** *** 7,11 **** SceneObject::SceneObject(SceneObject* parent) ! : m_parent(parent) { } --- 7,11 ---- SceneObject::SceneObject(SceneObject* parent) ! : m_parent(parent), m_displayListCreated(false) { } *************** *** 21,25 **** } ! bool SceneObject::draw(bool drawChildren) { } --- 21,62 ---- } ! bool SceneObject::makeDisplayList() { ! // first draw this object ! // generate a display list if we haven't already ! if(!m_displayListCreated) { ! if(_makeDisplayList()) { ! m_displayListCreated = true; ! } else { ! draw(); ! } ! // now call the display list ! } else { ! glCallList(m_displayListIndex); ! glFlush(); ! } ! ! return true; ! } ! ! bool SceneObject::draw() { ! // draw if there is no display list ! if(!m_displayListCreated) { ! _draw(); ! // otherwise call the display list ! } else { ! glCallList(m_displayListIndex); ! glFlush(); ! } ! ! return true; ! } ! ! bool SceneObject::_draw() { ! // then the children ! for(vector<SceneObject*>::iterator i = m_children.begin(); i != m_children.end(); i++) { ! (*i)->draw(); ! } ! ! return true; } *************** *** 27,36 **** --- 64,98 ---- m_parent = rhs.m_parent; m_children = rhs.m_children; + m_displayListCreated = rhs.m_displayListCreated; + m_displayListIndex = rhs.m_displayListIndex; return *this; } + bool SceneObject::_makeDisplayList() { + m_displayListIndex = glGenLists(1); + if(m_displayListIndex == 0) { + cout << "<ModelDrawer::_makeDisplayList>\terror when generating display list" << endl; + return false; + } + cout << "<ModelDrawer::_makeDisplayList>\tgot m_displayListIndex [" << m_displayListIndex << "]" << endl; + + glNewList(m_displayListIndex, GL_COMPILE); + if(!_draw()) { + cout << "<ModelDrawer::_makeDisplayList>\tcouldn't draw model" << endl; + return false; + } + glEndList(); + + return true; + }; + + /* $Log$ + Revision 1.3 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.2 2004/07/21 19:32:44 o3dozone - mesh and associated classes now 'work' Index: model_loader.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** model_loader.h 21 Jul 2004 19:34:51 -0000 1.1 --- model_loader.h 23 Jul 2004 05:43:48 -0000 1.2 *************** *** 36,47 **** private: ! bool _parseX3DFile(const char* filename); SceneObject* _convertDOMNode(DOMNode* domNode, SceneObject* parent = NULL, long curLevel = 0); ! SceneObject* _createSceneObjectFromDOMNode(DOMNode* domNode); ! bool _convertCharToIntVector(vector<int>& intVector, string intString); }; /* $Log$ Revision 1.1 2004/07/21 19:34:51 o3dozone - model loader initial import --- 36,52 ---- private: ! SceneObject* _parseX3DFile(const char* filename); SceneObject* _convertDOMNode(DOMNode* domNode, SceneObject* parent = NULL, long curLevel = 0); ! SceneObject* _createSceneObjectFromDOMNode(DOMNode* domNode, bool& parentMustHandleChildren); ! bool _convertCharToVector(vector<int>& intVector, string intString); ! bool _convertCharToVector(vector<double>& intVector, string intString); }; /* $Log$ + Revision 1.2 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.1 2004/07/21 19:34:51 o3dozone - model loader initial import Index: model_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** model_loader.cpp 22 Jul 2004 05:01:37 -0000 1.2 --- model_loader.cpp 23 Jul 2004 05:43:48 -0000 1.3 *************** *** 13,29 **** SceneObject* X3DLoader::loadModel(const string filename) { ! if(!_parseX3DFile(filename.c_str())) { cout << "error parsing x3d file" << endl; abort(); } ! cout << "stopping now" << endl; ! abort(); ! ! return NULL; } ! bool X3DLoader::_parseX3DFile(const char* filename) { try { XMLPlatformUtils::Initialize(); --- 13,27 ---- SceneObject* X3DLoader::loadModel(const string filename) { ! SceneObject* sceneRoot = NULL; ! if((sceneRoot = _parseX3DFile(filename.c_str())) == NULL) { cout << "error parsing x3d file" << endl; abort(); } ! return sceneRoot; } ! SceneObject* X3DLoader::_parseX3DFile(const char* filename) { try { XMLPlatformUtils::Initialize(); *************** *** 32,56 **** 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(); - SceneObject* sceneRoot = NULL; if(domDocument->getDocumentElement() == NULL) { cout << "empty document" << endl; ! return false; } else if((sceneRoot = _convertDOMNode(domDocument->getDocumentElement())) == NULL) { cout << "couldn't dump dom document" << endl; ! return false; } } catch (const XMLException& toCatch) { --- 30,54 ---- 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) { *************** *** 58,70 **** 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; } --- 56,68 ---- 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; } *************** *** 72,76 **** delete errHandler; ! return true; } --- 70,74 ---- delete errHandler; ! return sceneRoot; } *************** *** 100,104 **** // get a scene object from the DOM Node ! scene = _createSceneObjectFromDOMNode(domNode); if(scene == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty scene" << endl; --- 98,104 ---- // get a scene object from the DOM Node ! // *** NOTE *** slightly dodgy, but handleChildren gets set in the _createSceneObjectFromDOMNode call below ! bool handleChildren = true; ! scene = _createSceneObjectFromDOMNode(domNode, handleChildren); if(scene == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty scene" << endl; *************** *** 110,126 **** cout << "[" << curLevel << "] dumping attributes complete" << endl; ! ! // 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; } } /* --- 110,128 ---- cout << "[" << curLevel << "] dumping attributes complete" << endl; ! ! 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; } } } /* *************** *** 156,160 **** } ! SceneObject* X3DLoader::_createSceneObjectFromDOMNode(DOMNode* domNode) { assert(domNode != NULL); assert(domNode->getNodeType() == DOMNode::ELEMENT_NODE); --- 158,162 ---- } ! SceneObject* X3DLoader::_createSceneObjectFromDOMNode(DOMNode* domNode, bool& parentMustHandleChildren) { assert(domNode != NULL); assert(domNode->getNodeType() == DOMNode::ELEMENT_NODE); *************** *** 165,171 **** --- 167,181 ---- // 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; + // this is a mesh Mesh* mesh = new Mesh(); + vector<int> coordIndexes; + vector<int> normalIndexes; + vector<double> coords; + vector<double> normals; + // get the attributes (containing the coord/normal indexes) DOMNamedNodeMap* attributes = domNode->getAttributes(); *************** *** 173,193 **** // get the coord indices DOMNode* coordIndexesNode = attributes->getNamedItem(XMLString::transcode("coordIndex")); - vector<int> coordIndexes; if(coordIndexesNode->getNodeValue() != NULL) { //cout << "coordIndexes [" << XMLString::transcode(coordIndexesNode->getNodeValue()) << "]" << endl; ! _convertCharToIntVector(coordIndexes, XMLString::transcode(coordIndexesNode->getNodeValue())); } // get the normal indices DOMNode* normalIndexesNode = attributes->getNamedItem(XMLString::transcode("normalIndex")); - vector<int> normalIndexes; if(normalIndexesNode->getNodeValue() != NULL) { //cout << "normalIndexes [" << XMLString::transcode(normalIndexesNode->getNodeValue()) << "]" << endl; ! _convertCharToIntVector(normalIndexes, XMLString::transcode(normalIndexesNode->getNodeValue())); } } // now we need to get the coord/normal objects nodes // done, return --- 183,285 ---- // 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; + } + + // now run through the coords and add them to the mesh + // *** NOTE *** we make the assumption that there are the same number of normals as vertices + // *** NOTE *** we need to presize the mesh vector, because it keeps on copying the polygons + vector<int>::size_type normalCount = normalIndexes.size(); + vector<double>::size_type coordsSize = coords.size(); + vector<double>::size_type normalsSize = normals.size(); + int coordIndex = 0; + int normalIndex = 0; + Coord3D coord; + Coord3D normal; + Polygon* curPolygon = new Polygon(); + for(vector<int>::size_type i = 0; i < normalCount; i++) { + + //cout << "\tcoordIndex [" << coordIndexes[i] << "] coord x [" << coord.m_x << "] y [" << coord.m_y << "] z [" << coord.m_z << "]" << endl; + //cout << "\tnormalIndex [" << normalIndexes[i] << "] normal x [" << normal.m_x << "] y [" << normal.m_y << "] z [" << normal.m_z << "]" << endl; + + // add to mesh and restart for next polygon + // *** NOTE *** we could be reusing the polygon, but I just want to get this going + if(coordIndexes[i] == -1) { + mesh->addPolygon(*curPolygon); + + delete(curPolygon); + curPolygon = new Polygon(); + } else { + coordIndex = coordIndexes[i] * 3; + normalIndex = normalIndexes[i] * 3; + + //assert((coordIndex + 2) < coordsSize); + //assert((normalIndex + 2) < normalsSize); + if(coordIndex + 2 >= coordsSize) { + cout << "coordsSize [" << coordsSize << "] coordIndex [" << coordIndex << "]" << endl; + break; + } + if(normalIndex + 2 >= normalsSize) { + cout << "normalsSize [" << normalsSize << "] normalIndex [" << normalIndex << "]" << endl; + break; + } + coord.m_x = coords[coordIndex]; + coord.m_y = coords[coordIndex + 1]; + coord.m_z = coords[coordIndex + 2]; + normal.m_x = normals[normalIndex]; + normal.m_y = normals[normalIndex + 1]; + normal.m_z = normals[normalIndex + 2]; + + curPolygon->addCoord(coord); + curPolygon->addNormal(normal); + } + } // done, return *************** *** 205,213 **** } ! bool X3DLoader::_convertCharToIntVector(vector<int>& intVector, string intString) { string piece; string::size_type startPos = 0; string::size_type endPos = 0; while(endPos != string::npos) { endPos = intString.find(' ', startPos); --- 297,308 ---- } ! bool X3DLoader::_convertCharToVector(vector<int>& intVector, string intString) { string piece; + //cout << "###############################################" << endl; + string::size_type startPos = 0; string::size_type endPos = 0; + //int pieceCount = 0; while(endPos != string::npos) { endPos = intString.find(' ', startPos); *************** *** 221,225 **** intVector.push_back(atoi(piece.c_str())); ! //cout << "piece [" << piece.c_str() << "]" << endl; startPos += pieceLength; --- 316,321 ---- intVector.push_back(atoi(piece.c_str())); ! //pieceCount++; ! //cout << "piece [" << piece.c_str() << "] pieceCount [" << pieceCount << "]" << endl; startPos += pieceLength; *************** *** 231,235 **** } ! cout << "<X3DLoader::_convertCharToIntVector>\tvector size [" << intVector.size() << "]" << endl; return true; --- 327,365 ---- } ! cout << "<X3DLoader::_convertCharToVector(int)>\tvector size [" << intVector.size() << "]" << endl; ! ! return true; ! } ! ! bool X3DLoader::_convertCharToVector(vector<double>& intVector, string intString) { ! string piece; ! ! //cout << "###############################################" << endl; ! string::size_type startPos = 0; ! string::size_type endPos = 0; ! //int pieceCount = 0; ! while(endPos != string::npos) { ! endPos = intString.find(' ', startPos); ! if(endPos == string::npos) { ! break; ! } ! ! string::size_type pieceLength = endPos - startPos; ! piece = intString.substr(startPos, pieceLength); ! ! intVector.push_back(atof(piece.c_str())); ! ! //pieceCount++; ! //cout << "piece [" << piece.c_str() << "] pieceCount [" << pieceCount << "]" << endl; ! ! startPos += pieceLength; ! while((intString[startPos] == ' ') && (startPos != string::npos)) { ! startPos++; ! } ! ! endPos = startPos; ! } ! ! cout << "<X3DLoader::_convertCharToVector(double)>\tvector size [" << intVector.size() << "]" << endl; return true; *************** *** 238,241 **** --- 368,375 ---- /* $Log$ + Revision 1.3 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.2 2004/07/22 05:01:37 o3dozone - tree is now correctly built (albeit very sparse) Index: mesh.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mesh.h 21 Jul 2004 19:32:44 -0000 1.2 --- mesh.h 23 Jul 2004 05:43:48 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- public: Mesh(SceneObject* parent = NULL); + Mesh(const Mesh& rhs); virtual ~Mesh(); *************** *** 23,26 **** --- 24,29 ---- virtual Mesh& operator=(const Mesh& rhs); + protected: + virtual bool _draw(); private: vector<Polygon> m_polygons; *************** *** 35,38 **** --- 38,45 ---- /* $Log$ + Revision 1.3 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.2 2004/07/21 19:32:44 o3dozone - mesh and associated classes now 'work' Index: object3d.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/object3d.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** object3d.h 24 Jun 2004 10:45:22 -0000 1.1.1.1 --- object3d.h 23 Jul 2004 05:43:48 -0000 1.2 *************** *** 9,187 **** #include "model.h" ! typedef long double pos_t; ! ! struct Coord3D { ! Coord3D() ! : m_x(0), m_y(0), m_z(0) ! {}; ! ! Coord3D(pos_t x, pos_t y, pos_t z) ! : m_x(x), m_y(y), m_z(z) ! {}; ! ! Coord3D(const Coord3D& rhs) ! : m_x(rhs.m_x), m_y(rhs.m_y), m_z(rhs.m_z) ! {}; ! ! bool isZero() { ! if(m_x == 0 && m_y == 0 && m_z == 0) { ! return true; ! } else { ! return false; ! } ! }; ! ! bool operator==(const Coord3D& rhs) { ! if((m_x == rhs.m_x) && (m_y == rhs.m_y) && (m_z == rhs.m_z)) { ! return true; ! } else { ! return false; ! } ! }; ! ! bool operator==(const Coord3D& rhs) const { ! return((Coord3D)(*this) == rhs); ! }; ! ! Coord3D& operator=(const Coord3D& rhs) { ! m_x = rhs.m_x; ! m_y = rhs.m_y; ! m_z = rhs.m_z; ! ! return(*this); ! }; ! ! Coord3D operator*(long double rhs) const { ! return((Coord3D)(*this) * rhs); ! }; ! ! Coord3D operator*(long double rhs) { ! Coord3D result(0, 0, 0); ! ! result.m_x = m_x * rhs; ! result.m_y = m_y * rhs; ! result.m_z = m_z * rhs; ! ! return result; ! }; ! ! Coord3D operator+(const Coord3D& rhs) const { ! return((Coord3D)(*this) + rhs); ! }; ! ! Coord3D operator+(const Coord3D& rhs) { ! Coord3D result(0, 0, 0); ! ! result.m_x = m_x + rhs.m_x; ! result.m_y = m_y + rhs.m_y; ! result.m_z = m_z + rhs.m_z; ! ! return result; ! }; ! ! Coord3D operator-(const Coord3D& rhs) const { ! return((Coord3D)(*this) + rhs); ! }; ! ! Coord3D operator-(const Coord3D& rhs) { ! Coord3D result(0, 0, 0); ! ! result.m_x = m_x - rhs.m_x; ! result.m_y = m_y - rhs.m_y; ! result.m_z = m_z - rhs.m_z; ! ! return result; ! }; ! ! Coord3D crossProduct(const Coord3D& rhs) { ! Coord3D result(0, 0, 0); ! ! //(aybz - azby)i+ (azbx - axbz)j+ (axby - aybx)k; ! result.m_x = m_y * rhs.m_z - m_z * rhs.m_y; ! result.m_y = m_z * rhs.m_x - m_x * rhs.m_z; ! result.m_z = m_x * rhs.m_y - m_y * rhs.m_x; ! ! return result; ! }; ! ! Coord3D distance(const Coord3D& rhs) { ! Coord3D result(0, 0, 0); ! ! result.m_x = m_x - rhs.m_x; ! result.m_y = m_y - rhs.m_y; ! result.m_z = m_z - rhs.m_z; ! ! return result; ! }; ! ! void normalise() { ! pos_t vectorLength = length(); ! ! if(vectorLength != 0) { ! m_x /= vectorLength; ! m_y /= vectorLength; ! m_z /= vectorLength; ! } else { ! m_x = 0; ! m_y = 0; ! m_z = 0; ! } ! }; ! ! bool isParallel(const Coord3D& rhs, bool& sameDirection) { ! pos_t x = m_x / rhs.m_x; ! pos_t y = m_y / rhs.m_y; ! pos_t z = m_z / rhs.m_z; ! ! //cout << "<::isParallel>\tx [" << x << "] y [" << y << "] z [" << z << "]" << endl; ! ! /* ! if((m_x == rhs.m_x) && (m_x == 0)) { ! cout << "x is zero" << endl; ! } else if((m_y == rhs.m_y) && (m_y == 0)) { ! cout << "y is zero" << endl; ! } else if((m_z == rhs.m_z) && (m_z == 0)) { ! cout << "z is zero" << endl; ! } ! */ ! ! sameDirection = true; ! ! if((!((m_x == rhs.m_x) && (m_x == 0))) && (!((m_y == rhs.m_y) && (m_y == 0))) && (x != y)) { ! cout << "1" << endl; ! return false; ! } else if((!((m_x == rhs.m_x) && (m_x == 0))) && (!((m_z == rhs.m_z) && (m_z == 0))) && (x != z)) { ! cout << "2" << endl; ! return false; ! } else if((!((m_z == rhs.m_z) && (m_z == 0))) && (!((m_y == rhs.m_y) && (m_y == 0))) && (z != y)) { ! cout << "3" << endl; ! return false; ! } else { ! ! //cout << "parallel" << endl; ! ! if((x < 0) || (y < 0) || (z < 0)) { ! //cout << "\topposite direction" << endl; ! sameDirection = false; ! } ! ! return true; ! } ! }; ! ! pos_t length() const { ! return (pos_t)sqrt(m_x * m_x + m_y * m_y + m_z * m_z); ! } ! ! pos_t length() { ! return (pos_t)sqrt(m_x * m_x + m_y * m_y + m_z * m_z); ! } ! ! pos_t m_x; ! pos_t m_y; ! pos_t m_z; ! }; ! ! Coord3D operator*(long double lhs, const Coord3D& rhs); class Object3D { --- 9,13 ---- #include "model.h" ! #include "coord3d.h" class Object3D { Index: polygon.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/polygon.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** polygon.cpp 21 Jul 2004 19:32:44 -0000 1.2 --- polygon.cpp 23 Jul 2004 05:43:48 -0000 1.3 *************** *** 9,13 **** : SceneObject(parent) { ! cout << "<Mesh::Mesh>\tcalled" << endl; } --- 9,13 ---- : SceneObject(parent) { ! //cout << "<Polygon::Polygon>\tcalled" << endl; } *************** *** 16,38 **** Polygon::Polygon(const Polygon& rhs) { ! cout << "<Polygon::Polygon(copy)>\tcalled" << endl; } ! /* ! bool Polygon::setNormal(double normal) { ! m_normal = normal; return true; } ! bool setCoord(Coord3D& coord) { ! m_coord = coord; return true; } - */ /* $Log$ Revision 1.2 2004/07/21 19:32:44 o3dozone - mesh and associated classes now 'work' --- 16,74 ---- Polygon::Polygon(const Polygon& rhs) { ! //cout << "<Polygon::Polygon(copy)>\tcalled" << endl; ! m_coords = rhs.m_coords; ! m_normals = rhs.m_normals; } ! bool Polygon::addNormal(Coord3D& normal) { ! m_normals.push_back(normal); return true; } ! bool Polygon::addCoord(Coord3D& coord) { ! m_coords.push_back(coord); ! ! return true; ! } ! ! bool Polygon::_draw() { ! vector<Coord3D>::size_type verticeCount = m_coords.size(); ! ! // start of drawing ! if(verticeCount == 3) { ! glBegin(GL_TRIANGLES); ! //glBegin(GL_LINES); ! } else if(verticeCount == 4) { ! glBegin(GL_QUADS); ! //glBegin(GL_LINES); ! } else { ! cout << "<Polygon::_draw>\tbad vertice count [" << verticeCount << "]" << endl; ! return false; ! } ! ! ! for(vector<Coord3D>::size_type i = 0; i < verticeCount; i++) { ! glNormal3f(m_normals[i].m_x, m_normals[i].m_y, m_normals[i].m_z); ! glVertex3f(m_coords[i].m_x, m_coords[i].m_y, m_coords[i].m_z); ! } ! ! glEnd(); ! ! glBegin(GL_LINES); ! glVertex3f(0, 1, 0); ! glVertex3f(0, 3, 0); ! glEnd(); ! // end of drawing return true; } /* $Log$ + Revision 1.3 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.2 2004/07/21 19:32:44 o3dozone - mesh and associated classes now 'work' Index: polygon.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/polygon.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** polygon.h 21 Jul 2004 19:32:44 -0000 1.2 --- polygon.h 23 Jul 2004 05:43:48 -0000 1.3 *************** *** 8,12 **** #include "scene_object.h" ! //#include "coord3d.h" #include <iostream> --- 8,12 ---- #include "scene_object.h" ! #include "coord3d.h" #include <iostream> *************** *** 18,30 **** 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' --- 18,36 ---- virtual ~Polygon(); ! bool addNormal(Coord3D& normal); ! bool addCoord(Coord3D& coord); ! protected: ! virtual bool _draw(); private: ! vector<Coord3D> m_normals; ! vector<Coord3D> m_coords; }; /* $Log$ + Revision 1.3 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.2 2004/07/21 19:32:44 o3dozone - mesh and associated classes now 'work' Index: scene_object.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/scene_object.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** scene_object.h 21 Jul 2004 19:32:44 -0000 1.2 --- scene_object.h 23 Jul 2004 05:43:48 -0000 1.3 *************** *** 9,12 **** --- 9,15 ---- #include <vector> #include <string> + #include <iostream> + + #include "opengl_includes.h" using namespace std; *************** *** 18,31 **** bool addChild(SceneObject* child); ! bool draw(bool drawChildren = true); virtual SceneObject& operator=(const SceneObject& rhs); private: SceneObject* m_parent; vector<SceneObject*> m_children; }; /* $Log$ Revision 1.2 2004/07/21 19:32:44 o3dozone - mesh and associated classes now 'work' --- 21,45 ---- bool addChild(SceneObject* child); ! bool makeDisplayList(); ! virtual bool draw(); virtual SceneObject& operator=(const SceneObject& rhs); + protected: + virtual bool _draw(); private: SceneObject* m_parent; vector<SceneObject*> m_children; + bool m_displayListCreated; + GLuint m_displayListIndex; + + bool _makeDisplayList(); }; /* $Log$ + Revision 1.3 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.2 2004/07/21 19:32:44 o3dozone - mesh and associated classes now 'work' Index: mesh.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/mesh.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mesh.cpp 21 Jul 2004 19:32:44 -0000 1.2 --- mesh.cpp 23 Jul 2004 05:43:48 -0000 1.3 *************** *** 12,15 **** --- 12,21 ---- } + Mesh::Mesh(const Mesh& rhs) + : SceneObject(rhs) + { + m_polygons = rhs.m_polygons; + } + Mesh::~Mesh() { } *************** *** 24,34 **** 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' --- 30,55 ---- SceneObject::operator=(rhs); ! m_polygons = rhs.m_polygons; return *this; } + bool Mesh::_draw() { + // first draw myself + + // then draw the children + for(vector<Polygon>::iterator i = m_polygons.begin(); i != m_polygons.end(); i++) { + (*i).draw(); + } + + return true; + } + /* $Log$ + Revision 1.3 2004/07/23 05:43:48 o3dozone + - now correctly parses x3d vertice arrays + - does *not* parse transforms etc + Revision 1.2 2004/07/21 19:32:44 o3dozone - mesh and associated classes now 'work' |
|
From: Mike D. <o3d...@us...> - 2004-07-22 05:01:46
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5251 Modified Files: model_loader.cpp Log Message: - tree is now correctly built (albeit very sparse) Index: model_loader.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/model_loader.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** model_loader.cpp 21 Jul 2004 19:34:51 -0000 1.1 --- model_loader.cpp 22 Jul 2004 05:01:37 -0000 1.2 *************** *** 45,52 **** parser->parse(filename); DOMDocument* domDocument = parser->getDocument(); if(domDocument->getDocumentElement() == NULL) { cout << "empty document" << endl; return false; ! } else if(!_convertDOMNode(domDocument->getDocumentElement())) { cout << "couldn't dump dom document" << endl; return false; --- 45,54 ---- parser->parse(filename); DOMDocument* domDocument = parser->getDocument(); + SceneObject* sceneRoot = NULL; + if(domDocument->getDocumentElement() == NULL) { cout << "empty document" << endl; return false; ! } else if((sceneRoot = _convertDOMNode(domDocument->getDocumentElement())) == NULL) { cout << "couldn't dump dom document" << endl; return false; *************** *** 80,90 **** // some sensible defaults - SceneObject* scene = NULL; - // if we don't have a parent, make one - // normally used for the root node, but right now we're not parsing everything, - // so we could land up with a sparse tree if(parent == NULL) { parent = new SceneObject(); } try { --- 82,89 ---- // some sensible defaults if(parent == NULL) { parent = new SceneObject(); } + SceneObject* scene = NULL; try { *************** *** 104,108 **** if(scene == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty scene" << endl; ! return NULL; } --- 103,110 ---- if(scene == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty scene" << endl; ! ! // *** NOTE *** This is a little 'hack', so we can avoid a scene with mostly dummy nodes ! scene = parent; ! //return NULL; } *************** *** 114,118 **** // dump the child SceneObject* child = _convertDOMNode(curChild, scene, curLevel + 1); ! if(child != NULL) { scene->addChild(child); } --- 116,120 ---- // dump the child SceneObject* child = _convertDOMNode(curChild, scene, curLevel + 1); ! if((child != NULL) && (child != scene)) { scene->addChild(child); } *************** *** 122,129 **** curChild = nextChild; } ! } else { cout << "<X3DLoader::_convertDOMNode>\tignoring scene without attributes" << endl; scene = new SceneObject(); } } else if(domNode->getNodeType() == DOMNode::ATTRIBUTE_NODE) { --- 124,133 ---- curChild = nextChild; } ! } /* ! else { cout << "<X3DLoader::_convertDOMNode>\tignoring scene without attributes" << endl; scene = new SceneObject(); } + */ } else if(domNode->getNodeType() == DOMNode::ATTRIBUTE_NODE) { *************** *** 189,196 **** // done, return return mesh; ! } else { SceneObject* dummy = new SceneObject(); return dummy; } return NULL; --- 193,204 ---- // done, return return mesh; ! } ! ! /* ! else { SceneObject* dummy = new SceneObject(); return dummy; } + */ return NULL; *************** *** 230,233 **** --- 238,244 ---- /* $Log$ + Revision 1.2 2004/07/22 05:01:37 o3dozone + - tree is now correctly built (albeit very sparse) + Revision 1.1 2004/07/21 19:34:51 o3dozone - model loader initial import |
|
From: Mike D. <o3d...@us...> - 2004-07-21 19:35:01
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9108 Added Files: model_loader.cpp model_loader.h Log Message: - model loader initial import - loads models from various type of files --- NEW FILE: model_loader.h --- #ifndef MODEL_LOADER_H #define MODEL_LOADER_H #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 "mesh.h" #include <assert.h> #include <vector> XERCES_CPP_NAMESPACE_USE using namespace std; class ModelLoader { public: ModelLoader(); virtual SceneObject* loadModel(const string filename) = 0; private: }; class X3DLoader : public ModelLoader { public: X3DLoader(); virtual SceneObject* loadModel(const string filename); private: bool _parseX3DFile(const char* filename); SceneObject* _convertDOMNode(DOMNode* domNode, SceneObject* parent = NULL, long curLevel = 0); SceneObject* _createSceneObjectFromDOMNode(DOMNode* domNode); bool _convertCharToIntVector(vector<int>& intVector, string intString); }; /* $Log: model_loader.h,v $ Revision 1.1 2004/07/21 19:34:51 o3dozone - model loader initial import - loads models from various type of files */ #endif --- NEW FILE: model_loader.cpp --- /* $Id: model_loader.cpp,v 1.1 2004/07/21 19:34:51 o3dozone Exp $ */ #include "model_loader.h" ModelLoader::ModelLoader() { } X3DLoader::X3DLoader() { } SceneObject* X3DLoader::loadModel(const string filename) { if(!_parseX3DFile(filename.c_str())) { cout << "error parsing x3d file" << endl; abort(); } cout << "stopping now" << endl; abort(); return NULL; } bool 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 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(domDocument->getDocumentElement() == NULL) { cout << "empty document" << endl; return false; } else if(!_convertDOMNode(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; } SceneObject* X3DLoader::_convertDOMNode(DOMNode* domNode, SceneObject* parent, long curLevel) { if(domNode == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty DOM node" << endl; return NULL; } // some sensible defaults SceneObject* scene = NULL; // if we don't have a parent, make one // normally used for the root node, but right now we're not parsing everything, // so we could land up with a sparse tree if(parent == NULL) { parent = new SceneObject(); } 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 scene = _createSceneObjectFromDOMNode(domNode); if(scene == NULL) { cout << "<X3DLoader::_convertDOMNode>\tempty scene" << endl; return NULL; } cout << "[" << curLevel << "] dumping attributes complete" << endl; // 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) { 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" ; return NULL; } return scene; } SceneObject* X3DLoader::_createSceneObjectFromDOMNode(DOMNode* domNode) { 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) { // this is a mesh Mesh* mesh = new Mesh(); // 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")); vector<int> coordIndexes; if(coordIndexesNode->getNodeValue() != NULL) { //cout << "coordIndexes [" << XMLString::transcode(coordIndexesNode->getNodeValue()) << "]" << endl; _convertCharToIntVector(coordIndexes, XMLString::transcode(coordIndexesNode->getNodeValue())); } // get the normal indices DOMNode* normalIndexesNode = attributes->getNamedItem(XMLString::transcode("normalIndex")); vector<int> normalIndexes; if(normalIndexesNode->getNodeValue() != NULL) { //cout << "normalIndexes [" << XMLString::transcode(normalIndexesNode->getNodeValue()) << "]" << endl; _convertCharToIntVector(normalIndexes, XMLString::transcode(normalIndexesNode->getNodeValue())); } } // now we need to get the coord/normal objects nodes // done, return return mesh; } else { SceneObject* dummy = new SceneObject(); return dummy; } return NULL; } bool X3DLoader::_convertCharToIntVector(vector<int>& intVector, string intString) { string piece; string::size_type startPos = 0; string::size_type endPos = 0; while(endPos != string::npos) { endPos = intString.find(' ', startPos); if(endPos == string::npos) { break; } string::size_type pieceLength = endPos - startPos; piece = intString.substr(startPos, pieceLength); intVector.push_back(atoi(piece.c_str())); //cout << "piece [" << piece.c_str() << "]" << endl; startPos += pieceLength; while((intString[startPos] == ' ') && (startPos != string::npos)) { startPos++; } endPos = startPos; } cout << "<X3DLoader::_convertCharToIntVector>\tvector size [" << intVector.size() << "]" << endl; return true; } /* $Log: model_loader.cpp,v $ Revision 1.1 2004/07/21 19:34:51 o3dozone - model loader initial import - loads models from various type of files */ |
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 |
|
From: Mike D. <o3d...@us...> - 2004-07-21 07:59:03
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6584 Removed Files: mesh.cpp~ mesh.h~ polygon.cpp~ polygon.h~ scene_object.cpp~ scene_object.h~ Log Message: - removing accidentalyl added files --- mesh.cpp~ DELETED --- --- mesh.h~ DELETED --- --- polygon.h~ DELETED --- --- scene_object.cpp~ DELETED --- --- polygon.cpp~ DELETED --- --- scene_object.h~ DELETED --- |
|
From: Mike D. <o3d...@us...> - 2004-07-21 07:41:13
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3987 Added Files: mesh.cpp mesh.cpp~ mesh.h mesh.h~ model.cpp polygon.cpp polygon.cpp~ polygon.h polygon.h~ scene_object.cpp scene_object.cpp~ scene_object.h scene_object.h~ Log Message: -now using x3d for models --- NEW FILE: mesh.cpp~ --- /* $Id: mesh.cpp~,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "mesh.h" Mesh::Mesh(SceneObject* parent) : SceneObject(parent) { } bool Mesh::addPolygon(Polygon& polygon) { m_polygons.push_back(polygon); return true; } /* $Log: mesh.cpp~,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ --- NEW FILE: mesh.h~ --- #ifndef MESH_H #define MESH_H /* $Id: mesh.h~,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "scene_object.h" class Mesh : public SceneObject { public: Mesh(SceneObject* parent = NULL); virtual ~Mesh; bool addPolygon(Polygon& polygon); private: vector<Polygon> m_polygons; /* coordIndex normalIndex coord - point (3d coord?) normal - vector */ }; /* $Log: mesh.h~,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ #endif --- NEW FILE: model.cpp --- #include "model.h" Model::Model(const string& vrmlFilename) { /* m_x3dLoader = new X3D::XercesLoader(new X3D::Creator()); if((m_x3dScene = m_x3dLoader->load(vrmlFilename.c_str(), false)) == NULL) { cout << "<Model::Model>\tcouldn't parse file [" << vrmlFilename << "]" << endl; throw("could not parse file"); } cout << "<Model::Model>\tmodel loaded" << endl; _dumpX3DScene(m_x3dScene); */ if(!_parseX3DFile(vrmlFilename.c_str())) { cout << "error parsing x3d file" << endl; abort(); } cout << "stopping now" << endl; abort(); /* if(!_parseVrmlFile(vrmlFilename.c_str())) { cout << "<Model::Model>\tcouldn't parse file [" << vrmlFilename << "]" << endl; throw("could not parse file"); } */ // 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; } --- NEW FILE: polygon.h~ --- #ifndef POLYGON_H #define POLYGON_H /* $Id: polygon.h~,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "scene_object.h" #include "coord3d.h" class PolyGon : public SceneObject { public: PolyGon(SceneObject* parent = NULL); virtual ~PolyGon; bool setNormal(double normal); bool setCoord(Coord3D& coord); private: double m_normal; Coord3D m_coord; }; /* $Log: polygon.h~,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ #endif --- NEW FILE: scene_object.cpp --- /* $Id: scene_object.cpp,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "scene_object.h" SceneObject::SceneObject(SceneObject* parent) : m_parent(parent) { } bool SceneObject::addChild(SceneObject* child) { m_children.push_back(child); return true; } bool SceneObject::draw(bool drawChildren) { } /* $Log: scene_object.cpp,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ --- NEW FILE: scene_object.cpp~ --- /* $Id: scene_object.cpp~,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "scene_object.h" SceneObject::SceneObject(SceneObject* parent) : m_parent(parent) { } bool SceneObject::addChild(SceneObject* child) { m_children.push_back(child); return true; } bool SceneObject::draw(bool drawChildren) { } /* $Log: scene_object.cpp~,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ --- NEW FILE: polygon.cpp~ --- /* $Id: polygon.cpp~,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "polygon.h" PolyGon::PolyGon(SceneObject* parent) : SceneObject(parent) { cout << "<Mesh::Mesh>\tcalled" << endl; } Polygon::Polygon(const Polygon& rhs) { cout << "<Polygon::Polygon(copy)>\tcalled" << endl; } bool PolyGon::setNormal(double normal) { m_normal = normal; return true; } bool setCoord(Coord3D& coord) { m_coord = coord; return true; } /* $Log: polygon.cpp~,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ --- NEW FILE: scene_object.h~ --- /* $Id: scene_object.h~,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #ifndef SCENE_OBJECT #define SCENE_OBJECT #include <vector> #include <string> using namespace std; class SceneObject { public: SceneObject(SceneObject* parent = NULL); virtual ~SceneObject(); bool addChild(SceneObject* child); bool draw(bool drawChildren = true); private: SceneObject* m_parent; vector<SceneObject*> m_children; }; /* $Log: scene_object.h~,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ #endif --- NEW FILE: mesh.h --- #ifndef MESH_H #define MESH_H /* $Id: mesh.h,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "scene_object.h" #include <vector> using namespace std; class Mesh : public SceneObject { public: Mesh(SceneObject* parent = NULL); virtual ~Mesh; bool addPolygon(Polygon& polygon); private: vector<Polygon> m_polygons; /* coordIndex normalIndex coord - point (3d coord?) normal - vector */ }; /* $Log: mesh.h,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ #endif --- NEW FILE: polygon.cpp --- /* $Id: polygon.cpp,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "polygon.h" PolyGon::PolyGon(SceneObject* parent) : SceneObject(parent) { cout << "<Mesh::Mesh>\tcalled" << endl; } Polygon::Polygon(const Polygon& rhs) { cout << "<Polygon::Polygon(copy)>\tcalled" << endl; } bool PolyGon::setNormal(double normal) { m_normal = normal; return true; } bool setCoord(Coord3D& coord) { m_coord = coord; return true; } /* $Log: polygon.cpp,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ --- NEW FILE: polygon.h --- #ifndef POLYGON_H #define POLYGON_H /* $Id: polygon.h,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #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: polygon.h,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ #endif --- NEW FILE: scene_object.h --- /* $Id: scene_object.h,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #ifndef SCENE_OBJECT_H #define SCENE_OBJECT_H #include <vector> #include <string> using namespace std; class SceneObject { public: SceneObject(SceneObject* parent = NULL); virtual ~SceneObject(); bool addChild(SceneObject* child); bool draw(bool drawChildren = true); private: SceneObject* m_parent; vector<SceneObject*> m_children; }; /* $Log: scene_object.h,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ #endif --- NEW FILE: mesh.cpp --- /* $Id: mesh.cpp,v 1.1 2004/07/21 07:41:03 o3dozone Exp $ */ #include "mesh.h" Mesh::Mesh(SceneObject* parent) : SceneObject(parent) { cout << "<Mesh::Mesh>\tcalled" << endl; } bool Mesh::addPolygon(Polygon& polygon) { m_polygons.push_back(polygon); return true; } /* $Log: mesh.cpp,v $ Revision 1.1 2004/07/21 07:41:03 o3dozone -now using x3d for models */ |
|
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 |
|
From: Mike D. <o3d...@us...> - 2004-06-24 19:46:50
|
Update of /cvsroot/grappelmann/spaceplane In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29777 Modified Files: gravity.cpp gravity.h Log Message: - added magic CVS tags Index: gravity.cpp =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gravity.cpp 24 Jun 2004 16:44:05 -0000 1.2 --- gravity.cpp 24 Jun 2004 19:46:40 -0000 1.3 *************** *** 1,2 **** --- 1,6 ---- + /* + $Id$ + */ + #include "gravity.h" *************** *** 424,426 **** --- 428,436 ---- } + /* + $Log$ + Revision 1.3 2004/06/24 19:46:40 o3dozone + - added magic CVS tags + + */ Index: gravity.h =================================================================== RCS file: /cvsroot/grappelmann/spaceplane/gravity.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gravity.h 24 Jun 2004 10:45:23 -0000 1.1.1.1 --- gravity.h 24 Jun 2004 19:46:40 -0000 1.2 *************** *** 1,2 **** --- 1,6 ---- + /* + $Id$ + */ + #ifndef GRAVITY_H #define GRAVITY_H *************** *** 22,23 **** --- 26,34 ---- #endif + /* + $Log$ + Revision 1.2 2004/06/24 19:46:40 o3dozone + - added magic CVS tags + + */ + |