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

Fix frame name loading

This commit is contained in:
Daniel Evans 2014-02-10 09:48:40 +00:00
parent be39a691cf
commit 9f0834e65e
3 changed files with 33 additions and 33 deletions

View File

@ -240,21 +240,19 @@ GTAVehicle *GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos, co
auto info = gameData.vehicleInfo.find(vti->second->handlingID);
if(model && info != gameData.vehicleInfo.end()) {
if( info->second.wheels.size() == 0 && info->second.seats.size() == 0 ) {
for( size_t f = 0; f < model->frames.size(); ++f) {
if( model->frameNames.size() > f) {
std::string& name = model->frameNames[f];
if( name.substr(0, 5) == "wheel" ) {
auto frameTrans = model->frames[f]->getMatrix();
info->second.wheels.push_back({glm::vec3(frameTrans[3])});
}
if(name.substr(0, 3) == "ped" && name.substr(name.size()-4) == "seat") {
auto p = model->frames[f]->getDefaultTranslation();
p.x = p.x * -1.f;
info->second.seats.push_back({p});
p.x = p.x * -1.f;
info->second.seats.push_back({p});
}
for( const ModelFrame* f : model->frames ) {
const std::string& name = f->getName();
if( name.size() > 5 && name.substr(0, 5) == "wheel" ) {
auto frameTrans = f->getMatrix();
info->second.wheels.push_back({glm::vec3(frameTrans[3])});
}
if(name.size() > 3 && name.substr(0, 3) == "ped" && name.substr(name.size()-4) == "seat") {
auto p = f->getDefaultTranslation();
p.x = p.x * -1.f;
info->second.seats.push_back({p});
p.x = p.x * -1.f;
info->second.seats.push_back({p});
}
}
}

View File

@ -41,17 +41,17 @@ Model* LoaderDFF::loadFromMemory(char *data, GameData *gameData)
}
size_t fldataI = 0;
size_t fn = 0;
while( sec.hasMoreData(fldataI)) {
auto listsec = sec.getNextChildSection(fldataI);
if( listsec.header.id == RW::SID_Extension) {
size_t extI = 0;
while( listsec.hasMoreData(extI)) {
auto extSec = listsec.getNextChildSection(extI);
size_t fn = 0;
if( extSec.header.id == RW::SID_NodeName) {
std::string framename(extSec.raw(), extSec.header.size);
std::transform(framename.begin(), framename.end(), framename.begin(), ::tolower );
std::string framename(extSec.raw(), extSec.header.size);
std::transform(framename.begin(), framename.end(), framename.begin(), ::tolower );
// !HACK!
if(framename == "swaist") {
model->rootFrameIdx = model->frameNames.size();

View File

@ -268,8 +268,10 @@ void GTARenderer::renderWorld()
matrixModel = glm::translate(matrixModel,
v->getPosition());
matrixModel = matrixModel * glm::mat4_cast(v->getRotation());
glm::vec3 seatpos = v->info.seats[charac->getCurrentSeat()].offset;
matrixModel = glm::translate(matrixModel, seatpos);
if(charac->getCurrentSeat() < v->info.seats.size()) {
glm::vec3 seatpos = v->info.seats[charac->getCurrentSeat()].offset;
matrixModel = glm::translate(matrixModel, seatpos);
}
}
else {
matrixModel = glm::translate(matrixModel, charac->getPosition());
@ -403,20 +405,16 @@ void GTARenderer::renderWorld()
void GTARenderer::renderNamedFrame(Model* model, const glm::mat4 &matrix, const std::string& name)
{
for (size_t f = 0; f < model->frames.size(); f++)
size_t n = 0;
for (const ModelFrame* f : model->frames)
{
if( model->frameNames.size() > f) {
std::string& fname = model->frameNames[f];
bool LOD = (fname.find("_l1") != fname.npos || fname.find("_l0") != fname.npos);
if( LOD || fname != name ) {
continue;
}
}
else {
const std::string& fname = f->getName();
bool LOD = (fname.find("_l1") != fname.npos || fname.find("_l0") != fname.npos);
if( LOD || fname != name ) {
continue;
}
size_t g = f;
size_t g = 3;
RW::BSGeometryBounds& bounds = model->geometries[g]->geometryBounds;
if(! camera.frustum.intersects(bounds.center + glm::vec3(matrix[3]), bounds.radius)) {
culled++;
@ -455,8 +453,12 @@ bool GTARenderer::renderFrame(Model* m, ModelFrame* f, const glm::mat4& matrix,
if( object && object->type() == GTAObject::Vehicle ) {
auto& name = f->getName();
if( name.substr(name.size()-3) == "dam" || name.find("lo") != name.npos || name.find("dummy") != name.npos ) {
continue;
if(name.size() > 3) {
if(name.substr(name.size()-3) == "dam"
|| name.find("lo") != name.npos
|| name.find("dummy") != name.npos) {
continue;
}
}
}