From 50073ae406474e270a37d262f9aab9652413a3f0 Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 24 Jun 2013 00:45:45 +0200 Subject: [PATCH 1/4] rendermax: make citizen glow --- plugins/rendermax/renderer_light.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index 187b3d2d8..05f1d2c96 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -2,12 +2,14 @@ #include #include +#include #include "Types.h" #include "modules/Gui.h" #include "modules/Screen.h" #include "modules/Maps.h" +#include "modules/Units.h" #include "df/graphic.h" #include "df/viewscreen_dwarfmodest.h" @@ -503,4 +505,15 @@ void lightingEngineViewscreen::doOcupancyAndLights() int tile=getIndex(wx,wy); addLight(tile,cursor); } -} \ No newline at end of file + lightSource citizen(lightCell(0.80f,0.80f,0.90f),6); + for (int i=0;iunits.active.size();++i) + { + df::unit *u = df::global::world->units.active[i]; + if (u->pos.z != window_z || + (u->pos.x < window_x || u->pos.x >= window_x+vpW) || + (u->pos.y < window_y || u->pos.y >= window_y+vpH)) + continue; + if (DFHack::Units::isCitizen(u)) + addLight(getIndex(u->pos.x-window_x+1, u->pos.y-window_y+1),citizen); + } +} From fb5d248720f0de4d2971b09fb3ab8fd408ec383a Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 24 Jun 2013 01:54:09 +0200 Subject: [PATCH 2/4] rendermax: basic daylight --- plugins/rendermax/renderer_light.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index 05f1d2c96..633871e2a 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -253,13 +253,16 @@ void lightingEngineViewscreen::initRawSpecific() static size_t max_list_size = 100000; // Avoid iterating over huge lists void lightingEngineViewscreen::doOcupancyAndLights() { - lightSource sun(lightCell(1,1,1),15); + // TODO better curve (+red dawn ?) + float daycol = abs((*df::global::cur_year_tick % 1200) - 600.0) / 600.0; + lightCell sky_col(daycol, daycol, daycol); + lightSource sky(sky_col, 15); + lightSource lava(lightCell(0.8f,0.2f,0.2f),5); lightSource candle(lightCell(0.96f,0.84f,0.03f),5); lightSource torch(lightCell(0.9f,0.75f,0.3f),8); rect2d vp=getMapViewport(); - - + int window_x=*df::global::window_x; int window_y=*df::global::window_y; int window_z=*df::global::window_z; @@ -277,7 +280,7 @@ void lightingEngineViewscreen::doOcupancyAndLights() for(int block_x = 0; block_x < 16; block_x++) for(int block_y = 0; block_y < 16; block_y++) { - cellArray[block_x][block_y] = lightCell(1,1,1); + cellArray[block_x][block_y] = sky_col; } int totalBlank = 0; int topLevel = df::global::world->map.z_count-1; @@ -347,7 +350,7 @@ void lightingEngineViewscreen::doOcupancyAndLights() if(!type) { //unallocated, do sky - addLight(tile,sun); + addLight(tile,sky); continue; } df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,*type); @@ -438,7 +441,7 @@ void lightingEngineViewscreen::doOcupancyAndLights() } if(d->bits.outside && d->bits.flow_size==0) { - addLight(tile,sun); + addLight(tile,sky); } } From b95683adb2567a713175e7ad5de7d927b7d74eca Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 24 Jun 2013 02:22:30 +0200 Subject: [PATCH 3/4] rendermax: sunlight travels down stairs --- plugins/rendermax/renderer_light.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index d5d19815a..8aa45cc14 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -317,13 +317,17 @@ void lightingEngineViewscreen::doOcupancyAndLights() { cellArray[block_x][block_y]=lightCell(0,0,0); } - else if(basic_shape==df::tiletype_shape_basic::Floor || basic_shape==df::tiletype_shape_basic::Ramp || basic_shape==df::tiletype_shape_basic::Stair) + else if(basic_shape==df::tiletype_shape_basic::Floor || basic_shape==df::tiletype_shape_basic::Ramp || shape==df::tiletype_shape::STAIR_UP) { if(ZZ!=window_z) { cellArray[block_x][block_y]=lightCell(0,0,0); } } + else if(shape==df::tiletype_shape::STAIR_DOWN || shape==df::tiletype_shape::STAIR_UPDOWN) + { + cellArray[block_x][block_y]*=lightCell(0.9,0.9,0.9); + } if(d.bits.liquid_type == df::enums::tile_liquid::Water && d.bits.flow_size) { cellArray[block_x][block_y] *= (lightCell(1,1,1) - (lightCell(1,1,1) - lightCell(0.63f,0.63f,0.75f))*(d.bits.flow_size/7)); From 19952b9139803155ba24aedcdb87e8448f9ce55f Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 24 Jun 2013 02:27:43 +0200 Subject: [PATCH 4/4] rendermax: lights off when sleeping --- plugins/rendermax/renderer_light.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index 8aa45cc14..01042fc95 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -535,7 +535,7 @@ void lightingEngineViewscreen::doOcupancyAndLights() (u->pos.x < window_x || u->pos.x >= window_x+vpW) || (u->pos.y < window_y || u->pos.y >= window_y+vpH)) continue; - if (DFHack::Units::isCitizen(u)) + if (DFHack::Units::isCitizen(u) && !u->counters.unconscious) addLight(getIndex(u->pos.x-window_x+1, u->pos.y-window_y+1),citizen); } }