本文整理汇总了C++中RendererPtr::GetUniqueObjectName方法的典型用法代码示例。如果您正苦于以下问题:C++ RendererPtr::GetUniqueObjectName方法的具体用法?C++ RendererPtr::GetUniqueObjectName怎么用?C++ RendererPtr::GetUniqueObjectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RendererPtr
的用法示例。
在下文中一共展示了RendererPtr::GetUniqueObjectName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CommitChanges
bool EC_OgreCustomObject::CommitChanges(Ogre::ManualObject* object)
{
if (!object)
return false;
if (renderer_.expired())
return false;
RendererPtr renderer = renderer_.lock();
DestroyEntity();
// If placeable is not set yet, set it manually by searching it from the parent entity
if (!placeable_)
{
Scene::Entity* entity = GetParentEntity();
if (entity)
{
ComponentPtr placeable = entity->GetComponent(EC_Placeable::TypeNameStatic());
if (placeable)
placeable_ = placeable;
}
}
if (!object->getNumSections())
return true;
try
{
std::string mesh_name = renderer->GetUniqueObjectName("EC_OgreCustomObject_mesh");
object->convertToMesh(mesh_name);
object->clear();
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
entity_ = scene_mgr->createEntity(renderer->GetUniqueObjectName("EC_OgreCustomObject_entity"), mesh_name);
if (entity_)
{
AttachEntity();
entity_->setRenderingDistance(draw_distance_);
entity_->setCastShadows(cast_shadows_);
entity_->setUserAny(Ogre::Any(GetParentEntity()));
// Set UserAny also on subentities
for (uint i = 0; i < entity_->getNumSubEntities(); ++i)
entity_->getSubEntity(i)->setUserAny(entity_->getUserAny());
}
else
{
OgreRenderingModule::LogError("Could not create entity from manualobject mesh");
return false;
}
}
catch (Ogre::Exception& e)
{
OgreRenderingModule::LogError("Could not convert manualobject to mesh: " + std::string(e.what()));
return false;
}
return true;
}
示例2: PrepareMesh
Ogre::Mesh* EC_Mesh::PrepareMesh(const std::string& mesh_name, bool clone)
{
if (!ViewEnabled())
return 0;
if (renderer_.expired())
return 0;
RendererPtr renderer = renderer_.lock();
Ogre::MeshManager& mesh_mgr = Ogre::MeshManager::getSingleton();
Ogre::MeshPtr mesh = mesh_mgr.getByName(SanitateAssetIdForOgre(mesh_name));
// For local meshes, mesh will not get automatically loaded until used in an entity. Load now if necessary
if (mesh.isNull())
{
try
{
mesh_mgr.load(mesh_name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mesh = mesh_mgr.getByName(mesh_name);
}
catch (Ogre::Exception& e)
{
LogError("Could not load mesh " + mesh_name + ": " + std::string(e.what()));
return 0;
}
}
// If mesh is still null, must abort
if (mesh.isNull())
{
LogError("Mesh " + mesh_name + " does not exist");
return 0;
}
if (clone)
{
try
{
mesh = mesh->clone(renderer->GetUniqueObjectName("EC_Mesh_clone"));
mesh->setAutoBuildEdgeLists(false);
cloned_mesh_name_ = mesh->getName();
}
catch (Ogre::Exception& e)
{
LogError("Could not clone mesh " + mesh_name + ":" + std::string(e.what()));
return 0;
}
}
if (mesh->hasSkeleton())
{
Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().getByName(mesh->getSkeletonName());
if (skeleton.isNull() || skeleton->getNumBones() == 0)
{
LogDebug("Mesh " + mesh_name + " has a skeleton with 0 bones. Disabling the skeleton.");
mesh->setSkeletonName("");
}
}
return mesh.get();
}
示例3:
EC_OgreLight::EC_OgreLight(Foundation::ModuleInterface* module) :
Foundation::ComponentInterface(module->GetFramework()),
renderer_(checked_static_cast<OgreRenderingModule*>(module)->GetRenderer()),
light_(0),
attached_(false)
{
RendererPtr renderer = renderer_.lock();
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
light_ = scene_mgr->createLight(renderer->GetUniqueObjectName());
}
示例4: CreateSunlight
void EC_OgreEnvironment::CreateSunlight()
{
if (renderer_.expired())
return;
RendererPtr renderer = renderer_.lock();
Ogre::SceneManager* sceneManager = renderer->GetSceneManager();
sunlight_ = sceneManager->createLight(renderer->GetUniqueObjectName());
sunlight_->setType(Ogre::Light::LT_DIRECTIONAL);
///\todo Read parameters from config file?
sunlight_->setDiffuseColour(0.93f, 1, 0.13f);
sunlight_->setDirection(-1, -1, -1);
sunlight_->setCastShadows(true);
SetAmbientLightColor(Color(0.5, 0.5, 0.5, 1));
}
示例5:
EC_OgreCamera::EC_OgreCamera(Foundation::ModuleInterface* module) :
Foundation::ComponentInterface(module->GetFramework()),
renderer_(checked_static_cast<OgreRenderingModule*>(module)->GetRenderer()),
attached_(false),
camera_(0)
{
RendererPtr renderer = renderer_.lock();
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
Ogre::Viewport* viewport = renderer->GetViewport();
camera_ = scene_mgr->createCamera(renderer->GetUniqueObjectName());
// Set default values for the camera
camera_->setNearClipDistance(0.1f);
camera_->setFarClipDistance(2000.f);
camera_->setAspectRatio(Ogre::Real(viewport->getActualWidth() / Ogre::Real(viewport->getActualHeight())));
camera_->setAutoAspectRatio(true);
}
示例6: drawDistanceData
EC_Mesh::EC_Mesh(IModule* module) :
IComponent(module->GetFramework()),
// Note: we put the opensim haxor adjust right here in the defaults, instead of hardcoding it in code.
nodeTransformation(this, "Transform", Transform(Vector3df(0,0,0),Vector3df(90,0,180),Vector3df(1,1,1))),
meshRef(this, "Mesh ref"),
skeletonRef(this, "Skeleton ref"),
meshMaterial(this, "Mesh materials"),
drawDistance(this, "Draw distance", 0.0f),
castShadows(this, "Cast shadows", false),
renderer_(checked_static_cast<OgreRenderingModule*>(module)->GetRenderer()),
entity_(0),
bone_tagpoint_(0),
bone_parent_mesh_(0),
bone_attached_mesh_(0),
attached_(false),
attached_to_bone_(false)
{
static AttributeMetadata drawDistanceData("", "0", "10000");
drawDistance.SetMetadata(&drawDistanceData);
static AttributeMetadata materialMetadata;
materialMetadata.elementType = "assetreference";
meshMaterial.SetMetadata(&materialMetadata);
static AttributeMetadata meshRefMetadata;
AttributeMetadata::ButtonInfoList meshRefButtons;
meshRefButtons.push_back(AttributeMetadata::ButtonInfo(meshRef.GetName(), "V", "View"));
meshRefMetadata.buttons = meshRefButtons;
meshRef.SetMetadata(&meshRefMetadata);
RendererPtr renderer = renderer_.lock();
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
adjustment_node_ = scene_mgr->createSceneNode(renderer->GetUniqueObjectName("EC_Mesh_adjustment_node"));
connect(this, SIGNAL(ParentEntitySet()), SLOT(UpdateSignals()));
connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)), SLOT(OnAttributeUpdated(IAttribute*)));
meshAsset = AssetRefListenerPtr(new AssetRefListener());
connect(meshAsset.get(), SIGNAL(Loaded(AssetPtr)), this, SLOT(OnMeshAssetLoaded(AssetPtr)), Qt::UniqueConnection);
skeletonAsset = AssetRefListenerPtr(new AssetRefListener());
connect(skeletonAsset.get(), SIGNAL(Loaded(AssetPtr)), this, SLOT(OnSkeletonAssetLoaded(AssetPtr)), Qt::UniqueConnection);
}
示例7: SetAttachmentMesh
bool EC_Mesh::SetAttachmentMesh(uint index, const std::string& mesh_name, const std::string& attach_point, bool share_skeleton)
{
if (!ViewEnabled())
return false;
if (renderer_.expired())
return false;
RendererPtr renderer = renderer_.lock();
if (!entity_)
{
LogError("No mesh entity created yet, can not create attachments");
return false;
}
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
size_t oldsize = attachment_entities_.size();
size_t newsize = index + 1;
if (oldsize < newsize)
{
attachment_entities_.resize(newsize);
attachment_nodes_.resize(newsize);
for (uint i = oldsize; i < newsize; ++i)
{
attachment_entities_[i] = 0;
attachment_nodes_[i] = 0;
}
}
RemoveAttachmentMesh(index);
Ogre::Mesh* mesh = PrepareMesh(mesh_name, false);
if (!mesh)
return false;
if (share_skeleton)
{
// If sharing a skeleton, force the attachment mesh to use the same skeleton
// This is theoretically quite a scary operation, for there is possibility for things to go wrong
Ogre::SkeletonPtr entity_skel = entity_->getMesh()->getSkeleton();
if (entity_skel.isNull())
{
LogError("Cannot share skeleton for attachment, not found");
return false;
}
try
{
mesh->_notifySkeleton(entity_skel);
}
catch (Ogre::Exception e)
{
LogError("Could not set shared skeleton for attachment");
return false;
}
}
try
{
QString entityName = QString("EC_Mesh_attach") + QString::number(index);
attachment_entities_[index] = scene_mgr->createEntity(renderer->GetUniqueObjectName(entityName.toStdString()), mesh->getName());
if (!attachment_entities_[index])
{
LogError("Could not set attachment mesh " + mesh_name);
return false;
}
attachment_entities_[index]->setRenderingDistance(drawDistance.Get());
attachment_entities_[index]->setCastShadows(castShadows.Get());
attachment_entities_[index]->setUserAny(entity_->getUserAny());
// Set UserAny also on subentities
for (uint i = 0; i < attachment_entities_[index]->getNumSubEntities(); ++i)
attachment_entities_[index]->getSubEntity(i)->setUserAny(entity_->getUserAny());
Ogre::Bone* attach_bone = 0;
if (!attach_point.empty())
{
Ogre::Skeleton* skel = entity_->getSkeleton();
if (skel && skel->hasBone(attach_point))
attach_bone = skel->getBone(attach_point);
}
if (attach_bone)
{
Ogre::TagPoint* tag = entity_->attachObjectToBone(attach_point, attachment_entities_[index]);
attachment_nodes_[index] = tag;
}
else
{
QString nodeName = QString("EC_Mesh_attachment_") + QString::number(index);
Ogre::SceneNode* node = scene_mgr->createSceneNode(renderer->GetUniqueObjectName(nodeName.toStdString()));
node->attachObject(attachment_entities_[index]);
adjustment_node_->addChild(node);
attachment_nodes_[index] = node;
}
if (share_skeleton && entity_->hasSkeleton() && attachment_entities_[index]->hasSkeleton())
{
attachment_entities_[index]->shareSkeletonInstanceWith(entity_);
}
}
//.........这里部分代码省略.........
示例8: SetMeshWithSkeleton
bool EC_Mesh::SetMeshWithSkeleton(const std::string& mesh_name, const std::string& skeleton_name, bool clone)
{
if (!ViewEnabled())
return false;
if (renderer_.expired())
return false;
RendererPtr renderer = renderer_.lock();
Ogre::SkeletonPtr skel = Ogre::SkeletonManager::getSingleton().getByName(SanitateAssetIdForOgre(skeleton_name));
if (skel.isNull())
{
LogError("Could not set skeleton " + skeleton_name + " to mesh " + mesh_name + ": not found");
return false;
}
RemoveMesh();
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
Ogre::Mesh* mesh = PrepareMesh(mesh_name, clone);
if (!mesh)
return false;
try
{
mesh->_notifySkeleton(skel);
// LogDebug("Set skeleton " + skeleton_name + " to mesh " + mesh_name);
}
catch (Ogre::Exception& e)
{
LogError("Could not set skeleton " + skeleton_name + " to mesh " + mesh_name + ": " + std::string(e.what()));
return false;
}
try
{
entity_ = scene_mgr->createEntity(renderer->GetUniqueObjectName("EC_Mesh_entwithskel"), mesh->getName());
if (!entity_)
{
LogError("Could not set mesh " + mesh_name);
return false;
}
entity_->setRenderingDistance(drawDistance.Get());
entity_->setCastShadows(castShadows.Get());
entity_->setUserAny(Ogre::Any(GetParentEntity()));
// Set UserAny also on subentities
for (uint i = 0; i < entity_->getNumSubEntities(); ++i)
entity_->getSubEntity(i)->setUserAny(entity_->getUserAny());
if (entity_->hasSkeleton())
{
Ogre::SkeletonInstance* skel = entity_->getSkeleton();
// Enable cumulative mode on skeletal animations
if (skel)
skel->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
}
}
catch (Ogre::Exception& e)
{
LogError("Could not set mesh " + mesh_name + ": " + std::string(e.what()));
return false;
}
AttachEntity();
emit MeshChanged();
return true;
}
示例9: SetMesh
bool EC_Mesh::SetMesh(QString meshResourceName, bool clone)
{
if (!ViewEnabled())
return false;
if (renderer_.expired())
return false;
RendererPtr renderer = renderer_.lock();
std::string mesh_name = meshResourceName.trimmed().toStdString();
RemoveMesh();
// If placeable is not set yet, set it manually by searching it from the parent entity
if (!placeable_)
{
Scene::Entity* entity = GetParentEntity();
if (entity)
{
ComponentPtr placeable = entity->GetComponent(EC_Placeable::TypeNameStatic());
if (placeable)
placeable_ = placeable;
}
}
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
Ogre::Mesh* mesh = PrepareMesh(mesh_name, clone);
if (!mesh)
return false;
try
{
entity_ = scene_mgr->createEntity(renderer->GetUniqueObjectName("EC_Mesh_entity"), mesh->getName());
if (!entity_)
{
LogError("Could not set mesh " + mesh_name);
return false;
}
entity_->setRenderingDistance(drawDistance.Get());
entity_->setCastShadows(castShadows.Get());
entity_->setUserAny(Ogre::Any(GetParentEntity()));
// Set UserAny also on subentities
for (uint i = 0; i < entity_->getNumSubEntities(); ++i)
entity_->getSubEntity(i)->setUserAny(entity_->getUserAny());
if (entity_->hasSkeleton())
{
Ogre::SkeletonInstance* skel = entity_->getSkeleton();
// Enable cumulative mode on skeletal animations
if (skel)
skel->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
}
// Make sure adjustment node is uptodate
if (adjustment_node_)
{
Transform newTransform = nodeTransformation.Get();
adjustment_node_->setPosition(newTransform.position.x, newTransform.position.y, newTransform.position.z);
Quaternion adjust(DEGTORAD * newTransform.rotation.x,
DEGTORAD * newTransform.rotation.y,
DEGTORAD * newTransform.rotation.z);
adjustment_node_->setOrientation(Ogre::Quaternion(adjust.w, adjust.x, adjust.y, adjust.z));
// Prevent Ogre exception from zero scale
if (newTransform.scale.x < 0.0000001f)
newTransform.scale.x = 0.0000001f;
if (newTransform.scale.y < 0.0000001f)
newTransform.scale.y = 0.0000001f;
if (newTransform.scale.z < 0.0000001f)
newTransform.scale.z = 0.0000001f;
adjustment_node_->setScale(newTransform.scale.x, newTransform.scale.y, newTransform.scale.z);
}
// Force a re-apply of all materials to this new mesh.
ApplyMaterial();
}
catch (Ogre::Exception& e)
{
LogError("Could not set mesh " + mesh_name + ": " + std::string(e.what()));
return false;
}
AttachEntity();
emit MeshChanged();
return true;
}