1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 10:22:52 +01:00

Rename Object classes and files

This commit is contained in:
Daniel Evans 2014-06-06 15:22:26 +01:00
parent 61931145fe
commit 439749e34f
26 changed files with 179 additions and 182 deletions

View File

@ -4,7 +4,6 @@ FILE(GLOB_RECURSE RENDERWARE_HEADERS "include/*.hpp")
source_group("Header Files" FILES ${RENDERWARE_HEADERS})
source_group("Source Files" FILES ${RENDERWARE_SOURCES})
add_library(rwengine
${RENDERWARE_SOURCES}
${RENDERWARE_HEADERS}

View File

@ -5,7 +5,7 @@
#include <glm/gtc/quaternion.hpp>
#include <data/PathData.hpp>
struct GTAInstance;
struct InstanceObject;
struct GTAAINode;
class AIGraph

View File

@ -5,8 +5,8 @@
#include <glm/gtc/quaternion.hpp>
#include <string>
struct GTACharacter;
struct GTAVehicle;
struct CharacterObject;
struct VehicleObject;
/**
* @class GTAAIController
@ -25,7 +25,7 @@ public:
virtual std::string name() const = 0;
virtual bool update(GTACharacter* character, GTAAIController* controller) = 0;
virtual bool update(CharacterObject* character, GTAAIController* controller) = 0;
};
protected:
@ -33,7 +33,7 @@ protected:
/**
* The character being controlled.
*/
GTACharacter* character;
CharacterObject* character;
Activity* _currentActivity;
Activity* _nextActivity;
@ -43,7 +43,7 @@ protected:
public:
GTAAIController(GTACharacter* character);
GTAAIController(CharacterObject* character);
Activity* getCurrentActivity() { return _currentActivity; }
@ -84,21 +84,21 @@ namespace Activities {
GoTo( const glm::vec3& target )
: target( target ) {}
bool update(GTACharacter* character, GTAAIController* controller);
bool update(CharacterObject* character, GTAAIController* controller);
};
struct EnterVehicle : public GTAAIController::Activity {
DECL_ACTIVITY( EnterVehicle )
GTAVehicle* vehicle;
VehicleObject* vehicle;
unsigned int seat;
bool entering;
EnterVehicle( GTAVehicle* vehicle, unsigned int seat = 0 )
EnterVehicle( VehicleObject* vehicle, unsigned int seat = 0 )
: vehicle( vehicle ), seat( seat ), entering(false) {}
bool update(GTACharacter *character, GTAAIController *controller);
bool update(CharacterObject *character, GTAAIController *controller);
};
struct ExitVehicle : public GTAAIController::Activity {
@ -107,7 +107,7 @@ namespace Activities {
ExitVehicle( )
{}
bool update(GTACharacter *character, GTAAIController *controller);
bool update(CharacterObject *character, GTAAIController *controller);
};
}

View File

@ -9,7 +9,7 @@ class GTADefaultAIController : public GTAAIController
{
public:
GTADefaultAIController(GTACharacter* character)
GTADefaultAIController(CharacterObject* character)
: GTAAIController(character) {}
glm::vec3 getTargetPosition();

View File

@ -17,7 +17,7 @@ class GTAPlayerAIController : public GTAAIController
public:
GTAPlayerAIController(GTACharacter* character);
GTAPlayerAIController(CharacterObject* character);
void setRunning(bool run);

View File

@ -11,9 +11,9 @@
class WorkContext;
class GameObject;
class GTACharacter;
class GTAInstance;
class GTAVehicle;
class CharacterObject;
class InstanceObject;
class VehicleObject;
#include <glm/glm.hpp>
@ -90,17 +90,17 @@ public:
/**
* Creates an instance
*/
GTAInstance *createInstance(const uint16_t id, const glm::vec3& pos, const glm::quat& rot = glm::quat());
InstanceObject *createInstance(const uint16_t id, const glm::vec3& pos, const glm::quat& rot = glm::quat());
/**
* Creates a vehicle
*/
GTAVehicle *createVehicle(const uint16_t id, const glm::vec3& pos, const glm::quat& rot = glm::quat());
VehicleObject *createVehicle(const uint16_t id, const glm::vec3& pos, const glm::quat& rot = glm::quat());
/**
* Creates a pedestrian.
*/
GTACharacter* createPedestrian(const uint16_t id, const glm::vec3& pos, const glm::quat& rot = glm::quat());
CharacterObject* createPedestrian(const uint16_t id, const glm::vec3& pos, const glm::quat& rot = glm::quat());
/**
* Destroys an existing Object
@ -160,22 +160,22 @@ public:
/**
* Game Objects!
*/
std::vector<std::shared_ptr<GTAInstance>> objectInstances;
std::vector<std::shared_ptr<InstanceObject>> objectInstances;
/**
* Map of Model Names to Instances
*/
std::map<std::string, std::shared_ptr<GTAInstance>> modelInstances;
std::map<std::string, std::shared_ptr<InstanceObject>> modelInstances;
/**
* Game Vehicles!
*/
std::vector<GTAVehicle*> vehicleInstances;
std::vector<VehicleObject*> vehicleInstances;
/**
* Pedestrians and PCs.
*/
std::vector<GTACharacter*> pedestrians;
std::vector<CharacterObject*> pedestrians;
/**
* AI Graph

View File

@ -7,7 +7,7 @@
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <glm/glm.hpp>
class GTAVehicle;
class VehicleObject;
class GameWorld;
struct AnimationGroup
@ -38,12 +38,12 @@ struct AnimationGroup
/**
* @brief The GTACharacter struct
* Stores data relating to an instance of a "pedestrian".
* Implements Character object behaviours.
*/
struct GTACharacter : public GameObject
struct CharacterObject : public GameObject
{
private:
GTAVehicle* currentVehicle;
VehicleObject* currentVehicle;
size_t currentSeat;
void createActor(const glm::vec3& size = glm::vec3(0.35f, 0.35f, 1.3f));
@ -90,9 +90,9 @@ public:
* @param model
* @param ped PEDS_t struct to use.
*/
GTACharacter(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, ModelHandle *model, std::shared_ptr<CharacterData> data);
CharacterObject(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, ModelHandle *model, std::shared_ptr<CharacterData> data);
~GTACharacter();
~CharacterObject();
Type type() { return Character; }
@ -113,11 +113,11 @@ public:
virtual glm::quat getRotation() const;
bool enterVehicle(GTAVehicle* vehicle, size_t seat);
bool enterVehicle(VehicleObject* vehicle, size_t seat);
GTAVehicle *getCurrentVehicle() const;
VehicleObject *getCurrentVehicle() const;
size_t getCurrentSeat() const;
void setCurrentVehicle(GTAVehicle *value, size_t seat);
void setCurrentVehicle(VehicleObject *value, size_t seat);
virtual bool takeDamage(const DamageInfo& damage);

View File

@ -1,26 +1,26 @@
#pragma once
#ifndef _GTAINSTANCE_HPP_
#define _GTAINSTANCE_HPP_
#ifndef _OBJECTINSTANCE_HPP_
#define _OBJECTINSTANCE_HPP_
#include <engine/GameObject.hpp>
/**
* @struct GTAInstance
* Stores references to the Object data and the instance
* @struct InstanceObject
* A simple object instance
*/
struct GTAInstance : public GameObject
struct InstanceObject : public GameObject
{
glm::vec3 scale;
std::shared_ptr<ObjectData> object;
std::shared_ptr<GTAInstance> LODinstance;
std::shared_ptr<InstanceObject> LODinstance;
GTAInstance(
InstanceObject(
GameWorld* engine,
const glm::vec3& pos,
const glm::quat& rot,
ModelHandle* model,
const glm::vec3& scale,
std::shared_ptr<ObjectData> obj,
std::shared_ptr<GTAInstance> lod
std::shared_ptr<InstanceObject> lod
);
Type type() { return Instance; }

View File

@ -1,16 +1,16 @@
#pragma once
#ifndef _GTAVEHICLE_HPP_
#define _GTAVEHICLE_HPP_
#ifndef _VEHICLEOBJECT_HPP_
#define _VEHICLEOBJECT_HPP_
#include <engine/GameObject.hpp>
#include <bullet/btBulletDynamicsCommon.h>
#include <map>
#include <objects/VehicleInfo.hpp>
/**
* @class GTAVehicle
* Stores references to the vehicle data and the instance
* @class VehicleObject
* Implements Vehicle behaviours.
*/
struct GTAVehicle : public GameObject
struct VehicleObject : public GameObject
{
public:
@ -49,7 +49,7 @@ public:
btVehicleRaycaster* physRaycaster;
btRaycastVehicle* physVehicle;
GTAVehicle(GameWorld* engine,
VehicleObject(GameWorld* engine,
const glm::vec3& pos,
const glm::quat& rot,
ModelHandle* model,
@ -58,7 +58,7 @@ public:
const glm::vec3& prim,
const glm::vec3& sec);
virtual ~GTAVehicle();
virtual ~VehicleObject();
void setPosition(const glm::vec3& pos);

View File

@ -1,5 +1,5 @@
#include "ai/AIGraph.hpp"
#include "objects/GTAInstance.hpp"
#include "objects/InstanceObject.hpp"
#include "ai/GTAAINode.hpp"
void AIGraph::createPathNodes(const glm::vec3& position, const glm::quat& rotation, PathData& path)
@ -47,4 +47,4 @@ void AIGraph::createPathNodes(const glm::vec3& position, const glm::quat& rotati
nodes[realNodes[path.nodes[pn].next]]->connections.push_back(node);
}
}
}
}

View File

@ -1,5 +1,6 @@
#include <ai/GTAAIController.hpp>
#include <objects/GTACharacter.hpp>
#include <objects/CharacterObject.hpp>
#include <objects/VehicleObject.hpp>
#include <engine/Animator.hpp>
bool GTAAIController::updateActivity()
@ -18,11 +19,11 @@ void GTAAIController::setActivity(GTAAIController::Activity* activity)
if( _currentActivity == nullptr ) {
// TODO make idle an actual activity or something,
character->clearTargetPosition();
character->enterAction( GTACharacter::Idle );
character->enterAction( CharacterObject::Idle );
}
}
GTAAIController::GTAAIController(GTACharacter* character)
GTAAIController::GTAAIController(CharacterObject* character)
: character(character), _currentActivity(nullptr), _nextActivity(nullptr)
{
character->controller = this;
@ -59,15 +60,13 @@ void GTAAIController::update(float dt)
}
}
bool Activities::GoTo::update(GTACharacter *character, GTAAIController *controller)
bool Activities::GoTo::update(CharacterObject *character, GTAAIController *controller)
{
/* TODO: Use the ai nodes to navigate to the position */
glm::vec3 targetDirection = target - character->getPosition();
if( glm::length(targetDirection) < 0.01f ) {
character->enterAction(GTACharacter::Idle);
character->enterAction(CharacterObject::Idle);
return true;
}
@ -75,21 +74,20 @@ bool Activities::GoTo::update(GTACharacter *character, GTAAIController *controll
glm::quat r( glm::vec3{ 0.f, 0.f, atan2(targetDirection.y, targetDirection.x) - glm::half_pi<float>() } );
character->rotation = r;
character->enterAction(GTACharacter::Walk);
character->enterAction(CharacterObject::Walk);
return false;
}
#include <objects/GTAVehicle.hpp>
bool Activities::EnterVehicle::update(GTACharacter *character, GTAAIController *controller)
bool Activities::EnterVehicle::update(CharacterObject *character, GTAAIController *controller)
{
if( entering ) {
// TODO: decouple from the character's animator.
if( character->currentActivity == GTACharacter::VehicleGetIn ) {
if( character->currentActivity == CharacterObject::VehicleGetIn ) {
character->enterVehicle(vehicle, seat);
}
else if( character->currentActivity == GTACharacter::VehicleOpen ) {
else if( character->currentActivity == CharacterObject::VehicleOpen ) {
// Ensure the player remains aligned with the vehicle
character->setPosition(vehicle->getSeatEntryPosition(seat));
character->rotation = vehicle->getRotation();
@ -110,7 +108,7 @@ bool Activities::EnterVehicle::update(GTACharacter *character, GTAAIController *
entering = true;
// Warp character to vehicle orientation
character->rotation = vehicle->getRotation();
character->enterAction(GTACharacter::VehicleOpen);
character->enterAction(CharacterObject::VehicleOpen);
}
else if( targetDistance > 15.f ) {
return true; // Give up if the vehicle is too far away.
@ -120,18 +118,18 @@ bool Activities::EnterVehicle::update(GTACharacter *character, GTAAIController *
glm::quat r( glm::vec3{ 0.f, 0.f, atan2(targetDirection.y, targetDirection.x) - glm::half_pi<float>() } );
character->rotation = r;
character->enterAction(GTACharacter::Walk);
character->enterAction(CharacterObject::Walk);
}
}
return false;
}
bool Activities::ExitVehicle::update(GTACharacter *character, GTAAIController *controller)
bool Activities::ExitVehicle::update(CharacterObject *character, GTAAIController *controller)
{
if( character->getCurrentVehicle() == nullptr ) return true;
if( character->currentActivity == GTACharacter::Idle ) {
if( character->currentActivity == CharacterObject::Idle ) {
auto vehicle = character->getCurrentVehicle();
auto exitpos = vehicle->getSeatEntryPosition(character->getCurrentSeat());
@ -141,6 +139,6 @@ bool Activities::ExitVehicle::update(GTACharacter *character, GTAAIController *c
return true;
}
character->enterAction(GTACharacter::VehicleGetOut);
character->enterAction(CharacterObject::VehicleGetOut);
return false;
}

View File

@ -1,5 +1,5 @@
#include "ai/GTADefaultAIController.hpp"
#include <objects/GTACharacter.hpp>
#include <objects/CharacterObject.hpp>
#include <engine/GameWorld.hpp>
glm::vec3 GTADefaultAIController::getTargetPosition()

View File

@ -1,10 +1,10 @@
#include "ai/GTAPlayerAIController.hpp"
#include <objects/GTACharacter.hpp>
#include <objects/GTAVehicle.hpp>
#include <objects/CharacterObject.hpp>
#include <objects/VehicleObject.hpp>
#include <engine/GameWorld.hpp>
#include <glm/gtc/matrix_transform.hpp>
GTAPlayerAIController::GTAPlayerAIController(GTACharacter* character)
GTAPlayerAIController::GTAPlayerAIController(CharacterObject* character)
: GTAAIController(character), lastRotation(glm::vec3(0.f, 0.f, 0.f)), running(false)
{
@ -37,7 +37,7 @@ void GTAPlayerAIController::enterNearestVehicle()
{
if(! character->getCurrentVehicle()) {
auto world = character->engine;
GTAVehicle* nearest = nullptr; float d = 10.f;
VehicleObject* nearest = nullptr; float d = 10.f;
for(auto it = world->vehicleInstances.begin(); it != world->vehicleInstances.end(); ++it) {
float vd = glm::length( character->getPosition() - (*it)->getPosition());
if( vd < d ) {
@ -60,13 +60,13 @@ void GTAPlayerAIController::update(float dt)
}
if( _currentActivity == nullptr ) {
if( character->currentActivity != GTACharacter::Jump )
if( character->currentActivity != CharacterObject::Jump )
{
if( glm::length(direction) > 0.001f ) {
character->enterAction(running ? GTACharacter::Run : GTACharacter::Walk);
character->enterAction(running ? CharacterObject::Run : CharacterObject::Walk);
}
else {
character->enterAction(GTACharacter::Idle);
character->enterAction(CharacterObject::Idle);
}
if( character->getCurrentVehicle() ) {

View File

@ -7,9 +7,9 @@
#include <WorkContext.hpp>
// 3 isn't enough to cause a factory.
#include <objects/GTACharacter.hpp>
#include <objects/GTAInstance.hpp>
#include <objects/GTAVehicle.hpp>
#include <objects/CharacterObject.hpp>
#include <objects/InstanceObject.hpp>
#include <objects/VehicleObject.hpp>
GameWorld::GameWorld(const std::string& path)
: gameTime(0.f), gameData(path), renderer(this), randomEngine(rand()),
@ -176,7 +176,7 @@ bool GameWorld::loadZone(const std::string& path)
return false;
}
GTAInstance *GameWorld::createInstance(const uint16_t id, const glm::vec3& pos, const glm::quat& rot)
InstanceObject *GameWorld::createInstance(const uint16_t id, const glm::vec3& pos, const glm::quat& rot)
{
auto oi = objectTypes.find(id);
if( oi != objectTypes.end()) {
@ -188,7 +188,7 @@ GTAInstance *GameWorld::createInstance(const uint16_t id, const glm::vec3& pos,
gameData.loadTXD(oi->second->textureName + ".txd", true);
}
auto instance = std::shared_ptr<GTAInstance>(new GTAInstance(
auto instance = std::shared_ptr<InstanceObject>(new InstanceObject(
this,
pos,
rot,
@ -212,7 +212,7 @@ GTAInstance *GameWorld::createInstance(const uint16_t id, const glm::vec3& pos,
return nullptr;
}
GTAVehicle *GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos, const glm::quat& rot)
VehicleObject *GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos, const glm::quat& rot)
{
auto vti = vehicleTypes.find(id);
if(vti != vehicleTypes.end()) {
@ -267,13 +267,13 @@ GTAVehicle *GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos, co
}
}
vehicleInstances.push_back(new GTAVehicle{ this, pos, rot, m, vti->second, info->second, prim, sec });
vehicleInstances.push_back(new VehicleObject{ this, pos, rot, m, vti->second, info->second, prim, sec });
return vehicleInstances.back();
}
return nullptr;
}
GTACharacter* GameWorld::createPedestrian(const uint16_t id, const glm::vec3 &pos, const glm::quat& rot)
CharacterObject* GameWorld::createPedestrian(const uint16_t id, const glm::vec3 &pos, const glm::quat& rot)
{
auto pti = pedestrianTypes.find(id);
if( pti != pedestrianTypes.end() ) {
@ -292,7 +292,7 @@ GTACharacter* GameWorld::createPedestrian(const uint16_t id, const glm::vec3 &po
ModelHandle* m = gameData.models[pt->modelName];
if(m != nullptr) {
auto ped = new GTACharacter( this, pos, rot, m, pt );
auto ped = new CharacterObject( this, pos, rot, m, pt );
pedestrians.push_back(ped);
new GTADefaultAIController(ped);
return ped;

View File

@ -1,13 +1,13 @@
#include <objects/GTACharacter.hpp>
#include <objects/CharacterObject.hpp>
#include <ai/GTAAIController.hpp>
#include <engine/GameWorld.hpp>
#include <engine/Animator.hpp>
#include <objects/GTAVehicle.hpp>
#include <objects/VehicleObject.hpp>
// TODO: make this not hardcoded
static glm::vec3 enter_offset(0.81756252f, 0.34800607f, -0.486281008f);
GTACharacter::GTACharacter(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, ModelHandle* model, std::shared_ptr<CharacterData> data)
CharacterObject::CharacterObject(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, ModelHandle* model, std::shared_ptr<CharacterData> data)
: GameObject(engine, pos, rot, model),
currentVehicle(nullptr), currentSeat(0),
_hasTargetPosition(false),
@ -42,19 +42,19 @@ GTACharacter::GTACharacter(GameWorld* engine, const glm::vec3& pos, const glm::q
}
}
GTACharacter::~GTACharacter()
CharacterObject::~CharacterObject()
{
destroyActor();
}
void GTACharacter::enterAction(GTACharacter::Action act)
void CharacterObject::enterAction(CharacterObject::Action act)
{
if(currentActivity != act) {
currentActivity = act;
}
}
void GTACharacter::createActor(const glm::vec3& size)
void CharacterObject::createActor(const glm::vec3& size)
{
if(physCharacter) {
destroyActor();
@ -81,7 +81,7 @@ void GTACharacter::createActor(const glm::vec3& size)
}
}
void GTACharacter::destroyActor()
void CharacterObject::destroyActor()
{
if(physCharacter) {
engine->dynamicsWorld->removeCollisionObject(physObject);
@ -94,7 +94,7 @@ void GTACharacter::destroyActor()
}
}
void GTACharacter::tick(float dt)
void CharacterObject::tick(float dt)
{
if(controller) {
controller->update(dt);
@ -179,7 +179,7 @@ void GTACharacter::tick(float dt)
}
}
void GTACharacter::updateCharacter(float dt)
void CharacterObject::updateCharacter(float dt)
{
if(physCharacter) {
// Check to see if the character should be knocked down.
@ -214,7 +214,7 @@ void GTACharacter::updateCharacter(float dt)
if(otherObject->getUserPointer()) {
GameObject* object = static_cast<GameObject*>(otherObject->getUserPointer());
if(object->type() == Vehicle) {
GTAVehicle* vehicle = static_cast<GTAVehicle*>(object);
VehicleObject* vehicle = static_cast<VehicleObject*>(object);
if(vehicle->physBody->getLinearVelocity().length() > 0.1f) {
enterAction(KnockedDown);
}
@ -225,11 +225,11 @@ void GTACharacter::updateCharacter(float dt)
}
}
if(currentActivity == GTACharacter::Jump)
if(currentActivity == CharacterObject::Jump)
{
if(physCharacter->onGround())
{
enterAction(GTACharacter::Idle);
enterAction(CharacterObject::Idle);
}
}
else
@ -271,14 +271,14 @@ void GTACharacter::updateCharacter(float dt)
}
}
void GTACharacter::setPosition(const glm::vec3& pos)
void CharacterObject::setPosition(const glm::vec3& pos)
{
btTransform& tf = physCharacter->getGhostObject()->getWorldTransform();
tf.setOrigin(btVector3(pos.x, pos.y, pos.z));
position = pos;
}
glm::vec3 GTACharacter::getPosition() const
glm::vec3 CharacterObject::getPosition() const
{
if(physCharacter) {
btVector3 Pos = physCharacter->getGhostObject()->getWorldTransform().getOrigin();
@ -301,7 +301,7 @@ glm::vec3 GTACharacter::getPosition() const
return position;
}
glm::quat GTACharacter::getRotation() const
glm::quat CharacterObject::getRotation() const
{
if(currentVehicle) {
return currentVehicle->getRotation();
@ -309,7 +309,7 @@ glm::quat GTACharacter::getRotation() const
return GameObject::getRotation();
}
bool GTACharacter::enterVehicle(GTAVehicle* vehicle, size_t seat)
bool CharacterObject::enterVehicle(VehicleObject* vehicle, size_t seat)
{
if(vehicle) {
// Check that the seat is free
@ -337,17 +337,17 @@ bool GTACharacter::enterVehicle(GTAVehicle* vehicle, size_t seat)
return false;
}
GTAVehicle *GTACharacter::getCurrentVehicle() const
VehicleObject *CharacterObject::getCurrentVehicle() const
{
return currentVehicle;
}
size_t GTACharacter::getCurrentSeat() const
size_t CharacterObject::getCurrentSeat() const
{
return currentSeat;
}
void GTACharacter::setCurrentVehicle(GTAVehicle *value, size_t seat)
void CharacterObject::setCurrentVehicle(VehicleObject *value, size_t seat)
{
currentVehicle = value;
currentSeat = seat;
@ -359,21 +359,21 @@ void GTACharacter::setCurrentVehicle(GTAVehicle *value, size_t seat)
}
}
bool GTACharacter::takeDamage(const GameObject::DamageInfo& dmg)
bool CharacterObject::takeDamage(const GameObject::DamageInfo& dmg)
{
mHealth -= dmg.hitpoints;
return true;
}
void GTACharacter::jump()
void CharacterObject::jump()
{
if( physCharacter ) {
physCharacter->jump();
enterAction(GTACharacter::Jump);
enterAction(CharacterObject::Jump);
}
}
void GTACharacter::resetToAINode()
void CharacterObject::resetToAINode()
{
auto nodes = engine->aigraph.nodes;
bool vehicleNode = !! getCurrentVehicle();
@ -403,18 +403,18 @@ void GTACharacter::resetToAINode()
}
}
void GTACharacter::setTargetPosition(const glm::vec3 &target)
void CharacterObject::setTargetPosition(const glm::vec3 &target)
{
_targetPosition = target;
_hasTargetPosition = true;
}
void GTACharacter::clearTargetPosition()
void CharacterObject::clearTargetPosition()
{
_hasTargetPosition = false;
}
bool GTACharacter::isAnimationFixed() const
bool CharacterObject::isAnimationFixed() const
{
// TODO probably get rid of how this works.
auto ca = animator->getAnimation();

View File

@ -1,14 +1,14 @@
#include <objects/GTAInstance.hpp>
#include <objects/InstanceObject.hpp>
#include <engine/GameWorld.hpp>
#include <data/CollisionModel.hpp>
GTAInstance::GTAInstance(GameWorld* engine,
InstanceObject::InstanceObject(GameWorld* engine,
const glm::vec3& pos,
const glm::quat& rot,
ModelHandle *model,
const glm::vec3& scale,
std::shared_ptr<ObjectData> obj,
std::shared_ptr<GTAInstance> lod
std::shared_ptr<InstanceObject> lod
)
: GameObject(engine, pos, rot, model), scale(scale), object(obj), LODinstance(lod)
{
@ -77,7 +77,7 @@ GTAInstance::GTAInstance(GameWorld* engine,
}
}
bool GTAInstance::takeDamage(const GameObject::DamageInfo& dmg)
bool InstanceObject::takeDamage(const GameObject::DamageInfo& dmg)
{
bool explodeOnHit = (object->flags&ObjectData::EXPLODEONHIT) == ObjectData::EXPLODEONHIT;
bool smash = (object->flags&ObjectData::SMASHABLE) == ObjectData::SMASHABLE;

View File

@ -1,12 +1,12 @@
#include <objects/GTAVehicle.hpp>
#include <objects/GTACharacter.hpp>
#include <objects/VehicleObject.hpp>
#include <objects/CharacterObject.hpp>
#include <engine/GameWorld.hpp>
#include <BulletDynamics/Vehicle/btRaycastVehicle.h>
#include <sys/stat.h>
#include <data/CollisionModel.hpp>
#include <render/Model.hpp>
GTAVehicle::GTAVehicle(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, ModelHandle* model, VehicleDataHandle data, VehicleInfoHandle info, const glm::vec3& prim, const glm::vec3& sec)
VehicleObject::VehicleObject(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, ModelHandle* model, VehicleDataHandle data, VehicleInfoHandle info, const glm::vec3& prim, const glm::vec3& sec)
: GameObject(engine, pos, rot, model),
steerAngle(0.f), throttle(0.f), brake(0.f), handbrake(false),
damageFlags(0), vehicle(data), info(info), colourPrimary(prim),
@ -102,7 +102,7 @@ GTAVehicle::GTAVehicle(GameWorld* engine, const glm::vec3& pos, const glm::quat&
}
}
GTAVehicle::~GTAVehicle()
VehicleObject::~VehicleObject()
{
engine->dynamicsWorld->removeRigidBody(physBody);
engine->dynamicsWorld->removeVehicle(physVehicle);
@ -113,7 +113,7 @@ GTAVehicle::~GTAVehicle()
ejectAll();
}
void GTAVehicle::setPosition(const glm::vec3& pos)
void VehicleObject::setPosition(const glm::vec3& pos)
{
GameObject::setPosition(pos);
if(physBody) {
@ -123,7 +123,7 @@ void GTAVehicle::setPosition(const glm::vec3& pos)
}
}
glm::vec3 GTAVehicle::getPosition() const
glm::vec3 VehicleObject::getPosition() const
{
if(physBody) {
btVector3 Pos = physBody->getWorldTransform().getOrigin();
@ -132,7 +132,7 @@ glm::vec3 GTAVehicle::getPosition() const
return position;
}
glm::quat GTAVehicle::getRotation() const
glm::quat VehicleObject::getRotation() const
{
if(physBody) {
btQuaternion rot = physBody->getWorldTransform().getRotation();
@ -141,7 +141,7 @@ glm::quat GTAVehicle::getRotation() const
return rotation;
}
void GTAVehicle::tick(float dt)
void VehicleObject::tick(float dt)
{
if(physVehicle) {
for(int w = 0; w < physVehicle->getNumWheels(); ++w) {
@ -165,53 +165,53 @@ void GTAVehicle::tick(float dt)
}
}
void GTAVehicle::setSteeringAngle(float a)
void VehicleObject::setSteeringAngle(float a)
{
steerAngle = a;
}
float GTAVehicle::getSteeringAngle() const
float VehicleObject::getSteeringAngle() const
{
return steerAngle;
}
void GTAVehicle::setThrottle(float t)
void VehicleObject::setThrottle(float t)
{
throttle = t;
}
float GTAVehicle::getThrottle() const
float VehicleObject::getThrottle() const
{
return throttle;
}
void GTAVehicle::setBraking(float b)
void VehicleObject::setBraking(float b)
{
brake = b;
}
float GTAVehicle::getBraking() const
float VehicleObject::getBraking() const
{
return brake;
}
void GTAVehicle::setHandbraking(bool hb)
void VehicleObject::setHandbraking(bool hb)
{
handbrake = hb;
}
bool GTAVehicle::getHandbraking() const
bool VehicleObject::getHandbraking() const
{
return handbrake;
}
void GTAVehicle::ejectAll()
void VehicleObject::ejectAll()
{
for(std::map<size_t, GameObject*>::iterator it = seatOccupants.begin();
it != seatOccupants.end();
) {
if(it->second->type() == GameObject::Character) {
GTACharacter* c = static_cast<GTACharacter*>(it->second);
CharacterObject* c = static_cast<CharacterObject*>(it->second);
c->setCurrentVehicle(nullptr, 0);
c->setPosition(getPosition());
}
@ -219,7 +219,7 @@ void GTAVehicle::ejectAll()
}
}
GameObject* GTAVehicle::getOccupant(size_t seat)
GameObject* VehicleObject::getOccupant(size_t seat)
{
auto it = seatOccupants.find(seat);
if( it != seatOccupants.end() ) {
@ -228,7 +228,7 @@ GameObject* GTAVehicle::getOccupant(size_t seat)
return nullptr;
}
void GTAVehicle::setOccupant(size_t seat, GameObject* occupant)
void VehicleObject::setOccupant(size_t seat, GameObject* occupant)
{
auto it = seatOccupants.find(seat);
if(occupant == nullptr) {
@ -243,13 +243,13 @@ void GTAVehicle::setOccupant(size_t seat, GameObject* occupant)
}
}
bool GTAVehicle::takeDamage(const GameObject::DamageInfo& dmg)
bool VehicleObject::takeDamage(const GameObject::DamageInfo& dmg)
{
mHealth -= dmg.hitpoints;
return true;
}
void GTAVehicle::setPartDamaged(unsigned int flag, bool damaged)
void VehicleObject::setPartDamaged(unsigned int flag, bool damaged)
{
if(damaged) {
damageFlags |= flag;
@ -261,23 +261,23 @@ void GTAVehicle::setPartDamaged(unsigned int flag, bool damaged)
unsigned int nameToDamageFlag(const std::string& name)
{
if(name.find("bonnet") != name.npos) return GTAVehicle::DF_Bonnet;
if(name.find("door_lf") != name.npos) return GTAVehicle::DF_Door_lf;
if(name.find("door_rf") != name.npos) return GTAVehicle::DF_Door_rf;
if(name.find("door_lr") != name.npos) return GTAVehicle::DF_Door_lr;
if(name.find("door_rr") != name.npos) return GTAVehicle::DF_Door_rr;
if(name.find("boot") != name.npos) return GTAVehicle::DF_Boot;
if(name.find("windscreen") != name.npos) return GTAVehicle::DF_Windscreen;
if(name.find("bump_front") != name.npos) return GTAVehicle::DF_Bump_front;
if(name.find("bump_rear") != name.npos) return GTAVehicle::DF_Bump_rear;
if(name.find("wing_lf") != name.npos) return GTAVehicle::DF_Wing_lf;
if(name.find("wing_rf") != name.npos) return GTAVehicle::DF_Wing_rf;
if(name.find("wing_lr") != name.npos) return GTAVehicle::DF_Wing_lr;
if(name.find("wing_rr") != name.npos) return GTAVehicle::DF_Wing_rr;
if(name.find("bonnet") != name.npos) return VehicleObject::DF_Bonnet;
if(name.find("door_lf") != name.npos) return VehicleObject::DF_Door_lf;
if(name.find("door_rf") != name.npos) return VehicleObject::DF_Door_rf;
if(name.find("door_lr") != name.npos) return VehicleObject::DF_Door_lr;
if(name.find("door_rr") != name.npos) return VehicleObject::DF_Door_rr;
if(name.find("boot") != name.npos) return VehicleObject::DF_Boot;
if(name.find("windscreen") != name.npos) return VehicleObject::DF_Windscreen;
if(name.find("bump_front") != name.npos) return VehicleObject::DF_Bump_front;
if(name.find("bump_rear") != name.npos) return VehicleObject::DF_Bump_rear;
if(name.find("wing_lf") != name.npos) return VehicleObject::DF_Wing_lf;
if(name.find("wing_rf") != name.npos) return VehicleObject::DF_Wing_rf;
if(name.find("wing_lr") != name.npos) return VehicleObject::DF_Wing_lr;
if(name.find("wing_rr") != name.npos) return VehicleObject::DF_Wing_rr;
return 0;
}
bool GTAVehicle::isFrameVisible(ModelFrame *frame) const
bool VehicleObject::isFrameVisible(ModelFrame *frame) const
{
auto& name = frame->getName();
bool isDam = name.find("_dam") != name.npos;
@ -287,7 +287,7 @@ bool GTAVehicle::isFrameVisible(ModelFrame *frame) const
if(isDam || isOk) {
unsigned int dft = nameToDamageFlag(name);
if(dft == GTAVehicle::DF_Door_lf) return false;
if(dft == VehicleObject::DF_Door_lf) return false;
if(isDam) {
return (damageFlags & dft) == dft;
}

View File

@ -4,9 +4,9 @@
#include <render/TextureAtlas.hpp>
#include <render/Model.hpp>
#include <objects/GTACharacter.hpp>
#include <objects/GTAInstance.hpp>
#include <objects/GTAVehicle.hpp>
#include <objects/CharacterObject.hpp>
#include <objects/InstanceObject.hpp>
#include <objects/VehicleObject.hpp>
#include <ai/GTAAIController.hpp>
#include <data/ObjectData.hpp>
@ -261,7 +261,7 @@ void GTARenderer::renderWorld(float alpha)
rendered = culled = 0;
for(size_t i = 0; i < engine->pedestrians.size(); ++i) {
GTACharacter* charac = engine->pedestrians[i];
CharacterObject* charac = engine->pedestrians[i];
glm::mat4 matrixModel;
@ -274,7 +274,7 @@ void GTARenderer::renderWorld(float alpha)
}
for(size_t i = 0; i < engine->objectInstances.size(); ++i) {
GTAInstance& inst = *engine->objectInstances[i];
InstanceObject& inst = *engine->objectInstances[i];
if(inst.object->timeOn != inst.object->timeOff) {
// Update rendering flags.
@ -322,7 +322,7 @@ void GTARenderer::renderWorld(float alpha)
}
for(size_t v = 0; v < engine->vehicleInstances.size(); ++v) {
GTAVehicle* inst = engine->vehicleInstances[v];
VehicleObject* inst = engine->vehicleInstances[v];
if(!inst->model)
{
@ -491,7 +491,7 @@ bool GTARenderer::renderSubgeometry(Model* model, size_t g, size_t sg, const glm
if( (model->geometries[g]->flags & RW::BSGeometry::ModuleMaterialColor) == RW::BSGeometry::ModuleMaterialColor) {
auto col = mat.colour;
if( object && object->type() == GameObject::Vehicle ) {
auto vehicle = static_cast<GTAVehicle*>(object);
auto vehicle = static_cast<VehicleObject*>(object);
if( (mat.flags&Model::MTF_PrimaryColour) != 0 ) {
glUniform4f(uniCol, vehicle->colourPrimary.r, vehicle->colourPrimary.g, vehicle->colourPrimary.b, 1.f);
}
@ -574,7 +574,7 @@ void GTARenderer::renderPaths()
for(size_t i = 0; i < engine->pedestrians.size(); ++i) {
GTACharacter* charac = engine->pedestrians[i];
CharacterObject* charac = engine->pedestrians[i];
if(charac->controller) {
carlines.push_back(charac->getPosition());

View File

@ -1,6 +1,6 @@
#include "debugstate.hpp"
#include "game.hpp"
#include <objects/GTACharacter.hpp>
#include <objects/CharacterObject.hpp>
DebugState::DebugState()
{

View File

@ -18,8 +18,8 @@ bool hitWorldRay(const glm::vec3& start, const glm::vec3& direction,
sf::Window& getWindow();
GameWorld* getWorld();
GTACharacter* getPlayerCharacter();
void setPlayerCharacter(GTACharacter* playerCharacter);
CharacterObject* getPlayerCharacter();
void setPlayerCharacter(CharacterObject* playerCharacter);
sf::Font& getFont();

View File

@ -2,8 +2,8 @@
#include "game.hpp"
#include "pausestate.hpp"
#include "debugstate.hpp"
#include <objects/GTACharacter.hpp>
#include <objects/GTAVehicle.hpp>
#include <objects/CharacterObject.hpp>
#include <objects/VehicleObject.hpp>
#include <render/Model.hpp>
IngameState::IngameState()

View File

@ -9,7 +9,7 @@
class IngameState : public State
{
GTAPlayerAIController* _player;
GTACharacter* _playerCharacter;
CharacterObject* _playerCharacter;
glm::vec2 _lookAngles;
glm::vec3 _movement;

View File

@ -5,8 +5,8 @@
#include <loaders/LoaderDFF.hpp>
#include <render/DebugDraw.hpp>
#include <render/Model.hpp>
#include <objects/GTACharacter.hpp>
#include <objects/GTAVehicle.hpp>
#include <objects/VehicleObject.hpp>
#include <objects/CharacterObject.hpp>
#include <ai/GTAAIController.hpp>
#include <glm/glm.hpp>
@ -30,7 +30,7 @@ constexpr int WIDTH = 800,
sf::RenderWindow window;
GameWorld* gta = nullptr;
GTACharacter* player = nullptr;
CharacterObject* player = nullptr;
DebugDraw* debugDrawer = nullptr;
@ -63,12 +63,12 @@ sf::Font& getFont()
return font;
}
void setPlayerCharacter(GTACharacter *playerCharacter)
void setPlayerCharacter(CharacterObject *playerCharacter)
{
player = playerCharacter;
}
GTACharacter* getPlayerCharacter()
CharacterObject* getPlayerCharacter()
{
return player;
}

View File

@ -1,6 +1,6 @@
#include <boost/test/unit_test.hpp>
#include <objects/GTACharacter.hpp>
#include <objects/GTAVehicle.hpp>
#include <objects/CharacterObject.hpp>
#include <objects/VehicleObject.hpp>
#include <ai/GTADefaultAIController.hpp>
#include "test_globals.hpp"
@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(test_activities)
delete controller;
}
{
GTAVehicle* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
BOOST_REQUIRE(vehicle != nullptr);
BOOST_REQUIRE(vehicle->model != nullptr);

View File

@ -1,6 +1,6 @@
#include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <objects/GTAInstance.hpp>
#include <objects/InstanceObject.hpp>
#include <engine/GameWorld.hpp>
BOOST_AUTO_TEST_SUITE(ObjectUnitTests)
@ -8,7 +8,7 @@ BOOST_AUTO_TEST_SUITE(ObjectUnitTests)
BOOST_AUTO_TEST_CASE(instance_test_damage)
{
std::shared_ptr<ObjectData> object(new ObjectData);
GTAInstance inst(Global::get().e,
InstanceObject inst(Global::get().e,
glm::vec3(0.f, 0.f, 0.f),
glm::quat(), nullptr,
glm::vec3(1.f),
@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(instance_test_damage)
BOOST_AUTO_TEST_CASE(instance_test_destroy)
{
std::shared_ptr<ObjectData> object(new ObjectData);
GTAInstance inst(Global::get().e,
InstanceObject inst(Global::get().e,
glm::vec3(0.f, 0.f, 0.f),
glm::quat(), nullptr,
glm::vec3(1.f),

View File

@ -1,13 +1,13 @@
#include <boost/test/unit_test.hpp>
#include "test_globals.hpp"
#include <objects/GTAVehicle.hpp>
#include <objects/VehicleObject.hpp>
#include <render/Model.hpp>
BOOST_AUTO_TEST_SUITE(VehicleTests)
BOOST_AUTO_TEST_CASE(test_create_vehicle)
{
GTAVehicle* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
BOOST_REQUIRE(vehicle != nullptr);
@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(test_create_vehicle)
BOOST_AUTO_TEST_CASE(vehicle_frame_flags)
{
GTAVehicle* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(), glm::quat());
BOOST_REQUIRE(vehicle != nullptr);
BOOST_REQUIRE(vehicle->model != nullptr);
@ -39,12 +39,12 @@ BOOST_AUTO_TEST_CASE(vehicle_frame_flags)
BOOST_CHECK(vehicle->isFrameVisible(bonnet_ok));
BOOST_CHECK(!vehicle->isFrameVisible(bonnet_dam));
vehicle->setPartDamaged(GTAVehicle::DF_Bonnet, true);
vehicle->setPartDamaged(VehicleObject::DF_Bonnet, true);
BOOST_CHECK(!vehicle->isFrameVisible(bonnet_ok));
BOOST_CHECK(vehicle->isFrameVisible(bonnet_dam));
vehicle->setPartDamaged(GTAVehicle::DF_Bonnet, false);
vehicle->setPartDamaged(VehicleObject::DF_Bonnet, false);
BOOST_CHECK(vehicle->isFrameVisible(bonnet_ok));
BOOST_CHECK(!vehicle->isFrameVisible(bonnet_dam));
@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(vehicle_frame_flags)
BOOST_AUTO_TEST_CASE(test_door_position)
{
GTAVehicle* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
VehicleObject* vehicle = Global::get().e->createVehicle(90u, glm::vec3(10.f, 0.f, 0.f), glm::quat());
BOOST_REQUIRE(vehicle != nullptr);