Revision: 2697 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2697&view=rev Author: rorthomas Date: 2012-05-26 04:30:36 +0000 (Sat, 26 May 2012) Log Message: -----------
Modified Paths: -------------- trunk/source/main/gameplay/GEnv.h trunk/source/main/gameplay/RoRFrameListener.cpp trunk/source/main/gameplay/Savegame.cpp trunk/source/main/gameplay/road2.cpp trunk/source/main/gameplay/road2.h Modified: trunk/source/main/gameplay/GEnv.h =================================================================== --- trunk/source/main/gameplay/GEnv.h 2012-05-26 04:23:45 UTC (rev 2696) +++ trunk/source/main/gameplay/GEnv.h 2012-05-26 04:30:36 UTC (rev 2697) @@ -27,6 +27,7 @@ class Water; class Network; class MapControl; +class Character; class GlobalEnvironment { @@ -44,6 +45,7 @@ , water(0) , network(0) , surveyMap(0) + , player(0) { } Ogre::Root *ogreRoot; @@ -59,6 +61,7 @@ Water *water; Network *network; MapControl *surveyMap; + Character *player; }; #endif // GEnv_H__ Modified: trunk/source/main/gameplay/RoRFrameListener.cpp =================================================================== --- trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-26 04:23:45 UTC (rev 2696) +++ trunk/source/main/gameplay/RoRFrameListener.cpp 2012-05-26 04:30:36 UTC (rev 2697) @@ -1100,6 +1100,7 @@ int colourNum = 0; if (net->getLocalUserData()) colourNum = net->getLocalUserData()->colournum; person = (Character *)CharacterFactory::getSingleton().createLocal(colourNum); + gEnv->player = person; // network chat stuff netChat = ChatSystemFactory::getSingleton().createLocal(colourNum); Modified: trunk/source/main/gameplay/Savegame.cpp =================================================================== --- trunk/source/main/gameplay/Savegame.cpp 2012-05-26 04:23:45 UTC (rev 2696) +++ trunk/source/main/gameplay/Savegame.cpp 2012-05-26 04:30:36 UTC (rev 2697) @@ -71,18 +71,17 @@ h.entries = free_truck; h.current_truck = current_truck; - if(RoRFrameListener::eflsingleton) { // and generic things like character and camera - if(RoRFrameListener::eflsingleton->person) + if(gEnv->player) { - Vector3 pos = RoRFrameListener::eflsingleton->person->getPosition(); + Vector3 pos = gEnv->player->getPosition(); // WARNING: breaks if Real == double! memcpy(&h.player_pos, pos.ptr(), sizeof(float) * 3); } - if(RoRFrameListener::eflsingleton->getCamera()) + if(gEnv->ogreCamera) { - Vector3 pos = RoRFrameListener::eflsingleton->getCamera()->getPosition(); + Vector3 pos = gEnv->ogreCamera->getPosition(); // WARNING: breaks if Real == double! memcpy(&h.cam_pos, pos.ptr(), sizeof(float) * 3); } @@ -247,12 +246,11 @@ } // restore generic things: characer and camera - if(RoRFrameListener::eflsingleton) { // and generic things like character and camera - if(RoRFrameListener::eflsingleton->person) + if(gEnv->player) { - RoRFrameListener::eflsingleton->person->setPosition(Vector3(h.player_pos)); + gEnv->player->setPosition(Vector3(h.player_pos)); } // TODO: FIX savegame camera integration Modified: trunk/source/main/gameplay/road2.cpp =================================================================== --- trunk/source/main/gameplay/road2.cpp 2012-05-26 04:23:45 UTC (rev 2696) +++ trunk/source/main/gameplay/road2.cpp 2012-05-26 04:30:36 UTC (rev 2697) @@ -21,13 +21,12 @@ #include "road2.h" #include "ResourceBuffer.h" +#include "IHeightFinder.h" + using namespace Ogre; -Road2::Road2(SceneManager *manager, HeightFinder *hf, Collisions *collisions, int id) : - smanager(manager) - , coll(collisions) - , first(true) - , hfinder(hf) +Road2::Road2(int id) : + first(true) , mid(id) , snode(0) , tricount(0) @@ -54,7 +53,7 @@ for(std::vector<int>::iterator it = registeredCollTris.begin(); it != registeredCollTris.end(); it++) { //coll->enableCollisionTri(*it, false); - coll->removeCollisionTri(*it); + gEnv->collisions->removeCollisionTri(*it); } } } @@ -80,8 +79,8 @@ createMesh(); String entity_name = String("RoadSystem_Instance-").append(StringConverter::toString(mid)); String mesh_name = String("RoadSystem-").append(StringConverter::toString(mid)); - Entity *ec = smanager->createEntity(entity_name, mesh_name); - snode = smanager->getRootSceneNode()->createChildSceneNode(); + Entity *ec = gEnv->ogreSceneManager->createEntity(entity_name, mesh_name); + snode = gEnv->ogreSceneManager->getRootSceneNode()->createChildSceneNode(); snode->attachObject(ec); } @@ -93,8 +92,8 @@ //define type Vector3 leftv=pos+rot*Vector3(0,0,bwidth+width/2.0); Vector3 rightv=pos+rot*Vector3(0,0,-bwidth-width/2.0); - float dleft=leftv.y-hfinder->getHeightAt(leftv.x, leftv.z); - float dright=rightv.y-hfinder->getHeightAt(rightv.x, rightv.z); + float dleft=leftv.y-gEnv->heightFinder->getHeightAt(leftv.x, leftv.z); + float dright=rightv.y-gEnv->heightFinder->getHeightAt(rightv.x, rightv.z); if (dleft<bheight+0.1 && dright<bheight+0.1) type=ROAD_FLAT; if (dleft<bheight+0.1 && dright>=bheight+0.1 && dright<4.0) type=ROAD_LEFT; if (dleft>=bheight+0.1 && dleft<4.0 && dright<bheight+0.1) type=ROAD_RIGHT; @@ -161,9 +160,9 @@ Vector3 rightv=pos+rot*Vector3(0,0,-bwidth-width/2.0); Vector3 middle = lpts[0] - ((lpts[0] + (pts[1] - lpts[0]) / 2) - (lpts[7] + (pts[6] - lpts[7]) / 2)) * 0.5; - float heightleft = hfinder->getHeightAt(leftv.x, leftv.z); - float heightright = hfinder->getHeightAt(rightv.x, rightv.z); - float heightmiddle = hfinder->getHeightAt(middle.x, middle.z); + float heightleft = gEnv->heightFinder->getHeightAt(leftv.x, leftv.z); + float heightright = gEnv->heightFinder->getHeightAt(rightv.x, rightv.z); + float heightmiddle = gEnv->heightFinder->getHeightAt(middle.x, middle.z); bool builtpillars = true; @@ -191,7 +190,7 @@ middle = lpts[0] - ((lpts[0] + (pts[1] - lpts[0]) / 2) - (lpts[7] + (pts[6] - lpts[7]) / 2)) * sidefactor; - float len = middle.y - hfinder->getHeightAt(middle.x, middle.z) + 5; + float len = middle.y - gEnv->heightFinder->getHeightAt(middle.x, middle.z) + 5; float width2 = len / 30; if(pillartype == 2 && len > 20) @@ -330,7 +329,7 @@ inline Vector3 Road2::baseOf(Vector3 p) { - float y = hfinder->getHeightAt(p.x, p.z) - 0.01; + float y = gEnv->heightFinder->getHeightAt(p.x, p.z) - 0.01; if (y > p.y) { @@ -375,9 +374,9 @@ } if (collision) { - ground_model_t *gm = coll->getGroundModelByString("concrete"); + ground_model_t *gm = gEnv->collisions->getGroundModelByString("concrete"); if (texfit==TEXFIT_ROAD || texfit==TEXFIT_ROADS1 || texfit==TEXFIT_ROADS2 || texfit==TEXFIT_ROADS3 || texfit==TEXFIT_ROADS4) - gm = coll->getGroundModelByString("asphalt"); + gm = gEnv->collisions->getGroundModelByString("asphalt"); addCollisionQuad(p1, p2, p3, p4, gm, flip); } tricount+=2; @@ -521,23 +520,23 @@ int triID=0; if (flip) { - triID = coll->addCollisionTri(p1, p2, p4, gm); + triID = gEnv->collisions->addCollisionTri(p1, p2, p4, gm); if(triID>=0) registeredCollTris.push_back(triID); - triID = coll->addCollisionTri(p4, p2, p3, gm); + triID = gEnv->collisions->addCollisionTri(p4, p2, p3, gm); if(triID>=0) registeredCollTris.push_back(triID); } else { - triID = coll->addCollisionTri(p1, p2, p3, gm); + triID = gEnv->collisions->addCollisionTri(p1, p2, p3, gm); if(triID>=0) registeredCollTris.push_back(triID); - triID = coll->addCollisionTri(p1, p3, p4, gm); + triID = gEnv->collisions->addCollisionTri(p1, p3, p4, gm); if(triID>=0) registeredCollTris.push_back(triID); } -// coll->addCollisionTri(p1, p4, p3); -// coll->addCollisionTri(p1, p3, p2); +// gEnv->collisions->addCollisionTri(p1, p4, p3); +// gEnv->collisions->addCollisionTri(p1, p3, p2); } Modified: trunk/source/main/gameplay/road2.h =================================================================== --- trunk/source/main/gameplay/road2.h 2012-05-26 04:23:45 UTC (rev 2696) +++ trunk/source/main/gameplay/road2.h 2012-05-26 04:30:36 UTC (rev 2697) @@ -23,7 +23,7 @@ #include "RoRPrerequisites.h" -#include "heightfinder.h" + #include "collisions.h" // dynamic roads @@ -32,7 +32,7 @@ { public: - Road2(Ogre::SceneManager *manager, HeightFinder *hf, Collisions *collisions, int id); + Road2(int id); ~Road2(); void addBlock(Ogre::Vector3 pos, Ogre::Quaternion rot, int type, float width, float bwidth, float bheight, int pillartype=1); @@ -66,7 +66,6 @@ Ogre::MeshPtr msh; Ogre::SubMesh* mainsub; - Ogre::SceneManager *smanager; Ogre::Vector2 tex[MAX_VERTEX]; Ogre::Vector3 vertex[MAX_VERTEX]; @@ -74,8 +73,6 @@ int vertexcount; short tris[MAX_TRIS*3]; - Collisions *coll; - HeightFinder* hfinder; Ogre::Quaternion lastrot; Ogre::SceneNode *snode; Ogre::Vector3 lastpos; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel