Revision: 2660 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2660&view=rev Author: rorthomas Date: 2012-05-25 01:56:26 +0000 (Fri, 25 May 2012) Log Message: ----------- added alpha multiplier to blendmaps
Modified Paths: -------------- trunk/source/main/gameplay/TerrainManager.cpp trunk/source/main/gameplay/TerrainManager.h Modified: trunk/source/main/gameplay/TerrainManager.cpp =================================================================== --- trunk/source/main/gameplay/TerrainManager.cpp 2012-05-25 01:55:47 UTC (rev 2659) +++ trunk/source/main/gameplay/TerrainManager.cpp 2012-05-25 01:56:26 UTC (rev 2660) @@ -174,21 +174,22 @@ terrainOptions->setUseRayBoxDistanceCalculation(false); // load the textures and blendmaps into our data structures - blendMaps.clear(); - blendMode.clear(); + blendInfo.clear(); terrainLayers = StringConverter::parseInt(terrainConfig.getSetting("Layers.count")); if (terrainLayers > 0) { defaultimp.layerList.resize(terrainLayers); - blendMaps.resize(terrainLayers); - blendMode.resize(terrainLayers); + blendInfo.resize(terrainLayers); for(int i = 0; i < terrainLayers; i++) { defaultimp.layerList[i].worldSize = PARSEINT(terrainConfig.getSetting("Layers."+TOSTRING(i)+".size")); defaultimp.layerList[i].textureNames.push_back(terrainConfig.getSetting("Layers."+TOSTRING(i)+".diffusespecular")); defaultimp.layerList[i].textureNames.push_back(terrainConfig.getSetting("Layers."+TOSTRING(i)+".normalheight")); - blendMaps[i] = terrainConfig.getSetting("Layers."+TOSTRING(i)+".blendmap"); - blendMode[i] = terrainConfig.getSetting("Layers."+TOSTRING(i)+".blendmapmode"); + + blendLayerInfo_t &bi = blendInfo[i]; + bi.blendMapTextureFilename = terrainConfig.getSetting("Layers."+TOSTRING(i)+".blendmap"); + bi.blendMode = *terrainConfig.getSetting("Layers."+TOSTRING(i)+".blendmapmode").c_str(); + bi.alpha = Ogre::StringConverter::parseReal(terrainConfig.getSetting("Layers."+TOSTRING(i)+".alpha")); } } } @@ -200,15 +201,16 @@ int layerCount = terrain->getLayerCount(); for(int i = 1; i < layerCount; i++) { + blendLayerInfo_t &bi = blendInfo[i]; Ogre::Image img; //std::pair<uint8,uint8> textureIndex = terrain->getLayerBlendTextureIndex(i); //uint8 bti = terrain->getBlendTextureIndex(i); try { - img.load(blendMaps[i], ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME); + img.load(bi.blendMapTextureFilename, ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME); } catch(Exception &e) { - LOG("Error loading blendmap: " + blendMaps[i] + " : " + e.getFullDescription()); + LOG("Error loading blendmap: " + bi.blendMapTextureFilename + " : " + e.getFullDescription()); continue; } @@ -226,14 +228,14 @@ for (Ogre::uint32 y = 0; y != blendmapSize; y++) { Ogre::ColourValue c = img.getColourAt(x, y, 0); - float alpha = 1;//(1/b); - if (blendMode[i] == "R") + float alpha = bi.alpha; + if (bi.blendMode == 'R') *ptr++ = c.r * alpha; - else if (blendMode[i] == "G") + else if (bi.blendMode == 'G') *ptr++ = c.g * alpha; - else if (blendMode[i] == "B") + else if (bi.blendMode == 'B') *ptr++ = c.b * alpha; - else if (blendMode[i] == "A") + else if (bi.blendMode == 'A') *ptr++ = c.a * alpha; } } Modified: trunk/source/main/gameplay/TerrainManager.h =================================================================== --- trunk/source/main/gameplay/TerrainManager.h 2012-05-25 01:55:47 UTC (rev 2659) +++ trunk/source/main/gameplay/TerrainManager.h 2012-05-25 01:56:26 UTC (rev 2660) @@ -54,8 +54,15 @@ Ogre::TerrainGroup *mTerrainGroup; Ogre::TerrainPaging* mTerrainPaging; Ogre::PageManager* mPageManager; - Ogre::StringVector blendMaps, blendMode; + typedef struct blendLayerInfo_t { + Ogre::String blendMapTextureFilename; + char blendMode; + float alpha; + } blendLayerInfo_t; + + std::vector<blendLayerInfo_t> blendInfo; + void initTerrain(); bool loadTerrainConfig(Ogre::String filename); void configureTerrainDefaults(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel