void EERIE_MESH_TWEAK_Skin(EERIE_3DOBJ * obj, const res::path & s1, const res::path & s2) {
	
	LogDebug("Tweak Skin " << s1 << " " << s2);
	
	if(obj == NULL || s1.empty() || s2.empty()) {
		LogError << "Tweak Skin got NULL Pointer";
		return;
	}
	
	LogDebug("Tweak Skin " << s1 << " " << s2);
	
	res::path skintochange = "graph/obj3d/textures" / s1;
	
	res::path skinname = "graph/obj3d/textures" / s2;
	TextureContainer * tex = TextureContainer::Load(skinname);
	if(!tex) {
		return;
	}
	
	if(obj->originaltextures.empty()) {
		obj->originaltextures.resize(obj->texturecontainer.size());
		for(size_t i = 0; i < obj->texturecontainer.size(); i++) {
			if(obj->texturecontainer[i]) {
				obj->originaltextures[i] = obj->texturecontainer[i]->m_texName;
			}
		}
	}
	
	arx_assert(obj->originaltextures.size() == obj->texturecontainer.size());
	
	bool found = false;
	
	for(size_t i = 0; i < obj->texturecontainer.size(); i++) {
		if(obj->originaltextures[i] == skintochange) {
			obj->texturecontainer[i] = tex;
			found = true;
		}
	}
	
	if(found) {
		return;
	}
	
	for(size_t i = 0; i < obj->texturecontainer.size(); i++) {
		if(obj->texturecontainer[i]->m_texName == skintochange) {
			obj->texturecontainer[i] = tex;
		}
	}
	
}
Exemple #2
0
bool PakReader::addFiles(const fs::path & path, const res::path & mount) {
	
	if(fs::is_directory(path)) {
			
		bool ret = addFiles(addDirectory(mount), path);
	
		if(ret) {
			LogInfo << "Added dir " << path;
		}
		
		return ret;
		
	} else if(fs::is_regular_file(path) && !mount.empty()) {
		
		PakDirectory * dir = addDirectory(mount.parent());
		
		return addFile(dir, path, mount.filename());
		
	}
	
	return false;
}
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;
}