|
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 */ |