mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 18:32:44 +01:00
clang-format files in rwengine/src/data
This commit is contained in:
parent
6444bca8db
commit
1e4d7ea133
@ -1,127 +1,106 @@
|
|||||||
#include "data/Chase.hpp"
|
#include "data/Chase.hpp"
|
||||||
#include <fstream>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <rw/defines.hpp>
|
|
||||||
#include <objects/GameObject.hpp>
|
|
||||||
#include <engine/GameWorld.hpp>
|
#include <engine/GameWorld.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
#include <objects/GameObject.hpp>
|
||||||
|
#include <rw/defines.hpp>
|
||||||
|
|
||||||
#define KEYFRAMES_PER_SECOND 30
|
#define KEYFRAMES_PER_SECOND 30
|
||||||
|
|
||||||
bool ChaseKeyframe::load(const std::string &filePath, std::vector<ChaseKeyframe> &frames)
|
bool ChaseKeyframe::load(const std::string &filePath,
|
||||||
{
|
std::vector<ChaseKeyframe> &frames) {
|
||||||
std::ifstream chaseFile(filePath, std::ios_base::binary);
|
std::ifstream chaseFile(filePath, std::ios_base::binary);
|
||||||
RW_CHECK(chaseFile.is_open(), "Failed to open chase file");
|
RW_CHECK(chaseFile.is_open(), "Failed to open chase file");
|
||||||
if (!chaseFile.is_open()) {
|
if (!chaseFile.is_open()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
chaseFile.seekg(0, std::ios_base::end);
|
chaseFile.seekg(0, std::ios_base::end);
|
||||||
size_t fileLength = chaseFile.tellg();
|
size_t fileLength = chaseFile.tellg();
|
||||||
chaseFile.seekg(0);
|
chaseFile.seekg(0);
|
||||||
|
|
||||||
struct ChaseEntryRecord {
|
struct ChaseEntryRecord {
|
||||||
int16_t velocity[3];
|
int16_t velocity[3];
|
||||||
int8_t right[3];
|
int8_t right[3];
|
||||||
int8_t up[3];
|
int8_t up[3];
|
||||||
uint8_t steering;
|
uint8_t steering;
|
||||||
uint8_t driving;
|
uint8_t driving;
|
||||||
uint8_t braking;
|
uint8_t braking;
|
||||||
uint8_t handbrake;
|
uint8_t handbrake;
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(ChaseEntryRecord) == 28, "ChaseEntryRecord is not 28 bytes");
|
static_assert(sizeof(ChaseEntryRecord) == 28,
|
||||||
RW_CHECK(fileLength % sizeof(ChaseEntryRecord) == 0, "File is not a mulitple of 28 byte");
|
"ChaseEntryRecord is not 28 bytes");
|
||||||
|
RW_CHECK(fileLength % sizeof(ChaseEntryRecord) == 0,
|
||||||
|
"File is not a mulitple of 28 byte");
|
||||||
|
|
||||||
size_t recordCount = fileLength / sizeof(ChaseEntryRecord);
|
size_t recordCount = fileLength / sizeof(ChaseEntryRecord);
|
||||||
|
|
||||||
for (size_t i = 0; i < recordCount; ++i)
|
for (size_t i = 0; i < recordCount; ++i) {
|
||||||
{
|
ChaseEntryRecord rec;
|
||||||
ChaseEntryRecord rec;
|
chaseFile.read((char *)&rec, sizeof(ChaseEntryRecord));
|
||||||
chaseFile.read((char*)&rec, sizeof(ChaseEntryRecord));
|
glm::vec3 velocity{
|
||||||
glm::vec3 velocity {
|
rec.velocity[0] / 16383.5f, rec.velocity[1] / 16383.5f,
|
||||||
rec.velocity[0]/16383.5f,
|
rec.velocity[2] / 16383.5f,
|
||||||
rec.velocity[1]/16383.5f,
|
};
|
||||||
rec.velocity[2]/16383.5f,
|
glm::vec3 right{
|
||||||
};
|
rec.right[0] / 127.5f, rec.right[1] / 127.5f, rec.right[2] / 127.5f,
|
||||||
glm::vec3 right{
|
};
|
||||||
rec.right[0]/127.5f,
|
glm::vec3 up{
|
||||||
rec.right[1]/127.5f,
|
rec.up[0] / 127.5f, rec.up[1] / 127.5f, rec.up[2] / 127.5f,
|
||||||
rec.right[2]/127.5f,
|
};
|
||||||
};
|
glm::mat3 rotation(right, up, glm::cross(right, up));
|
||||||
glm::vec3 up{
|
frames.push_back({velocity, rec.steering, rec.driving, rec.braking,
|
||||||
rec.up[0]/127.5f,
|
!!rec.handbrake, rec.position,
|
||||||
rec.up[1]/127.5f,
|
glm::quat_cast(rotation)});
|
||||||
rec.up[2]/127.5f,
|
}
|
||||||
};
|
|
||||||
glm::mat3 rotation(right, up, glm::cross(right, up));
|
|
||||||
frames.push_back({
|
|
||||||
velocity,
|
|
||||||
rec.steering,
|
|
||||||
rec.driving,
|
|
||||||
rec.braking,
|
|
||||||
!!rec.handbrake,
|
|
||||||
rec.position,
|
|
||||||
glm::quat_cast(rotation)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChaseCoordinator::addChaseVehicle(GameObject *vehicle, int index,
|
||||||
|
const std::string &pathFile) {
|
||||||
|
std::vector<ChaseKeyframe> keyframes;
|
||||||
bool ChaseCoordinator::addChaseVehicle(GameObject *vehicle, int index, const std::string &pathFile)
|
bool result = ChaseKeyframe::load(pathFile, keyframes);
|
||||||
{
|
RW_CHECK(result, "Failed to load chase keyframes: " + pathFile);
|
||||||
std::vector <ChaseKeyframe> keyframes;
|
chaseVehicles[index] = {keyframes, vehicle};
|
||||||
bool result = ChaseKeyframe::load(pathFile, keyframes);
|
return result;
|
||||||
RW_CHECK(result, "Failed to load chase keyframes: " + pathFile);
|
|
||||||
chaseVehicles[index] = {keyframes, vehicle};
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject*ChaseCoordinator::getChaseVehicle(int index)
|
GameObject *ChaseCoordinator::getChaseVehicle(int index) {
|
||||||
{
|
return chaseVehicles.at(index).object;
|
||||||
return chaseVehicles.at(index).object;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChaseCoordinator::removeChaseVehicle(int index)
|
void ChaseCoordinator::removeChaseVehicle(int index) {
|
||||||
{
|
auto it = chaseVehicles.find(index);
|
||||||
auto it = chaseVehicles.find(index);
|
RW_CHECK(it != chaseVehicles.end(), "Vehicle not in chase");
|
||||||
RW_CHECK(it != chaseVehicles.end(), "Vehicle not in chase");
|
if (it != chaseVehicles.end()) {
|
||||||
if (it != chaseVehicles.end())
|
chaseVehicles.erase(it);
|
||||||
{
|
}
|
||||||
chaseVehicles.erase(it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChaseCoordinator::start()
|
void ChaseCoordinator::start() {
|
||||||
{
|
chaseTime = 0.f;
|
||||||
chaseTime = 0.f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChaseCoordinator::update(float dt)
|
void ChaseCoordinator::update(float dt) {
|
||||||
{
|
chaseTime += dt;
|
||||||
chaseTime += dt;
|
size_t frameNum = chaseTime * KEYFRAMES_PER_SECOND;
|
||||||
size_t frameNum = chaseTime * KEYFRAMES_PER_SECOND;
|
for (auto &it : chaseVehicles) {
|
||||||
for(auto& it : chaseVehicles)
|
RW_CHECK(frameNum < it.second.keyframes.size(),
|
||||||
{
|
"Vehicle out of chase keyframes");
|
||||||
RW_CHECK(frameNum < it.second.keyframes.size(), "Vehicle out of chase keyframes");
|
if (frameNum >= it.second.keyframes.size()) continue;
|
||||||
if (frameNum >= it.second.keyframes.size()) continue;
|
|
||||||
|
|
||||||
const ChaseKeyframe& kf = it.second.keyframes[frameNum];
|
const ChaseKeyframe &kf = it.second.keyframes[frameNum];
|
||||||
it.second.object->setPosition(kf.position);
|
it.second.object->setPosition(kf.position);
|
||||||
it.second.object->setRotation(kf.rotation);
|
it.second.object->setRotation(kf.rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChaseCoordinator::cleanup()
|
void ChaseCoordinator::cleanup() {
|
||||||
{
|
for (auto &it : chaseVehicles) {
|
||||||
for(auto& it : chaseVehicles)
|
it.second.object->engine->destroyObject(it.second.object);
|
||||||
{
|
}
|
||||||
it.second.object->engine->destroyObject(it.second.object);
|
chaseVehicles.clear();
|
||||||
}
|
|
||||||
chaseVehicles.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,23 +3,23 @@
|
|||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
class GameObject;
|
class GameObject;
|
||||||
|
|
||||||
struct ChaseKeyframe
|
struct ChaseKeyframe {
|
||||||
{
|
glm::vec3 velocity;
|
||||||
glm::vec3 velocity;
|
int steeringAngle;
|
||||||
int steeringAngle;
|
int acceleratorPower;
|
||||||
int acceleratorPower;
|
int brakePower;
|
||||||
int brakePower;
|
bool handbrake;
|
||||||
bool handbrake;
|
glm::vec3 position;
|
||||||
glm::vec3 position;
|
glm::quat rotation;
|
||||||
glm::quat rotation;
|
|
||||||
|
|
||||||
static bool load(const std::string& filePath, std::vector<ChaseKeyframe>& frames);
|
static bool load(const std::string& filePath,
|
||||||
|
std::vector<ChaseKeyframe>& frames);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,30 +28,29 @@ struct ChaseKeyframe
|
|||||||
* It reads in ChaseKeyframes for a set of objects, and replays them
|
* It reads in ChaseKeyframes for a set of objects, and replays them
|
||||||
* over time.
|
* over time.
|
||||||
*/
|
*/
|
||||||
class ChaseCoordinator
|
class ChaseCoordinator {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
ChaseCoordinator() : chaseTime(-1.f) {
|
||||||
|
}
|
||||||
|
|
||||||
ChaseCoordinator()
|
bool addChaseVehicle(GameObject* vehicle, int index,
|
||||||
: chaseTime(-1.f)
|
const std::string& pathFile);
|
||||||
{ }
|
GameObject* getChaseVehicle(int index);
|
||||||
|
void removeChaseVehicle(int index);
|
||||||
|
|
||||||
bool addChaseVehicle(GameObject* vehicle, int index, const std::string& pathFile);
|
void start();
|
||||||
GameObject* getChaseVehicle(int index);
|
void update(float dt);
|
||||||
void removeChaseVehicle(int index);
|
|
||||||
|
|
||||||
void start();
|
void cleanup();
|
||||||
void update(float dt);
|
|
||||||
|
|
||||||
void cleanup();
|
|
||||||
private:
|
private:
|
||||||
float chaseTime;
|
float chaseTime;
|
||||||
struct ChaseObject {
|
struct ChaseObject {
|
||||||
std::vector<ChaseKeyframe> keyframes;
|
std::vector<ChaseKeyframe> keyframes;
|
||||||
GameObject* object;
|
GameObject* object;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<int, ChaseObject> chaseVehicles;
|
std::map<int, ChaseObject> chaseVehicles;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,47 +1,44 @@
|
|||||||
#ifndef RWENGINE_COLLISIONMODEL_HPP
|
#ifndef RWENGINE_COLLISIONMODEL_HPP
|
||||||
#define RWENGINE_COLLISIONMODEL_HPP
|
#define RWENGINE_COLLISIONMODEL_HPP
|
||||||
|
#include <cstdint>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class CollisionModel
|
* @class CollisionModel
|
||||||
* Collision shapes data container.
|
* Collision shapes data container.
|
||||||
*/
|
*/
|
||||||
struct CollisionModel
|
struct CollisionModel {
|
||||||
{
|
/// @todo give shapes surface data
|
||||||
/// @todo give shapes surface data
|
struct Sphere {
|
||||||
struct Sphere
|
glm::vec3 center;
|
||||||
{
|
float radius;
|
||||||
glm::vec3 center;
|
};
|
||||||
float radius;
|
|
||||||
};
|
struct Box {
|
||||||
|
glm::vec3 min;
|
||||||
struct Box
|
glm::vec3 max;
|
||||||
{
|
};
|
||||||
glm::vec3 min;
|
|
||||||
glm::vec3 max;
|
/// COL version
|
||||||
};
|
int version;
|
||||||
|
|
||||||
/// COL version
|
/// Model name
|
||||||
int version;
|
std::string name;
|
||||||
|
uint16_t modelid;
|
||||||
/// Model name
|
|
||||||
std::string name;
|
// Bounding radius
|
||||||
uint16_t modelid;
|
float radius;
|
||||||
|
|
||||||
// Bounding radius
|
glm::vec3 center;
|
||||||
float radius;
|
glm::vec3 min;
|
||||||
|
glm::vec3 max;
|
||||||
glm::vec3 center;
|
|
||||||
glm::vec3 min;
|
std::vector<Sphere> spheres;
|
||||||
glm::vec3 max;
|
std::vector<Box> boxes;
|
||||||
|
std::vector<glm::vec3> vertices;
|
||||||
std::vector<Sphere> spheres;
|
std::vector<uint32_t> indices;
|
||||||
std::vector<Box> boxes;
|
|
||||||
std::vector<glm::vec3> vertices;
|
|
||||||
std::vector<uint32_t> indices;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,145 +3,139 @@
|
|||||||
#define _CUTSCENEDATA_HPP_
|
#define _CUTSCENEDATA_HPP_
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stores data from .CUT files
|
* @brief Stores data from .CUT files
|
||||||
*/
|
*/
|
||||||
struct CutsceneMetadata
|
struct CutsceneMetadata {
|
||||||
{
|
struct ModelEntry {
|
||||||
struct ModelEntry {
|
std::string model;
|
||||||
std::string model;
|
std::string animation;
|
||||||
std::string animation;
|
};
|
||||||
};
|
struct TextEntry {
|
||||||
struct TextEntry {
|
float length;
|
||||||
float length;
|
std::string gxt;
|
||||||
std::string gxt;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
/// The origin for coordinates in the cutscene
|
/// The origin for coordinates in the cutscene
|
||||||
glm::vec3 sceneOffset;
|
glm::vec3 sceneOffset;
|
||||||
|
|
||||||
std::vector<ModelEntry> models;
|
std::vector<ModelEntry> models;
|
||||||
std::map<float, TextEntry> texts;
|
std::map<float, TextEntry> texts;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stores the Camera animation data from .DAT files
|
* @brief Stores the Camera animation data from .DAT files
|
||||||
*/
|
*/
|
||||||
struct CutsceneTracks
|
struct CutsceneTracks {
|
||||||
{
|
std::map<float, float> zoom;
|
||||||
std::map<float, float> zoom;
|
std::map<float, float> rotation;
|
||||||
std::map<float, float> rotation;
|
std::map<float, glm::vec3> position;
|
||||||
std::map<float, glm::vec3> position;
|
std::map<float, glm::vec3>
|
||||||
std::map<float, glm::vec3> target; /// Rotation is around the direction to this vector
|
target; /// Rotation is around the direction to this vector
|
||||||
|
|
||||||
float duration { 0.f };
|
float duration{0.f};
|
||||||
|
|
||||||
glm::vec3 getPositionAt(float time)
|
glm::vec3 getPositionAt(float time) {
|
||||||
{
|
glm::vec3 p = position.end()->second;
|
||||||
glm::vec3 p = position.end()->second;
|
for (auto it = position.begin(); it != position.end(); ++it) {
|
||||||
for(auto it = position.begin(); it != position.end(); ++it) {
|
if (it->first <= time) {
|
||||||
if( it->first <= time ) {
|
auto a = it->second;
|
||||||
auto a = it->second;
|
auto b = it->second;
|
||||||
auto b = it->second;
|
auto nextIt = it;
|
||||||
auto nextIt = it;
|
float t = it->first;
|
||||||
float t = it->first;
|
if (++nextIt != position.end()) {
|
||||||
if( ++nextIt != position.end() ) {
|
b = nextIt->second;
|
||||||
b = nextIt->second;
|
t = nextIt->first;
|
||||||
t = nextIt->first;
|
}
|
||||||
}
|
float tdiff = t - it->first;
|
||||||
float tdiff = t - it->first;
|
p = b;
|
||||||
p = b;
|
if (tdiff > 0.f) {
|
||||||
if( tdiff > 0.f ) {
|
float fac = (time - it->first) / tdiff;
|
||||||
float fac = (time - it->first) / tdiff;
|
p = glm::mix(a, b, fac);
|
||||||
p = glm::mix(a, b, fac);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return p;
|
||||||
return p;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 getTargetAt(float time)
|
glm::vec3 getTargetAt(float time) {
|
||||||
{
|
glm::vec3 p = position.end()->second;
|
||||||
glm::vec3 p = position.end()->second;
|
for (auto it = target.begin(); it != target.end(); ++it) {
|
||||||
for(auto it = target.begin(); it != target.end(); ++it) {
|
if (it->first <= time) {
|
||||||
if( it->first <= time ) {
|
auto a = it->second;
|
||||||
auto a = it->second;
|
auto b = it->second;
|
||||||
auto b = it->second;
|
auto nextIt = it;
|
||||||
auto nextIt = it;
|
float t = it->first;
|
||||||
float t = it->first;
|
if (++nextIt != target.end()) {
|
||||||
if( ++nextIt != target.end() ) {
|
b = nextIt->second;
|
||||||
b = nextIt->second;
|
t = nextIt->first;
|
||||||
t = nextIt->first;
|
}
|
||||||
}
|
float tdiff = t - it->first;
|
||||||
float tdiff = t - it->first;
|
p = b;
|
||||||
p = b;
|
if (tdiff > 0.f) {
|
||||||
if( tdiff > 0.f ) {
|
float fac = (time - it->first) / tdiff;
|
||||||
float fac = (time - it->first) / tdiff;
|
p = glm::mix(a, b, fac);
|
||||||
p = glm::mix(a, b, fac);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return p;
|
||||||
return p;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
float getZoomAt(float time)
|
float getZoomAt(float time) {
|
||||||
{
|
float r = zoom.end()->second;
|
||||||
float r = zoom.end()->second;
|
for (auto it = zoom.begin(); it != zoom.end(); ++it) {
|
||||||
for(auto it = zoom.begin(); it != zoom.end(); ++it) {
|
if (it->first <= time) {
|
||||||
if( it->first <= time ) {
|
auto a = it->second;
|
||||||
auto a = it->second;
|
auto b = it->second;
|
||||||
auto b = it->second;
|
auto nextIt = it;
|
||||||
auto nextIt = it;
|
float t = it->first;
|
||||||
float t = it->first;
|
if (++nextIt != zoom.end()) {
|
||||||
if( ++nextIt != zoom.end() ) {
|
b = nextIt->second;
|
||||||
b = nextIt->second;
|
t = nextIt->first;
|
||||||
t = nextIt->first;
|
}
|
||||||
}
|
float tdiff = t - it->first;
|
||||||
float tdiff = t - it->first;
|
r = b;
|
||||||
r = b;
|
if (tdiff > 0.f) {
|
||||||
if( tdiff > 0.f ) {
|
float fac = (time - it->first) / tdiff;
|
||||||
float fac = (time - it->first) / tdiff;
|
r = glm::mix(a, b, fac);
|
||||||
r = glm::mix(a, b, fac);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return r;
|
||||||
return r;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
float getRotationAt(float time)
|
float getRotationAt(float time) {
|
||||||
{
|
float r = rotation.end()->second;
|
||||||
float r = rotation.end()->second;
|
for (auto it = rotation.begin(); it != rotation.end(); ++it) {
|
||||||
for(auto it = rotation.begin(); it != rotation.end(); ++it) {
|
if (it->first <= time) {
|
||||||
if( it->first <= time ) {
|
auto a = it->second;
|
||||||
auto a = it->second;
|
auto b = it->second;
|
||||||
auto b = it->second;
|
auto nextIt = it;
|
||||||
auto nextIt = it;
|
float t = it->first;
|
||||||
float t = it->first;
|
if (++nextIt != rotation.end()) {
|
||||||
if( ++nextIt != rotation.end() ) {
|
b = nextIt->second;
|
||||||
b = nextIt->second;
|
t = nextIt->first;
|
||||||
t = nextIt->first;
|
}
|
||||||
}
|
float tdiff = t - it->first;
|
||||||
float tdiff = t - it->first;
|
r = b;
|
||||||
r = b;
|
if (tdiff > 0.f) {
|
||||||
if( tdiff > 0.f ) {
|
float fac = (time - it->first) / tdiff;
|
||||||
float fac = (time - it->first) / tdiff;
|
r = glm::mix(a, b, fac);
|
||||||
r = glm::mix(a, b, fac);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return r;
|
||||||
return r;
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CutsceneData
|
struct CutsceneData {
|
||||||
{
|
CutsceneMetadata meta;
|
||||||
CutsceneMetadata meta;
|
CutsceneTracks tracks;
|
||||||
CutsceneTracks tracks;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include "GameTexts.hpp"
|
#include "GameTexts.hpp"
|
||||||
|
|
||||||
GameString GameStringUtil::fromString(const std::string& str)
|
GameString GameStringUtil::fromString(const std::string& str) {
|
||||||
{
|
GameString s;
|
||||||
GameString s;
|
for (std::string::size_type i = 0u; i < str.size(); ++i) {
|
||||||
for (std::string::size_type i = 0u; i < str.size(); ++i) {
|
s += str[i];
|
||||||
s += str[i];
|
}
|
||||||
}
|
return s;
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
@ -18,47 +18,45 @@ using GameString = std::basic_string<GameStringChar>;
|
|||||||
*/
|
*/
|
||||||
using GameStringKey = std::string;
|
using GameStringKey = std::string;
|
||||||
|
|
||||||
namespace GameStringUtil
|
namespace GameStringUtil {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* @brief fromString Converts a string to a GameString
|
* @brief fromString Converts a string to a GameString
|
||||||
*
|
*
|
||||||
* Encoding of GameStrings depends on the font, only simple ASCII chars will map well
|
* Encoding of GameStrings depends on the font, only simple ASCII chars will map
|
||||||
|
* well
|
||||||
*/
|
*/
|
||||||
GameString fromString(const std::string& str);
|
GameString fromString(const std::string& str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Since the encoding of symbols is arbitrary, these constants should be used in
|
* Since the encoding of symbols is arbitrary, these constants should be used in
|
||||||
* hard-coded strings containing symbols outside of the ASCII-subset supported by
|
* hard-coded strings containing symbols outside of the ASCII-subset supported
|
||||||
|
* by
|
||||||
* all fonts
|
* all fonts
|
||||||
*/
|
*/
|
||||||
namespace GameSymbols
|
namespace GameSymbols {
|
||||||
{
|
static constexpr GameStringChar Money = '$';
|
||||||
static constexpr GameStringChar Money = '$';
|
static constexpr GameStringChar Heart = '{';
|
||||||
static constexpr GameStringChar Heart = '{';
|
static constexpr GameStringChar Armour = '[';
|
||||||
static constexpr GameStringChar Armour = '[';
|
static constexpr GameStringChar Star = ']';
|
||||||
static constexpr GameStringChar Star = ']';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class GameTexts
|
class GameTexts {
|
||||||
{
|
using StringTable = std::unordered_map<GameStringKey, GameString>;
|
||||||
using StringTable = std::unordered_map<GameStringKey, GameString>;
|
StringTable m_strings;
|
||||||
StringTable m_strings;
|
|
||||||
public:
|
public:
|
||||||
|
void addText(const GameStringKey& id, GameString&& text) {
|
||||||
|
m_strings.emplace(id, text);
|
||||||
|
}
|
||||||
|
|
||||||
void addText(const GameStringKey& id, GameString&& text) {
|
GameString text(const GameStringKey& id) {
|
||||||
m_strings.emplace(id, text);
|
auto a = m_strings.find(id);
|
||||||
}
|
if (a != m_strings.end()) {
|
||||||
|
return a->second;
|
||||||
GameString text(const GameStringKey& id) {
|
}
|
||||||
auto a = m_strings.find(id);
|
return GameStringUtil::fromString("MISSING: " + id);
|
||||||
if( a != m_strings.end() ) {
|
}
|
||||||
return a->second;
|
|
||||||
}
|
|
||||||
return GameStringUtil::fromString("MISSING: " + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,32 +1,31 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __INSTANCEDATA_HPP__
|
#ifndef __INSTANCEDATA_HPP__
|
||||||
#define __INSTANCEDATA_HPP__
|
#define __INSTANCEDATA_HPP__
|
||||||
#include <string>
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct InstanceData
|
struct InstanceData {
|
||||||
{
|
/**
|
||||||
/**
|
* ID of the object this instance
|
||||||
* ID of the object this instance
|
*/
|
||||||
*/
|
int id;
|
||||||
int id;
|
/**
|
||||||
/**
|
* Model name
|
||||||
* Model name
|
*/
|
||||||
*/
|
std::string model;
|
||||||
std::string model;
|
/**
|
||||||
/**
|
* Instance position
|
||||||
* Instance position
|
*/
|
||||||
*/
|
glm::vec3 pos;
|
||||||
glm::vec3 pos;
|
/**
|
||||||
/**
|
* Instance scaleX
|
||||||
* Instance scaleX
|
*/
|
||||||
*/
|
glm::vec3 scale;
|
||||||
glm::vec3 scale;
|
/**
|
||||||
/**
|
* Instance rotation
|
||||||
* Instance rotation
|
*/
|
||||||
*/
|
glm::quat rot;
|
||||||
glm::quat rot;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,6 +1,10 @@
|
|||||||
#include "data/ObjectData.hpp"
|
#include "data/ObjectData.hpp"
|
||||||
|
|
||||||
const ObjectInformation::ObjectClass ObjectData::class_id = ObjectInformation::_class("OBJS");
|
const ObjectInformation::ObjectClass ObjectData::class_id =
|
||||||
const ObjectInformation::ObjectClass VehicleData::class_id = ObjectInformation::_class("CARS");
|
ObjectInformation::_class("OBJS");
|
||||||
const ObjectInformation::ObjectClass CharacterData::class_id = ObjectInformation::_class("PEDS");
|
const ObjectInformation::ObjectClass VehicleData::class_id =
|
||||||
const ObjectInformation::ObjectClass CutsceneObjectData::class_id = ObjectInformation::_class("HIER");
|
ObjectInformation::_class("CARS");
|
||||||
|
const ObjectInformation::ObjectClass CharacterData::class_id =
|
||||||
|
ObjectInformation::_class("PEDS");
|
||||||
|
const ObjectInformation::ObjectClass CutsceneObjectData::class_id =
|
||||||
|
ObjectInformation::_class("HIER");
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#ifndef __GLT_OBJECTDATA_HPP__
|
#ifndef __GLT_OBJECTDATA_HPP__
|
||||||
#define __GLT_OBJECTDATA_HPP__
|
#define __GLT_OBJECTDATA_HPP__
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
|
|
||||||
#include <data/PathData.hpp>
|
#include <data/PathData.hpp>
|
||||||
#ifdef RW_WINDOWS
|
#ifdef RW_WINDOWS
|
||||||
@ -17,21 +17,20 @@ typedef uint16_t ObjectID;
|
|||||||
/**
|
/**
|
||||||
* Stores basic information about an Object and it's real type.
|
* Stores basic information about an Object and it's real type.
|
||||||
*/
|
*/
|
||||||
struct ObjectInformation
|
struct ObjectInformation {
|
||||||
{
|
typedef size_t ObjectClass;
|
||||||
typedef size_t ObjectClass;
|
static ObjectClass _class(const std::string& name) {
|
||||||
static ObjectClass _class(const std::string& name)
|
return std::hash<std::string>()(name);
|
||||||
{
|
}
|
||||||
return std::hash<std::string>()(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectID ID;
|
ObjectID ID;
|
||||||
const ObjectClass class_type;
|
const ObjectClass class_type;
|
||||||
|
|
||||||
ObjectInformation(const ObjectClass type)
|
ObjectInformation(const ObjectClass type) : class_type(type) {
|
||||||
: class_type(type) { }
|
}
|
||||||
|
|
||||||
virtual ~ObjectInformation() { }
|
virtual ~ObjectInformation() {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<ObjectInformation> ObjectInformationPtr;
|
typedef std::shared_ptr<ObjectInformation> ObjectInformationPtr;
|
||||||
@ -39,35 +38,48 @@ typedef std::shared_ptr<ObjectInformation> ObjectInformationPtr;
|
|||||||
/**
|
/**
|
||||||
* Data used by Normal Objects
|
* Data used by Normal Objects
|
||||||
*/
|
*/
|
||||||
struct ObjectData : public ObjectInformation
|
struct ObjectData : public ObjectInformation {
|
||||||
{
|
static const ObjectClass class_id;
|
||||||
static const ObjectClass class_id;
|
|
||||||
|
|
||||||
ObjectData()
|
ObjectData() : ObjectInformation(_class("OBJS")) {
|
||||||
: ObjectInformation(_class("OBJS")) { }
|
}
|
||||||
|
|
||||||
std::string modelName;
|
std::string modelName;
|
||||||
std::string textureName;
|
std::string textureName;
|
||||||
uint8_t numClumps;
|
uint8_t numClumps;
|
||||||
float drawDistance[3];
|
float drawDistance[3];
|
||||||
int32_t flags;
|
int32_t flags;
|
||||||
bool LOD;
|
bool LOD;
|
||||||
|
|
||||||
short timeOn;
|
|
||||||
short timeOff;
|
|
||||||
|
|
||||||
enum {
|
short timeOn;
|
||||||
NORMAL_CULL = 1, /// Cull model if player doesn't look at it. Ignored in GTA 3.
|
short timeOff;
|
||||||
DO_NOT_FADE = 1 << 1, /// Do not fade the object when it is being loaded into or out of view.
|
|
||||||
DRAW_LAST = 1 << 2, /// Model is transparent. Render this object after all opaque objects, allowing transparencies of other objects to be visible through this object.
|
|
||||||
ADDITIVE = 1 << 3, /// Render with additive blending. Previous flag must be enabled too.
|
|
||||||
IS_SUBWAY = 1 << 4, /// Model is a tunnel, i.e. set the object as invisible unless the player enters cull zone flag 128. This flag works only with static models.
|
|
||||||
IGNORE_LIGHTING = 1 << 5, /// Don't use static lighting, we want dynamic if it's possible.
|
|
||||||
NO_ZBUFFER_WRITE = 1 << 6, /// Model is a shadow. Disable writing to z-buffer when rendering it, allowing transparencies of other objects, shadows, and lights to be visible through this object. (Not implemented in the PS2 version)
|
|
||||||
};
|
|
||||||
|
|
||||||
// Information loaded from PATH sections
|
enum {
|
||||||
std::vector<PathData> paths;
|
NORMAL_CULL =
|
||||||
|
1, /// Cull model if player doesn't look at it. Ignored in GTA 3.
|
||||||
|
DO_NOT_FADE = 1 << 1, /// Do not fade the object when it is being
|
||||||
|
/// loaded into or out of view.
|
||||||
|
DRAW_LAST = 1 << 2, /// Model is transparent. Render this object after
|
||||||
|
/// all opaque objects, allowing transparencies of
|
||||||
|
/// other objects to be visible through this
|
||||||
|
/// object.
|
||||||
|
ADDITIVE = 1 << 3, /// Render with additive blending. Previous flag
|
||||||
|
/// must be enabled too.
|
||||||
|
IS_SUBWAY = 1 << 4, /// Model is a tunnel, i.e. set the object as
|
||||||
|
/// invisible unless the player enters cull zone
|
||||||
|
/// flag 128. This flag works only with static
|
||||||
|
/// models.
|
||||||
|
IGNORE_LIGHTING = 1 << 5, /// Don't use static lighting, we want
|
||||||
|
/// dynamic if it's possible.
|
||||||
|
NO_ZBUFFER_WRITE =
|
||||||
|
1 << 6, /// Model is a shadow. Disable writing to z-buffer when
|
||||||
|
/// rendering it, allowing transparencies of other objects,
|
||||||
|
/// shadows, and lights to be visible through this object.
|
||||||
|
/// (Not implemented in the PS2 version)
|
||||||
|
};
|
||||||
|
|
||||||
|
// Information loaded from PATH sections
|
||||||
|
std::vector<PathData> paths;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<ObjectData> ObjectDataPtr;
|
typedef std::shared_ptr<ObjectData> ObjectDataPtr;
|
||||||
@ -75,116 +87,110 @@ typedef std::shared_ptr<ObjectData> ObjectDataPtr;
|
|||||||
/**
|
/**
|
||||||
* Data used by peds
|
* Data used by peds
|
||||||
*/
|
*/
|
||||||
struct CharacterData : public ObjectInformation
|
struct CharacterData : public ObjectInformation {
|
||||||
{
|
static const ObjectClass class_id;
|
||||||
static const ObjectClass class_id;
|
|
||||||
|
|
||||||
CharacterData()
|
CharacterData() : ObjectInformation(_class("PEDS")) {
|
||||||
: ObjectInformation(_class("PEDS")) { }
|
}
|
||||||
|
|
||||||
std::string modelName;
|
std::string modelName;
|
||||||
std::string textureName;
|
std::string textureName;
|
||||||
std::string type;
|
std::string type;
|
||||||
std::string behaviour;
|
std::string behaviour;
|
||||||
std::string animGroup;
|
std::string animGroup;
|
||||||
uint8_t driveMask;
|
uint8_t driveMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stores vehicle data loaded from item definition files.
|
* @brief Stores vehicle data loaded from item definition files.
|
||||||
*/
|
*/
|
||||||
struct VehicleData : public ObjectInformation
|
struct VehicleData : public ObjectInformation {
|
||||||
{
|
static const ObjectClass class_id;
|
||||||
static const ObjectClass class_id;
|
|
||||||
|
|
||||||
VehicleData()
|
VehicleData() : ObjectInformation(_class("CARS")) {
|
||||||
: ObjectInformation(_class("CARS")) { }
|
}
|
||||||
|
|
||||||
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 {
|
enum VehicleClass {
|
||||||
CAR,
|
IGNORE = 0,
|
||||||
BOAT,
|
NORMAL = 1,
|
||||||
TRAIN,
|
POORFAMILY = 1 << 1,
|
||||||
PLANE,
|
RICHFAMILY = 1 << 2,
|
||||||
HELI,
|
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,
|
||||||
|
};
|
||||||
|
|
||||||
std::string modelName;
|
enum VehicleType {
|
||||||
std::string textureName;
|
CAR,
|
||||||
VehicleType type;
|
BOAT,
|
||||||
std::string handlingID;
|
TRAIN,
|
||||||
std::string gameName;
|
PLANE,
|
||||||
VehicleClass classType;
|
HELI,
|
||||||
uint8_t frequency; // big enough int type?
|
};
|
||||||
uint8_t lvl; // big enough int type?
|
|
||||||
uint16_t comprules;
|
std::string modelName;
|
||||||
union { // big enough int types?
|
std::string textureName;
|
||||||
uint16_t wheelModelID; // used only when type == CAR
|
VehicleType type;
|
||||||
int16_t modelLOD; // used only when type == PLANE
|
std::string handlingID;
|
||||||
};
|
std::string gameName;
|
||||||
float wheelScale; // used only when type == CAR
|
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
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::shared_ptr<VehicleData> VehicleDataHandle;
|
typedef std::shared_ptr<VehicleData> VehicleDataHandle;
|
||||||
|
|
||||||
struct CutsceneObjectData : public ObjectInformation
|
struct CutsceneObjectData : public ObjectInformation {
|
||||||
{
|
static const ObjectClass class_id;
|
||||||
static const ObjectClass class_id;
|
|
||||||
|
|
||||||
CutsceneObjectData()
|
CutsceneObjectData() : ObjectInformation(_class("HIER")) {
|
||||||
: ObjectInformation(_class("HIER")) { }
|
}
|
||||||
|
|
||||||
std::string modelName;
|
std::string modelName;
|
||||||
std::string textureName;
|
std::string textureName;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is orthogonal to object class, it gives
|
* This is orthogonal to object class, it gives
|
||||||
* Instances different physical properties.
|
* Instances different physical properties.
|
||||||
*/
|
*/
|
||||||
struct DynamicObjectData
|
struct DynamicObjectData {
|
||||||
{
|
std::string modelName;
|
||||||
std::string modelName;
|
float mass; // Kg
|
||||||
float mass; // Kg
|
float turnMass; // Kg m^3
|
||||||
float turnMass; // Kg m^3
|
float airRes; // fraction
|
||||||
float airRes; // fraction
|
float elacticity; // "
|
||||||
float elacticity; // "
|
float bouancy;
|
||||||
float bouancy;
|
float uprootForce; // Force
|
||||||
float uprootForce; // Force
|
float collDamageMulti;
|
||||||
float collDamageMulti;
|
/*
|
||||||
/*
|
* 1: change model
|
||||||
* 1: change model
|
* 2: split model
|
||||||
* 2: split model
|
* 3: smash
|
||||||
* 3: smash
|
* 4: change and smash
|
||||||
* 4: change and smash
|
*/
|
||||||
*/
|
uint8_t collDamageFlags;
|
||||||
uint8_t collDamageFlags;
|
/*
|
||||||
/*
|
* 1: lampost
|
||||||
* 1: lampost
|
* 2: smallbox
|
||||||
* 2: smallbox
|
* 3: bigbox
|
||||||
* 3: bigbox
|
* 4: fencepart
|
||||||
* 4: fencepart
|
*/
|
||||||
*/
|
uint8_t collResponseFlags;
|
||||||
uint8_t collResponseFlags;
|
bool cameraAvoid;
|
||||||
bool cameraAvoid;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,41 +1,33 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef __GLT_PATHDATA_HPP__
|
#ifndef __GLT_PATHDATA_HPP__
|
||||||
#define __GLT_PATHDATA_HPP__
|
#define __GLT_PATHDATA_HPP__
|
||||||
|
#include <stdint.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdint.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct PathNode
|
struct PathNode {
|
||||||
{
|
enum NodeType {
|
||||||
enum NodeType
|
EMPTY = 0, /// These are ignored
|
||||||
{
|
EXTERNAL = 1, /// May join with other paths
|
||||||
EMPTY = 0, /// These are ignored
|
INTERNAL = 2 /// Internal to this path
|
||||||
EXTERNAL = 1, /// May join with other paths
|
};
|
||||||
INTERNAL = 2 /// Internal to this path
|
|
||||||
};
|
|
||||||
|
|
||||||
NodeType type;
|
NodeType type;
|
||||||
int32_t next;
|
int32_t next;
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
float size;
|
float size;
|
||||||
int other_thing;
|
int other_thing;
|
||||||
int other_thing2;
|
int other_thing2;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PathData
|
struct PathData {
|
||||||
{
|
enum PathType { PATH_PED, PATH_CAR };
|
||||||
enum PathType
|
|
||||||
{
|
|
||||||
PATH_PED,
|
|
||||||
PATH_CAR
|
|
||||||
};
|
|
||||||
|
|
||||||
PathType type;
|
PathType type;
|
||||||
uint16_t ID;
|
uint16_t ID;
|
||||||
std::string modelName;
|
std::string modelName;
|
||||||
std::vector<PathNode> nodes;
|
std::vector<PathNode> nodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,123 +1,100 @@
|
|||||||
#include <data/Skeleton.hpp>
|
|
||||||
#include <data/Model.hpp>
|
#include <data/Model.hpp>
|
||||||
|
#include <data/Skeleton.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
Skeleton::FrameTransform Skeleton::IdentityTransform = { glm::vec3(0.f), glm::quat() };
|
Skeleton::FrameTransform Skeleton::IdentityTransform = {glm::vec3(0.f),
|
||||||
Skeleton::FrameData Skeleton::IdentityData = { Skeleton::IdentityTransform, Skeleton::IdentityTransform, true };
|
glm::quat()};
|
||||||
|
Skeleton::FrameData Skeleton::IdentityData = {
|
||||||
|
Skeleton::IdentityTransform, Skeleton::IdentityTransform, true};
|
||||||
|
|
||||||
Skeleton::Skeleton()
|
Skeleton::Skeleton() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::setAllData(const Skeleton::FramesData& data)
|
void Skeleton::setAllData(const Skeleton::FramesData& data) {
|
||||||
{
|
framedata = data;
|
||||||
framedata = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Skeleton::FrameData& Skeleton::getData(unsigned int frameIdx) const
|
const Skeleton::FrameData& Skeleton::getData(unsigned int frameIdx) const {
|
||||||
{
|
auto fdit = framedata.find(frameIdx);
|
||||||
auto fdit = framedata.find(frameIdx);
|
if (fdit == framedata.end()) {
|
||||||
if( fdit == framedata.end() )
|
return Skeleton::IdentityData;
|
||||||
{
|
}
|
||||||
return Skeleton::IdentityData;
|
|
||||||
}
|
return fdit->second;
|
||||||
|
|
||||||
return fdit->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::setData(unsigned int frameIdx, const Skeleton::FrameData& data)
|
void Skeleton::setData(unsigned int frameIdx, const Skeleton::FrameData& data) {
|
||||||
{
|
framedata[frameIdx] = data;
|
||||||
framedata[frameIdx] = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::setEnabled(ModelFrame* frame, bool enabled)
|
void Skeleton::setEnabled(ModelFrame* frame, bool enabled) {
|
||||||
{
|
auto fdit = framedata.find(frame->getIndex());
|
||||||
auto fdit = framedata.find(frame->getIndex());
|
if (fdit != framedata.end()) {
|
||||||
if( fdit != framedata.end() )
|
fdit->second.enabled = enabled;
|
||||||
{
|
} else {
|
||||||
fdit->second.enabled = enabled;
|
FrameTransform tf{frame->getDefaultTranslation(),
|
||||||
}
|
glm::quat_cast(frame->getDefaultRotation())};
|
||||||
else
|
framedata.insert({frame->getIndex(), {tf, tf, enabled}});
|
||||||
{
|
}
|
||||||
FrameTransform tf { frame->getDefaultTranslation(), glm::quat_cast(frame->getDefaultRotation()) };
|
|
||||||
framedata.insert(
|
|
||||||
{frame->getIndex(),
|
|
||||||
{ tf, tf, enabled }
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::setEnabled(unsigned int frameIdx, bool enabled)
|
void Skeleton::setEnabled(unsigned int frameIdx, bool enabled) {
|
||||||
{
|
auto fdit = framedata.find(frameIdx);
|
||||||
auto fdit = framedata.find(frameIdx);
|
if (fdit == framedata.end()) {
|
||||||
if( fdit == framedata.end() )
|
framedata.insert({frameIdx,
|
||||||
{
|
{Skeleton::IdentityTransform,
|
||||||
framedata.insert(
|
Skeleton::IdentityTransform, enabled}});
|
||||||
{ frameIdx, { Skeleton::IdentityTransform, Skeleton::IdentityTransform, enabled } }
|
} else {
|
||||||
);
|
fdit->second.enabled = enabled;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
fdit->second.enabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Skeleton::FrameTransform& Skeleton::getInterpolated(unsigned int frameIdx) const
|
const Skeleton::FrameTransform& Skeleton::getInterpolated(
|
||||||
{
|
unsigned int frameIdx) const {
|
||||||
auto itit = interpolateddata.find(frameIdx);
|
auto itit = interpolateddata.find(frameIdx);
|
||||||
if( itit == interpolateddata.end() )
|
if (itit == interpolateddata.end()) {
|
||||||
{
|
return Skeleton::IdentityTransform;
|
||||||
return Skeleton::IdentityTransform;
|
}
|
||||||
}
|
|
||||||
|
return itit->second;
|
||||||
return itit->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::interpolate(float alpha)
|
void Skeleton::interpolate(float alpha) {
|
||||||
{
|
interpolateddata.clear();
|
||||||
interpolateddata.clear();
|
|
||||||
|
for (auto i = framedata.begin(); i != framedata.end(); ++i) {
|
||||||
for(auto i = framedata.begin(); i != framedata.end(); ++i)
|
auto& t2 = i->second.a.translation;
|
||||||
{
|
auto& t1 = i->second.b.translation;
|
||||||
auto& t2 = i->second.a.translation;
|
|
||||||
auto& t1 = i->second.b.translation;
|
auto& r2 = i->second.a.rotation;
|
||||||
|
auto& r1 = i->second.b.rotation;
|
||||||
auto& r2 = i->second.a.rotation;
|
|
||||||
auto& r1 = i->second.b.rotation;
|
interpolateddata.insert(
|
||||||
|
{i->first, {glm::mix(t1, t2, alpha), glm::slerp(r1, r2, alpha)}});
|
||||||
interpolateddata.insert({
|
}
|
||||||
i->first,
|
|
||||||
{ glm::mix(t1, t2, alpha), glm::slerp(r1, r2, alpha) }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 Skeleton::getMatrix(unsigned int frameIdx) const
|
glm::mat4 Skeleton::getMatrix(unsigned int frameIdx) const {
|
||||||
{
|
const FrameTransform& ft = getInterpolated(frameIdx);
|
||||||
const FrameTransform& ft = getInterpolated(frameIdx);
|
|
||||||
|
glm::mat4 m;
|
||||||
glm::mat4 m;
|
|
||||||
|
m = glm::translate(m, ft.translation);
|
||||||
m = glm::translate( m, ft.translation );
|
m = m * glm::mat4_cast(ft.rotation);
|
||||||
m = m * glm::mat4_cast( ft.rotation );
|
|
||||||
|
return m;
|
||||||
return m;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 Skeleton::getMatrix(ModelFrame* frame) const
|
glm::mat4 Skeleton::getMatrix(ModelFrame* frame) const {
|
||||||
{
|
auto itit = interpolateddata.find(frame->getIndex());
|
||||||
auto itit = interpolateddata.find(frame->getIndex());
|
if (itit != interpolateddata.end()) {
|
||||||
if( itit != interpolateddata.end() )
|
glm::mat4 m;
|
||||||
{
|
|
||||||
glm::mat4 m;
|
m = glm::translate(m, itit->second.translation);
|
||||||
|
m = m * glm::mat4_cast(itit->second.rotation);
|
||||||
m = glm::translate( m, itit->second.translation );
|
|
||||||
m = m * glm::mat4_cast( itit->second.rotation );
|
return m;
|
||||||
|
}
|
||||||
return m;
|
|
||||||
}
|
return frame->getTransform();
|
||||||
|
|
||||||
return frame->getTransform();
|
|
||||||
}
|
}
|
||||||
|
@ -9,56 +9,51 @@
|
|||||||
class ModelFrame;
|
class ModelFrame;
|
||||||
/**
|
/**
|
||||||
* Data class for additional frame transformation and meta data.
|
* Data class for additional frame transformation and meta data.
|
||||||
*
|
*
|
||||||
* Provides interfaces to modify and query the visibility of model frames,
|
* Provides interfaces to modify and query the visibility of model frames,
|
||||||
* as well as their transformation. Modified by Animator to animate models.
|
* as well as their transformation. Modified by Animator to animate models.
|
||||||
*/
|
*/
|
||||||
class Skeleton
|
class Skeleton {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
struct FrameTransform
|
struct FrameTransform {
|
||||||
{
|
glm::vec3 translation;
|
||||||
glm::vec3 translation;
|
glm::quat rotation;
|
||||||
glm::quat rotation;
|
};
|
||||||
};
|
|
||||||
|
static FrameTransform IdentityTransform;
|
||||||
static FrameTransform IdentityTransform;
|
|
||||||
|
struct FrameData {
|
||||||
struct FrameData
|
FrameTransform a;
|
||||||
{
|
FrameTransform b;
|
||||||
FrameTransform a;
|
bool enabled;
|
||||||
FrameTransform b;
|
};
|
||||||
bool enabled;
|
|
||||||
};
|
static FrameData IdentityData;
|
||||||
|
|
||||||
static FrameData IdentityData;
|
typedef std::map<unsigned int, FrameData> FramesData;
|
||||||
|
typedef std::map<unsigned int, FrameTransform> TransformData;
|
||||||
typedef std::map<unsigned int, FrameData> FramesData;
|
|
||||||
typedef std::map<unsigned int, FrameTransform> TransformData;
|
Skeleton();
|
||||||
|
|
||||||
Skeleton();
|
void setAllData(const FramesData& data);
|
||||||
|
|
||||||
void setAllData(const FramesData& data);
|
const FrameData& getData(unsigned int frameIdx) const;
|
||||||
|
|
||||||
const FrameData& getData(unsigned int frameIdx) const;
|
void setData(unsigned int frameIdx, const FrameData& data);
|
||||||
|
void setEnabled(ModelFrame* frame, bool enabled);
|
||||||
void setData(unsigned int frameIdx, const FrameData& data);
|
|
||||||
void setEnabled(ModelFrame* frame, bool enabled);
|
void setEnabled(unsigned int frameIdx, bool enabled);
|
||||||
|
|
||||||
void setEnabled(unsigned int frameIdx, bool enabled);
|
const FrameTransform& getInterpolated(unsigned int frameIdx) const;
|
||||||
|
|
||||||
const FrameTransform& getInterpolated(unsigned int frameIdx) const;
|
glm::mat4 getMatrix(unsigned int frameIdx) const;
|
||||||
|
glm::mat4 getMatrix(ModelFrame* frame) const;
|
||||||
glm::mat4 getMatrix(unsigned int frameIdx) const;
|
|
||||||
glm::mat4 getMatrix(ModelFrame* frame) const;
|
void interpolate(float alpha);
|
||||||
|
|
||||||
void interpolate(float alpha);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
FramesData framedata;
|
||||||
FramesData framedata;
|
TransformData interpolateddata;
|
||||||
TransformData interpolateddata;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -5,67 +5,57 @@
|
|||||||
/**
|
/**
|
||||||
* Stores information about where the game can generate vehicles.
|
* Stores information about where the game can generate vehicles.
|
||||||
*/
|
*/
|
||||||
struct VehicleGenerator
|
struct VehicleGenerator {
|
||||||
{
|
/// Script reference ID
|
||||||
/// Script reference ID
|
size_t generatorID;
|
||||||
size_t generatorID;
|
glm::vec3 position;
|
||||||
glm::vec3 position;
|
float heading;
|
||||||
float heading;
|
/// ID of the vehicle to spawn, or -1 for random.
|
||||||
/// ID of the vehicle to spawn, or -1 for random.
|
int vehicleID;
|
||||||
int vehicleID;
|
/// @todo not yet used
|
||||||
/// @todo not yet used
|
int colourFG;
|
||||||
int colourFG;
|
/// @todo not yet used
|
||||||
/// @todo not yet used
|
int colourBG;
|
||||||
int colourBG;
|
bool alwaysSpawn;
|
||||||
bool alwaysSpawn;
|
/// @todo not yet used
|
||||||
/// @todo not yet used
|
short alarmThreshold;
|
||||||
short alarmThreshold;
|
/// @todo not yet used
|
||||||
/// @todo not yet used
|
short lockedThreshold;
|
||||||
short lockedThreshold;
|
|
||||||
|
|
||||||
int minDelay;
|
int minDelay;
|
||||||
/// @todo not yet used
|
/// @todo not yet used
|
||||||
int maxDelay;
|
int maxDelay;
|
||||||
int lastSpawnTime;
|
int lastSpawnTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of vehicles left to spawn 0-100, 101 = never decrement.
|
* Number of vehicles left to spawn 0-100, 101 = never decrement.
|
||||||
* Intentionally disabled to match behaviour
|
* Intentionally disabled to match behaviour
|
||||||
*/
|
*/
|
||||||
int remainingSpawns;
|
int remainingSpawns;
|
||||||
|
|
||||||
VehicleGenerator(size_t id,
|
VehicleGenerator(size_t id, const glm::vec3& position_, float heading_,
|
||||||
const glm::vec3& position_,
|
int modelID_, int colourFG_, int colourBG_,
|
||||||
float heading_,
|
bool alwaysSpawn_, short alarmThreshold_,
|
||||||
int modelID_,
|
short lockedThreshold_, int minDelay_, int maxDelay_,
|
||||||
int colourFG_,
|
int lastSpawnTime_, int remainingSpawns_)
|
||||||
int colourBG_,
|
: generatorID(id)
|
||||||
bool alwaysSpawn_,
|
, position(position_)
|
||||||
short alarmThreshold_,
|
, heading(heading_)
|
||||||
short lockedThreshold_,
|
, vehicleID(modelID_)
|
||||||
int minDelay_,
|
, colourFG(colourFG_)
|
||||||
int maxDelay_,
|
, colourBG(colourBG_)
|
||||||
int lastSpawnTime_,
|
, alwaysSpawn(alwaysSpawn_)
|
||||||
int remainingSpawns_)
|
, alarmThreshold(alarmThreshold_)
|
||||||
: generatorID(id)
|
, lockedThreshold(lockedThreshold_)
|
||||||
, position(position_)
|
, minDelay(minDelay_)
|
||||||
, heading(heading_)
|
, maxDelay(maxDelay_)
|
||||||
, vehicleID(modelID_)
|
, lastSpawnTime(lastSpawnTime_)
|
||||||
, colourFG(colourFG_)
|
, remainingSpawns(remainingSpawns_) {
|
||||||
, colourBG(colourBG_)
|
}
|
||||||
, alwaysSpawn(alwaysSpawn_)
|
|
||||||
, alarmThreshold(alarmThreshold_)
|
|
||||||
, lockedThreshold(lockedThreshold_)
|
|
||||||
, minDelay(minDelay_)
|
|
||||||
, maxDelay(maxDelay_)
|
|
||||||
, lastSpawnTime(lastSpawnTime_)
|
|
||||||
, remainingSpawns(remainingSpawns_)
|
|
||||||
{}
|
|
||||||
|
|
||||||
int getScriptObjectID() const
|
int getScriptObjectID() const {
|
||||||
{
|
return generatorID;
|
||||||
return generatorID;
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,43 +1,38 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#ifndef _WEAPONDATA_HPP_
|
#ifndef _WEAPONDATA_HPP_
|
||||||
#define _WEAPONDATA_HPP_
|
#define _WEAPONDATA_HPP_
|
||||||
#include <string>
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct WeaponData
|
struct WeaponData {
|
||||||
{
|
enum FireType { MELEE, INSTANT_HIT, PROJECTILE };
|
||||||
enum FireType {
|
|
||||||
MELEE,
|
|
||||||
INSTANT_HIT,
|
|
||||||
PROJECTILE
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
FireType fireType;
|
FireType fireType;
|
||||||
float hitRange;
|
float hitRange;
|
||||||
int fireRate;
|
int fireRate;
|
||||||
int reloadMS;
|
int reloadMS;
|
||||||
int clipSize;
|
int clipSize;
|
||||||
int damage;
|
int damage;
|
||||||
float speed;
|
float speed;
|
||||||
float meleeRadius;
|
float meleeRadius;
|
||||||
float lifeSpan;
|
float lifeSpan;
|
||||||
float spread;
|
float spread;
|
||||||
glm::vec3 fireOffset;
|
glm::vec3 fireOffset;
|
||||||
std::string animation1;
|
std::string animation1;
|
||||||
std::string animation2;
|
std::string animation2;
|
||||||
float animLoopStart;
|
float animLoopStart;
|
||||||
float animLoopEnd;
|
float animLoopEnd;
|
||||||
float animFirePoint; /* Must be between 2 ^ */
|
float animFirePoint; /* Must be between 2 ^ */
|
||||||
float animCrouchLoopStart;
|
float animCrouchLoopStart;
|
||||||
float animCrouchLoopEnd;
|
float animCrouchLoopEnd;
|
||||||
float animCrouchFirePoint;
|
float animCrouchFirePoint;
|
||||||
float breakoutAnim;
|
float breakoutAnim;
|
||||||
int modelID;
|
int modelID;
|
||||||
std::uint32_t flags;
|
std::uint32_t flags;
|
||||||
|
|
||||||
int inventorySlot;
|
int inventorySlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,35 +40,44 @@ struct WeaponData
|
|||||||
*
|
*
|
||||||
* @todo RADIUS hitscans
|
* @todo RADIUS hitscans
|
||||||
*/
|
*/
|
||||||
struct WeaponScan
|
struct WeaponScan {
|
||||||
{
|
enum ScanType {
|
||||||
enum ScanType {
|
/** Instant-hit ray weapons */
|
||||||
/** Instant-hit ray weapons */
|
HITSCAN,
|
||||||
HITSCAN,
|
/** Area of effect attack */
|
||||||
/** Area of effect attack */
|
RADIUS,
|
||||||
RADIUS,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const ScanType type;
|
const ScanType type;
|
||||||
|
|
||||||
float damage;
|
float damage;
|
||||||
|
|
||||||
glm::vec3 center;
|
glm::vec3 center;
|
||||||
float radius;
|
float radius;
|
||||||
|
|
||||||
glm::vec3 end;
|
glm::vec3 end;
|
||||||
|
|
||||||
WeaponData* weapon;
|
WeaponData* weapon;
|
||||||
|
|
||||||
// Constructor for a RADIUS hitscan
|
// Constructor for a RADIUS hitscan
|
||||||
WeaponScan( float damage, const glm::vec3& center, float radius, WeaponData* weapon = nullptr )
|
WeaponScan(float damage, const glm::vec3& center, float radius,
|
||||||
: type(RADIUS), damage(damage), center(center), radius(radius), weapon(weapon)
|
WeaponData* weapon = nullptr)
|
||||||
{}
|
: type(RADIUS)
|
||||||
|
, damage(damage)
|
||||||
|
, center(center)
|
||||||
|
, radius(radius)
|
||||||
|
, weapon(weapon) {
|
||||||
|
}
|
||||||
|
|
||||||
// Constructor for a ray hitscan
|
// Constructor for a ray hitscan
|
||||||
WeaponScan( float damage, const glm::vec3& start, const glm::vec3& end, WeaponData* weapon = nullptr )
|
WeaponScan(float damage, const glm::vec3& start, const glm::vec3& end,
|
||||||
: type(HITSCAN), damage(damage), center(start), end(end), weapon(weapon)
|
WeaponData* weapon = nullptr)
|
||||||
{}
|
: type(HITSCAN)
|
||||||
|
, damage(damage)
|
||||||
|
, center(start)
|
||||||
|
, end(end)
|
||||||
|
, weapon(weapon) {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,57 +11,56 @@
|
|||||||
* \class Zone
|
* \class Zone
|
||||||
* A Zone entry
|
* A Zone entry
|
||||||
*/
|
*/
|
||||||
struct ZoneData
|
struct ZoneData {
|
||||||
{
|
/**
|
||||||
/**
|
* The name of the Zone (see .gxt)
|
||||||
* The name of the Zone (see .gxt)
|
*/
|
||||||
*/
|
std::string name;
|
||||||
std::string name;
|
|
||||||
|
int type;
|
||||||
int type;
|
|
||||||
|
/**
|
||||||
/**
|
* Bottom left of the Zone
|
||||||
* Bottom left of the Zone
|
*/
|
||||||
*/
|
glm::vec3 min;
|
||||||
glm::vec3 min;
|
|
||||||
|
/**
|
||||||
/**
|
* Top Right of the zone
|
||||||
* Top Right of the zone
|
*/
|
||||||
*/
|
glm::vec3 max;
|
||||||
glm::vec3 max;
|
|
||||||
|
/**
|
||||||
/**
|
* Island number
|
||||||
* Island number
|
*/
|
||||||
*/
|
int island;
|
||||||
int island;
|
|
||||||
|
/**
|
||||||
/**
|
* Text of the zone?
|
||||||
* Text of the zone?
|
*/
|
||||||
*/
|
std::string Text;
|
||||||
std::string Text;
|
|
||||||
|
/**
|
||||||
/**
|
* Gang spawn density for daytime (8:00-19:00)
|
||||||
* Gang spawn density for daytime (8:00-19:00)
|
*/
|
||||||
*/
|
unsigned int gangDensityDay[ZONE_GANG_COUNT];
|
||||||
unsigned int gangDensityDay[ZONE_GANG_COUNT];
|
|
||||||
|
/**
|
||||||
/**
|
* Gang spawn density for nighttime (19:00-8:00)
|
||||||
* Gang spawn density for nighttime (19:00-8:00)
|
*/
|
||||||
*/
|
unsigned int gangDensityNight[ZONE_GANG_COUNT];
|
||||||
unsigned int gangDensityNight[ZONE_GANG_COUNT];
|
|
||||||
|
/**
|
||||||
/**
|
* Gang car spawn density for daytime (8:00-19:00)
|
||||||
* Gang car spawn density for daytime (8:00-19:00)
|
*/
|
||||||
*/
|
unsigned int gangCarDensityDay[ZONE_GANG_COUNT];
|
||||||
unsigned int gangCarDensityDay[ZONE_GANG_COUNT];
|
|
||||||
|
/**
|
||||||
/**
|
* Gang car spawn density for nighttime (19:00-8:00)
|
||||||
* Gang car spawn density for nighttime (19:00-8:00)
|
*/
|
||||||
*/
|
unsigned int gangCarDensityNight[ZONE_GANG_COUNT];
|
||||||
unsigned int gangCarDensityNight[ZONE_GANG_COUNT];
|
|
||||||
|
unsigned int pedGroupDay;
|
||||||
unsigned int pedGroupDay;
|
unsigned int pedGroupNight;
|
||||||
unsigned int pedGroupNight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user