1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

Fixed TEXDICTION and wheel rendering

This commit is contained in:
Daniel Evans 2014-06-01 17:41:09 +01:00
parent 624fc737d3
commit 6d604ffec0
4 changed files with 17 additions and 13 deletions

View File

@ -70,7 +70,7 @@ public:
*/
void renderWorld();
void renderNamedFrame(Model*, const glm::mat4& matrix, const std::string& name);
void renderWheel(Model*, const glm::mat4& matrix, const std::string& name);
void renderGeometry(Model*, size_t geom, const glm::mat4& modelMatrix, GameObject* = nullptr);

View File

@ -148,6 +148,7 @@ void GameData::parseDAT(const std::string& path)
texpath = findPathRealCase(datpath, texpath);
std::string texname = texpath.substr(texpath.find_last_of("/")+1);
fileLocations.insert({ texname, { false, texpath }});
loadTXD(texname);
}
}
}

View File

@ -359,7 +359,7 @@ void GTARenderer::renderWorld()
if(inst->physVehicle->getWheelInfo(w).m_chassisConnectionPointCS.x() < 0.f) {
wheel_tf = glm::scale(wheel_tf, glm::vec3(-1.f, 1.f, 1.f));
}
renderNamedFrame(wheelModel, /*matrixVehicle **/ wheel_tf, woi->second->modelName);
renderWheel(wheelModel, /*matrixVehicle **/ wheel_tf, woi->second->modelName);
}
else {
std::cout << "Wheel model " << woi->second->modelName << " not loaded" << std::endl;
@ -401,24 +401,26 @@ void GTARenderer::renderWorld()
glBindVertexArray( 0 );
}
void GTARenderer::renderNamedFrame(Model* model, const glm::mat4 &matrix, const std::string& name)
void GTARenderer::renderWheel(Model* model, const glm::mat4 &matrix, const std::string& name)
{
for (const ModelFrame* f : model->frames)
{
const std::string& fname = f->getName();
bool LOD = (fname.find("_l1") != fname.npos || fname.find("_l0") != fname.npos);
if( LOD || fname != name ) {
if( fname != name ) {
continue;
}
size_t g = 3;
RW::BSGeometryBounds& bounds = model->geometries[g]->geometryBounds;
if(! camera.frustum.intersects(bounds.center + glm::vec3(matrix[3]), bounds.radius)) {
culled++;
continue;
}
auto firstLod = f->getChildren()[0];
renderGeometry(model, g, matrix);
for( auto& g : firstLod->getGeometries() ) {
RW::BSGeometryBounds& bounds = model->geometries[g]->geometryBounds;
if(! camera.frustum.intersects(bounds.center + glm::vec3(matrix[3]), bounds.radius)) {
culled++;
continue;
}
renderGeometry(model, g, matrix);
}
break;
}
}

View File

@ -308,6 +308,7 @@ void init(std::string gtapath, bool loadWorld)
// This is harcoded in GTA III for some reason
gta->gameData.loadIMG("/models/gta3");
gta->gameData.loadIMG("/models/txd");
gta->load();