[Namc-developer] newengine command.cpp,1.9,1.10 localPlayer.cpp,1.9,1.10 main.cpp,1.2,1.3 renderGL.c
Status: Alpha
Brought to you by:
roguestar191
|
From: Matthew <rog...@us...> - 2005-11-05 07:19:04
|
Update of /cvsroot/namc/newengine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10317 Modified Files: command.cpp localPlayer.cpp main.cpp renderGL.cpp renderGL.h renderWorld.h tools.cpp tools.h vObject.h worldsheet.cpp worldsheet.h Log Message: updates Index: tools.h =================================================================== RCS file: /cvsroot/namc/newengine/tools.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tools.h 25 Oct 2005 04:14:49 -0000 1.12 --- tools.h 5 Nov 2005 07:18:55 -0000 1.13 *************** *** 100,107 **** vec(float X, float Y, float Z) {x = X; y = Y; z = Z; }; vec(const vec &in) { x = in.x; y = in.y; z = in.z; }; ! bool operator<( vec &two) { if(x < two.x && y < two.y && z < two.z) return true; return false; } bool ab( vec &two) { //about equals vec comb(x+two.x, y+two.y, z+two.z); --- 100,127 ---- vec(float X, float Y, float Z) {x = X; y = Y; z = Z; }; vec(const vec &in) { x = in.x; y = in.y; z = in.z; }; ! bool operator<( vec &two) const{ if(x < two.x && y < two.y && z < two.z) return true; return false; } + bool operator>(float what) const{ + if(what > x || what > y || what > z) return true; + return false; + } + bool operator>(int what) const{ + if(what > x || what > y || what > z) return true; + return false; + } + bool operator<(float what) const{ + if(what < x || what < y || what < z) return true; + return false; + } + bool operator<(int what) const{ + if(what < x || what < y || what < z) return true; + return false; + } + bool greater(int what) { + if(what > x || what > y || what > z) return true; + return false; + } bool ab( vec &two) { //about equals vec comb(x+two.x, y+two.y, z+two.z); Index: renderGL.cpp =================================================================== RCS file: /cvsroot/namc/newengine/renderGL.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** renderGL.cpp 12 Oct 2005 23:27:06 -0000 1.8 --- renderGL.cpp 5 Nov 2005 07:18:55 -0000 1.9 *************** *** 1,280 **** #include "renderGL.h" ! class OcculludeTable { // {{{ ! friend class renderGL; ! friend class world; ! class ocMe { ! friend class OcculludeTable; ! friend class std::vector<ocMe>; ! OcculludeTable *thisone; ! }; [...1037 lines suppressed...] ! if(e1->isSelected) { light.x=0.6f;light.y=1.8f;light.z=0.6f; }else light.x=0.5f;light.y=0.5f;light.z=0.5f; ! e1->renderthis(light, (*(scroller)).x, (*(scroller)).y, (*(scroller)).z, e1->yaw, e1->pitch, e1->roll, World->lookuptexture(e1->texture, X, Y), e1->quadtype); } //}}} // TYPE_CUBE {{{ else if(e1->type == TYPE_CUBE) { ! // world::anObject *anE = World->getObjectAt(worldSize); // vec light = { 20.0f, 20.0f, 20.0f }; ! vec light; ! if(e1->isSelected) { ! light.x=0.6f;light.y=1.8f;light.z=0.6f; ! }else ! light.x=0.5f;light.y=0.5f;light.z=0.5f; ! // vec newVec = { (*(scroller)).x, (*(scroller)).y, (*(scroller)).z }; // vec newVec2 = { 0, 0, 0 }; ! e1->renderthis(light, (*(scroller)).x, (*(scroller)).y, (*(scroller)).z, e1->yaw, e1->pitch, e1->roll, World->lookuptexture(e1->texture, X, Y)); } // }}} // TYPE_MM *Map Model {{{ Index: main.cpp =================================================================== RCS file: /cvsroot/namc/newengine/main.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.cpp 25 Oct 2005 04:14:49 -0000 1.2 --- main.cpp 5 Nov 2005 07:18:55 -0000 1.3 *************** *** 1,5 **** #include "localPlayer.h" #include <math.h> ! --- 1,5 ---- #include "localPlayer.h" #include <math.h> ! #include "music.h" *************** *** 83,86 **** --- 83,87 ---- lplayer = new localPlayer(World); World->addObject((object *)lplayer, "monster/ogro"); + MusicPlayer player; /* object *earth = new object( "Earth", 5.9742*10E7); Index: tools.cpp =================================================================== RCS file: /cvsroot/namc/newengine/tools.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tools.cpp 12 Oct 2005 21:20:17 -0000 1.4 --- tools.cpp 5 Nov 2005 07:18:55 -0000 1.5 *************** *** 341,347 **** } else { //get the size ! infile.seekg (0, std::ios::end); ! int length = infile.tellg(); ! length=length; infile.seekg (0, std::ios::beg); // char buf[length+1]; --- 341,347 ---- } else { //get the size ! // infile.seekg (0, std::ios::end); ! // int length = infile.tellg(); ! // length=length; infile.seekg (0, std::ios::beg); // char buf[length+1]; Index: localPlayer.cpp =================================================================== RCS file: /cvsroot/namc/newengine/localPlayer.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** localPlayer.cpp 14 Oct 2005 06:08:20 -0000 1.9 --- localPlayer.cpp 5 Nov 2005 07:18:55 -0000 1.10 *************** *** 1,4 **** --- 1,5 ---- #include "localPlayer.h" #include <sstream> + SDL_Surface *mainwindow; class LPMouse : public Extensions { friend class localPlayer; *************** *** 138,142 **** gamelog("video: mode"); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); ! if(SDL_SetVideoMode(scr_w, scr_h, 0, SDL_OPENGL|fs)==NULL) fatal("Unable to create OpenGL screen"); gamelog("video: misc"); SDL_WM_SetCaption("Namc2 engine", NULL); --- 139,147 ---- gamelog("video: mode"); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); ! if(fs != 0) { ! if( (mainwindow = SDL_SetVideoMode(scr_w, scr_h, 0, SDL_OPENGL|fs|SDL_HWSURFACE) )==NULL) fatal("Unable to create OpenGL screen"); ! } else { ! if( (mainwindow = SDL_SetVideoMode(scr_w, scr_h, 0, SDL_OPENGL|SDL_HWSURFACE) )==NULL) fatal("Unable to create OpenGL screen"); ! } gamelog("video: misc"); SDL_WM_SetCaption("Namc2 engine", NULL); *************** *** 186,189 **** --- 191,195 ---- //Destructor {{{ localPlayer::~localPlayer() { + SDL_FreeSurface(mainwindow); for(; keyMapVector.size() > 0;) { keyMapVector.pop_back(); *************** *** 399,403 **** glColor3fv((float *)&newVec); glEnable(GL_BLEND); ! draw_textf("obs: %d", 20, 1630, 2, World->worldSize()); draw_textf("verts: %d", 600, 1630, 2, verts); if(RText::rendermenu() == true) menuIsOn = true; --- 405,409 ---- glColor3fv((float *)&newVec); glEnable(GL_BLEND); ! draw_textf("obs: %d", 20, 1630, 2, renderGL::numrendering); draw_textf("verts: %d", 600, 1630, 2, verts); if(RText::rendermenu() == true) menuIsOn = true; Index: renderWorld.h =================================================================== RCS file: /cvsroot/namc/newengine/renderWorld.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** renderWorld.h 14 Oct 2005 02:52:17 -0000 1.2 --- renderWorld.h 5 Nov 2005 07:18:55 -0000 1.3 *************** *** 3,6 **** --- 3,7 ---- #define RENDERWORLD_INC 1 #include "worldsheet.h" + //unused class class renderWorld : public commandI { public: Index: renderGL.h =================================================================== RCS file: /cvsroot/namc/newengine/renderGL.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** renderGL.h 14 Oct 2005 02:52:17 -0000 1.3 --- renderGL.h 5 Nov 2005 07:18:55 -0000 1.4 *************** *** 46,49 **** --- 46,50 ---- public: + int numrendering; renderGL(world *inWorld, object *player) : renderCubes(inWorld, player) { *************** *** 72,75 **** --- 73,152 ---- }; + + class OcculludeTable { // {{{ + friend class renderGL; + friend class world; + class ocMe { + friend class OcculludeTable; + friend class std::vector<ocMe>; + OcculludeTable *thisone; + }; + static std::vector<ocMe> listofall; + static OcculludeTable *activetable; + static world *World; + vec mypos; + // Occullusion Cells {{{ + OcculludeTable *up; + OcculludeTable *down; + OcculludeTable *right; + OcculludeTable *left; + OcculludeTable *front; + OcculludeTable *back; + // }}} + + enum { UP, DOWN, LEFT, RIGHT, FRONT, BACK }; + //each of these is + or - 45 on the X, Y, or Z + OcculludeTable(world *in); + OcculludeTable(const OcculludeTable &in); + OcculludeTable(OcculludeTable &in, int dir); + ~OcculludeTable(); + void cleanup(); + void nullify(OcculludeTable *in); + + void setPos(int dir, OcculludeTable *from); + void setDir(int dir, OcculludeTable *in); + void connectCells(int dir, OcculludeTable *othercell); + int opposite(int in); + OcculludeTable *getDir(int in); + class obj { // {{{ + friend class renderGL; + friend class OcculludeTable; + friend class std::vector<obj>; + bool isoculled; + object *ojt; //poll this for a list of vertice's. + world::anObject *worldobject; + bool operator>(int what) { + if(what > x || what > y || what > z) return true; + else return false; + } + float x, y, z; + }; // }}} + + std::vector<obj> objs; + + vec getPositionInCell(object *what); + bool isOcculluded(object *in); + vec getOffset(vec &pos1, vec &pos2); + bool tryCreateNewCell(vec position); + bool moveToAnotherCell(obj *in, int dir); + void testMoveCell(obj *in); + void actuallyMove(obj &in, vec &offset); + void moveObject(object *in, vec &offset); + void addObject(object *in); + bool isInRange(int &dir, obj &base); + template<class T> + void retranslate(T *what2trans, int dir); + bool viewportTest(obj looking, vec way, object testagainst); + std::vector<obj> extraHiddenSurfaceRemoval(obj looking, vec way, std::vector<obj> &potentials); + class occHelper { + friend class OcculludeTable; + std::vector<OcculludeTable *> testedcell; + std::vector<obj> translatedobjs; + }; + bool cellsBeenTested(occHelper &in, OcculludeTable *table); + std::vector<obj> getCloseObjectsFrom(object *in); + };// }}} + + #endif Index: vObject.h =================================================================== RCS file: /cvsroot/namc/newengine/vObject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** vObject.h 25 Oct 2005 04:14:49 -0000 1.4 --- vObject.h 5 Nov 2005 07:18:55 -0000 1.5 *************** *** 40,44 **** #endif #ifdef HAVE_LIBSDL_MIXER ! #include <SDL_mixer.h> #else #error You don't have SDL_MIXER installed!, www.libsdl.org/projects/sdl_mixer I think --- 40,44 ---- #endif #ifdef HAVE_LIBSDL_MIXER ! #include <SDL/SDL_mixer.h> #else #error You don't have SDL_MIXER installed!, www.libsdl.org/projects/sdl_mixer I think Index: worldsheet.cpp =================================================================== RCS file: /cvsroot/namc/newengine/worldsheet.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** worldsheet.cpp 25 Oct 2005 04:14:49 -0000 1.8 --- worldsheet.cpp 5 Nov 2005 07:18:55 -0000 1.9 *************** *** 1,5 **** --- 1,27 ---- #include "worldsheet.h" + #include "renderGL.h" + extern OcculludeTable *Occtable; int lastmillis; //just holds the last sdl_tick VAR(maxroll, 0, 3, 20); + world::world(int factor) { + setupWorld(factor); + physicsfraction = physicsrepeat = 0; + std::cout << "World Created\n"; + // glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize); + // The above is called AFTER the renderGL object is created + // purgetextures(); + curtex = FIRSTTEX; + curtexnum = FIRSTTEX; + mapmodelreset(); + modelnum = 0; + Occtable = new OcculludeTable(this); + + } + world::~world() { + clearAllObjects(); + std::cout << "World destroyed\n"; + Occtable->cleanup(); + delete Occtable; + } // findObject by name (char *name) {{{ object *world::findObject(char *name) { *************** *** 30,33 **** --- 52,59 ---- iter < worldVector.end(); iter++ ) { if((*(iter))->pt2Object == obj) { + // vec realpos(Occtable->getPositionInCell(obj)); + // (*(iter))->x = realpos.x; + // (*(iter))->y = realpos.y; + // (*(iter))->z = realpos.z; return (*(iter)); } *************** *** 58,61 **** --- 84,88 ---- std::string name2add = ptr->getName(); float defaultGrav = 0; + // for(size_t iter = 0; iter < worldVector.size() ;iter++ ) { // anObject newPtr = worldVector.at(iter); *************** *** 78,81 **** --- 105,109 ---- oneToAdd->defaultGravity = defaultGrav; worldVector.push_back(oneToAdd); + Occtable->addObject(ptr); return true; }; *************** *** 97,102 **** oneToAdd->z = z_in; oneToAdd->defaultGravity = defaultGrav; ! ! worldVector.push_back(oneToAdd); return true; }; --- 125,130 ---- oneToAdd->z = z_in; oneToAdd->defaultGravity = defaultGrav; ! worldVector.push_back(oneToAdd); ! Occtable->addObject(ptr_in); return true; }; *************** *** 243,246 **** --- 271,275 ---- e->y += d.y; e->z += d.z; + Occtable->moveObject(e->pt2Object, d); }; // }}} *************** *** 629,634 **** --- 658,665 ---- }; // }}} + //Cube textures and mapmodel loading //add map model {{{ void world::addmapmodel(const char *d[]) { + //change to std::vector<std::string *> * //std::cout << "Map model added" << d[5]; char *d1 = const_cast<char *>(d[1]); Index: command.cpp =================================================================== RCS file: /cvsroot/namc/newengine/command.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** command.cpp 14 Oct 2005 06:08:20 -0000 1.9 --- command.cpp 5 Nov 2005 07:18:55 -0000 1.10 *************** *** 274,284 **** if(y < std::string::npos) { std::cout << "Comment\n"; std::cout.flush(); ! size_t end = incommand->size() - y -1; incommand->replace(y, end, ""); ! if(incommand->size() == 1 && static_cast<int>((*(incommand))[0]) == 13 ) { ! ! incommand->erase(); } ! if( incommand->size() <= 1) return false; } //************ try to replace erase leading space if there is one --- 274,283 ---- if(y < std::string::npos) { std::cout << "Comment\n"; std::cout.flush(); ! unsigned int end = incommand->size() - y; incommand->replace(y, end, ""); ! if(incommand->size() == 1 && incommand->compare(" ") == 0 ) { ! incommand->erase(); } ! if( incommand->size() < 1) return false; } //************ try to replace erase leading space if there is one *************** *** 772,812 **** void commandI::exec(char *cfgfile) { std::string filedata; filedata.append(Utils.readFile(cfgfile)); ! std::string newlinem; ! newlinem.append("\r\n"); ! size_t lastnewl = 0; ! size_t newl = filedata.find(newlinem); ! if(newl == std::string::npos) { ! newlinem.erase(); ! newlinem.append("\r\n"); ! newl = filedata.find(newlinem); ! if(newl == std::string::npos) { ! execute((std::string *)(&filedata), true); ! return; } } // for(std::string::size_type st=0,en=0; (en=filedata.find("\r\n",st),(st!=std::string::npos)); st=(en!=std::string::npos)?en+1:std::string::npos) { ! std::string::size_type last = 0, next = 0; ! next=filedata.find(newlinem); ! while(next < std::string::npos) { ! std::string part; ! std::ostringstream fuckingwork; ! while(last <= next) { ! fuckingwork << filedata[last]; ! last++; ! } ! part.append(fuckingwork.str()); ! if(part.size() <= 0) ; ! else { ! execute(&part, true); ! } ! last = next+newlinem.size(); ! next = filedata.find(newlinem, next+1); ! while(last == next) { ! last = next+2; ! next = filedata.find(newlinem, next+1); ! } ! } }; --- 771,813 ---- void commandI::exec(char *cfgfile) { + std::string filedata; filedata.append(Utils.readFile(cfgfile)); ! ! std::string worker; ! std::string::const_iterator end = filedata.end(); ! std::string::const_iterator scroller = filedata.begin(); ! for(; scroller < end; scroller++) { ! if(*scroller=='\r') continue; ! else if(*scroller=='\n') { ! execute(&worker, true); ! worker.erase(); } + else worker += *scroller; } + if(worker.size() > 0) execute(&worker, true); + // for(std::string::size_type st=0,en=0; (en=filedata.find("\r\n",st),(st!=std::string::npos)); st=(en!=std::string::npos)?en+1:std::string::npos) { ! // std::string::size_type last = 0, next = 0; ! // next=filedata.find(newlinem); ! // while(next < std::string::npos) { ! // std::string part; ! // std::ostringstream fuckingwork; ! // while(last <= next) { ! // fuckingwork << filedata[last]; ! // last++; ! // } ! // part.append(fuckingwork.str()); ! // if(part.size() <= 0) ; ! // else { ! /// execute(&part, true); ! // } ! // last = next+newlinem.size(); ! // next = filedata.find(newlinem, next+1); ! // while(last == next) { ! // last = next+2; ! // next = filedata.find(newlinem, next+1); ! // } ! // } }; Index: worldsheet.h =================================================================== RCS file: /cvsroot/namc/newengine/worldsheet.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** worldsheet.h 14 Oct 2005 02:52:17 -0000 1.4 --- worldsheet.h 5 Nov 2005 07:18:55 -0000 1.5 *************** *** 121,136 **** public: //Create the world ! world(int factor) { ! setupWorld(factor); ! physicsfraction = physicsrepeat = 0; ! std::cout << "World Created\n"; ! // glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glmaxtexsize); ! // The above is called AFTER the renderGL object is created ! // purgetextures(); ! curtex = FIRSTTEX; ! curtexnum = FIRSTTEX; ! mapmodelreset(); ! modelnum = 0; ! }; world(object o, int fac) {std::cout << "World inherited\n"; initWorld(o, fac);}; //run a world loop in a thread }; --- 121,125 ---- public: //Create the world ! world(int factor); world(object o, int fac) {std::cout << "World inherited\n"; initWorld(o, fac);}; //run a world loop in a thread }; *************** *** 139,143 **** purgetextures(); }; ! ~world() { clearAllObjects(); std::cout << "World destroyed\n"; }; std::vector<anObject *> worldVector; //initialize an empty vector object *findObject(char *name); --- 128,132 ---- purgetextures(); }; ! ~world(); std::vector<anObject *> worldVector; //initialize an empty vector object *findObject(char *name); |