diff --git a/doomsday/apps/client/src/render/gloomworldrenderer.cpp b/doomsday/apps/client/src/render/gloomworldrenderer.cpp index 3152602a7c..5cab3da07b 100644 --- a/doomsday/apps/client/src/render/gloomworldrenderer.cpp +++ b/doomsday/apps/client/src/render/gloomworldrenderer.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -66,22 +67,27 @@ DE_PIMPL(GloomWorldRenderer) viewdata_t *vd = &player->viewport(); pos = vd->current.origin.xzy() * metersPerUnit * worldMirror; - up = vd->upVec * worldMirror; - front = vd->frontVec * worldMirror; + up = vd->upVec; // * worldMirror; + front = vd->frontVec; // * worldMirror; // These axis flips are a bit silly, but they are here because the view matrices // come from Doomsday's old renderer. They also assume clockwise triangle winding. // Gloom uses counterclockwise (OpenGL default). We need to invert the coordinate // axes accordingly. - mvMat = Mat4f::scale(metersPerUnit.x) * + /*mvMat = Mat4f::scale(metersPerUnit.x) * // matrix applied VGA aspect Mat4f::rotate(180, Vec3f(0, 1, 0)) * Rend_GetModelViewMatrix(console) * Mat4f::scale(Vec3f(1.0f) / metersPerUnit) * - Mat4f::scale(worldMirror); + Mat4f::scale(worldMirror);*/ + + mvMat = Mat4f::rotate(vd->current.pitch * 85.0f / 110.0f, Vec3f(-1, 0, 0)) * + Mat4f::rotate(float(vd->current.angle()) / float(ANG180) * 180 - 90.0f, + Vec3f(0, -1, 0)) * + Mat4f::translate(-pos); projMat = Rend_GetProjectionMatrix(0.0f, metersPerUnit.x /* clip planes in meters */) * - Mat4f::scale(Vec3f(-1, 1, -1)); + Mat4f::scale(Vec3f(1, 1, -1)); } Vec3f cameraPosition() const @@ -110,11 +116,12 @@ DE_PIMPL(GloomWorldRenderer) } }; - PlayerCamera playerCamera; - std::unique_ptr glWorld; - Set planesToUpdate; - List sectorLut; // sector number => gloom ID - ImageBank images; + PlayerCamera playerCamera; + std::unique_ptr glWorld; + Set planesToUpdate; + List sectorLut; // sector number => gloom ID + ImageBank images; + std::shared_ptr testLight; Impl(Public *i) : Base(i) { @@ -169,10 +176,21 @@ void GloomWorldRenderer::loadMap(const String &mapId) *i++ = value->asUInt(); } } + + // Test light. + { + d->testLight = std::make_shared(); + d->testLight->setType(gloom::Entity::Light); + auto &map = d->glWorld->map(); + map.append(map.entities(), d->testLight); + + d->glWorld->mapRender().rebuild(); + } } void GloomWorldRenderer::unloadMap() { + d->testLight.reset(); d->sectorLut.clear(); } @@ -195,11 +213,17 @@ void GloomWorldRenderer::advanceTime(TimeSpan elapsed) plane->initialHeightOfMovement(), plane->movementBeganAt(), plane->speed() * TICSPERSEC); - - // TODO: Pass the target height and speed to glWorld and let the shaders update - // the heights on the GPU. Only update the plane heights buffer when a move begins. } } + + // Test light. + if (d->testLight) + { + Vec3d delta = d->playerCamera.cameraPosition() - d->testLight->position(); + + d->testLight->setPosition(d->testLight->position() + delta * elapsed * 0.5); + } + d->glWorld->update(elapsed); d->glWorld->setCurrentTime(world::World::get().time()); // TODO: time sync should happen once, and after that `elapsed` should be scaled diff --git a/doomsday/libs/gloom/include/gloom/render/lightrender.h b/doomsday/libs/gloom/include/gloom/render/lightrender.h index 942a767033..6a07494d6b 100644 --- a/doomsday/libs/gloom/include/gloom/render/lightrender.h +++ b/doomsday/libs/gloom/include/gloom/render/lightrender.h @@ -32,7 +32,7 @@ class Light; /** * Renders light source shadow maps and the deferred shading pass. */ -class LightRender : public Render +class LIBGLOOM_PUBLIC LightRender : public Render { public: LightRender(); diff --git a/doomsday/libs/gloom/include/gloom/world.h b/doomsday/libs/gloom/include/gloom/world.h index b60a740cda..bad7e9462b 100644 --- a/doomsday/libs/gloom/include/gloom/world.h +++ b/doomsday/libs/gloom/include/gloom/world.h @@ -57,6 +57,7 @@ class LIBGLOOM_PUBLIC World : public IWorld void update(TimeSpan elapsed); void render(const ICamera &camera); + Map & map(); const Map &map() const; MapRender &mapRender(); User * localUser() const; diff --git a/doomsday/libs/gloom/src/render/light.cpp b/doomsday/libs/gloom/src/render/light.cpp index b456aa2f7d..0dcad773b2 100644 --- a/doomsday/libs/gloom/src/render/light.cpp +++ b/doomsday/libs/gloom/src/render/light.cpp @@ -92,7 +92,8 @@ Vec3d Light::origin() const if (d->entity) { const auto p = d->entity->position(); - return p + Vec3d(0, 2, 0); // <---TESTING--- + // TODO: Add the light origin within entity. + return p; // + Vec3d(0, 2, 0); // <---TESTING--- } return d->origin; } diff --git a/doomsday/libs/gloom/src/render/lightrender.cpp b/doomsday/libs/gloom/src/render/lightrender.cpp index a7c528e933..6e2ab957f4 100644 --- a/doomsday/libs/gloom/src/render/lightrender.cpp +++ b/doomsday/libs/gloom/src/render/lightrender.cpp @@ -578,7 +578,7 @@ void LightRender::createLights() light->setEntity(ent); light->setType(Light::Omni); light->setCastShadows(true); - light->setIntensity(Vec3f(15, 15, 15)); + light->setIntensity(Vec3f(25, 25, 25)); d->lights.insert(ent->id(), light); d->activeLights.insert(light.get()); } diff --git a/doomsday/libs/gloom/src/world.cpp b/doomsday/libs/gloom/src/world.cpp index 645684065f..fd601a7f14 100644 --- a/doomsday/libs/gloom/src/world.cpp +++ b/doomsday/libs/gloom/src/world.cpp @@ -237,9 +237,10 @@ DE_PIMPL(World), public Asset currentTime += elapsed; renderContext.uCurrentTime = float(currentTime); - updateEntities(elapsed); +// updateEntities(elapsed); } +#if 0 void updateEntities(TimeSpan) { for (const auto &i : map.entities()) @@ -250,6 +251,7 @@ DE_PIMPL(World), public Asset ent.setPosition(pos); } } +#endif }; World::World(GLShaderBank &shaders, ImageBank &images) @@ -408,6 +410,11 @@ void World::render(const ICamera &camera) #endif } +Map &World::map() +{ + return d->map; +} + User *World::localUser() const { return d->localUser;