42 Ogre::SceneNode& parent_scene_node,
45 : scene_manager_(scene_manager), manual_object_(
NULL), bounds_(bounds)
48 static int material_count = 0;
49 std::stringstream material_name;
50 material_name <<
"NavGridMaterial" << material_count++;
51 material_ = Ogre::MaterialManager::getSingleton().getByName(
"rviz/Indexed8BitImage");
55 material_->getTechnique(0)->setLightingEnabled(
false);
57 material_->setCullingMode(Ogre::CULL_NONE);
60 static int map_count = 0;
61 std::stringstream object_name;
62 object_name <<
"NavGridObject" << map_count++;
65 static int node_count = 0;
66 std::stringstream node_name;
67 node_name <<
"NGNodeObject" << node_count++;
69 scene_node_ = parent_scene_node.createChildSceneNode(node_name.str());
120 std::vector<unsigned char> pixels;
130 manual_object_->detachFromParent();
136 Ogre::DataStreamPtr pixel_stream;
137 pixel_stream.bind(
new Ogre::MemoryDataStream(&pixels[0], pixels.size()));
139 if (!texture_.isNull())
141 Ogre::TextureManager::getSingleton().remove(texture_->getName());
145 static int tex_count = 0;
146 std::stringstream texture_name;
147 texture_name <<
"MapTexture" << tex_count++;
148 texture_ = Ogre::TextureManager::getSingleton().loadRawData(texture_name.str(),
149 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
150 pixel_stream, bounds_.getWidth(), bounds_.getHeight(), Ogre::PF_L8, Ogre::TEX_TYPE_2D,
153 setTexture(texture_->getName(), 0);
154 manual_object_->setVisible(
true);
160 manual_object_->setVisible(
false);
162 if (!texture_.isNull())
164 Ogre::TextureManager::getSingleton().remove(texture_->getName());
171 Ogre::Pass* pass = material_->getTechnique(0)->getPass(0);
172 Ogre::TextureUnitState* tex_unit =
NULL;
173 if (pass->getNumTextureUnitStates() > index)
175 tex_unit = pass->getTextureUnitState(index);
179 tex_unit = pass->createTextureUnitState();
181 tex_unit->setTextureName(texture_name);
182 tex_unit->setTextureFiltering(Ogre::TFO_NONE);
186 Ogre::Renderable::Visitor* alpha_setter)
188 material_->setSceneBlending(scene_blending);
189 material_->setDepthWriteEnabled(depth_write);
192 manual_object_->visitRenderables(alpha_setter);
193 manual_object_->setRenderQueueGroup(group);