diff --git a/framework2/include/renderwure/ai/AIGraph.hpp b/framework2/include/renderwure/ai/AIGraph.hpp index 000d06b9..7802da83 100644 --- a/framework2/include/renderwure/ai/AIGraph.hpp +++ b/framework2/include/renderwure/ai/AIGraph.hpp @@ -3,7 +3,7 @@ #define _AIGRAPH_HPP_ #include #include -#include +#include struct GTAInstance; struct GTAAINode; @@ -14,7 +14,7 @@ public: std::vector nodes; - void createPathNodes(const glm::vec3& position, const glm::quat& rotation, LoaderIDE::PATH_t& path); + void createPathNodes(const glm::vec3& position, const glm::quat& rotation, PathData& path); }; diff --git a/framework2/include/renderwure/data/ObjectData.hpp b/framework2/include/renderwure/data/ObjectData.hpp new file mode 100644 index 00000000..db2b044d --- /dev/null +++ b/framework2/include/renderwure/data/ObjectData.hpp @@ -0,0 +1,92 @@ +#pragma once +#ifndef __GLT_OBJECTDATA_HPP__ +#define __GLT_OBJECTDATA_HPP__ +#include +#include + +struct ObjectData +{ + uint16_t ID; + std::string modelName; + std::string textureName; + size_t numClumps; + float drawDistance[3]; + int32_t flags; + bool LOD; + + enum { + WET = 1, /// Render with a wet effect + NIGHTONLY = 1 << 1, /// Render only during the night + ALPHA1 = 1 << 2, /// Alpha + ALPHA2 = 1 << 3, /// Alpha + DAYONLY = 1 << 4, /// Render only during the day + INTERIOR = 1 << 5, /// Is part of an interior + NOSHADOWMESH = 1 << 6, /// Disable shadow mesh + DONTCULL = 1 << 7, /// Disable culling + NODRAWDIST = 1 << 8, /// Object won't be affected by draw distance + BREAKABLE = 1 << 9, /// Object can be broken + SMASHABLE = 1 << 10, /// Object can be smashed and broken + GRGEDOOR = 1 << 11, /// Is a garage door (SA and IV only) + MULTICLUMP = 1 << 12, /// Multiclump + WBRIGHTNESS = 1 << 13, /// Weather PoleShd value effects brightness. + EXPLODEONHIT = 1 << 14, /// Object explodes after being hit + }; +}; + +struct CarData +{ + enum VehicleClass + { + IGNORE = 0, + NORMAL = 1, + POORFAMILY = 1 << 1, + RICHFAMILY = 1 << 2, + EXECUTIVE = 1 << 3, + WORKER = 1 << 4, + BIG = 1 << 5, + TAXI = 1 << 6, + MOPED = 1 << 7, + MOTORBIKE = 1 << 8, + LEISUREBOAT = 1 << 9, + WORKERBOAT = 1 << 10, + BICYCLE = 1 << 11, + ONFOOT = 1 << 12, + }; + + enum VehicleType { + CAR, + BOAT, + TRAIN, + PLANE, + HELI, + }; + + uint16_t ID; + std::string modelName; + std::string textureName; + VehicleType type; + std::string handlingID; + std::string gameName; + VehicleClass classType; + uint8_t frequency; // big enough int type? + uint8_t lvl; // big enough int type? + uint16_t comprules; + union { // big enough int types? + uint16_t wheelModelID; // used only when type == CAR + int16_t modelLOD; // used only when type == PLANE + }; + float wheelScale; // used only when type == CAR +}; + +struct CharacterData +{ + uint16_t ID; + std::string modelName; + std::string textureName; + std::string type; + std::string behaviour; + std::string animGroup; + uint8_t driveMask; +}; + +#endif \ No newline at end of file diff --git a/framework2/include/renderwure/data/PathData.hpp b/framework2/include/renderwure/data/PathData.hpp new file mode 100644 index 00000000..1cb5a93a --- /dev/null +++ b/framework2/include/renderwure/data/PathData.hpp @@ -0,0 +1,40 @@ +#pragma once +#ifndef __GLT_PATHDATA_HPP__ +#define __GLT_PATHDATA_HPP__ +#include +#include +#include + +struct PathNode +{ + enum NodeType + { + EMPTY = 0, /// These are ignored + EXTERNAL = 1, /// May join with other paths + INTERNAL = 2 /// Internal to this path + }; + + NodeType type; + int32_t next; + glm::vec3 position; + float size; + int other_thing; + int other_thing2; +}; + +struct PathData +{ + enum PathType + { + PATH_PED, + PATH_CAR + }; + + PathType type; + uint16_t ID; + std::string modelName; + std::vector nodes; +}; + + +#endif \ No newline at end of file diff --git a/framework2/include/renderwure/engine/GTAEngine.hpp b/framework2/include/renderwure/engine/GTAEngine.hpp index 96b60d13..76ef6753 100644 --- a/framework2/include/renderwure/engine/GTAEngine.hpp +++ b/framework2/include/renderwure/engine/GTAEngine.hpp @@ -127,22 +127,22 @@ public: /** * Object Definitions */ - std::map> objectTypes; - - /** - * Paths associated with each object definition. - */ - std::map> objectNodes; - + std::map> objectTypes; + + /** + * Paths associated with each object definition. + */ + std::map>> objectNodes; + /** * Vehicle definitions */ - std::map> vehicleTypes; + std::map> vehicleTypes; - /** - * Ped definitions - */ - std::map> pedestrianTypes; + /** + * Ped definitions + */ + std::map> pedestrianTypes; /** * Game Objects! diff --git a/framework2/include/renderwure/loaders/LoaderIDE.hpp b/framework2/include/renderwure/loaders/LoaderIDE.hpp index 0a1965cd..488ca83e 100644 --- a/framework2/include/renderwure/loaders/LoaderIDE.hpp +++ b/framework2/include/renderwure/loaders/LoaderIDE.hpp @@ -4,7 +4,10 @@ #include #include +#include #include +#include +#include class LoaderIDE { @@ -20,128 +23,14 @@ public: TWODFX, PATH, }; - - struct OBJS_t - { - uint16_t ID; - std::string modelName; - std::string textureName; - size_t numClumps; - float drawDistance[3]; - int32_t flags; - bool LOD; - - enum { - WET = 1, /// Render with a wet effect - NIGHTONLY = 1 << 1, /// Render only during the night - ALPHA1 = 1 << 2, /// Alpha - ALPHA2 = 1 << 3, /// Alpha - DAYONLY = 1 << 4, /// Render only during the day - INTERIOR = 1 << 5, /// Is part of an interior - NOSHADOWMESH = 1 << 6, /// Disable shadow mesh - DONTCULL = 1 << 7, /// Disable culling - NODRAWDIST = 1 << 8, /// Object won't be affected by draw distance - BREAKABLE = 1 << 9, /// Object can be broken - SMASHABLE = 1 << 10, /// Object can be smashed and broken - GRGEDOOR = 1 << 11, /// Is a garage door (SA and IV only) - MULTICLUMP = 1 << 12, /// Multiclump - WBRIGHTNESS = 1 << 13, /// Weather PoleShd value effects brightness. - EXPLODEONHIT = 1 << 14, /// Object explodes after being hit - }; - }; - - enum VehicleClass - { - IGNORE = 0, - NORMAL = 1, - POORFAMILY = 1 << 1, - RICHFAMILY = 1 << 2, - EXECUTIVE = 1 << 3, - WORKER = 1 << 4, - BIG = 1 << 5, - TAXI = 1 << 6, - MOPED = 1 << 7, - MOTORBIKE = 1 << 8, - LEISUREBOAT = 1 << 9, - WORKERBOAT = 1 << 10, - BICYCLE = 1 << 11, - ONFOOT = 1 << 12, - }; - enum VehicleType { - CAR, - BOAT, - TRAIN, - PLANE, - HELI, - }; - struct CARS_t - { - uint16_t ID; - std::string modelName; - std::string textureName; - VehicleType type; - std::string handlingID; - std::string gameName; - VehicleClass classType; - uint8_t frequency; // big enough int type? - uint8_t lvl; // big enough int type? - uint16_t comprules; - union { // big enough int types? - uint16_t wheelModelID; // used only when type == CAR - int16_t modelLOD; // used only when type == PLANE - }; - float wheelScale; // used only when type == CAR - }; - - struct PEDS_t - { - uint16_t ID; - std::string modelName; - std::string textureName; - std::string type; - std::string behaviour; - std::string animGroup; - uint8_t driveMask; - }; - - enum PathType - { - PATH_PED, - PATH_CAR - }; - - enum NodeType - { - EMPTY = 0, /// These are ignored - EXTERNAL = 1, /// May join with other paths - INTERNAL = 2 /// Internal to this path - }; - - struct PathNode - { - NodeType type; - int32_t next; - glm::vec3 position; - float size; - int other_thing; - int other_thing2; - }; - - struct PATH_t - { - PathType type; - uint16_t ID; - std::string modelName; - std::vector nodes; - }; - + // Load the IDE data into memory bool load(const std::string& filename); - std::vector OBJSs; - std::vector CARSs; - std::vector PEDSs; - std::vector PATHs; + std::vector> OBJSs; + std::vector> CARSs; + std::vector> PEDSs; + std::vector> PATHs; }; #endif diff --git a/framework2/include/renderwure/objects/GTACharacter.hpp b/framework2/include/renderwure/objects/GTACharacter.hpp index ed14de17..dbfea681 100644 --- a/framework2/include/renderwure/objects/GTACharacter.hpp +++ b/framework2/include/renderwure/objects/GTACharacter.hpp @@ -35,7 +35,7 @@ public: GettingUp }; - std::shared_ptr ped; + std::shared_ptr ped; btKinematicCharacterController* physCharacter; btPairCachingGhostObject* physObject; @@ -50,7 +50,7 @@ public: * @param model * @param ped PEDS_t struct to use. */ - GTACharacter(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr ped); + GTACharacter(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr data); ~GTACharacter(); diff --git a/framework2/include/renderwure/objects/GTAInstance.hpp b/framework2/include/renderwure/objects/GTAInstance.hpp index 618b2f3f..8dc98d8f 100644 --- a/framework2/include/renderwure/objects/GTAInstance.hpp +++ b/framework2/include/renderwure/objects/GTAInstance.hpp @@ -10,7 +10,7 @@ struct GTAInstance : public GTAObject { glm::vec3 scale; - std::shared_ptr object; + std::shared_ptr object; std::shared_ptr LODinstance; GTAInstance( @@ -19,7 +19,7 @@ struct GTAInstance : public GTAObject const glm::quat& rot, Model* model, const glm::vec3& scale, - std::shared_ptr obj, + std::shared_ptr obj, std::shared_ptr lod ); diff --git a/framework2/include/renderwure/objects/GTAVehicle.hpp b/framework2/include/renderwure/objects/GTAVehicle.hpp index 124471bc..26d43707 100644 --- a/framework2/include/renderwure/objects/GTAVehicle.hpp +++ b/framework2/include/renderwure/objects/GTAVehicle.hpp @@ -18,7 +18,7 @@ private: bool handbrake; public: - std::shared_ptr vehicle; /// Vehicle type + std::shared_ptr vehicle; VehicleInfo info; glm::vec3 colourPrimary; glm::vec3 colourSecondary; @@ -31,7 +31,7 @@ public: const glm::vec3& pos, const glm::quat& rot, Model* model, - std::shared_ptr veh, + std::shared_ptr data, const VehicleInfo& info, const glm::vec3& prim, const glm::vec3& sec); diff --git a/framework2/src/ai/AIGraph.cpp b/framework2/src/ai/AIGraph.cpp index f42b94a7..f6843ec6 100644 --- a/framework2/src/ai/AIGraph.cpp +++ b/framework2/src/ai/AIGraph.cpp @@ -2,7 +2,7 @@ #include "renderwure/objects/GTAInstance.hpp" #include "renderwure/ai/GTAAINode.hpp" -void AIGraph::createPathNodes(const glm::vec3& position, const glm::quat& rotation, LoaderIDE::PATH_t& path) +void AIGraph::createPathNodes(const glm::vec3& position, const glm::quat& rotation, PathData& path) { size_t startIndex = nodes.size(); std::vector realNodes; @@ -13,7 +13,7 @@ void AIGraph::createPathNodes(const glm::vec3& position, const glm::quat& rotati GTAAINode* ainode = nullptr; glm::vec3 nodePosition = position + (rotation * node.position); - if( node.type == LoaderIDE::EXTERNAL ) { + if( node.type == PathNode::EXTERNAL ) { for( size_t rn = 0; rn < nodes.size(); ++rn ) { auto d = glm::length(nodes[rn]->position - nodePosition); if( d < 1.f ) { @@ -26,14 +26,14 @@ void AIGraph::createPathNodes(const glm::vec3& position, const glm::quat& rotati if( ainode == nullptr ) { ainode = new GTAAINode; - ainode->type = (path.type == LoaderIDE::PATH_PED ? GTAAINode::Pedestrian : GTAAINode::Vehicle); + ainode->type = (path.type == PathData::PATH_PED ? GTAAINode::Pedestrian : GTAAINode::Vehicle); ainode->nextIndex = node.next >= 0 ? startIndex + node.next : -1; ainode->flags = GTAAINode::None; ainode->size = node.size; ainode->other_thing = node.other_thing; ainode->other_thing2 = node.other_thing2; ainode->position = nodePosition; - ainode->external = node.type == LoaderIDE::EXTERNAL; + ainode->external = node.type == PathNode::EXTERNAL; realNodes.push_back(nodes.size()); nodes.push_back(ainode); diff --git a/framework2/src/engine/GTAEngine.cpp b/framework2/src/engine/GTAEngine.cpp index 71ffd63a..a340ad15 100644 --- a/framework2/src/engine/GTAEngine.cpp +++ b/framework2/src/engine/GTAEngine.cpp @@ -63,39 +63,38 @@ bool GTAEngine::defineItems(const std::string& name) if(idel.load(path)) { for( size_t o = 0; o < idel.OBJSs.size(); ++o) { objectTypes.insert({ - idel.OBJSs[o].ID, - std::shared_ptr(new LoaderIDE::OBJS_t(idel.OBJSs[o])) + idel.OBJSs[o]->ID, + idel.OBJSs[o] }); } for( size_t v = 0; v < idel.CARSs.size(); ++v) { - std::cout << "Vehicle ID " << idel.CARSs[v].ID << ": " << idel.CARSs[v].gameName << std::endl; vehicleTypes.insert({ - idel.CARSs[v].ID, - std::shared_ptr(new LoaderIDE::CARS_t(idel.CARSs[v])) + idel.CARSs[v]->ID, + idel.CARSs[v] }); } - for( size_t v = 0; v < idel.PEDSs.size(); ++v) { - pedestrianTypes.insert({ - idel.PEDSs[v].ID, - std::shared_ptr(new LoaderIDE::PEDS_t(idel.PEDSs[v])) - }); - } + for( size_t v = 0; v < idel.PEDSs.size(); ++v) { + pedestrianTypes.insert({ + idel.PEDSs[v]->ID, + idel.PEDSs[v] + }); + } - // Load AI information. - for( size_t a = 0; a < idel.PATHs.size(); ++a ) { - auto pathit = objectNodes.find(idel.PATHs[a].ID); - if( pathit == objectNodes.end() ) { - objectNodes.insert({ - idel.PATHs[a].ID, - {idel.PATHs[a]} - }); - } - else { - pathit->second.push_back(idel.PATHs[a]); - } - } + // Load AI information. + for( size_t a = 0; a < idel.PATHs.size(); ++a ) { + auto pathit = objectNodes.find(idel.PATHs[a]->ID); + if( pathit == objectNodes.end() ) { + objectNodes.insert({ + idel.PATHs[a]->ID, + {idel.PATHs[a]} + }); + } + else { + pathit->second.push_back(idel.PATHs[a]); + } + } } else { std::cerr << "Failed to load IDE " << path << std::endl; diff --git a/framework2/src/loaders/LoaderIDE.cpp b/framework2/src/loaders/LoaderIDE.cpp index 312a75d8..fd1e3129 100644 --- a/framework2/src/loaders/LoaderIDE.cpp +++ b/framework2/src/loaders/LoaderIDE.cpp @@ -48,7 +48,7 @@ bool LoaderIDE::load(const std::string &filename) switch (section) { case OBJS: { // Supports Type 1, 2 and 3 - OBJS_t objs; + std::shared_ptr objs(new ObjectData); std::string id, numClumps, flags, modelName, textureName; @@ -59,37 +59,37 @@ bool LoaderIDE::load(const std::string &filename) getline(strstream, textureName, ','); getline(strstream, numClumps, ','); - objs.numClumps = atoi(numClumps.c_str()); - for (size_t i = 0; i < objs.numClumps; i++) { + objs->numClumps = atoi(numClumps.c_str()); + for (size_t i = 0; i < objs->numClumps; i++) { std::string drawDistance; getline(strstream, drawDistance, ','); - objs.drawDistance[i] = atoi(drawDistance.c_str()); + objs->drawDistance[i] = atoi(drawDistance.c_str()); } getline(strstream, flags, ','); // Put stuff in our struct - objs.ID = atoi(id.c_str()); - objs.flags = atoi(flags.c_str()); - objs.modelName = modelName; - objs.textureName = textureName; - objs.LOD = modelName.find("LOD",0,3) != modelName.npos; + objs->ID = atoi(id.c_str()); + objs->flags = atoi(flags.c_str()); + objs->modelName = modelName; + objs->textureName = textureName; + objs->LOD = modelName.find("LOD",0,3) != modelName.npos; OBJSs.push_back(objs); break; } case CARS: { - CARS_t cars; + std::shared_ptr cars(new CarData); std::string id, type, classType, frequency, lvl, comprules, wheelModelID, wheelScale; getline(strstream, id, ','); - getline(strstream, cars.modelName, ','); - getline(strstream, cars.textureName, ','); + getline(strstream, cars->modelName, ','); + getline(strstream, cars->textureName, ','); getline(strstream, type, ','); - getline(strstream, cars.handlingID, ','); - getline(strstream, cars.gameName, ','); + getline(strstream, cars->handlingID, ','); + getline(strstream, cars->gameName, ','); getline(strstream, classType, ','); getline(strstream, frequency, ','); getline(strstream, lvl, ','); @@ -97,45 +97,45 @@ bool LoaderIDE::load(const std::string &filename) getline(strstream, wheelModelID, ','); getline(strstream, wheelScale, ','); - cars.ID = atoi(id.c_str()); - cars.frequency = atoi(frequency.c_str()); - cars.lvl = atoi(lvl.c_str()); - cars.comprules = atoi(comprules.c_str()); + cars->ID = atoi(id.c_str()); + cars->frequency = atoi(frequency.c_str()); + cars->lvl = atoi(lvl.c_str()); + cars->comprules = atoi(comprules.c_str()); if (type == "car") { - cars.type = CAR; - cars.wheelModelID = atoi(wheelModelID.c_str()); - cars.wheelScale = atof(wheelScale.c_str()); + cars->type = CarData::CAR; + cars->wheelModelID = atoi(wheelModelID.c_str()); + cars->wheelScale = atof(wheelScale.c_str()); } else if (type == "boat") { - cars.type = BOAT; + cars->type = CarData::BOAT; } else if (type == "train") { - cars.type = TRAIN; - cars.modelLOD = atoi(wheelModelID.c_str()); + cars->type = CarData::TRAIN; + cars->modelLOD = atoi(wheelModelID.c_str()); } else if (type == "plane") { - cars.type = PLANE; + cars->type = CarData::PLANE; } else if (type == "heli") { - cars.type = HELI; + cars->type = CarData::HELI; } - const std::map classTypes{ - {IGNORE, "ignore"}, - {NORMAL, "normal"}, - {POORFAMILY, "poorfamily"}, - {RICHFAMILY, "richfamily"}, - {EXECUTIVE, "executive"}, - {WORKER, "worker"}, - {BIG, "big"}, - {TAXI, "taxi"}, - {MOPED, "moped"}, - {MOTORBIKE, "motorbike"}, - {LEISUREBOAT, "leisureboat"}, - {WORKERBOAT, "workerboat"}, - {BICYCLE, "bicycle"}, - {ONFOOT, "onfoot"}, + const std::map classTypes{ + {CarData::IGNORE, "ignore"}, + {CarData::NORMAL, "normal"}, + {CarData::POORFAMILY, "poorfamily"}, + {CarData::RICHFAMILY, "richfamily"}, + {CarData::EXECUTIVE, "executive"}, + {CarData::WORKER, "worker"}, + {CarData::BIG, "big"}, + {CarData::TAXI, "taxi"}, + {CarData::MOPED, "moped"}, + {CarData::MOTORBIKE, "motorbike"}, + {CarData::LEISUREBOAT, "leisureboat"}, + {CarData::WORKERBOAT, "workerboat"}, + {CarData::BICYCLE, "bicycle"}, + {CarData::ONFOOT, "onfoot"}, }; for (auto &a : classTypes) { if (classType == a.second) { - cars.classType = a.first; + cars->classType = a.first; break; } } @@ -144,97 +144,96 @@ bool LoaderIDE::load(const std::string &filename) break; } case PEDS: { - PEDS_t peds; + std::shared_ptr peds(new CharacterData); std::string id, driveMask; getline(strstream, id, ','); - getline(strstream, peds.modelName, ','); - getline(strstream, peds.textureName, ','); - getline(strstream, peds.type, ','); - getline(strstream, peds.behaviour, ','); - getline(strstream, peds.animGroup, ','); + getline(strstream, peds->modelName, ','); + getline(strstream, peds->textureName, ','); + getline(strstream, peds->type, ','); + getline(strstream, peds->behaviour, ','); + getline(strstream, peds->animGroup, ','); getline(strstream, driveMask, ','); - peds.ID = atoi(id.c_str()); - peds.driveMask = atoi(driveMask.c_str()); + peds->ID = atoi(id.c_str()); + peds->driveMask = atoi(driveMask.c_str()); PEDSs.push_back(peds); break; } - case PATH: { - PATH_t path; + case PATH: { + std::shared_ptr path(new PathData); - std::string type; - getline(strstream, type, ','); - if( type == "ped" ) { - path.type = PATH_PED; - } - else if( type == "car") { - path.type = PATH_CAR; - } + std::string type; + getline(strstream, type, ','); + if( type == "ped" ) { + path->type = PathData::PATH_PED; + } + else if( type == "car") { + path->type = PathData::PATH_CAR; + } - std::string id; - getline(strstream, id, ','); - path.ID = atoi(id.c_str()); + std::string id; + getline(strstream, id, ','); + path->ID = atoi(id.c_str()); - getline(strstream, path.modelName); + getline(strstream, path->modelName); + std::string linebuff, buff; + for( size_t p = 0; p < 12; ++p ) { + PathNode node; - std::string linebuff, buff; - for( size_t p = 0; p < 12; ++p ) { - PathNode node; + getline(str, linebuff); + std::stringstream buffstream(linebuff); - getline(str, linebuff); - std::stringstream buffstream(linebuff); + getline(buffstream, buff, ','); + switch(atoi(buff.c_str())) { + case 0: + node.type = PathNode::EMPTY; + break; + case 2: + node.type = PathNode::INTERNAL; + break; + case 1: + node.type = PathNode::EXTERNAL; + break; + } - getline(buffstream, buff, ','); - switch(atoi(buff.c_str())) { - case 0: - node.type = EMPTY; - break; - case 2: - node.type = INTERNAL; - break; - case 1: - node.type = EXTERNAL; - break; - } + if( node.type == PathNode::EMPTY ) { + continue; + } - if( node.type == EMPTY ) { - continue; - } + getline(buffstream, buff, ','); + node.next = atoi(buff.c_str()); - getline(buffstream, buff, ','); - node.next = atoi(buff.c_str()); + getline(buffstream, buff, ','); // "Always 0" - getline(buffstream, buff, ','); // "Always 0" + getline(buffstream, buff, ','); + node.position.x = atof(buff.c_str()) * 1/16.f; - getline(buffstream, buff, ','); - node.position.x = atof(buff.c_str()) * 1/16.f; + getline(buffstream, buff, ','); + node.position.y = atof(buff.c_str()) * 1/16.f; - getline(buffstream, buff, ','); - node.position.y = atof(buff.c_str()) * 1/16.f; + getline(buffstream, buff, ','); + node.position.z = atof(buff.c_str()) * 1/16.f; - getline(buffstream, buff, ','); - node.position.z = atof(buff.c_str()) * 1/16.f; + getline(buffstream, buff, ','); + node.size = atof(buff.c_str()) * 1/16.f; - getline(buffstream, buff, ','); - node.size = atof(buff.c_str()) * 1/16.f; + getline(buffstream, buff, ','); + node.other_thing = atoi(buff.c_str()); - getline(buffstream, buff, ','); - node.other_thing = atoi(buff.c_str()); + getline(buffstream, buff, ','); + node.other_thing2 = atoi(buff.c_str()); - getline(buffstream, buff, ','); - node.other_thing2 = atoi(buff.c_str()); + path->nodes.push_back(node); + } - path.nodes.push_back(node); - } + PATHs.push_back(path); - PATHs.push_back(path); - - break; - } + break; + } } } diff --git a/framework2/src/objects/GTACharacter.cpp b/framework2/src/objects/GTACharacter.cpp index ca9a3338..f2b07970 100644 --- a/framework2/src/objects/GTACharacter.cpp +++ b/framework2/src/objects/GTACharacter.cpp @@ -4,9 +4,9 @@ #include #include -GTACharacter::GTACharacter(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr ped) +GTACharacter::GTACharacter(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr data) : GTAObject(engine, pos, rot, model), - currentVehicle(nullptr), ped(ped), physCharacter(nullptr), + currentVehicle(nullptr), ped(data), physCharacter(nullptr), controller(nullptr), currentActivity(None) { if(model) { diff --git a/framework2/src/objects/GTAInstance.cpp b/framework2/src/objects/GTAInstance.cpp index fb4c81eb..29247a8c 100644 --- a/framework2/src/objects/GTAInstance.cpp +++ b/framework2/src/objects/GTAInstance.cpp @@ -8,7 +8,7 @@ GTAInstance::GTAInstance( const glm::quat& rot, Model* model, const glm::vec3& scale, - std::shared_ptr obj, + std::shared_ptr obj, std::shared_ptr lod ) : GTAObject(engine, pos, rot, model), scale(scale), object(obj), LODinstance(lod) @@ -72,7 +72,7 @@ GTAInstance::GTAInstance( auto& pathlist = pathit->second; for( size_t p = 0; p < pathlist.size(); ++p ) { auto& path = pathlist[p]; - engine->aigraph.createPathNodes(position, rot, path); + engine->aigraph.createPathNodes(position, rot, *path); } } diff --git a/framework2/src/objects/GTAVehicle.cpp b/framework2/src/objects/GTAVehicle.cpp index 8b3c88fd..e3a6cdb8 100644 --- a/framework2/src/objects/GTAVehicle.cpp +++ b/framework2/src/objects/GTAVehicle.cpp @@ -3,13 +3,13 @@ #include #include -GTAVehicle::GTAVehicle(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr veh, const VehicleInfo& info, const glm::vec3& prim, const glm::vec3& sec) +GTAVehicle::GTAVehicle(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr data, const VehicleInfo& info, const glm::vec3& prim, const glm::vec3& sec) : GTAObject(engine, pos, rot, model), steerAngle(0.f), throttle(0.f), brake(0.f), handbrake(false), - vehicle(veh), info(info), colourPrimary(prim), colourSecondary(sec), physBody(nullptr), physVehicle(nullptr) + vehicle(data), info(info), colourPrimary(prim), colourSecondary(sec), physBody(nullptr), physVehicle(nullptr) { - if(! veh->modelName.empty()) { - auto phyit = engine->gameData.collisions.find(veh->modelName); + if(! data->modelName.empty()) { + auto phyit = engine->gameData.collisions.find(data->modelName); if( phyit != engine->gameData.collisions.end()) { btCompoundShape* cmpShape = new btCompoundShape; btDefaultMotionState* msta = new btDefaultMotionState; @@ -85,7 +85,7 @@ GTAVehicle::GTAVehicle(GTAEngine* engine, const glm::vec3& pos, const glm::quat& for(size_t w = 0; w < info.wheels.size(); ++w) { btVector3 connection(info.wheels[w].position.x, info.wheels[w].position.y, info.wheels[w].position.z - info.handling.suspensionLowerLimit); bool front = connection.y() > 0; - btWheelInfo& wi = physVehicle->addWheel(connection + com, btVector3(0.f, 0.f, -1.f), btVector3(1.f, 0.f, 0.f), travel, veh->wheelScale / 2.f, tuning, front); + btWheelInfo& wi = physVehicle->addWheel(connection + com, btVector3(0.f, 0.f, -1.f), btVector3(1.f, 0.f, 0.f), travel, data->wheelScale / 2.f, tuning, front); wi.m_suspensionStiffness = info.handling.suspensionForce * 10.f; wi.m_wheelsDampingCompression = kC * 2.f * btSqrt(wi.m_suspensionStiffness); wi.m_wheelsDampingRelaxation = kR * 2.f * btSqrt(wi.m_suspensionStiffness); diff --git a/framework2/src/render/GTARenderer.cpp b/framework2/src/render/GTARenderer.cpp index f1c575d7..41781562 100644 --- a/framework2/src/render/GTARenderer.cpp +++ b/framework2/src/render/GTARenderer.cpp @@ -279,7 +279,7 @@ void GTARenderer::renderWorld() for(size_t i = 0; i < engine->objectInstances.size(); ++i) { GTAInstance& inst = *engine->objectInstances[i]; - if(((inst.object->flags & LoaderIDE::OBJS_t::NIGHTONLY) | (inst.object->flags & LoaderIDE::OBJS_t::DAYONLY)) != 0) { + if(((inst.object->flags & ObjectData::NIGHTONLY) | (inst.object->flags & ObjectData::DAYONLY)) != 0) { //continue; } diff --git a/game/main.cpp b/game/main.cpp index cb1238e7..77556cb0 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -102,7 +102,7 @@ void init(std::string gtapath) glm::vec3 spawnPos = plyPos + glm::vec3(-5, -20, 0.0); size_t k = 1; // Spawn every vehicle, cause why not. - for(std::map>::iterator it = gta->vehicleTypes.begin(); + for(std::map>::iterator it = gta->vehicleTypes.begin(); it != gta->vehicleTypes.end(); ++it) { if(it->first == 140) continue; // get this plane out of here. gta->createVehicle(it->first, spawnPos); @@ -111,23 +111,23 @@ void init(std::string gtapath) } spawnPos = plyPos + glm::vec3(-5, 20 + (2.5 * gta->pedestrianTypes.size()/4), 0); - k = 1; - // Spawn every pedestrian. - for(auto it = gta->pedestrianTypes.begin(); - it != gta->pedestrianTypes.end(); ++it) { - gta->createPedestrian(it->first, spawnPos); - spawnPos += glm::vec3(2.5, 0, 0); - if((k++ % 6) == 0) { spawnPos += glm::vec3(-15, -2.5, 0); } - } - - debugDrawer = new DebugDraw; - debugDrawer->setShaderProgram(gta->renderer.worldProgram); - debugDrawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe); - gta->dynamicsWorld->setDebugDrawer(debugDrawer); + k = 1; + // Spawn every pedestrian. + /*for(auto it = gta->pedestrianTypes.begin(); + it != gta->pedestrianTypes.end(); ++it) { + gta->createPedestrian(it->first, spawnPos); + spawnPos += glm::vec3(2.5, 0, 0); + if((k++ % 6) == 0) { spawnPos += glm::vec3(-15, -2.5, 0); } + }*/ + + debugDrawer = new DebugDraw; + debugDrawer->setShaderProgram(gta->renderer.worldProgram); + debugDrawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe); + gta->dynamicsWorld->setDebugDrawer(debugDrawer); std::cout << "Loaded " - << gta->gameData.models.size() << " models, " - << gta->gameData.textures.size() << " textures" << std::endl; + << gta->gameData.models.size() << " models, " + << gta->gameData.textures.size() << " textures" << std::endl; } void update(float dt) diff --git a/viewer/main.cpp b/viewer/main.cpp index e63a9576..68606481 100644 --- a/viewer/main.cpp +++ b/viewer/main.cpp @@ -138,8 +138,9 @@ void handleGlobalEvent(sf::Event &event) case sf::Keyboard::Escape: window.close(); break; - case sf::Keyboard::Insert: - commandMode = !commandMode; + case sf::Keyboard::M: + //commandMode = !commandMode; + command("player-vehicle"); break; default: break; } @@ -264,7 +265,7 @@ void init(std::string gtapath, bool loadWorld) glm::vec3 spawnPos = plyPos + glm::vec3(-5, -20, 0.0); size_t k = 1; // Spawn every vehicle, cause why not. - for(std::map>::iterator it = gta->vehicleTypes.begin(); + for(std::map>::iterator it = gta->vehicleTypes.begin(); it != gta->vehicleTypes.end(); ++it) { if(it->first == 140) continue; // get this plane out of here. gta->createVehicle(it->first, spawnPos); @@ -275,12 +276,12 @@ void init(std::string gtapath, bool loadWorld) spawnPos = plyPos + glm::vec3(-5, 20 + (2.5 * gta->pedestrianTypes.size()/4), 0); k = 1; // Spawn every pedestrian. - for(auto it = gta->pedestrianTypes.begin(); + /*for(auto it = gta->pedestrianTypes.begin(); it != gta->pedestrianTypes.end(); ++it) { gta->createPedestrian(it->first, spawnPos); spawnPos += glm::vec3(2.5, 0, 0); if((k++ % 6) == 0) { spawnPos += glm::vec3(-15, -2.5, 0); } - } + }*/ debugDrawer = new DebugDraw; debugDrawer->setShaderProgram(gta->renderer.worldProgram);