1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-14 09:04:31 +02:00

- fix light position

- upscale to original world size
This commit is contained in:
XProger
2016-08-20 15:35:08 +03:00
parent 3d8c871ea7
commit 2946ba6fb0
2 changed files with 10 additions and 30 deletions

View File

@@ -18,7 +18,7 @@ struct Camera {
if (Input::down[ikD]) v = v + dir.cross(vec3(0, 1, 0));
if (Input::down[ikA]) v = v - dir.cross(vec3(0, 1, 0));
pos = pos + v.normal() * (Core::deltaTime);
pos = pos + v.normal() * (Core::deltaTime * 2048.0f);
if (Input::down[ikMouseL]) {
vec2 delta = Input::mouse.pos - Input::mouse.start.L;
@@ -40,11 +40,6 @@ struct Camera {
Core::mProj = mat4(fov, (float)Core::width / (float)Core::height, znear, zfar);
Core::mViewProj = Core::mProj * Core::mView;
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((GLfloat*)&Core::mProj);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((GLfloat*)&Core::mView);
}
};
@@ -59,10 +54,10 @@ namespace Game {
level = new Level("data\\LEVEL3A.PHD");
camera.fov = 90.0f;
camera.znear = 0.1f;
camera.zfar = 1000.0f;
camera.znear = 0.1f * 2048.0f;
camera.zfar = 1000.0f * 2048.0f;
// camera.pos = vec3(-10, -2, 26);
camera.pos = vec3(-13.25f, 0.42f, 38.06f);
camera.pos = vec3(-13.25f, 0.42f, 38.06f) * 2048.0f;
// camera.pos = vec3(-36, -1, 2);
camera.angle = vec3(0);
}
@@ -80,26 +75,12 @@ namespace Game {
}
void render() {
// Core::clear(vec4(0.1f, 0.4f, 0.4f, 0.0));
Core::clear(vec4(0.0f, 0.0f, 0.0f, 0.0));
Core::setViewport(0, 0, Core::width, Core::height);
Core::setBlending(bmAlpha);
camera.setup();
/*
Debug::Draw::begin();
glDisable(GL_TEXTURE_2D);
Debug::Draw::axes(10);
glEnable(GL_TEXTURE_2D);
*/
vec3 pos = Core::mView.inverse().getPos();
GLfloat p[4] = { pos.x, pos.y, pos.z, 1.0f };
glLightfv(GL_LIGHT0, GL_POSITION, p);
glEnable(GL_DEPTH_TEST);
level->render();
//Debug::Draw::end();
}
/*

View File

@@ -43,6 +43,7 @@ const char SHADER[] = \
" light += uAmbient;\n"\
" color.xyz *= light;\n"\
" color.xyz = pow(color.xyz, vec3(1.0/2.2));\n"\
" //color.xyz = normalize(vLightVec) * 0.5 + 0.5;\n"\
" gl_FragColor = color;\n"\
" }\n"\
"#endif";
@@ -448,7 +449,7 @@ struct Level {
return NULL;
}
#define SCALE (1.0f / 1024.0f / 2.0f)
//#define SCALE (1.0f / 1024.0f / 2.0f)
void renderRoom(int index) {
TR::Room &room = level.rooms[index];
@@ -683,7 +684,7 @@ struct Level {
if (idx > -1) {
TR::Room::Light &light = level.rooms[room].lights[idx];
float c = level.rooms[room].lights[idx].Intensity / 8191.0f;
Core::lightPos = vec3(-light.x, -light.y, light.z);
Core::lightPos = vec3(-light.x, -light.y, light.z);// * SCALE;
Core::lightColor = vec4(c, c, c, 0.0f);
} else {
Core::lightPos = vec3(0.0f);
@@ -1000,15 +1001,13 @@ struct Level {
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.9f);
glEnable(GL_TEXTURE_2D);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
//glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
Core::setCulling(cfFront);
Core::mModel.identity();
Core::mModel.scale(vec3(-SCALE, -SCALE, SCALE));
// Core::mModel.scale(vec3(-SCALE, -SCALE, SCALE));
Core::mModel.scale(vec3(-1, -1, 1));
Core::color = vec4(1.0f);
Core::ambient = vec3(0.0f);