From 28985167c9460433b6e93c66f7f541152499238e Mon Sep 17 00:00:00 2001 From: Warmist Date: Thu, 27 Jun 2013 18:11:50 +0300 Subject: [PATCH] Fixed bug with buildings and added gems to material definition. --- plugins/rendermax/renderer_light.cpp | 8 ++++++-- plugins/rendermax/renderer_light.hpp | 1 - plugins/rendermax/rendermax.lua | 12 +++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index ec30bcd1e..4f5bdd90c 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -884,11 +884,15 @@ void lightingEngineViewscreen::doOcupancyAndLights() df::coord2d p1(bld->x1,bld->y1); df::coord2d p2(bld->x2,bld->y2); p1=worldToViewportCoord(p1,vp,window2d); - p2=worldToViewportCoord(p1,vp,window2d); + p2=worldToViewportCoord(p2,vp,window2d); if(isInViewport(p1,vp)||isInViewport(p2,vp)) { - int tile=getIndex(p1.x,p1.y); //TODO multitile buildings. How they would work? + int tile; + if(isInViewport(p1,vp)) + tile=getIndex(p1.x,p1.y); //TODO multitile buildings. How they would work? + else + tile=getIndex(p2.x,p2.y); df::building_type type = bld->getType(); buildingLightDef* def=getBuilding(bld); if(!def) diff --git a/plugins/rendermax/renderer_light.hpp b/plugins/rendermax/renderer_light.hpp index 58676e29c..5a53242b0 100644 --- a/plugins/rendermax/renderer_light.hpp +++ b/plugins/rendermax/renderer_light.hpp @@ -114,7 +114,6 @@ struct matLightDef matLightDef(lightCell transparency):isTransparent(true),isEmiting(false),transparency(transparency){} lightSource makeSource(float size=1) const { - //TODO implement sizeModifiesPower/range if(size>0.999 && size<1.001) return lightSource(emitColor,radius); else diff --git a/plugins/rendermax/rendermax.lua b/plugins/rendermax/rendermax.lua index 74e5fc2d0..df2619864 100644 --- a/plugins/rendermax/rendermax.lua +++ b/plugins/rendermax/rendermax.lua @@ -92,6 +92,16 @@ function makeMaterialDef(transparency,emitance,radius,flags) end return {tr=transparency,em=emitance,rad=radius,flags=flg} end +function colorFrom16(col16) + return copyall(df.global.enabler.ccolor[col16]) +end +function addGems() + for k,v in pairs(df.global.world.raws.inorganics) do + if v.material.flags.IS_GEM then + addMaterial("INORGANIC:"..v.id,colorFrom16(v.material.build_color[0])) + end + end +end ------------------------------------------------------------------------ ---------------- Configuration Starts Here ------------------------- ------------------------------------------------------------------------ @@ -128,7 +138,7 @@ addMaterial("PLANT:MUSHROOM_HELMET_PLUMP",nil,{0.2,0.1,0.6},2) addMaterial("INORGANIC:ADAMANTINE",{0.1,0.3,0.3},{0.1,0.3,0.3},4) -- creature stuff addMaterial("CREATURE:DRAGON:BLOOD",nil,{0.6,0.1,0.1},4) --- TODO gems +addGems() --buildings addBuilding("Statue",{1,1,1},{0.9,0.75,0.3},8) addBuilding("Bed",{1,1,1},{0.3,0.2,0.0},2)