예제 #1
0
void RigidObject::setSegmentIndex(int segment_ind) {
  segment_ind_ = segment_ind;

  Ogre::SubEntity *pSub = entity_->getSubEntity(0);
  // mark segment index for vertex shader
  pSub->setCustomParameter(1, Ogre::Vector4(segment_ind_, 0, 0, 0));
}
void LIRenAttachmentEntity::update_settings ()
{
	if (entity == NULL)
		return;

	entity->setCastShadows (object->get_shadow_casting ());
	entity->setRenderQueueGroup (object->get_render_queue ());

	// Set the custom parameters of subentities.
	const std::map<int, Ogre::Vector4>& params = object->get_custom_params ();
	for (size_t subent_idx = 0 ; subent_idx < entity->getNumSubEntities () ; ++subent_idx)
	{
		Ogre::SubEntity* subent = entity->getSubEntity (subent_idx);
		std::map<int, Ogre::Vector4>::const_iterator iter;
		for (iter = params.begin () ; iter != params.end () ; iter++)
			subent->setCustomParameter (iter->first, iter->second);
	}
}
예제 #3
0
RigidObject::RigidObject(std::string file_name,
                         Ogre::SceneManager *scene_manager, int segment_ind)
    : segment_ind_{ segment_ind }, scene_manager_{ scene_manager } {
  Ogre::MeshPtr object_mesh = render::loadMeshFromResource(file_name);
  entity_ = scene_manager_->createEntity(file_name);
  Ogre::MaterialPtr mat =
      Ogre::MaterialManager::getSingleton().getByName("textured");
  std::stringstream ss;
  ss << "textured_" << segment_ind_;
  Ogre::MaterialPtr cloned_mat = mat->clone(ss.str());
  Ogre::Pass *pass = cloned_mat->getTechnique(0)->getPass(0);
  Ogre::TextureUnitState *tex_unit = pass->createTextureUnitState();
  Ogre::MaterialPtr tmp = Ogre::MaterialManager::getSingleton().getByName(
      object_mesh->getSubMesh(0)->getMaterialName());
  tex_unit->setTextureName(tmp->getTechnique(0)
                               ->getPass(0)
                               ->getTextureUnitState(0)
                               ->getTextureName());
  entity_->setMaterial(cloned_mat);

  texture_name_ = tex_unit->getTextureName();
  file_name_ = file_name;

  Ogre::SubEntity *pSub = entity_->getSubEntity(0);
  // mark segment index for vertex shader
  pSub->setCustomParameter(1, Ogre::Vector4(segment_ind_, 0, 0, 0));

  visual_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();
  visual_node_->attachObject(entity_);

  // store the vertex positions
  extractMeshPositions(object_mesh.get());
  //  std::cout << "extracted " << positions_.size() << " vertices\n";

  // compute the bounding box
  computeBoundingBox();
}