MaterialTransitPtr OctreeVisualization::createMatLine(OctreePtr tree, const Octree::OTNodePtr node, const Color3f& CoolColor, const Color3f& HotColor, Real32 Alpha, BlendChunk* BaseBlendChunk, LineChunk* BaseLineChunk ) { //Calculate the Color Real32 t = static_cast<Real32>(node->getDepth())/static_cast<Real32>(tree->getDepth()); Color3f NodeColor(t*HotColor + (1.0f-t)*CoolColor); Color4f NodeColorWithAlpha(NodeColor.red(),NodeColor.green(),NodeColor.blue(),Alpha); MaterialChunkRecPtr DefaultMatChunk = MaterialChunk::create(); DefaultMatChunk->setAmbient(NodeColorWithAlpha); DefaultMatChunk->setDiffuse(NodeColorWithAlpha); ChunkMaterialRecPtr NodeMat = ChunkMaterial::create(); NodeMat->setSortKey(1); NodeMat->addChunk(BaseBlendChunk); NodeMat->addChunk(DefaultMatChunk); NodeMat->addChunk(BaseLineChunk); return MaterialTransitPtr(NodeMat); }
void VRTransform::initTranslator() { // TODO if (translator != 0) return; translator = makeCoordAxis(0.3, 3, false); translator->setTravMask(0); addChild(translator); GeometryRecPtr geo = dynamic_cast<Geometry*>(translator->getCore()); string shdr_vp = "void main( void ) {" " gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;" " gl_Position.z = -0.1;" " gl_FrontColor = gl_Color;" "}"; /*string shdr_fp = "void main( void ) {" " gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;" " gl_Position.z = -0.1;" "}";*/ ChunkMaterialRecPtr mat = ChunkMaterial::create(); mat->setSortKey(100);// render last SimpleSHLChunkRecPtr shader_chunk = SimpleSHLChunk::create(); shader_chunk->setVertexProgram(shdr_vp.c_str()); //shader_chunk->setVertexProgram(shdr_fp.c_str()); mat->addChunk(shader_chunk); geo->setMaterial(mat); }
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); }