MaterialTransitPtr OctreeVisualization::createMatFilled(OctreePtr tree, const Octree::OTNodePtr node, const Color3f& CoolColor, const Color3f& HotColor, Real32 Alpha, BlendChunk* BaseBlendChunk, PolygonChunk* BasePolygonChunk ) { //Calculate the Color //Real32 t = static_cast<Real32>(node->getDepth())/static_cast<Real32>(tree->getDepth()); //Color3f NodeColor(t*HotColor + (1.0f-t)*CoolColor); Color3f NodeColor; Color4f NodeColorWithAlpha; if(node->getContainsObstacles()) { NodeColor = HotColor; NodeColorWithAlpha.setValuesRGBA(NodeColor.red(),NodeColor.green(),NodeColor.blue(),0.55); } else { NodeColor = CoolColor; NodeColorWithAlpha.setValuesRGBA(NodeColor.red(),NodeColor.green(),NodeColor.blue(),0.05); } MaterialChunkRecPtr DefaultMatChunk = MaterialChunk::create(); DefaultMatChunk->setAmbient(NodeColorWithAlpha); DefaultMatChunk->setDiffuse(NodeColorWithAlpha); ChunkMaterialRecPtr NodeMat = ChunkMaterial::create(); NodeMat->setSortKey(1); NodeMat->addChunk(BaseBlendChunk); NodeMat->addChunk(BasePolygonChunk); NodeMat->addChunk(DefaultMatChunk); return MaterialTransitPtr(NodeMat); }
Vec3f colorToVector( Color3f color ) { return Vec3f( color.red(), color.green(), color.blue() ); }