Rename Model -> Clump

This commit is contained in:
Daniel Evans 2017-01-03 14:18:06 +00:00
parent 66dd55620d
commit 8e4d73fca9
35 changed files with 127 additions and 128 deletions

View file

@ -1,6 +1,6 @@
#include <btBulletDynamicsCommon.h> #include <btBulletDynamicsCommon.h>
#include <ai/CharacterController.hpp> #include <ai/CharacterController.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <engine/Animator.hpp> #include <engine/Animator.hpp>
#include <engine/GameData.hpp> #include <engine/GameData.hpp>
#include <engine/GameWorld.hpp> #include <engine/GameWorld.hpp>

View file

@ -8,7 +8,7 @@
#include <vector> #include <vector>
#include <data/CollisionModel.hpp> #include <data/CollisionModel.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/PathData.hpp> #include <data/PathData.hpp>
#include <rw/defines.hpp> #include <rw/defines.hpp>
#ifdef RW_WINDOWS #ifdef RW_WINDOWS
@ -133,13 +133,13 @@ public:
} }
/// @todo change with librw /// @todo change with librw
void setAtomic(Model* model, int n, ModelFrame* atomic) { void setAtomic(Clump* model, int n, ModelFrame* atomic) {
model_ = model; model_ = model;
atomics_[n] = atomic; atomics_[n] = atomic;
} }
/// @todo remove this /// @todo remove this
Model* getModel() const { Clump* getModel() const {
return model_; return model_;
} }
@ -204,7 +204,7 @@ public:
}; };
private: private:
Model* model_ = nullptr; Clump* model_ = nullptr;
ModelFrame* atomics_[3] = {}; ModelFrame* atomics_[3] = {};
float loddistances_[3] = {}; float loddistances_[3] = {};
uint8_t numatomics_ = 0; uint8_t numatomics_ = 0;
@ -231,11 +231,11 @@ public:
ClumpModelInfo(ModelDataType type) : BaseModelInfo(type) { ClumpModelInfo(ModelDataType type) : BaseModelInfo(type) {
} }
void setModel(Model* model) { void setModel(Clump* model) {
model_ = model; model_ = model;
} }
Model* getModel() const { Clump* getModel() const {
return model_; return model_;
} }
@ -249,7 +249,7 @@ public:
} }
private: private:
Model* model_ = nullptr; Clump* model_ = nullptr;
}; };
/** /**

View file

@ -1,4 +1,4 @@
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>

View file

@ -1,10 +1,10 @@
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
#include <engine/Animator.hpp> #include <engine/Animator.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <loaders/LoaderDFF.hpp> #include <loaders/LoaderDFF.hpp>
Animator::Animator(Model* model, Skeleton* skeleton) Animator::Animator(Clump* model, Skeleton* skeleton)
: model(model), skeleton(skeleton) { : model(model), skeleton(skeleton) {
} }

View file

@ -8,7 +8,7 @@
#include <map> #include <map>
#include <rw/defines.hpp> #include <rw/defines.hpp>
class Model; class Clump;
class ModelFrame; class ModelFrame;
class Skeleton; class Skeleton;
@ -49,7 +49,7 @@ class Animator {
/** /**
* @brief model The model being animated. * @brief model The model being animated.
*/ */
Model* model; Clump* model;
/** /**
* @brief Skeleton instance. * @brief Skeleton instance.
@ -62,7 +62,7 @@ class Animator {
std::vector<AnimationState> animations; std::vector<AnimationState> animations;
public: public:
Animator(Model* model, Skeleton* skeleton); Animator(Clump* model, Skeleton* skeleton);
Animation* getAnimation(unsigned int slot) { Animation* getAnimation(unsigned int slot) {
if (slot < animations.size()) { if (slot < animations.size()) {

View file

@ -1,4 +1,4 @@
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/ModelData.hpp> #include <data/ModelData.hpp>
#include <data/WeaponData.hpp> #include <data/WeaponData.hpp>
#include <engine/GameData.hpp> #include <engine/GameData.hpp>
@ -363,7 +363,7 @@ void GameData::getNameAndLod(std::string& name, int& lod) {
} }
} }
Model* GameData::loadClump(const std::string& name) { Clump* GameData::loadClump(const std::string& name) {
auto file = index.openFile(name); auto file = index.openFile(name);
if (!file) { if (!file) {
logger->error("Data", "Failed to load model " + name); logger->error("Data", "Failed to load model " + name);

View file

@ -133,7 +133,7 @@ public:
/** /**
* Loads an archived model and returns it directly * Loads an archived model and returns it directly
*/ */
Model* loadClump(const std::string& name); Clump* loadClump(const std::string& name);
/** /**
* Loads a DFF and associates its atomics with models. * Loads a DFF and associates its atomics with models.

View file

@ -7,7 +7,7 @@
#include <BulletCollision/CollisionDispatch/btGhostObject.h> #include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <ai/DefaultAIController.hpp> #include <ai/DefaultAIController.hpp>
#include <ai/TrafficDirector.hpp> #include <ai/TrafficDirector.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/WeaponData.hpp> #include <data/WeaponData.hpp>
#include <loaders/LoaderIDE.hpp> #include <loaders/LoaderIDE.hpp>
#include <loaders/LoaderIPL.hpp> #include <loaders/LoaderIPL.hpp>

View file

@ -3,7 +3,7 @@
#include <objects/CutsceneObject.hpp> #include <objects/CutsceneObject.hpp>
CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos, CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos,
const glm::quat &rot, Model *model, const glm::quat &rot, Clump *model,
BaseModelInfo *modelinfo) BaseModelInfo *modelinfo)
: GameObject(engine, pos, rot, modelinfo) : GameObject(engine, pos, rot, modelinfo)
, _parent(nullptr) , _parent(nullptr)

View file

@ -12,7 +12,7 @@ class CutsceneObject : public GameObject {
public: public:
CutsceneObject(GameWorld* engine, const glm::vec3& pos, CutsceneObject(GameWorld* engine, const glm::vec3& pos,
const glm::quat& rot, Model* model, const glm::quat& rot, Clump* model,
BaseModelInfo* modelinfo); BaseModelInfo* modelinfo);
~CutsceneObject(); ~CutsceneObject();

View file

@ -2,7 +2,7 @@
#ifndef _GAMEOBJECT_HPP_ #ifndef _GAMEOBJECT_HPP_
#define _GAMEOBJECT_HPP_ #define _GAMEOBJECT_HPP_
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
#include <loaders/LoaderIDE.hpp> #include <loaders/LoaderIDE.hpp>
@ -33,7 +33,7 @@ class GameObject {
/** /**
* Model used for rendering * Model used for rendering
*/ */
Model* model_; Clump* model_;
protected: protected:
void changeModelInfo(BaseModelInfo* next) { void changeModelInfo(BaseModelInfo* next) {
@ -106,14 +106,14 @@ public:
/** /**
* @return The model used in rendering * @return The model used in rendering
*/ */
Model* getModel() const { Clump* getModel() const {
return model_; return model_;
} }
/** /**
* Changes the current model, used for re-dressing chars * Changes the current model, used for re-dressing chars
*/ */
void setModel(Model* model) { void setModel(Clump* model) {
model_ = model; model_ = model;
} }

View file

@ -1,6 +1,6 @@
#include <BulletDynamics/Vehicle/btRaycastVehicle.h> #include <BulletDynamics/Vehicle/btRaycastVehicle.h>
#include <data/CollisionModel.hpp> #include <data/CollisionModel.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
#include <dynamics/CollisionInstance.hpp> #include <dynamics/CollisionInstance.hpp>
#include <dynamics/RaycastCallbacks.hpp> #include <dynamics/RaycastCallbacks.hpp>

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <LinearMath/btIDebugDraw.h> #include <LinearMath/btIDebugDraw.h>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <render/GameRenderer.hpp> #include <render/GameRenderer.hpp>
class DebugDraw : public btIDebugDraw { class DebugDraw : public btIDebugDraw {
@ -28,7 +28,7 @@ public:
protected: protected:
int debugMode; int debugMode;
std::vector<Model::GeometryVertex> lines; std::vector<Clump::GeometryVertex> lines;
size_t maxlines; size_t maxlines;
GeometryBuffer *lineBuff; GeometryBuffer *lineBuff;
DrawBuffer *dbuff; DrawBuffer *dbuff;

View file

@ -1,4 +1,4 @@
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <engine/Animator.hpp> #include <engine/Animator.hpp>
#include <engine/GameState.hpp> #include <engine/GameState.hpp>
#include <engine/GameWorld.hpp> #include <engine/GameWorld.hpp>
@ -475,11 +475,11 @@ void GameRenderer::renderPostProcess() {
renderer->drawArrays(glm::mat4(), &ssRectDraw, wdp); renderer->drawArrays(glm::mat4(), &ssRectDraw, wdp);
} }
void GameRenderer::renderGeometry(Model* model, size_t g, void GameRenderer::renderGeometry(Clump* model, size_t g,
const glm::mat4& modelMatrix, float opacity, const glm::mat4& modelMatrix, float opacity,
GameObject* object) { GameObject* object) {
for (size_t sg = 0; sg < model->geometries[g]->subgeom.size(); ++sg) { for (size_t sg = 0; sg < model->geometries[g]->subgeom.size(); ++sg) {
Model::SubGeometry& subgeom = model->geometries[g]->subgeom[sg]; Clump::SubGeometry& subgeom = model->geometries[g]->subgeom[sg];
Renderer::DrawParameters dp; Renderer::DrawParameters dp;
@ -489,7 +489,7 @@ void GameRenderer::renderGeometry(Model* model, size_t g,
dp.textures = {0}; dp.textures = {0};
if (model->geometries[g]->materials.size() > subgeom.material) { if (model->geometries[g]->materials.size() > subgeom.material) {
Model::Material& mat = Clump::Material& mat =
model->geometries[g]->materials[subgeom.material]; model->geometries[g]->materials[subgeom.material];
if (mat.textures.size() > 0) { if (mat.textures.size() > 0) {
@ -656,7 +656,7 @@ void GameRenderer::drawColour(const glm::vec4& colour, glm::vec4 extents) {
renderer->invalidate(); renderer->invalidate();
} }
bool GameRenderer::renderFrame(Model* m, ModelFrame* f, const glm::mat4& matrix, bool GameRenderer::renderFrame(Clump* m, ModelFrame* f, const glm::mat4& matrix,
GameObject* object, float opacity, GameObject* object, float opacity,
bool queueTransparent) { bool queueTransparent) {
auto localmatrix = matrix; auto localmatrix = matrix;
@ -693,7 +693,7 @@ bool GameRenderer::renderFrame(Model* m, ModelFrame* f, const glm::mat4& matrix,
return true; return true;
} }
void GameRenderer::renderModel(Model* model, const glm::mat4& modelMatrix, void GameRenderer::renderModel(Clump* model, const glm::mat4& modelMatrix,
GameObject* object) { GameObject* object) {
renderFrame(model, model->frames[model->rootFrameIdx], modelMatrix, object, renderFrame(model, model->frames[model->rootFrameIdx], modelMatrix, object,
1.f); 1.f);

View file

@ -16,7 +16,7 @@ class Logger;
#include "TextRenderer.hpp" #include "TextRenderer.hpp"
#include "WaterRenderer.hpp" #include "WaterRenderer.hpp"
class Model; class Clump;
class ModelFrame; class ModelFrame;
class GameWorld; class GameWorld;
class GameObject; class GameObject;
@ -53,7 +53,7 @@ class GameRenderer {
/** Stores data for deferring transparent objects */ /** Stores data for deferring transparent objects */
struct RQueueEntry { struct RQueueEntry {
Model* model; Clump* model;
size_t g; size_t g;
size_t sg; size_t sg;
glm::mat4 matrix; glm::mat4 matrix;
@ -71,7 +71,7 @@ class GameRenderer {
* materials * materials
* @return True if the frame was drawn, false if it should be queued * @return True if the frame was drawn, false if it should be queued
*/ */
bool renderFrame(Model* m, ModelFrame* f, const glm::mat4& matrix, bool renderFrame(Clump* m, ModelFrame* f, const glm::mat4& matrix,
GameObject* object, float opacity, GameObject* object, float opacity,
bool queueTransparent = true); bool queueTransparent = true);
@ -158,10 +158,10 @@ public:
/** /**
* Renders a model (who'd have thought) * Renders a model (who'd have thought)
*/ */
void renderModel(Model*, const glm::mat4& modelMatrix, void renderModel(Clump*, const glm::mat4& modelMatrix,
GameObject* = nullptr); GameObject* = nullptr);
void renderGeometry(Model*, size_t geom, const glm::mat4& modelMatrix, void renderGeometry(Clump*, size_t geom, const glm::mat4& modelMatrix,
float opacity, GameObject* = nullptr); float opacity, GameObject* = nullptr);
/** method for rendering AI debug information */ /** method for rendering AI debug information */
@ -207,15 +207,15 @@ public:
* *
* GameRenderer will take ownership of the Model* pointer * GameRenderer will take ownership of the Model* pointer
*/ */
void setSpecialModel(SpecialModel usage, Model* model) { void setSpecialModel(SpecialModel usage, Clump* model) {
specialmodels_[usage].reset(model); specialmodels_[usage].reset(model);
} }
private: private:
/// Hard-coded models to use for each of the special models /// Hard-coded models to use for each of the special models
std::unique_ptr<Model> std::unique_ptr<Clump>
specialmodels_[SpecialModel::SpecialModelCount]; specialmodels_[SpecialModel::SpecialModelCount];
Model* getSpecialModel(SpecialModel usage) const { Clump* getSpecialModel(SpecialModel usage) const {
return specialmodels_[usage].get(); return specialmodels_[usage].get();
} }
}; };

View file

@ -1,5 +1,5 @@
#include <data/CutsceneData.hpp> #include <data/CutsceneData.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
#include <engine/GameData.hpp> #include <engine/GameData.hpp>
#include <engine/GameState.hpp> #include <engine/GameState.hpp>
@ -33,11 +33,11 @@ RenderKey createKey(bool transparent, float normalizedDepth,
uint8_t(0xFF & (textures.size() > 0 ? textures[0] : 0)) << 0; uint8_t(0xFF & (textures.size() > 0 ? textures[0] : 0)) << 0;
} }
void ObjectRenderer::renderGeometry(Model* model, size_t g, void ObjectRenderer::renderGeometry(Clump* model, size_t g,
const glm::mat4& modelMatrix, float opacity, const glm::mat4& modelMatrix, float opacity,
GameObject* object, RenderList& outList) { GameObject* object, RenderList& outList) {
for (size_t sg = 0; sg < model->geometries[g]->subgeom.size(); ++sg) { for (size_t sg = 0; sg < model->geometries[g]->subgeom.size(); ++sg) {
Model::SubGeometry& subgeom = model->geometries[g]->subgeom[sg]; Clump::SubGeometry& subgeom = model->geometries[g]->subgeom[sg];
bool isTransparent = false; bool isTransparent = false;
@ -56,7 +56,7 @@ void ObjectRenderer::renderGeometry(Model* model, size_t g,
} }
if (model->geometries[g]->materials.size() > subgeom.material) { if (model->geometries[g]->materials.size() > subgeom.material) {
Model::Material& mat = Clump::Material& mat =
model->geometries[g]->materials[subgeom.material]; model->geometries[g]->materials[subgeom.material];
if (mat.textures.size() > 0) { if (mat.textures.size() > 0) {
@ -107,7 +107,7 @@ void ObjectRenderer::renderGeometry(Model* model, size_t g,
&model->geometries[g]->dbuff, dp); &model->geometries[g]->dbuff, dp);
} }
} }
bool ObjectRenderer::renderFrame(Model* m, ModelFrame* f, bool ObjectRenderer::renderFrame(Clump* m, ModelFrame* f,
const glm::mat4& matrix, GameObject* object, const glm::mat4& matrix, GameObject* object,
float opacity, RenderList& outList) { float opacity, RenderList& outList) {
auto localmatrix = matrix; auto localmatrix = matrix;
@ -175,12 +175,12 @@ void ObjectRenderer::renderInstance(InstanceObject* instance,
instance->getModel()->getBoundingRadius(); instance->getModel()->getBoundingRadius();
mindist *= 1.f / kDrawDistanceFactor; mindist *= 1.f / kDrawDistanceFactor;
Model* model = nullptr; Clump* model = nullptr;
ModelFrame* frame = nullptr; ModelFrame* frame = nullptr;
// These are used to gracefully fade out things that are just out of view // These are used to gracefully fade out things that are just out of view
// distance. // distance.
Model* fadingModel = nullptr; Clump* fadingModel = nullptr;
ModelFrame* fadingFrame = nullptr; ModelFrame* fadingFrame = nullptr;
auto fadingMatrix = matrixModel; auto fadingMatrix = matrixModel;
float opacity = 0.f; float opacity = 0.f;

View file

@ -37,10 +37,10 @@ public:
size_t culled; size_t culled;
void buildRenderList(GameObject* object, RenderList& outList); void buildRenderList(GameObject* object, RenderList& outList);
bool renderFrame(Model* m, ModelFrame* f, const glm::mat4& matrix, bool renderFrame(Clump* m, ModelFrame* f, const glm::mat4& matrix,
GameObject* object, float opacity, RenderList& outList); GameObject* object, float opacity, RenderList& outList);
void renderGeometry(Model* model, size_t g, const glm::mat4& modelMatrix, void renderGeometry(Clump* model, size_t g, const glm::mat4& modelMatrix,
float opacity, GameObject* object, RenderList& outList); float opacity, GameObject* object, RenderList& outList);
private: private:

View file

@ -6,7 +6,7 @@
#include <ai/PlayerController.hpp> #include <ai/PlayerController.hpp>
#include <data/CutsceneData.hpp> #include <data/CutsceneData.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/WeaponData.hpp> #include <data/WeaponData.hpp>
#include <dynamics/CollisionInstance.hpp> #include <dynamics/CollisionInstance.hpp>
#include <dynamics/RaycastCallbacks.hpp> #include <dynamics/RaycastCallbacks.hpp>

View file

@ -23,8 +23,8 @@ SET(RWLIB_SOURCES
"source/platform/FileIndex.hpp" "source/platform/FileIndex.hpp"
"source/platform/FileIndex.cpp" "source/platform/FileIndex.cpp"
"source/data/Model.hpp" "source/data/Clump.hpp"
"source/data/Model.cpp" "source/data/Clump.cpp"
"source/loaders/LoaderIMG.hpp" "source/loaders/LoaderIMG.hpp"
"source/loaders/LoaderIMG.cpp" "source/loaders/LoaderIMG.cpp"

View file

@ -1,12 +1,12 @@
#include "data/Model.hpp" #include "data/Clump.hpp"
#include <iostream> #include <iostream>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
Model::Geometry::Geometry() : flags(0) { Clump::Geometry::Geometry() : flags(0) {
} }
Model::Geometry::~Geometry() { Clump::Geometry::~Geometry() {
} }
ModelFrame::ModelFrame(unsigned int index, ModelFrame* parent, glm::mat3 dR, ModelFrame::ModelFrame(unsigned int index, ModelFrame* parent, glm::mat3 dR,
@ -30,13 +30,13 @@ void ModelFrame::addGeometry(size_t idx) {
geometries.push_back(idx); geometries.push_back(idx);
} }
Model::~Model() { Clump::~Clump() {
for (auto mf : frames) { for (auto mf : frames) {
delete mf; delete mf;
} }
} }
void Model::recalculateMetrics() { void Clump::recalculateMetrics() {
boundingRadius = std::numeric_limits<float>::min(); boundingRadius = std::numeric_limits<float>::min();
for (size_t g = 0; g < geometries.size(); g++) { for (size_t g = 0; g < geometries.size(); g++) {
RW::BSGeometryBounds& bounds = geometries[g]->geometryBounds; RW::BSGeometryBounds& bounds = geometries[g]->geometryBounds;

View file

@ -76,10 +76,9 @@ public:
}; };
/** /**
* Model stores all the data contained within a DFF, as well as data required * A clump is a collection of Frames and Atomics
* to render them.
*/ */
class Model { class Clump {
public: public:
enum FaceType { Triangles = 0, TriangleStrip = 1 }; enum FaceType { Triangles = 0, TriangleStrip = 1 };
@ -167,7 +166,7 @@ public:
return fit != frames.end() ? *fit : nullptr; return fit != frames.end() ? *fit : nullptr;
} }
~Model(); ~Clump();
void recalculateMetrics(); void recalculateMetrics();

View file

@ -1,4 +1,4 @@
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <loaders/LoaderDFF.hpp> #include <loaders/LoaderDFF.hpp>
#include <algorithm> #include <algorithm>
@ -40,7 +40,7 @@ struct RWBSFrame {
uint32_t matrixflags; // Not used uint32_t matrixflags; // Not used
}; };
void LoaderDFF::readFrameList(Model *model, const RWBStream &stream) { void LoaderDFF::readFrameList(Clump *model, const RWBStream &stream) {
auto listStream = stream.getInnerStream(); auto listStream = stream.getInnerStream();
auto listStructID = listStream.getNextChunk(); auto listStructID = listStream.getNextChunk();
@ -102,7 +102,7 @@ void LoaderDFF::readFrameList(Model *model, const RWBStream &stream) {
} }
} }
void LoaderDFF::readGeometryList(Model *model, const RWBStream &stream) { void LoaderDFF::readGeometryList(Clump *model, const RWBStream &stream) {
auto listStream = stream.getInnerStream(); auto listStream = stream.getInnerStream();
auto listStructID = listStream.getNextChunk(); auto listStructID = listStream.getNextChunk();
@ -129,7 +129,7 @@ void LoaderDFF::readGeometryList(Model *model, const RWBStream &stream) {
} }
} }
void LoaderDFF::readGeometry(Model *model, const RWBStream &stream) { void LoaderDFF::readGeometry(Clump *model, const RWBStream &stream) {
auto geomStream = stream.getInnerStream(); auto geomStream = stream.getInnerStream();
auto geomStructID = geomStream.getNextChunk(); auto geomStructID = geomStream.getNextChunk();
@ -137,7 +137,7 @@ void LoaderDFF::readGeometry(Model *model, const RWBStream &stream) {
throw DFFLoaderException("Geometry missing struct chunk"); throw DFFLoaderException("Geometry missing struct chunk");
} }
std::shared_ptr<Model::Geometry> geom(new Model::Geometry); std::shared_ptr<Clump::Geometry> geom(new Clump::Geometry);
char *headerPtr = geomStream.getCursor(); char *headerPtr = geomStream.getCursor();
@ -156,7 +156,7 @@ void LoaderDFF::readGeometry(Model *model, const RWBStream &stream) {
/*unsigned int numFrames = *(std::uint32_t*)headerPtr;*/ /*unsigned int numFrames = *(std::uint32_t*)headerPtr;*/
headerPtr += sizeof(std::uint32_t); headerPtr += sizeof(std::uint32_t);
std::vector<Model::GeometryVertex> verts; std::vector<Clump::GeometryVertex> verts;
verts.resize(numVerts); verts.resize(numVerts);
if (geomStream.getChunkVersion() < 0x1003FFFF) { if (geomStream.getChunkVersion() < 0x1003FFFF) {
@ -235,7 +235,7 @@ void LoaderDFF::readGeometry(Model *model, const RWBStream &stream) {
} }
geom->dbuff.setFaceType( geom->dbuff.setFaceType(
geom->facetype == Model::Triangles ? GL_TRIANGLES : GL_TRIANGLE_STRIP); geom->facetype == Clump::Triangles ? GL_TRIANGLES : GL_TRIANGLE_STRIP);
geom->gbuff.uploadVertices(verts); geom->gbuff.uploadVertices(verts);
geom->dbuff.addGeometry(&geom->gbuff); geom->dbuff.addGeometry(&geom->gbuff);
@ -244,7 +244,7 @@ void LoaderDFF::readGeometry(Model *model, const RWBStream &stream) {
size_t icount = std::accumulate( size_t icount = std::accumulate(
geom->subgeom.begin(), geom->subgeom.end(), 0u, geom->subgeom.begin(), geom->subgeom.end(), 0u,
[](size_t a, const Model::SubGeometry &b) { return a + b.numIndices; }); [](size_t a, const Clump::SubGeometry &b) { return a + b.numIndices; });
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32_t) * icount, 0, glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32_t) * icount, 0,
GL_STATIC_DRAW); GL_STATIC_DRAW);
for (auto &sg : geom->subgeom) { for (auto &sg : geom->subgeom) {
@ -253,7 +253,7 @@ void LoaderDFF::readGeometry(Model *model, const RWBStream &stream) {
} }
} }
void LoaderDFF::readMaterialList(Model *model, const RWBStream &stream) { void LoaderDFF::readMaterialList(Clump *model, const RWBStream &stream) {
auto listStream = stream.getInnerStream(); auto listStream = stream.getInnerStream();
auto listStructID = listStream.getNextChunk(); auto listStructID = listStream.getNextChunk();
@ -277,7 +277,7 @@ void LoaderDFF::readMaterialList(Model *model, const RWBStream &stream) {
} }
} }
void LoaderDFF::readMaterial(Model *model, const RWBStream &stream) { void LoaderDFF::readMaterial(Clump *model, const RWBStream &stream) {
auto materialStream = stream.getInnerStream(); auto materialStream = stream.getInnerStream();
auto matStructID = materialStream.getNextChunk(); auto matStructID = materialStream.getNextChunk();
@ -287,7 +287,7 @@ void LoaderDFF::readMaterial(Model *model, const RWBStream &stream) {
char *matData = materialStream.getCursor(); char *matData = materialStream.getCursor();
Model::Material material; Clump::Material material;
// Unkown // Unkown
matData += sizeof(std::uint32_t); matData += sizeof(std::uint32_t);
@ -320,7 +320,7 @@ void LoaderDFF::readMaterial(Model *model, const RWBStream &stream) {
} }
} }
void LoaderDFF::readTexture(Model *model, const RWBStream &stream) { void LoaderDFF::readTexture(Clump *model, const RWBStream &stream) {
auto texStream = stream.getInnerStream(); auto texStream = stream.getInnerStream();
auto texStructID = texStream.getNextChunk(); auto texStructID = texStream.getNextChunk();
@ -347,7 +347,7 @@ void LoaderDFF::readTexture(Model *model, const RWBStream &stream) {
{name, alpha, textureinst}); {name, alpha, textureinst});
} }
void LoaderDFF::readGeometryExtension(Model *model, const RWBStream &stream) { void LoaderDFF::readGeometryExtension(Clump *model, const RWBStream &stream) {
auto extStream = stream.getInnerStream(); auto extStream = stream.getInnerStream();
RWBStream::ChunkID chunkID; RWBStream::ChunkID chunkID;
@ -362,11 +362,11 @@ void LoaderDFF::readGeometryExtension(Model *model, const RWBStream &stream) {
} }
} }
void LoaderDFF::readBinMeshPLG(Model *model, const RWBStream &stream) { void LoaderDFF::readBinMeshPLG(Clump *model, const RWBStream &stream) {
auto data = stream.getCursor(); auto data = stream.getCursor();
model->geometries.back()->facetype = model->geometries.back()->facetype =
static_cast<Model::FaceType>(*(std::uint32_t *)data); static_cast<Clump::FaceType>(*(std::uint32_t *)data);
data += sizeof(std::uint32_t); data += sizeof(std::uint32_t);
unsigned int numSplits = *(std::uint32_t *)data; unsigned int numSplits = *(std::uint32_t *)data;
@ -380,7 +380,7 @@ void LoaderDFF::readBinMeshPLG(Model *model, const RWBStream &stream) {
size_t start = 0; size_t start = 0;
for (size_t s = 0; s < numSplits; ++s) { for (size_t s = 0; s < numSplits; ++s) {
Model::SubGeometry sg; Clump::SubGeometry sg;
sg.numIndices = *(std::uint32_t *)data; sg.numIndices = *(std::uint32_t *)data;
data += sizeof(std::uint32_t); data += sizeof(std::uint32_t);
sg.material = *(std::uint32_t *)data; sg.material = *(std::uint32_t *)data;
@ -397,7 +397,7 @@ void LoaderDFF::readBinMeshPLG(Model *model, const RWBStream &stream) {
} }
} }
void LoaderDFF::readAtomic(Model *model, const RWBStream &stream) { void LoaderDFF::readAtomic(Clump *model, const RWBStream &stream) {
auto atomicStream = stream.getInnerStream(); auto atomicStream = stream.getInnerStream();
auto atomicStructID = atomicStream.getNextChunk(); auto atomicStructID = atomicStream.getNextChunk();
@ -405,7 +405,7 @@ void LoaderDFF::readAtomic(Model *model, const RWBStream &stream) {
throw DFFLoaderException("Atomic missing struct chunk"); throw DFFLoaderException("Atomic missing struct chunk");
} }
Model::Atomic atom; Clump::Atomic atom;
auto data = atomicStream.getCursor(); auto data = atomicStream.getCursor();
atom.frame = *(std::uint32_t *)data; atom.frame = *(std::uint32_t *)data;
data += sizeof(std::uint32_t); data += sizeof(std::uint32_t);
@ -416,8 +416,8 @@ void LoaderDFF::readAtomic(Model *model, const RWBStream &stream) {
/// @todo are any atomic extensions important? /// @todo are any atomic extensions important?
} }
Model *LoaderDFF::loadFromMemory(FileHandle file) { Clump *LoaderDFF::loadFromMemory(FileHandle file) {
auto model = new Model; auto model = new Clump;
RWBStream rootStream(file->data, file->length); RWBStream rootStream(file->data, file->length);

View file

@ -9,7 +9,7 @@
#include <functional> #include <functional>
#include <string> #include <string>
class Model; class Clump;
class DFFLoaderException { class DFFLoaderException {
std::string _message; std::string _message;
@ -29,29 +29,29 @@ class LoaderDFF {
* @param model * @param model
* @param stream * @param stream
*/ */
void readFrameList(Model* model, const RWBStream& stream); void readFrameList(Clump* model, const RWBStream& stream);
void readGeometryList(Model* model, const RWBStream& stream); void readGeometryList(Clump* model, const RWBStream& stream);
void readGeometry(Model* model, const RWBStream& stream); void readGeometry(Clump* model, const RWBStream& stream);
void readMaterialList(Model* model, const RWBStream& stream); void readMaterialList(Clump* model, const RWBStream& stream);
void readMaterial(Model* model, const RWBStream& stream); void readMaterial(Clump* model, const RWBStream& stream);
void readTexture(Model* model, const RWBStream& stream); void readTexture(Clump* model, const RWBStream& stream);
void readGeometryExtension(Model* model, const RWBStream& stream); void readGeometryExtension(Clump* model, const RWBStream& stream);
void readBinMeshPLG(Model* model, const RWBStream& stream); void readBinMeshPLG(Clump* model, const RWBStream& stream);
void readAtomic(Model* model, const RWBStream& stream); void readAtomic(Clump* model, const RWBStream& stream);
public: public:
using TextureLookupCallback = std::function<TextureData::Handle( using TextureLookupCallback = std::function<TextureData::Handle(
const std::string&, const std::string&)>; const std::string&, const std::string&)>;
Model* loadFromMemory(FileHandle file); Clump* loadFromMemory(FileHandle file);
void setTextureLookupCallback(TextureLookupCallback tlc) { void setTextureLookupCallback(TextureLookupCallback tlc) {
texturelookup = tlc; texturelookup = tlc;

View file

@ -2,7 +2,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QMouseEvent> #include <QMouseEvent>
#include <algorithm> #include <algorithm>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
#include <engine/Animator.hpp> #include <engine/Animator.hpp>
#include <glm/gtc/type_ptr.hpp> #include <glm/gtc/type_ptr.hpp>
@ -103,7 +103,7 @@ void ViewerWidget::paintGL() {
vc.frustum.fov = viewFov; vc.frustum.fov = viewFov;
vc.frustum.aspectRatio = width() / (height() * 1.f); vc.frustum.aspectRatio = width() / (height() * 1.f);
Model* model = activeModel; Clump* model = activeModel;
if (model != _lastModel) { if (model != _lastModel) {
_lastModel = model; _lastModel = model;
emit modelChanged(_lastModel); emit modelChanged(_lastModel);
@ -197,7 +197,7 @@ void ViewerWidget::showObject(qint16 item) {
} }
} }
void ViewerWidget::showModel(Model* model) { void ViewerWidget::showModel(Clump* model) {
if (dummyObject) gworld->destroyObject(dummyObject); if (dummyObject) gworld->destroyObject(dummyObject);
dummyObject = nullptr; dummyObject = nullptr;
activeModel = model; activeModel = model;
@ -259,7 +259,7 @@ void ViewerWidget::keyReleaseEvent(QKeyEvent* e) {
if (e->key() == Qt::Key_Shift) moveFast = false; if (e->key() == Qt::Key_Shift) moveFast = false;
} }
Model* ViewerWidget::currentModel() const { Clump* ViewerWidget::currentModel() const {
return activeModel; return activeModel;
} }

View file

@ -2,7 +2,7 @@
#ifndef _VIEWERWIDGET_HPP_ #ifndef _VIEWERWIDGET_HPP_
#define _VIEWERWIDGET_HPP_ #define _VIEWERWIDGET_HPP_
#include <QTimer> #include <QTimer>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <engine/GameData.hpp> #include <engine/GameData.hpp>
#include <engine/GameWorld.hpp> #include <engine/GameWorld.hpp>
#include <gl/DrawBuffer.hpp> #include <gl/DrawBuffer.hpp>
@ -16,7 +16,7 @@
#include <QGLWidget> #include <QGLWidget>
class GameRenderer; class GameRenderer;
class Model; class Clump;
class ViewerWidget : public QGLWidget { class ViewerWidget : public QGLWidget {
Q_OBJECT Q_OBJECT
@ -27,12 +27,12 @@ class ViewerWidget : public QGLWidget {
QTimer timer; QTimer timer;
GameWorld* gworld; GameWorld* gworld;
Model* activeModel; Clump* activeModel;
ModelFrame* selectedFrame; ModelFrame* selectedFrame;
GameObject* dummyObject; GameObject* dummyObject;
quint16 currentObjectID; quint16 currentObjectID;
Model* _lastModel; Clump* _lastModel;
Animation* canimation; Animation* canimation;
float viewDistance; float viewDistance;
@ -60,7 +60,7 @@ public:
virtual void paintGL(); virtual void paintGL();
Model* currentModel() const; Clump* currentModel() const;
GameObject* currentObject() const; GameObject* currentObject() const;
GameWorld* world(); GameWorld* world();
@ -68,7 +68,7 @@ public:
public slots: public slots:
void showObject(qint16 item); void showObject(qint16 item);
void showModel(Model* model); void showModel(Clump* model);
void selectFrame(ModelFrame* frame); void selectFrame(ModelFrame* frame);
void exportModel(); void exportModel();
@ -81,7 +81,7 @@ signals:
void fileOpened(const QString& file); void fileOpened(const QString& file);
void modelChanged(Model* model); void modelChanged(Clump* model);
protected: protected:
void keyPressEvent(QKeyEvent*) override; void keyPressEvent(QKeyEvent*) override;

View file

@ -1,8 +1,8 @@
#include "DFFFramesTreeModel.hpp" #include "DFFFramesTreeModel.hpp"
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
DFFFramesTreeModel::DFFFramesTreeModel(Model* m, Skeleton* skel, DFFFramesTreeModel::DFFFramesTreeModel(Clump* m, Skeleton* skel,
QObject* parent) QObject* parent)
: QAbstractItemModel(parent), model(m), skeleton(skel) { : QAbstractItemModel(parent), model(m), skeleton(skel) {
} }

View file

@ -4,15 +4,15 @@
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <rw/types.hpp> #include <rw/types.hpp>
class Model; class Clump;
class Skeleton; class Skeleton;
class DFFFramesTreeModel : public QAbstractItemModel { class DFFFramesTreeModel : public QAbstractItemModel {
Model* model; Clump* model;
Skeleton* skeleton; Skeleton* skeleton;
public: public:
explicit DFFFramesTreeModel(Model* m, Skeleton* skel, QObject* parent = 0); explicit DFFFramesTreeModel(Clump* m, Skeleton* skel, QObject* parent = 0);
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;

View file

@ -40,7 +40,7 @@ void ModelViewer::setViewerWidget(ViewerWidget* widget) {
showModel(viewing); showModel(viewing);
} }
void ModelViewer::showModel(Model* model) { void ModelViewer::showModel(Clump* model) {
viewing = model; viewing = model;
if (skeleton) { if (skeleton) {
delete skeleton; delete skeleton;

View file

@ -14,7 +14,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
class ViewerWidget; class ViewerWidget;
class Model; class Clump;
class Skeleton; class Skeleton;
class ModelFramesWidget; class ModelFramesWidget;
class Animation; class Animation;
@ -22,7 +22,7 @@ class Animation;
class ModelViewer : public ViewerInterface { class ModelViewer : public ViewerInterface {
Q_OBJECT Q_OBJECT
Model* viewing; Clump* viewing;
Skeleton* skeleton; Skeleton* skeleton;
QSplitter* mainSplit; QSplitter* mainSplit;
@ -45,7 +45,7 @@ public slots:
/** /**
* Display a raw model * Display a raw model
*/ */
void showModel(Model* model); void showModel(Clump* model);
/** /**
* Display a game object's model * Display a game object's model

View file

@ -12,7 +12,7 @@
#include <QTableView> #include <QTableView>
class ViewerWidget; class ViewerWidget;
class Model; class Clump;
class ObjectViewer : public ViewerInterface { class ObjectViewer : public ViewerInterface {
Q_OBJECT Q_OBJECT
@ -40,7 +40,7 @@ protected:
signals: signals:
void modelChanged(Model* model); void modelChanged(Clump* model);
void showObjectModel(uint16_t object); void showObjectModel(uint16_t object);

View file

@ -1,8 +1,8 @@
#include "ModelFramesWidget.hpp" #include "ModelFramesWidget.hpp"
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <glm/gtx/string_cast.hpp> #include <glm/gtx/string_cast.hpp>
void ModelFramesWidget::updateInfoBox(Model* model, ModelFrame* f) { void ModelFramesWidget::updateInfoBox(Clump* model, ModelFrame* f) {
if (f == nullptr) { if (f == nullptr) {
_frameLabel->setText(""); _frameLabel->setText("");
} else { } else {
@ -14,8 +14,8 @@ void ModelFramesWidget::updateInfoBox(Model* model, ModelFrame* f) {
for (size_t gi : f->getGeometries()) { for (size_t gi : f->getGeometries()) {
auto& g = model->geometries[gi]; auto& g = model->geometries[gi];
// for(Model::SubGeometry& sg : g->subgeom) // for(Model::SubGeometry& sg : g->subgeom)
for (Model::Material& m : g->materials) { for (Clump::Material& m : g->materials) {
for (Model::Texture& t : m.textures) { for (Clump::Texture& t : m.textures) {
geomString += QString("\n %1 (%2)") geomString += QString("\n %1 (%2)")
.arg(t.name.c_str()) .arg(t.name.c_str())
.arg(t.alphaName.c_str()); .arg(t.alphaName.c_str());
@ -46,7 +46,7 @@ ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
setLayout(_layout); setLayout(_layout);
} }
void ModelFramesWidget::setModel(Model* model, Skeleton* skeleton) { void ModelFramesWidget::setModel(Clump* model, Skeleton* skeleton) {
if (framemodel) { if (framemodel) {
delete framemodel; delete framemodel;
framemodel = nullptr; framemodel = nullptr;

View file

@ -13,7 +13,7 @@ class ModelFrame;
class ModelFramesWidget : public QWidget { class ModelFramesWidget : public QWidget {
Q_OBJECT Q_OBJECT
Model* gmodel; Clump* gmodel;
DFFFramesTreeModel* framemodel; DFFFramesTreeModel* framemodel;
QTreeView* tree; QTreeView* tree;
QVBoxLayout* _layout; QVBoxLayout* _layout;
@ -21,7 +21,7 @@ class ModelFramesWidget : public QWidget {
private slots: private slots:
void updateInfoBox(Model* model, ModelFrame* f); void updateInfoBox(Clump* model, ModelFrame* f);
void selectedModelChanged(const QModelIndex&, const QModelIndex&); void selectedModelChanged(const QModelIndex&, const QModelIndex&);
@ -30,7 +30,7 @@ public:
public slots: public slots:
void setModel(Model* model, Skeleton* skeleton); void setModel(Clump* model, Skeleton* skeleton);
signals: signals:

View file

@ -1,5 +1,5 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
#include <engine/Animator.hpp> #include <engine/Animator.hpp>
#include <glm/gtx/string_cast.hpp> #include <glm/gtx/string_cast.hpp>

View file

@ -1,5 +1,5 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include "test_globals.hpp" #include "test_globals.hpp"
BOOST_AUTO_TEST_SUITE(LoaderDFFTests) BOOST_AUTO_TEST_SUITE(LoaderDFFTests)
@ -11,7 +11,7 @@ BOOST_AUTO_TEST_CASE(test_load_dff) {
LoaderDFF loader; LoaderDFF loader;
Model* m = loader.loadFromMemory(d); Clump* m = loader.loadFromMemory(d);
BOOST_REQUIRE(m != nullptr); BOOST_REQUIRE(m != nullptr);
@ -27,7 +27,7 @@ BOOST_AUTO_TEST_CASE(test_load_dff) {
BOOST_REQUIRE(m->atomics.size() > 0); BOOST_REQUIRE(m->atomics.size() > 0);
for (Model::Atomic& a : m->atomics) { for (Clump::Atomic& a : m->atomics) {
BOOST_CHECK(a.frame < m->frames.size()); BOOST_CHECK(a.frame < m->frames.size());
BOOST_CHECK(a.geometry < m->geometries.size()); BOOST_CHECK(a.geometry < m->geometries.size());
} }

View file

@ -1,5 +1,5 @@
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <data/Model.hpp> #include <data/Clump.hpp>
#include <data/Skeleton.hpp> #include <data/Skeleton.hpp>
#include <objects/VehicleObject.hpp> #include <objects/VehicleObject.hpp>
#include "test_globals.hpp" #include "test_globals.hpp"