mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 10:22:52 +01:00
Use Atomic instead of ModelFrame in ObjectRenderer
This commit is contained in:
parent
34c70b0be2
commit
d798509f93
@ -133,8 +133,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @todo change with librw
|
/// @todo change with librw
|
||||||
void setAtomic(Clump* model, int n, ModelFrame* atomic) {
|
void setAtomic(Clump* model, int n, AtomicPtr atomic) {
|
||||||
model_ = model;
|
model_ = model;
|
||||||
|
/// @todo disassociated the Atomic from Clump
|
||||||
atomics_[n] = atomic;
|
atomics_[n] = atomic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,8 +144,8 @@ public:
|
|||||||
return model_;
|
return model_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModelFrame* getAtomic(int n) const {
|
Atomic* getAtomic(int n) const {
|
||||||
return atomics_[n];
|
return atomics_[n].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLodDistance(int n, float d) {
|
void setLodDistance(int n, float d) {
|
||||||
@ -205,7 +206,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Clump* model_ = nullptr;
|
Clump* model_ = nullptr;
|
||||||
ModelFrame* atomics_[3] = {};
|
std::array<AtomicPtr, 3> atomics_;
|
||||||
float loddistances_[3] = {};
|
float loddistances_[3] = {};
|
||||||
uint8_t numatomics_ = 0;
|
uint8_t numatomics_ = 0;
|
||||||
uint8_t alpha_ = 0; /// @todo ask aap why
|
uint8_t alpha_ = 0; /// @todo ask aap why
|
||||||
|
@ -390,9 +390,9 @@ void GameData::loadModelFile(const std::string& name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Associate the frames with models.
|
// Associate the frames with models.
|
||||||
for (auto& frame : m->frames) {
|
for (const auto& atomic : m->getAtomics()) {
|
||||||
/// @todo this is useful elsewhere, please move elsewhere
|
/// @todo this is useful elsewhere, please move elsewhere
|
||||||
std::string name = frame->getName();
|
std::string name = atomic->getFrame()->getName();
|
||||||
int lod = 0;
|
int lod = 0;
|
||||||
getNameAndLod(name, lod);
|
getNameAndLod(name, lod);
|
||||||
for (auto& model : modelinfo) {
|
for (auto& model : modelinfo) {
|
||||||
@ -402,7 +402,9 @@ void GameData::loadModelFile(const std::string& name) {
|
|||||||
}
|
}
|
||||||
if (boost::iequals(info->name, name)) {
|
if (boost::iequals(info->name, name)) {
|
||||||
auto simple = static_cast<SimpleModelInfo*>(info);
|
auto simple = static_cast<SimpleModelInfo*>(info);
|
||||||
simple->setAtomic(m, lod, frame);
|
simple->setAtomic(m, lod, atomic);
|
||||||
|
auto identity = std::make_shared<ModelFrame>();
|
||||||
|
atomic->setFrame(identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,11 +460,13 @@ void GameData::loadModel(ModelID model) {
|
|||||||
if (isSimple) {
|
if (isSimple) {
|
||||||
auto simple = static_cast<SimpleModelInfo*>(info);
|
auto simple = static_cast<SimpleModelInfo*>(info);
|
||||||
// Associate atomics
|
// Associate atomics
|
||||||
for (auto& frame : m->frames) {
|
for (auto& atomic : m->getAtomics()) {
|
||||||
auto name = frame->getName();
|
auto name = atomic->getFrame()->getName();
|
||||||
int lod = 0;
|
int lod = 0;
|
||||||
getNameAndLod(name, lod);
|
getNameAndLod(name, lod);
|
||||||
simple->setAtomic(m, lod, frame);
|
simple->setAtomic(m, lod, atomic);
|
||||||
|
auto identity = std::make_shared<ModelFrame>();
|
||||||
|
atomic->setFrame(identity);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Associate clumps
|
// Associate clumps
|
||||||
|
@ -318,8 +318,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera,
|
|||||||
m, glm::vec3(i.radius +
|
m, glm::vec3(i.radius +
|
||||||
0.15f * glm::sin(_renderWorld->getGameTime() * 5.f)));
|
0.15f * glm::sin(_renderWorld->getGameTime() * 5.f)));
|
||||||
|
|
||||||
objectRenderer.renderFrame(sphereModel, sphereModel->frames[0], m,
|
objectRenderer.renderClump(sphereModel, m, nullptr, renderList);
|
||||||
nullptr, 1.f, renderList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render arrows above anything that isn't radar only (or hidden)
|
// Render arrows above anything that isn't radar only (or hidden)
|
||||||
@ -346,8 +345,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera,
|
|||||||
glm::vec3(0.f, 0.f, 2.5f + glm::sin(a) * 0.5f));
|
glm::vec3(0.f, 0.f, 2.5f + glm::sin(a) * 0.5f));
|
||||||
model = glm::rotate(model, a, glm::vec3(0.f, 0.f, 1.f));
|
model = glm::rotate(model, a, glm::vec3(0.f, 0.f, 1.f));
|
||||||
model = glm::scale(model, glm::vec3(1.5f, 1.5f, 1.5f));
|
model = glm::scale(model, glm::vec3(1.5f, 1.5f, 1.5f));
|
||||||
objectRenderer.renderFrame(arrowModel, arrowModel->frames[0], model,
|
objectRenderer.renderClump(arrowModel, model, nullptr, renderList);
|
||||||
nullptr, 1.f, renderList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RW_PROFILE_END();
|
RW_PROFILE_END();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <data/CutsceneData.hpp>
|
|
||||||
#include <data/Clump.hpp>
|
#include <data/Clump.hpp>
|
||||||
|
#include <data/CutsceneData.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,12 +33,10 @@ 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(Clump* model, size_t g,
|
void ObjectRenderer::renderGeometry(Geometry* geom,
|
||||||
const glm::mat4& modelMatrix, float opacity,
|
const glm::mat4& modelMatrix,
|
||||||
GameObject* object, RenderList& outList) {
|
GameObject* object, RenderList& outList) {
|
||||||
for (size_t sg = 0; sg < model->geometries[g]->subgeom.size(); ++sg) {
|
for (SubGeometry& subgeom : geom->subgeom) {
|
||||||
SubGeometry& subgeom = model->geometries[g]->subgeom[sg];
|
|
||||||
|
|
||||||
bool isTransparent = false;
|
bool isTransparent = false;
|
||||||
|
|
||||||
Renderer::DrawParameters dp;
|
Renderer::DrawParameters dp;
|
||||||
@ -55,9 +53,8 @@ void ObjectRenderer::renderGeometry(Clump* model, size_t g,
|
|||||||
!(modelinfo->flags & SimpleModelInfo::NO_ZBUFFER_WRITE);
|
!(modelinfo->flags & SimpleModelInfo::NO_ZBUFFER_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model->geometries[g]->materials.size() > subgeom.material) {
|
if (geom->materials.size() > subgeom.material) {
|
||||||
Geometry::Material& mat =
|
Geometry::Material& mat = geom->materials[subgeom.material];
|
||||||
model->geometries[g]->materials[subgeom.material];
|
|
||||||
|
|
||||||
if (mat.textures.size() > 0) {
|
if (mat.textures.size() > 0) {
|
||||||
auto tex = mat.textures[0].texture;
|
auto tex = mat.textures[0].texture;
|
||||||
@ -69,8 +66,7 @@ void ObjectRenderer::renderGeometry(Clump* model, size_t g,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((model->geometries[g]->flags &
|
if ((geom->flags & RW::BSGeometry::ModuleMaterialColor) ==
|
||||||
RW::BSGeometry::ModuleMaterialColor) ==
|
|
||||||
RW::BSGeometry::ModuleMaterialColor) {
|
RW::BSGeometry::ModuleMaterialColor) {
|
||||||
dp.colour = mat.colour;
|
dp.colour = mat.colour;
|
||||||
|
|
||||||
@ -86,7 +82,7 @@ void ObjectRenderer::renderGeometry(Clump* model, size_t g,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dp.visibility = opacity;
|
dp.visibility = 1.f;
|
||||||
|
|
||||||
if (dp.colour.a < 255) {
|
if (dp.colour.a < 255) {
|
||||||
isTransparent = true;
|
isTransparent = true;
|
||||||
@ -104,44 +100,40 @@ void ObjectRenderer::renderGeometry(Clump* model, size_t g,
|
|||||||
(m_camera.frustum.far - m_camera.frustum.near);
|
(m_camera.frustum.far - m_camera.frustum.near);
|
||||||
outList.emplace_back(
|
outList.emplace_back(
|
||||||
createKey(isTransparent, depth * depth, dp.textures), modelMatrix,
|
createKey(isTransparent, depth * depth, dp.textures), modelMatrix,
|
||||||
&model->geometries[g]->dbuff, dp);
|
&geom->dbuff, dp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool ObjectRenderer::renderFrame(Clump* m, ModelFrame* f,
|
|
||||||
const glm::mat4& matrix, GameObject* object,
|
|
||||||
float opacity, RenderList& outList) {
|
|
||||||
auto localmatrix = matrix;
|
|
||||||
bool vis = true;
|
|
||||||
|
|
||||||
if (object && object->skeleton) {
|
void ObjectRenderer::renderAtomic(Atomic* atomic,
|
||||||
// Skeleton is loaded with the correct matrix via Animator.
|
const glm::mat4& worldtransform,
|
||||||
localmatrix *= object->skeleton->getMatrix(f);
|
GameObject* object, RenderList& render) {
|
||||||
|
RW_CHECK(atomic->getGeometry(), "Can't render an atomic without geometry");
|
||||||
|
RW_CHECK(atomic->getFrame(), "Can't render an atomic without a frame");
|
||||||
|
|
||||||
vis = object->skeleton->getData(f->getIndex()).enabled;
|
const auto& geometry = atomic->getGeometry();
|
||||||
} else {
|
const auto& frame = atomic->getFrame();
|
||||||
localmatrix *= f->getTransform();
|
|
||||||
|
RW::BSGeometryBounds& bounds = geometry->geometryBounds;
|
||||||
|
|
||||||
|
glm::vec3 boundpos = bounds.center + glm::vec3(worldtransform[3]);
|
||||||
|
if (!m_camera.frustum.intersects(boundpos, bounds.radius)) {
|
||||||
|
culled++;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vis) {
|
renderGeometry(geometry.get(), worldtransform, object, render);
|
||||||
for (size_t g : f->getGeometries()) {
|
}
|
||||||
if (!object || !object->animator) {
|
|
||||||
RW::BSGeometryBounds& bounds = m->geometries[g]->geometryBounds;
|
|
||||||
|
|
||||||
glm::vec3 boundpos = bounds.center + glm::vec3(localmatrix[3]);
|
void ObjectRenderer::renderClump(Clump* model, const glm::mat4& worldtransform,
|
||||||
if (!m_camera.frustum.intersects(boundpos, bounds.radius)) {
|
GameObject* object, RenderList& render) {
|
||||||
culled++;
|
for (const auto& atomic : model->getAtomics()) {
|
||||||
continue;
|
const auto flags = atomic->getFlags();
|
||||||
}
|
if ((flags & Atomic::ATOMIC_RENDER) == 0) {
|
||||||
}
|
continue;
|
||||||
|
|
||||||
renderGeometry(m, g, localmatrix, opacity, object, outList);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (ModelFrame* c : f->getChildren()) {
|
renderAtomic(atomic.get(), worldtransform, object, render);
|
||||||
renderFrame(m, c, localmatrix, object, opacity, outList);
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectRenderer::renderInstance(InstanceObject* instance,
|
void ObjectRenderer::renderInstance(InstanceObject* instance,
|
||||||
@ -175,13 +167,12 @@ void ObjectRenderer::renderInstance(InstanceObject* instance,
|
|||||||
instance->getModel()->getBoundingRadius();
|
instance->getModel()->getBoundingRadius();
|
||||||
mindist *= 1.f / kDrawDistanceFactor;
|
mindist *= 1.f / kDrawDistanceFactor;
|
||||||
|
|
||||||
Clump* model = nullptr;
|
Atomic* atomic = 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.
|
||||||
Clump* fadingModel = nullptr;
|
Atomic* fadingAtomic = nullptr;
|
||||||
ModelFrame* fadingFrame = nullptr;
|
|
||||||
auto fadingMatrix = matrixModel;
|
auto fadingMatrix = matrixModel;
|
||||||
float opacity = 0.f;
|
float opacity = 0.f;
|
||||||
constexpr float fadeRange = 50.f;
|
constexpr float fadeRange = 50.f;
|
||||||
@ -203,32 +194,27 @@ void ObjectRenderer::renderInstance(InstanceObject* instance,
|
|||||||
matrixModel =
|
matrixModel =
|
||||||
instance->LODinstance->getTimeAdjustedTransform(
|
instance->LODinstance->getTimeAdjustedTransform(
|
||||||
m_renderAlpha);
|
m_renderAlpha);
|
||||||
|
atomic = lodmodelinfo->getAtomic(0);
|
||||||
// If the object is only just out of range, keep
|
// If the object is only just out of range, keep
|
||||||
// rendering it and screen-door the LOD.
|
// rendering it and screen-door the LOD.
|
||||||
if (overlap < fadeRange) {
|
if (overlap < fadeRange) {
|
||||||
model = instance->LODinstance->getModel();
|
fadingAtomic = modelinfo->getAtomic(0);
|
||||||
fadingModel = instance->getModel();
|
|
||||||
opacity = 1.f - (overlap / fadeRange);
|
opacity = 1.f - (overlap / fadeRange);
|
||||||
} else {
|
|
||||||
model = instance->LODinstance->getModel();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We don't have a LOD object, so fade out gracefully.
|
// We don't have a LOD object, so fade out gracefully.
|
||||||
else if (overlap < fadeRange) {
|
else if (overlap < fadeRange) {
|
||||||
fadingModel = instance->getModel();
|
fadingAtomic = modelinfo->getAtomic(0);
|
||||||
opacity = 1.f - (overlap / fadeRange);
|
opacity = 1.f - (overlap / fadeRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise, if we aren't marked as a LOD model, we can render
|
// Otherwise, if we aren't marked as a LOD model, we can render
|
||||||
else if (!modelinfo->LOD) {
|
else if (!modelinfo->LOD) {
|
||||||
model = instance->getModel();
|
atomic = modelinfo->getAtomic(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto root = instance->getModel()->frames[0];
|
auto root = instance->getModel()->getFrame();
|
||||||
auto objectModel = instance->getModel();
|
|
||||||
fadingFrame = nullptr;
|
|
||||||
fadingModel = nullptr;
|
|
||||||
|
|
||||||
matrixModel *= root->getTransform();
|
matrixModel *= root->getTransform();
|
||||||
|
|
||||||
@ -236,30 +222,20 @@ void ObjectRenderer::renderInstance(InstanceObject* instance,
|
|||||||
auto ind = (modelinfo->getNumAtomics() - 1) - i;
|
auto ind = (modelinfo->getNumAtomics() - 1) - i;
|
||||||
float lodDistance = modelinfo->getLodDistance(i);
|
float lodDistance = modelinfo->getLodDistance(i);
|
||||||
if (mindist > lodDistance) {
|
if (mindist > lodDistance) {
|
||||||
fadingFrame = root->getChildren()[ind];
|
fadingAtomic = modelinfo->getAtomic(ind);
|
||||||
fadingModel = objectModel;
|
|
||||||
opacity = 1.f - ((mindist - lodDistance) / fadeRange);
|
opacity = 1.f - ((mindist - lodDistance) / fadeRange);
|
||||||
} else {
|
} else {
|
||||||
model = objectModel;
|
fadingAtomic = modelinfo->getAtomic(ind);
|
||||||
frame = root->getChildren()[ind];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model) {
|
if (atomic) {
|
||||||
frame = frame ? frame : model->frames[0];
|
renderAtomic(atomic, matrixModel, instance, outList);
|
||||||
renderFrame(model, frame,
|
|
||||||
matrixModel * glm::inverse(frame->getTransform()), instance,
|
|
||||||
1.f, outList);
|
|
||||||
}
|
}
|
||||||
if (fadingModel) {
|
if (fadingAtomic && opacity >= 0.01f) {
|
||||||
if (opacity >= 0.01f) {
|
// @todo pass opacity
|
||||||
fadingFrame = fadingFrame ? fadingFrame : fadingModel->frames[0];
|
renderAtomic(fadingAtomic, fadingMatrix, instance, outList);
|
||||||
renderFrame(
|
|
||||||
fadingModel, fadingFrame,
|
|
||||||
fadingMatrix * glm::inverse(fadingFrame->getTransform()),
|
|
||||||
instance, opacity, outList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,10 +262,7 @@ void ObjectRenderer::renderCharacter(CharacterObject* pedestrian,
|
|||||||
|
|
||||||
if (!pedestrian->getModel()) return;
|
if (!pedestrian->getModel()) return;
|
||||||
|
|
||||||
auto root = pedestrian->getModel()->frames[0];
|
renderClump(pedestrian->getModel(), matrixModel, nullptr, outList);
|
||||||
|
|
||||||
renderFrame(pedestrian->getModel(), root->getChildren()[0], matrixModel,
|
|
||||||
pedestrian, 1.f, outList);
|
|
||||||
|
|
||||||
auto item = pedestrian->getActiveItem();
|
auto item = pedestrian->getActiveItem();
|
||||||
const auto& weapon = pedestrian->engine->data->weaponData[item];
|
const auto& weapon = pedestrian->engine->data->weaponData[item];
|
||||||
@ -312,9 +285,8 @@ void ObjectRenderer::renderCharacter(CharacterObject* pedestrian,
|
|||||||
// Assume items are all simple
|
// Assume items are all simple
|
||||||
auto simple =
|
auto simple =
|
||||||
m_world->data->findModelInfo<SimpleModelInfo>(weapon->modelID);
|
m_world->data->findModelInfo<SimpleModelInfo>(weapon->modelID);
|
||||||
auto geometry = simple->getAtomic(0)->getGeometries().at(0);
|
auto itematomic = simple->getAtomic(0);
|
||||||
renderGeometry(simple->getModel(), geometry, matrixModel * localMatrix, 1.f,
|
renderAtomic(itematomic, matrixModel * localMatrix, nullptr, outList);
|
||||||
nullptr, outList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectRenderer::renderVehicle(VehicleObject* vehicle,
|
void ObjectRenderer::renderVehicle(VehicleObject* vehicle,
|
||||||
@ -327,8 +299,7 @@ void ObjectRenderer::renderVehicle(VehicleObject* vehicle,
|
|||||||
|
|
||||||
glm::mat4 matrixModel = vehicle->getTimeAdjustedTransform(m_renderAlpha);
|
glm::mat4 matrixModel = vehicle->getTimeAdjustedTransform(m_renderAlpha);
|
||||||
|
|
||||||
renderFrame(vehicle->getModel(), vehicle->getModel()->frames[0],
|
renderClump(vehicle->getModel(), matrixModel, vehicle, outList);
|
||||||
matrixModel, vehicle, 1.f, outList);
|
|
||||||
|
|
||||||
auto modelinfo = vehicle->getVehicle();
|
auto modelinfo = vehicle->getVehicle();
|
||||||
|
|
||||||
@ -338,7 +309,8 @@ void ObjectRenderer::renderVehicle(VehicleObject* vehicle,
|
|||||||
if (!woi || !woi->isLoaded()) {
|
if (!woi || !woi->isLoaded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto wheelgeom = woi->getAtomic(0)->getGeometries().at(0);
|
|
||||||
|
auto wheelatomic = woi->getAtomic(0);
|
||||||
for (size_t w = 0; w < vehicle->info->wheels.size(); ++w) {
|
for (size_t w = 0; w < vehicle->info->wheels.size(); ++w) {
|
||||||
auto& wi = vehicle->physVehicle->getWheelInfo(w);
|
auto& wi = vehicle->physVehicle->getWheelInfo(w);
|
||||||
// Construct our own matrix so we can use the local transform
|
// Construct our own matrix so we can use the local transform
|
||||||
@ -371,8 +343,7 @@ void ObjectRenderer::renderVehicle(VehicleObject* vehicle,
|
|||||||
wheelM = glm::scale(wheelM, glm::vec3(-1.f, 1.f, 1.f));
|
wheelM = glm::scale(wheelM, glm::vec3(-1.f, 1.f, 1.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
renderGeometry(woi->getModel(), wheelgeom, wheelM, 1.f, nullptr,
|
renderAtomic(wheelatomic, wheelM, nullptr, outList);
|
||||||
outList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,16 +356,9 @@ void ObjectRenderer::renderPickup(PickupObject* pickup, RenderList& outList) {
|
|||||||
|
|
||||||
auto odata = pickup->getModelInfo<SimpleModelInfo>();
|
auto odata = pickup->getModelInfo<SimpleModelInfo>();
|
||||||
|
|
||||||
auto model = odata->getModel();
|
auto atomic = odata->getAtomic(0);
|
||||||
auto itemModel = odata->getAtomic(0);
|
|
||||||
auto geom = 0;
|
|
||||||
if (!itemModel->getGeometries().empty()) {
|
|
||||||
geom = itemModel->getGeometries()[0];
|
|
||||||
} else if (!itemModel->getChildren().empty()) {
|
|
||||||
geom = itemModel->getChildren()[0]->getGeometries()[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
renderGeometry(model, geom, modelMatrix, 1.f, pickup, outList);
|
renderAtomic(atomic, modelMatrix, nullptr, outList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectRenderer::renderCutsceneObject(CutsceneObject* cutscene,
|
void ObjectRenderer::renderCutsceneObject(CutsceneObject* cutscene,
|
||||||
@ -413,7 +377,8 @@ void ObjectRenderer::renderCutsceneObject(CutsceneObject* cutscene,
|
|||||||
matrixModel = glm::translate(matrixModel, cutsceneOffset);
|
matrixModel = glm::translate(matrixModel, cutsceneOffset);
|
||||||
// matrixModel =
|
// matrixModel =
|
||||||
// cutscene->getParentActor()->getTimeAdjustedTransform(_renderAlpha);
|
// cutscene->getParentActor()->getTimeAdjustedTransform(_renderAlpha);
|
||||||
// matrixModel = glm::translate(matrixModel, glm::vec3(0.f, 0.f, 1.f));
|
// matrixModel = glm::translate(matrixModel, glm::vec3(0.f, 0.f,
|
||||||
|
// 1.f));
|
||||||
glm::mat4 localMatrix;
|
glm::mat4 localMatrix;
|
||||||
auto boneframe = cutscene->getParentFrame();
|
auto boneframe = cutscene->getParentFrame();
|
||||||
while (boneframe) {
|
while (boneframe) {
|
||||||
@ -432,11 +397,9 @@ void ObjectRenderer::renderCutsceneObject(CutsceneObject* cutscene,
|
|||||||
glm::mat4 align;
|
glm::mat4 align;
|
||||||
/// @todo figure out where this 90 degree offset is coming from.
|
/// @todo figure out where this 90 degree offset is coming from.
|
||||||
align = glm::rotate(align, glm::half_pi<float>(), {0.f, 1.f, 0.f});
|
align = glm::rotate(align, glm::half_pi<float>(), {0.f, 1.f, 0.f});
|
||||||
renderFrame(model, model->frames[0], matrixModel * align, cutscene, 1.f,
|
renderClump(model, matrixModel * align, nullptr, outList);
|
||||||
outList);
|
|
||||||
} else {
|
} else {
|
||||||
renderFrame(model, model->frames[0], matrixModel, cutscene, 1.f,
|
renderClump(model, matrixModel, nullptr, outList);
|
||||||
outList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,11 +410,8 @@ void ObjectRenderer::renderProjectile(ProjectileObject* projectile,
|
|||||||
auto odata = m_world->data->findModelInfo<SimpleModelInfo>(
|
auto odata = m_world->data->findModelInfo<SimpleModelInfo>(
|
||||||
projectile->getProjectileInfo().weapon->modelID);
|
projectile->getProjectileInfo().weapon->modelID);
|
||||||
|
|
||||||
auto model = odata->getModel();
|
auto atomic = odata->getAtomic(0);
|
||||||
auto modelframe = odata->getAtomic(0);
|
renderAtomic(atomic, modelMatrix, nullptr, outList);
|
||||||
auto geom = modelframe->getGeometries().at(0);
|
|
||||||
|
|
||||||
renderGeometry(model, geom, modelMatrix, 1.f, projectile, outList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectRenderer::buildRenderList(GameObject* object, RenderList& outList) {
|
void ObjectRenderer::buildRenderList(GameObject* object, RenderList& outList) {
|
||||||
|
@ -37,11 +37,25 @@ public:
|
|||||||
size_t culled;
|
size_t culled;
|
||||||
void buildRenderList(GameObject* object, RenderList& outList);
|
void buildRenderList(GameObject* object, RenderList& outList);
|
||||||
|
|
||||||
bool renderFrame(Clump* m, ModelFrame* f, const glm::mat4& matrix,
|
void renderGeometry(Geometry* geom, const glm::mat4& modelMatrix,
|
||||||
GameObject* object, float opacity, RenderList& outList);
|
GameObject* object, RenderList& outList);
|
||||||
|
|
||||||
void renderGeometry(Clump* model, size_t g, const glm::mat4& modelMatrix,
|
/**
|
||||||
float opacity, GameObject* object, RenderList& outList);
|
* @brief renderAtomic renders an atomic with the given worldtransform
|
||||||
|
* @param model
|
||||||
|
* @param atomic
|
||||||
|
* @param worldtransform
|
||||||
|
* @param object
|
||||||
|
*/
|
||||||
|
void renderAtomic(Atomic* atomic, const glm::mat4& worldtransform, GameObject* object, RenderList& render);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief renderClump Renders all visible atomics in the clump
|
||||||
|
* @param model
|
||||||
|
* @param worldtransform
|
||||||
|
* @param render
|
||||||
|
*/
|
||||||
|
void renderClump(Clump* model, const glm::mat4& worldtransform, GameObject* object, RenderList& render);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameWorld* m_world;
|
GameWorld* m_world;
|
||||||
|
@ -187,10 +187,15 @@ struct Geometry {
|
|||||||
class Atomic {
|
class Atomic {
|
||||||
ModelFramePtr frame_;
|
ModelFramePtr frame_;
|
||||||
GeometryPtr geometry_;
|
GeometryPtr geometry_;
|
||||||
|
uint32_t flags_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum {
|
||||||
|
// If this is set, the atomic will be rendered
|
||||||
|
ATOMIC_RENDER = 0x04
|
||||||
|
};
|
||||||
|
|
||||||
void setFrame(ModelFramePtr& frame) {
|
void setFrame(ModelFramePtr frame) {
|
||||||
frame_ = frame;
|
frame_ = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +210,23 @@ public:
|
|||||||
const GeometryPtr& getGeometry() const {
|
const GeometryPtr& getGeometry() const {
|
||||||
return geometry_;
|
return geometry_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setFlags(uint32_t flags) {
|
||||||
|
flags_ = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getFlags() const {
|
||||||
|
return flags_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFlag(uint32_t flag, bool set) {
|
||||||
|
if (set) {
|
||||||
|
flags_ |= flag;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
flags_ &= ~flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -418,6 +418,8 @@ AtomicPtr LoaderDFF::readAtomic(FrameList &framelist,
|
|||||||
auto frame = *(std::uint32_t *)data;
|
auto frame = *(std::uint32_t *)data;
|
||||||
data += sizeof(std::uint32_t);
|
data += sizeof(std::uint32_t);
|
||||||
auto geometry = *(std::uint32_t *)data;
|
auto geometry = *(std::uint32_t *)data;
|
||||||
|
data += sizeof(std::uint32_t);
|
||||||
|
auto flags = *(std::uint32_t *) data;
|
||||||
|
|
||||||
// Verify the atomic's particulars
|
// Verify the atomic's particulars
|
||||||
RW_CHECK(frame < framelist.size(), "atomic frame " << frame
|
RW_CHECK(frame < framelist.size(), "atomic frame " << frame
|
||||||
@ -432,6 +434,7 @@ AtomicPtr LoaderDFF::readAtomic(FrameList &framelist,
|
|||||||
if (frame < framelist.size()) {
|
if (frame < framelist.size()) {
|
||||||
atomic->setFrame(framelist[frame]);
|
atomic->setFrame(framelist[frame]);
|
||||||
}
|
}
|
||||||
|
atomic->setFlags(flags);
|
||||||
|
|
||||||
return atomic;
|
return atomic;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user