mirror of
https://github.com/XProger/OpenLara.git
synced 2025-04-19 18:41:54 +02:00
fixed #179
This commit is contained in:
parent
efc8f86d21
commit
4b61742598
@ -72,6 +72,7 @@ struct IGame {
|
||||
virtual void setupBinding() {}
|
||||
virtual void getVisibleRooms(int *roomsList, int &roomsCount, int from, int to, const vec4 &viewPort, bool water, int count = 0) {}
|
||||
virtual void renderEnvironment(int roomIndex, const vec3 &pos, Texture **targets, int stride = 0, Core::Pass pass = Core::passAmbient) {}
|
||||
virtual void renderModelFull(int modelIndex, bool underwater, Basis *joints) {}
|
||||
virtual void renderCompose(int roomIndex) {}
|
||||
virtual void renderView(int roomIndex, bool water, int roomsCount = 0, int *roomsList = NULL) {}
|
||||
virtual void renderGame(bool showUI) {}
|
||||
|
57
src/format.h
57
src/format.h
@ -3713,6 +3713,7 @@ namespace TR {
|
||||
}
|
||||
|
||||
void appendObjectTex(TextureInfo *&objTex, int32 &count) {
|
||||
if (!objTex) return;
|
||||
TextureInfo *newObjectTextures = new TextureInfo[objectTexturesCount + count];
|
||||
memcpy(newObjectTextures, objectTextures, sizeof(TextureInfo) * objectTexturesCount);
|
||||
memcpy(newObjectTextures + objectTexturesCount, objTex, sizeof(TextureInfo) * count);
|
||||
@ -3991,28 +3992,28 @@ namespace TR {
|
||||
void initTextureTypes() {
|
||||
// rooms geometry
|
||||
for (int roomIndex = 0; roomIndex < roomsCount; roomIndex++) {
|
||||
TR::Room &room = rooms[roomIndex];
|
||||
TR::Room::Data &data = room.data;
|
||||
Room &room = rooms[roomIndex];
|
||||
Room::Data &data = room.data;
|
||||
for (int i = 0; i < data.fCount; i++) {
|
||||
Face &f = data.faces[i];
|
||||
ASSERT(!f.colored);
|
||||
ASSERT(f.flags.texture < objectTexturesCount);
|
||||
TR::TextureInfo &t = objectTextures[f.flags.texture];
|
||||
TextureInfo &t = objectTextures[f.flags.texture];
|
||||
t.type = TEX_TYPE_ROOM;
|
||||
}
|
||||
}
|
||||
|
||||
// rooms static meshes
|
||||
for (int staticMeshIndex = 0; staticMeshIndex < staticMeshesCount; staticMeshIndex++) {
|
||||
TR::StaticMesh *staticMesh = &staticMeshes[staticMeshIndex];
|
||||
StaticMesh *staticMesh = &staticMeshes[staticMeshIndex];
|
||||
if (!meshOffsets[staticMesh->mesh]) continue;
|
||||
TR::Mesh &mesh = meshes[meshOffsets[staticMesh->mesh]];
|
||||
Mesh &mesh = meshes[meshOffsets[staticMesh->mesh]];
|
||||
|
||||
for (int i = 0; i < mesh.fCount; i++) {
|
||||
TR::Face &f = mesh.faces[i];
|
||||
Face &f = mesh.faces[i];
|
||||
ASSERT(f.colored || f.flags.texture < objectTexturesCount);
|
||||
if (f.colored) continue;
|
||||
TR::TextureInfo &t = objectTextures[f.flags.texture];
|
||||
TextureInfo &t = objectTextures[f.flags.texture];
|
||||
t.type = TEX_TYPE_ROOM;
|
||||
}
|
||||
}
|
||||
@ -4026,6 +4027,48 @@ namespace TR {
|
||||
t.type = TEX_TYPE_ROOM;
|
||||
}
|
||||
}
|
||||
|
||||
// objects (duplicate all textures that are simultaneously used for static meshes)
|
||||
TextureInfo *dupObjTex = NULL;
|
||||
int dupObjTexCount = 0;
|
||||
|
||||
for (int modelIndex = 0; modelIndex < modelsCount; modelIndex++) {
|
||||
Model &model = models[modelIndex];
|
||||
for (int meshIndex = model.mStart; meshIndex < model.mStart + model.mCount; meshIndex++) {
|
||||
Mesh &mesh = meshes[meshOffsets[meshIndex]];
|
||||
|
||||
for (int i = 0; i < mesh.fCount; i++) {
|
||||
Face &f = mesh.faces[i];
|
||||
ASSERT(f.colored || f.flags.texture < objectTexturesCount);
|
||||
if (f.colored) continue;
|
||||
TextureInfo &t = objectTextures[f.flags.texture];
|
||||
if (t.type != TEX_TYPE_OBJECT) {
|
||||
if (!dupObjTex) {
|
||||
dupObjTex = new TextureInfo[128];
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
while (index < dupObjTexCount) {
|
||||
TextureInfo &ot = dupObjTex[index];
|
||||
if (ot.tile == t.tile && ot.clut == t.clut && ot.texCoord[0] == t.texCoord[0] && ot.texCoord[1] == t.texCoord[1])
|
||||
break;
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index == dupObjTexCount) {
|
||||
ASSERT(index <= 128);
|
||||
dupObjTex[dupObjTexCount] = t;
|
||||
dupObjTex[dupObjTexCount].type = TEX_TYPE_OBJECT;
|
||||
dupObjTexCount++;
|
||||
}
|
||||
|
||||
f.flags.texture = objectTexturesCount + index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appendObjectTex(dupObjTex, dupObjTexCount);
|
||||
}
|
||||
|
||||
static Entity::Type convToInv(Entity::Type type) {
|
||||
|
@ -516,8 +516,6 @@ struct Inventory {
|
||||
void render(IGame *game, const Basis &basis) {
|
||||
if (!anim) return;
|
||||
|
||||
MeshBuilder *mesh = game->getMesh();
|
||||
|
||||
TR::Level *level = game->getLevel();
|
||||
TR::Model &m = level->models[desc.model];
|
||||
Basis joints[MAX_SPHERES];
|
||||
@ -533,9 +531,7 @@ struct Inventory {
|
||||
joints[1].rotate(quat(vec3(0.0f, 1.0f, 0.0f), -params.x));
|
||||
}
|
||||
|
||||
Core::setBasis(joints, m.mCount);
|
||||
|
||||
mesh->renderModelFull(desc.model);
|
||||
game->renderModelFull(desc.model, false, joints);
|
||||
}
|
||||
|
||||
void choose() {
|
||||
|
35
src/level.h
35
src/level.h
@ -612,6 +612,41 @@ struct Level : IGame {
|
||||
Core::pass = tmpPass;
|
||||
Core::eye = tmpEye;
|
||||
}
|
||||
|
||||
virtual void renderModelFull(int modelIndex, bool underwater, Basis *joints) {
|
||||
vec4 ambient[6] = { vec4(0), vec4(0), vec4(0), vec4(0), vec4(0), vec4(0) };
|
||||
|
||||
// opaque
|
||||
Core::setBlendMode(bmPremult); // inventory items has fade-out/in alpha
|
||||
mesh->transparent = 0;
|
||||
setShader(Core::passCompose, Shader::ENTITY, underwater, false);
|
||||
Core::setBasis(joints, level.models[modelIndex].mCount);
|
||||
Core::active.shader->setParam(uMaterial, Core::active.material);
|
||||
Core::active.shader->setParam(uAmbient, ambient[0], 6);
|
||||
Core::updateLights();
|
||||
mesh->renderModel(modelIndex, underwater);
|
||||
// transparent
|
||||
mesh->transparent = 1;
|
||||
setShader(Core::passCompose, Shader::ENTITY, underwater, true);
|
||||
Core::setBasis(joints, level.models[modelIndex].mCount);
|
||||
Core::active.shader->setParam(uMaterial, Core::active.material);
|
||||
Core::active.shader->setParam(uAmbient, ambient[0], 6);
|
||||
Core::updateLights();
|
||||
mesh->renderModel(modelIndex, underwater);
|
||||
// additive
|
||||
Core::setBlendMode(bmAdd);
|
||||
Core::setDepthWrite(false);
|
||||
mesh->transparent = 2;
|
||||
setShader(Core::passCompose, Shader::ENTITY, underwater, false);
|
||||
Core::setBasis(joints, level.models[modelIndex].mCount);
|
||||
Core::active.shader->setParam(uMaterial, Core::active.material);
|
||||
Core::active.shader->setParam(uAmbient, ambient[0], 6);
|
||||
Core::updateLights();
|
||||
mesh->renderModel(modelIndex, underwater);
|
||||
Core::setDepthWrite(true);
|
||||
Core::setBlendMode(bmNone);
|
||||
mesh->transparent = 0;
|
||||
}
|
||||
|
||||
virtual void setEffect(Controller *controller, TR::Effect::Type effect) {
|
||||
this->effect = effect;
|
||||
|
15
src/mesh.h
15
src/mesh.h
@ -1504,21 +1504,6 @@ struct MeshBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
void renderModelFull(int modelIndex, bool underwater = false) {
|
||||
Core::setBlendMode(bmPremult);
|
||||
transparent = 0;
|
||||
renderModel(modelIndex, underwater);
|
||||
transparent = 1;
|
||||
renderModel(modelIndex, underwater);
|
||||
Core::setBlendMode(bmAdd);
|
||||
Core::setDepthWrite(false);
|
||||
transparent = 2;
|
||||
renderModel(modelIndex, underwater);
|
||||
Core::setDepthWrite(true);
|
||||
Core::setBlendMode(bmNone);
|
||||
transparent = 0;
|
||||
}
|
||||
|
||||
void renderShadowBlob() {
|
||||
mesh->render(shadowBlob);
|
||||
}
|
||||
|
4
src/ui.h
4
src/ui.h
@ -719,7 +719,6 @@ namespace UI {
|
||||
|
||||
Core::setDepthTest(true);
|
||||
|
||||
MeshBuilder *mesh = game->getMesh();
|
||||
for (int i = 0; i < pickups.length; i++) {
|
||||
const PickupItem &item = pickups[i];
|
||||
|
||||
@ -741,7 +740,6 @@ namespace UI {
|
||||
matrix.rotateY(item.time * PI * 0.5f);
|
||||
|
||||
item.animation->getJoints(matrix, -1, true, joints);
|
||||
Core::setBasis(joints, item.animation->model->mCount);
|
||||
|
||||
float alpha = 1.0f - min(PICKUP_SHOW_TIME - item.time, 1.0f);
|
||||
alpha *= alpha;
|
||||
@ -750,7 +748,7 @@ namespace UI {
|
||||
|
||||
Core::setMaterial(1.0f, 0.0f, 0.0f, alpha);
|
||||
|
||||
mesh->renderModelFull(item.modelIndex - 1);
|
||||
game->renderModelFull(item.modelIndex - 1, false, joints);
|
||||
}
|
||||
|
||||
Core::setDepthTest(false);
|
||||
|
@ -1042,6 +1042,8 @@ struct short2 {
|
||||
|
||||
short2() {}
|
||||
short2(int16 x, int16 y) : x(x), y(y) {}
|
||||
|
||||
inline bool operator == (const short2 &v) const { return x == v.x && y == v.y; }
|
||||
};
|
||||
|
||||
struct short3 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user