1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-18 16:32:32 +02:00

Added documentation

This commit is contained in:
Daniel Evans 2014-02-13 10:55:11 +00:00
parent 42c9480271
commit c5171eb673
8 changed files with 47 additions and 24 deletions

View File

@ -6,6 +6,9 @@
#include <vector> #include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
/**
* Data used by Object Instances
*/
struct ObjectData struct ObjectData
{ {
uint16_t ID; uint16_t ID;
@ -38,6 +41,9 @@ struct ObjectData
}; };
}; };
/**
* Data used by vehicles
*/
struct CarData struct CarData
{ {
enum VehicleClass enum VehicleClass
@ -83,6 +89,9 @@ struct CarData
float wheelScale; // used only when type == CAR float wheelScale; // used only when type == CAR
}; };
/**
* Data used by peds
*/
struct CharacterData struct CharacterData
{ {
uint16_t ID; uint16_t ID;

View File

@ -15,8 +15,7 @@ class Animator;
class GameWorld; class GameWorld;
/** /**
* @brief The GTAObject struct * Stores data used by call types of object instances.
* Stores data that is relevant to all types of objects.
*/ */
struct GTAObject struct GTAObject
{ {

View File

@ -5,6 +5,9 @@
#include <vector> #include <vector>
#include <glm/glm.hpp> #include <glm/glm.hpp>
/**
* Vehicle handling data
*/
struct VehicleHandlingInfo struct VehicleHandlingInfo
{ {
enum EngineType enum EngineType

View File

@ -4,6 +4,10 @@
#include <GL/glew.h> #include <GL/glew.h>
class GeometryBuffer; class GeometryBuffer;
/**
* DrawBuffer stores VAO state
*/
class DrawBuffer { class DrawBuffer {
GLuint vao; GLuint vao;

View File

@ -14,6 +14,12 @@ class GameWorld;
class GTAObject; class GTAObject;
class Animator; class Animator;
/**
* Renderer
*
* Handles low level rendering of Models, as well as high level rendering of
* objects in the world.
*/
class GTARenderer class GTARenderer
{ {
GameWorld* engine; GameWorld* engine;
@ -46,6 +52,7 @@ public:
size_t rendered; size_t rendered;
size_t culled; size_t culled;
/* TODO clean up all these variables */
GLint uniModel, uniProj, uniView, uniCol, uniAmbientCol, uniSunDirection, uniDynamicCol; GLint uniModel, uniProj, uniView, uniCol, uniAmbientCol, uniSunDirection, uniDynamicCol;
GLint uniMatDiffuse, uniMatAmbient, uniFogStart, uniFogEnd; GLint uniMatDiffuse, uniMatAmbient, uniFogStart, uniFogEnd;
GLuint worldProgram; GLuint worldProgram;
@ -59,7 +66,7 @@ public:
GLuint debugTex; GLuint debugTex;
/** /**
* @brief renderWorld renders the world. * Renders the current World.
*/ */
void renderWorld(); void renderWorld();
@ -67,10 +74,13 @@ public:
void renderGeometry(Model*, size_t geom, const glm::mat4& modelMatrix, GTAObject* = nullptr); void renderGeometry(Model*, size_t geom, const glm::mat4& modelMatrix, GTAObject* = nullptr);
/**
* Renders a model (who'd have thought)
*/
void renderModel(Model*, const glm::mat4& modelMatrix, GTAObject* = nullptr, Animator* animator = nullptr); void renderModel(Model*, const glm::mat4& modelMatrix, GTAObject* = nullptr, Animator* animator = nullptr);
/** /**
* @brief renderPaths renders the AI paths. * Debug method renders all AI paths
*/ */
void renderPaths(); void renderPaths();
}; };

View File

@ -27,6 +27,9 @@ struct AttributeIndex {
typedef std::vector<AttributeIndex> AttributeList; typedef std::vector<AttributeIndex> AttributeList;
/**
* GeometryBuffer stores a set of vertex attribute data
*/
class GeometryBuffer { class GeometryBuffer {
GLuint vbo; GLuint vbo;
GLsizei num; GLsizei num;
@ -42,6 +45,9 @@ public:
/** /**
* Uploads Vertex Buffer data from an STL vector * Uploads Vertex Buffer data from an STL vector
*
* vertex_attributes() is assumed to exist so that vertex types
* can implicitly declare the strides and offsets for their data.
*/ */
template<class T> void uploadVertices(const std::vector<T>& data) { template<class T> void uploadVertices(const std::vector<T>& data) {
uploadVertices(data.size(), data.size()*sizeof(T), data.data()); uploadVertices(data.size(), data.size()*sizeof(T), data.data());

View File

@ -11,17 +11,10 @@
#include "DrawBuffer.hpp" #include "DrawBuffer.hpp"
#include "GeometryBuffer.hpp" #include "GeometryBuffer.hpp"
/** /**
* Frame * ModelFrame stores the hierarchy of a model's geometry as well as default
* => Atomic * transformations.
* => Geometry */
* - defaultRotation
* - defaultTranslation
*
* + setTransform(mat)
* + resetTransform()
*/
class ModelFrame { class ModelFrame {
glm::mat3 defaultRotation; glm::mat3 defaultRotation;
glm::vec3 defaultTranslation; glm::vec3 defaultTranslation;
@ -65,6 +58,10 @@ public:
{ return geometries; } { return geometries; }
}; };
/**
* Model stores all the data contained within a DFF, as well as data required
* to render them.
*/
class Model class Model
{ {
public: public:
@ -108,6 +105,7 @@ public:
glm::vec2 texcoord; /* 48 */ glm::vec2 texcoord; /* 48 */
glm::vec4 colour; /* 64 */ glm::vec4 colour; /* 64 */
/** @see GeometryBuffer */
static const AttributeList vertex_attributes() { static const AttributeList vertex_attributes() {
return { return {
{ATRS_Position, 3, sizeof(GeometryVertex), 0ul}, {ATRS_Position, 3, sizeof(GeometryVertex), 0ul},
@ -145,9 +143,7 @@ public:
}; };
std::vector<ModelFrame*> frames; std::vector<ModelFrame*> frames;
/** @TODO clean up this mess a little */
std::vector<std::string> frameNames;
std::vector<std::shared_ptr<Geometry>> geometries; std::vector<std::shared_ptr<Geometry>> geometries;
std::vector<Atomic> atomics; std::vector<Atomic> atomics;

View File

@ -52,13 +52,9 @@ Model* LoaderDFF::loadFromMemory(char *data, GameData *gameData)
std::string framename(extSec.raw(), extSec.header.size); std::string framename(extSec.raw(), extSec.header.size);
std::transform(framename.begin(), framename.end(), framename.begin(), ::tolower ); std::transform(framename.begin(), framename.end(), framename.begin(), ::tolower );
// !HACK!
if(framename == "swaist") {
model->rootFrameIdx = model->frameNames.size();
}
if( fn < model->frames.size() ) { if( fn < model->frames.size() ) {
model->frames[(fn++)]->setName(framename); model->frames[fn]->setName(framename);
fn++;
} }
} }
} }