mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-18 16:32:32 +02:00
Refactored IDE data out to shared headers
This commit is contained in:
parent
67cedd9357
commit
0b046947da
@ -3,7 +3,7 @@
|
||||
#define _AIGRAPH_HPP_
|
||||
#include <vector>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <renderwure/loaders/LoaderIDE.hpp>
|
||||
#include <renderwure/data/PathData.hpp>
|
||||
|
||||
struct GTAInstance;
|
||||
struct GTAAINode;
|
||||
@ -14,7 +14,7 @@ public:
|
||||
|
||||
std::vector<GTAAINode*> 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);
|
||||
|
||||
};
|
||||
|
||||
|
92
framework2/include/renderwure/data/ObjectData.hpp
Normal file
92
framework2/include/renderwure/data/ObjectData.hpp
Normal file
@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
#ifndef __GLT_OBJECTDATA_HPP__
|
||||
#define __GLT_OBJECTDATA_HPP__
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
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
|
40
framework2/include/renderwure/data/PathData.hpp
Normal file
40
framework2/include/renderwure/data/PathData.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#ifndef __GLT_PATHDATA_HPP__
|
||||
#define __GLT_PATHDATA_HPP__
|
||||
#include <glm/glm.hpp>
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
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<PathNode> nodes;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -127,22 +127,22 @@ public:
|
||||
/**
|
||||
* Object Definitions
|
||||
*/
|
||||
std::map<uint16_t, std::shared_ptr<LoaderIDE::OBJS_t>> objectTypes;
|
||||
|
||||
/**
|
||||
* Paths associated with each object definition.
|
||||
*/
|
||||
std::map<uint16_t, std::vector<LoaderIDE::PATH_t>> objectNodes;
|
||||
|
||||
std::map<uint16_t, std::shared_ptr<ObjectData>> objectTypes;
|
||||
|
||||
/**
|
||||
* Paths associated with each object definition.
|
||||
*/
|
||||
std::map<uint16_t, std::vector<std::shared_ptr<PathData>>> objectNodes;
|
||||
|
||||
/**
|
||||
* Vehicle definitions
|
||||
*/
|
||||
std::map<uint16_t, std::shared_ptr<LoaderIDE::CARS_t>> vehicleTypes;
|
||||
std::map<uint16_t, std::shared_ptr<CarData>> vehicleTypes;
|
||||
|
||||
/**
|
||||
* Ped definitions
|
||||
*/
|
||||
std::map<uint16_t, std::shared_ptr<LoaderIDE::PEDS_t>> pedestrianTypes;
|
||||
/**
|
||||
* Ped definitions
|
||||
*/
|
||||
std::map<uint16_t, std::shared_ptr<CharacterData>> pedestrianTypes;
|
||||
|
||||
/**
|
||||
* Game Objects!
|
||||
|
@ -4,7 +4,10 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
#include <renderwure/data/ObjectData.hpp>
|
||||
#include <renderwure/data/PathData.hpp>
|
||||
|
||||
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<PathNode> nodes;
|
||||
};
|
||||
|
||||
|
||||
// Load the IDE data into memory
|
||||
bool load(const std::string& filename);
|
||||
|
||||
std::vector<OBJS_t> OBJSs;
|
||||
std::vector<CARS_t> CARSs;
|
||||
std::vector<PEDS_t> PEDSs;
|
||||
std::vector<PATH_t> PATHs;
|
||||
std::vector<std::shared_ptr<ObjectData>> OBJSs;
|
||||
std::vector<std::shared_ptr<CarData>> CARSs;
|
||||
std::vector<std::shared_ptr<CharacterData>> PEDSs;
|
||||
std::vector<std::shared_ptr<PathData>> PATHs;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
GettingUp
|
||||
};
|
||||
|
||||
std::shared_ptr<LoaderIDE::PEDS_t> ped;
|
||||
std::shared_ptr<CharacterData> 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<LoaderIDE::PEDS_t> ped);
|
||||
GTACharacter(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr<CharacterData> data);
|
||||
|
||||
~GTACharacter();
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
struct GTAInstance : public GTAObject
|
||||
{
|
||||
glm::vec3 scale;
|
||||
std::shared_ptr<LoaderIDE::OBJS_t> object;
|
||||
std::shared_ptr<ObjectData> object;
|
||||
std::shared_ptr<GTAInstance> LODinstance;
|
||||
|
||||
GTAInstance(
|
||||
@ -19,7 +19,7 @@ struct GTAInstance : public GTAObject
|
||||
const glm::quat& rot,
|
||||
Model* model,
|
||||
const glm::vec3& scale,
|
||||
std::shared_ptr<LoaderIDE::OBJS_t> obj,
|
||||
std::shared_ptr<ObjectData> obj,
|
||||
std::shared_ptr<GTAInstance> lod
|
||||
);
|
||||
|
||||
|
@ -18,7 +18,7 @@ private:
|
||||
bool handbrake;
|
||||
public:
|
||||
|
||||
std::shared_ptr<LoaderIDE::CARS_t> vehicle; /// Vehicle type
|
||||
std::shared_ptr<CarData> 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<LoaderIDE::CARS_t> veh,
|
||||
std::shared_ptr<CarData> data,
|
||||
const VehicleInfo& info,
|
||||
const glm::vec3& prim,
|
||||
const glm::vec3& sec);
|
||||
|
@ -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<size_t> 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);
|
||||
|
@ -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<LoaderIDE::OBJS_t>(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<LoaderIDE::CARS_t>(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<LoaderIDE::PEDS_t>(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;
|
||||
|
@ -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<ObjectData> 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<CarData> 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<VehicleClass, std::string> 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<CarData::VehicleClass, std::string> 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<CharacterData> 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<PathData> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include <renderwure/engine/Animator.hpp>
|
||||
#include <renderwure/objects/GTAVehicle.hpp>
|
||||
|
||||
GTACharacter::GTACharacter(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr<LoaderIDE::PEDS_t> ped)
|
||||
GTACharacter::GTACharacter(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr<CharacterData> data)
|
||||
: GTAObject(engine, pos, rot, model),
|
||||
currentVehicle(nullptr), ped(ped), physCharacter(nullptr),
|
||||
currentVehicle(nullptr), ped(data), physCharacter(nullptr),
|
||||
controller(nullptr), currentActivity(None)
|
||||
{
|
||||
if(model) {
|
||||
|
@ -8,7 +8,7 @@ GTAInstance::GTAInstance(
|
||||
const glm::quat& rot,
|
||||
Model* model,
|
||||
const glm::vec3& scale,
|
||||
std::shared_ptr<LoaderIDE::OBJS_t> obj,
|
||||
std::shared_ptr<ObjectData> obj,
|
||||
std::shared_ptr<GTAInstance> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,13 @@
|
||||
#include <BulletDynamics/Vehicle/btRaycastVehicle.h>
|
||||
#include <renderwure/data/CollisionModel.hpp>
|
||||
|
||||
GTAVehicle::GTAVehicle(GTAEngine* engine, const glm::vec3& pos, const glm::quat& rot, Model* model, std::shared_ptr<LoaderIDE::CARS_t> 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<CarData> 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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<uint16_t, std::shared_ptr<LoaderIDE::CARS_t>>::iterator it = gta->vehicleTypes.begin();
|
||||
for(std::map<uint16_t, std::shared_ptr<CarData>>::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)
|
||||
|
@ -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<uint16_t, std::shared_ptr<LoaderIDE::CARS_t>>::iterator it = gta->vehicleTypes.begin();
|
||||
for(std::map<uint16_t, std::shared_ptr<CarData>>::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);
|
||||
|
Loading…
Reference in New Issue
Block a user