void EERIE_MESH_TWEAK_Do(INTERACTIVE_OBJ * io, long tw, char * _path) { if (!ALLOW_MESH_TWEAKING) return; char file2[256]; char filet[256]; char path[256]; File_Standardize(_path, path); strcpy(filet, "GAME\\"); strcat(filet, path); SetExt(filet, ".FTL"); File_Standardize(filet, file2); if ((!PAK_FileExist(file2)) && (!PAK_FileExist(path))) return; if (tw == TWEAK_ERROR) return; if (io == NULL) return; if (io->obj == NULL) return; EERIE_MESH_ReleaseTransPolys(io->obj); if ((path == NULL) && (tw == TWEAK_REMOVE)) { if (io->tweaky) { ReleaseEERIE3DObj(io->obj); io->obj = io->tweaky; EERIE_Object_Precompute_Fast_Access(io->obj); io->tweaky = NULL; } return; } EERIE_3DOBJ * tobj = NULL; EERIE_3DOBJ * result = NULL; EERIE_3DOBJ * result2 = NULL; if ((PAK_FileExist(file2)) || (PAK_FileExist(path))) { const char DIR_TEXTURES[] = "Graph\\Obj3D\\Textures\\"; if (io->ioflags & IO_NPC) tobj = TheoToEerie_Fast(DIR_TEXTURES, path, TTE_NPC); else tobj = TheoToEerie_Fast(DIR_TEXTURES, path, 0); if (!tobj) return; switch (tw) { case TWEAK_ALL: if (io->tweaky == NULL) io->tweaky = io->obj; else ReleaseEERIE3DObj(io->obj); long i; TextureContainer * tc; tc = NULL; for (i = 0; i < tobj->nbfaces; i++) { if ((tobj->facelist[i].texid >= 0) && (tobj->texturecontainer[tobj->facelist[i].texid])) { tc = tobj->texturecontainer[tobj->facelist[i].texid]; if (!tc->m_pddsSurface) tc->Restore(GDevice); } } io->obj = tobj; return; break; case TWEAK_UPPER: result2 = CreateIntermediaryMesh(io->obj, tobj, TWEAK_HEAD); result = CreateIntermediaryMesh(result2, tobj, TWEAK_TORSO); ReleaseEERIE3DObj(result2); break; case TWEAK_LOWER: result2 = CreateIntermediaryMesh(io->obj, tobj, TWEAK_TORSO); result = CreateIntermediaryMesh(result2, tobj, TWEAK_LEGS); ReleaseEERIE3DObj(result2); break; case TWEAK_UP_LO: result = CreateIntermediaryMesh(tobj, io->obj, TWEAK_TORSO); break; default: result = CreateIntermediaryMesh(io->obj, tobj, tw); break; } if (result == NULL) { ReleaseEERIE3DObj(tobj); return; } result->pdata = NULL; result->cdata = NULL; if (io->tweaky == NULL) io->tweaky = io->obj; else if (io->tweaky != io->obj) ReleaseEERIE3DObj(io->obj); io->obj = result; EERIE_Object_Precompute_Fast_Access(io->obj); } EERIE_CreateCedricData(io->obj); if (io) { io->lastanimtime = 0; io->nb_lastanimvertex = 0; } ReleaseEERIE3DObj(tobj); }
void EERIE_MESH_TWEAK_Do(Entity * io, TweakType tw, const res::path & path) { res::path ftl_file = ("game" / path).set_ext("ftl"); if ((!g_resources->getFile(ftl_file)) && (!g_resources->getFile(path))) return; if (!tw) return; if (io == NULL) return; if (io->obj == NULL) return; if(path.empty() && tw == TWEAK_REMOVE) { if(io->tweaky) { delete io->obj; io->obj = io->tweaky; EERIE_Object_Precompute_Fast_Access(io->obj); io->tweaky = NULL; } return; } EERIE_3DOBJ * tobj = NULL; EERIE_3DOBJ * result = NULL; { tobj = loadObject(path); if (!tobj) return; switch (tw) { case (u32)TWEAK_HEAD | (u32)TWEAK_TORSO | (u32)TWEAK_LEGS: if (!io->tweaky) io->tweaky = io->obj; else delete io->obj; io->obj = tobj; return; break; case (u32)TWEAK_HEAD | (u32)TWEAK_TORSO: { EERIE_3DOBJ * result2 = CreateIntermediaryMesh(io->obj, tobj, TWEAK_HEAD); result = CreateIntermediaryMesh(result2, tobj, TWEAK_TORSO); delete result2; break; } case (u32)TWEAK_TORSO | (u32)TWEAK_LEGS: { EERIE_3DOBJ * result2 = CreateIntermediaryMesh(io->obj, tobj, TWEAK_TORSO); result = CreateIntermediaryMesh(result2, tobj, TWEAK_LEGS); delete result2; break; } case (u32)TWEAK_HEAD | (u32)TWEAK_LEGS: result = CreateIntermediaryMesh(tobj, io->obj, TWEAK_TORSO); break; default: result = CreateIntermediaryMesh(io->obj, tobj, tw); break; } if(!result) { delete tobj; return; } if (io->tweaky == NULL) io->tweaky = io->obj; else if (io->tweaky != io->obj) delete io->obj; io->obj = result; EERIE_Object_Precompute_Fast_Access(io->obj); } EERIE_CreateCedricData(io->obj); io->animBlend.lastanimtime = 0; io->animBlend.m_active = false; delete tobj; }