本文整理汇总了C++中OgreWorldPtr类的典型用法代码示例。如果您正苦于以下问题:C++ OgreWorldPtr类的具体用法?C++ OgreWorldPtr怎么用?C++ OgreWorldPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OgreWorldPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveWaterPlane
void EC_WaterPlane::CreateWaterPlane()
{
if (!ViewEnabled())
return;
if (entity_)
RemoveWaterPlane();
OgreWorldPtr world = world_.lock();
// Create water plane
if (world)
{
Ogre::SceneManager *sceneMgr = world->GetSceneManager();
assert(sceneMgr);
if (node_ != 0)
{
int x = xSize.Get();
int y = ySize.Get();
float uTile = scaleUfactor.Get() * x; /// Default x-size 5000 --> uTile 1.0
float vTile = scaleVfactor.Get() * y;
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().createPlane(Name().toStdString().c_str(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::Plane(Ogre::Vector3::UNIT_Y, 0),
x, y, xSegments.Get(), ySegments.Get(), true, 1, uTile, vTile, Ogre::Vector3::UNIT_X);
entity_ = sceneMgr->createEntity(world->GetUniqueObjectName("EC_WaterPlane_entity"), Name().toStdString().c_str());
entity_->setMaterialName(materialName.Get().toStdString().c_str());
entity_->setCastShadows(false);
// Tries to attach entity, if there is not EC_Placeable availible, it will not attach object
AttachEntity();
}
}
}
示例2: IComponent
EC_Mesh::EC_Mesh(Scene* scene) :
IComponent(scene),
nodeTransformation(this, "Transform", Transform(float3(0,0,0),float3(0,0,0),float3(1,1,1))),
meshRef(this, "Mesh ref", AssetReference("", "OgreMesh")),
skeletonRef(this, "Skeleton ref", AssetReference("", "OgreSkeleton")),
meshMaterial(this, "Mesh materials", AssetReferenceList("OgreMaterial")),
drawDistance(this, "Draw distance", 0.0f),
castShadows(this, "Cast shadows", false),
entity_(0),
attached_(false)
{
if (scene)
world_ = scene->GetWorld<OgreWorld>();
static AttributeMetadata drawDistanceData("", "0", "10000");
drawDistance.SetMetadata(&drawDistanceData);
static AttributeMetadata materialMetadata;
materialMetadata.elementType = "assetreference";
meshMaterial.SetMetadata(&materialMetadata);
meshAsset = AssetRefListenerPtr(new AssetRefListener());
skeletonAsset = AssetRefListenerPtr(new AssetRefListener());
OgreWorldPtr world = world_.lock();
if (world)
{
Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
adjustment_node_ = sceneMgr->createSceneNode(world->GetUniqueObjectName("EC_Mesh_adjustment_node"));
connect(this, SIGNAL(ParentEntitySet()), SLOT(UpdateSignals()));
connect(meshAsset.get(), SIGNAL(Loaded(AssetPtr)), this, SLOT(OnMeshAssetLoaded(AssetPtr)), Qt::UniqueConnection);
connect(skeletonAsset.get(), SIGNAL(Loaded(AssetPtr)), this, SLOT(OnSkeletonAssetLoaded(AssetPtr)), Qt::UniqueConnection);
}
}
示例3: RemoveMesh
void EC_Mesh::RemoveMesh()
{
OgreWorldPtr world = world_.lock();
if (entity_)
{
emit MeshAboutToBeDestroyed();
RemoveAllAttachments();
DetachEntity();
Ogre::SceneManager* sceneMgr = world->OgreSceneManager();
sceneMgr->destroyEntity(entity_);
entity_ = 0;
}
if (!cloned_mesh_name_.empty())
{
try
{
Ogre::MeshManager::getSingleton().remove(cloned_mesh_name_);
}
catch(Ogre::Exception& e)
{
LogWarning("EC_Mesh::RemoveMesh: Could not remove cloned mesh:" + std::string(e.what()));
}
cloned_mesh_name_ = std::string();
}
}
示例4: LogError
EC_Placeable::~EC_Placeable()
{
if (world_.expired())
{
if (sceneNode_)
LogError("EC_Placeable: World has expired, skipping uninitialization!");
return;
}
emit AboutToBeDestroyed();
OgreWorldPtr world = world_.lock();
Ogre::SceneManager* sceneMgr = world->GetSceneManager();
if (sceneNode_)
{
DetachNode();
sceneMgr->destroySceneNode(sceneNode_);
sceneNode_ = 0;
}
// Destroy the attachment node if it was created
if (boneAttachmentNode_)
{
sceneMgr->getRootSceneNode()->removeChild(boneAttachmentNode_);
sceneMgr->destroySceneNode(boneAttachmentNode_);
boneAttachmentNode_ = 0;
}
}
示例5: PrepareMesh
Ogre::Mesh* EC_Mesh::PrepareMesh(const std::string& mesh_name, bool clone)
{
if (!ViewEnabled())
return 0;
OgreWorldPtr world = world_.lock();
Ogre::MeshManager& mesh_mgr = Ogre::MeshManager::getSingleton();
Ogre::MeshPtr mesh = mesh_mgr.getByName(AssetAPI::SanitateAssetRef(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("EC_Mesh::PrepareMesh: Could not load mesh " + mesh_name + ": " + std::string(e.what()));
return 0;
}
}
// If mesh is still null, must abort
if (mesh.isNull())
{
LogError("EC_Mesh::PrepareMesh: Mesh " + mesh_name + " does not exist");
return 0;
}
if (clone)
{
try
{
mesh = mesh->clone(world->GetUniqueObjectName("EC_Mesh_clone"));
mesh->setAutoBuildEdgeLists(false);
cloned_mesh_name_ = mesh->getName();
}
catch(Ogre::Exception& e)
{
LogError("EC_Mesh::PrepareMesh: 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("EC_Mesh::PrepareMesh: Mesh " + mesh_name + " has a skeleton with 0 bones. Disabling the skeleton.");
mesh->setSkeletonName("");
}
}
return mesh.get();
}
示例6: addPoint
void OcclusionDebugRenderer::addPoint(const Umbra::Vector3& pt, const Umbra::Vector4& color)
{
OgreWorldPtr ogreWorld = renderer_->GetActiveOgreWorld();
if(!ogreWorld.get())
return;
// Nothing to do here
float3 point = Vector3ToFloat3(pt);
ogreWorld->DebugDrawSphere(point, 0.1f, 6, Color::Red);
}
示例7: addLine
void OcclusionDebugRenderer::addLine(const Umbra::Vector3& start, const Umbra::Vector3& end, const Umbra::Vector4& color)
{
OgreWorldPtr ogreWorld = renderer_->GetActiveOgreWorld();
if(!ogreWorld.get())
return;
float3 start_ = Vector3ToFloat3(start);
float3 end_ = Vector3ToFloat3(end);
ogreWorld->DebugDrawLine(start_, end_, Color::Yellow);
}
示例8:
EC_SelectionBox::~EC_SelectionBox()
{
if (selectionBox_)
{
OgreWorldPtr world = world_.lock();
if (world)
{
Ogre::SceneManager* sceneMgr = world->GetSceneManager();
sceneMgr->destroyManualObject(selectionBox_);
selectionBox_ = 0;
}
}
}
示例9: addAABB
void OcclusionDebugRenderer::addAABB(const Umbra::Vector3& mn, const Umbra::Vector3& mx, const Umbra::Vector4& color)
{
OgreWorldPtr ogreWorld = renderer_->GetActiveOgreWorld();
if(!ogreWorld.get())
return;
float3 mn_ = Vector3ToFloat3(mn);
float3 mx_ = Vector3ToFloat3(mx);
Color color_ = Vector4ToColor(color);
AABB aabb(mn_, mx_);
ogreWorld->DebugDrawAABB(aabb, color_);
}
示例10: PROFILE
void EC_Hydrax::Create()
{
PROFILE(EC_Hydrax_Create);
SAFE_DELETE(impl);
if (!framework || framework->IsHeadless())
return;
try
{
if (!ParentScene())
{
LogError("EC_Hydrax: no parent scene. Cannot be created.");
return;
}
OgreWorldPtr w = ParentScene()->Subsystem<OgreWorld>();
assert(w);
connect(w->Renderer(), SIGNAL(MainCameraChanged(Entity *)), SLOT(OnActiveCameraChanged(Entity *)), Qt::UniqueConnection);
Entity *mainCamera = w->Renderer()->MainCamera();
if (!mainCamera)
{
// Can't create Hydrax just yet, no main camera set (Hydrax needs a valid camera to initialize).
// This error is benign, and Hydrax will now postpone its initialization to until a camera is set.
// (see OnActiveCameraChanged()).
LogDebug("Cannot create EC_Hydrax: No main camera set!");
return;
}
Ogre::Camera *cam = mainCamera->GetComponent<EC_Camera>()->GetCamera();
impl = new EC_HydraxImpl();
impl->hydrax = new Hydrax::Hydrax(w->OgreSceneManager(), cam, w->Renderer()->MainViewport());
// Using projected grid module by default
Hydrax::Module::ProjectedGrid *module = new Hydrax::Module::ProjectedGrid(impl->hydrax, new Hydrax::Noise::Perlin(),
Ogre::Plane(Ogre::Vector3::UNIT_Y, Ogre::Vector3::ZERO), Hydrax::MaterialManager::NM_VERTEX);
impl->hydrax->setModule(module);
impl->module = module;
// Load all parameters from config file, but position attribute is always authoritative for the position.
RequestConfigAsset();
connect(framework->Frame(), SIGNAL(PostFrameUpdate(float)), SLOT(Update(float)), Qt::UniqueConnection);
}
catch(const Ogre::Exception &e)
{
// Currently if we try to create more than one Hydrax component we end up here due to Ogre internal name collision.
LogError("Could not create EC_Hydrax: " + std::string(e.what()));
}
}
示例11: IComponent
EC_SelectionBox::EC_SelectionBox(Scene* scene) :
IComponent(scene),
selectionBox_(0)
{
if (scene)
world_ = scene->GetWorld<OgreWorld>();
OgreWorldPtr world = world_.lock();
Ogre::SceneManager* sceneMgr = world->GetSceneManager();
selectionBox_ = sceneMgr->createManualObject(world->GetUniqueObjectName("EC_Selected"));
selectionBox_->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY);
selectionBox_->setUseIdentityProjection(true);
selectionBox_->setUseIdentityView(true);
selectionBox_->setQueryFlags(0);
sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(selectionBox_);
}
示例12: ShowMessage
void EC_HoveringText::ShowMessage(const QString &text)
{
if (!ViewEnabled())
return;
if (world_.expired())
return;
OgreWorldPtr world = world_.lock();
Ogre::SceneManager *scene = world->OgreSceneManager();
assert(scene);
if (!scene)
return;
Entity* entity = ParentEntity();
assert(entity);
if (!entity)
return;
EC_Placeable *node = entity->GetComponent<EC_Placeable>().get();
if (!node)
return;
Ogre::SceneNode *sceneNode = node->GetSceneNode();
assert(sceneNode);
if (!sceneNode)
return;
// Create billboard if it doesn't exist.
if (!billboardSet_)
{
billboardSet_ = scene->createBillboardSet(world->GetUniqueObjectName("EC_HoveringText"), 1);
assert(billboardSet_);
billboardSet_->Ogre::MovableObject::setUserAny(Ogre::Any(static_cast<IComponent *>(this)));
billboardSet_->Ogre::Renderable::setUserAny(Ogre::Any(static_cast<IComponent *>(this)));
sceneNode->attachObject(billboardSet_);
}
if (billboardSet_ && !billboard_)
{
billboard_ = billboardSet_->createBillboard(Ogre::Vector3(0, 0, 0.7f));
SetBillboardSize(width.Get(), height.Get());
SetPosition(position.Get());
}
Redraw();
}
示例13: IComponent
EC_Placeable::EC_Placeable(Scene* scene) :
IComponent(scene),
sceneNode_(0),
boneAttachmentNode_(0),
parentBone_(0),
parentPlaceable_(0),
parentMesh_(0),
attached_(false),
transform(this, "Transform"),
drawDebug(this, "Show bounding box", false),
visible(this, "Visible", true),
selectionLayer(this, "Selection layer", 1),
parentRef(this, "Parent entity ref", EntityReference()),
parentBone(this, "Parent bone name", "")
{
if (scene)
world_ = scene->GetWorld<OgreWorld>();
// Enable network interpolation for the transform
static AttributeMetadata transAttrData;
static AttributeMetadata nonDesignableAttrData;
static bool metadataInitialized = false;
if(!metadataInitialized)
{
transAttrData.interpolation = AttributeMetadata::Interpolate;
nonDesignableAttrData.designable = false;
metadataInitialized = true;
}
transform.SetMetadata(&transAttrData);
OgreWorldPtr world = world_.lock();
if (world)
{
Ogre::SceneManager* sceneMgr = world->GetSceneManager();
sceneNode_ = sceneMgr->createSceneNode(world->GetUniqueObjectName("EC_Placeable_SceneNode"));
// Would like to do this for improved debugging in the Profiler window, but because we don't have the parent entity yet, we don't know the id or the name of this entity.
// sceneNode_ = sceneMgr->createSceneNode(world->GetUniqueObjectName(("EC_Placeable_SceneNode_" + QString::number(ParentEntity()->Id()) + "_" + ParentEntity()->Name()).toStdString()));
// Hook the transform attribute change
connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)),
SLOT(HandleAttributeChanged(IAttribute*, AttributeChange::Type)));
connect(this, SIGNAL(ParentEntitySet()), SLOT(RegisterActions()));
AttachNode();
}
}
示例14: addQuad
void OcclusionDebugRenderer::addQuad(const Umbra::Vector3& x0y0, const Umbra::Vector3& x0y1, const Umbra::Vector3& x1y1, const Umbra::Vector3& x1y0, const Umbra::Vector4& color)
{
OgreWorldPtr ogreWorld = renderer_->GetActiveOgreWorld();
if(!ogreWorld.get())
return;
// Nothing to do here
float3 x0y0_, x0y1_, x1y0_, x1y1_;
x0y0_ = Vector3ToFloat3(x0y0);
x0y1_ = Vector3ToFloat3(x0y1);
x1y0_ = Vector3ToFloat3(x1y0);
x1y1_ = Vector3ToFloat3(x1y1);
ogreWorld->DebugDrawLine(x0y0_, x1y0_, Color::Yellow);
ogreWorld->DebugDrawLine(x1y0_, x1y1_, Color::Yellow);
ogreWorld->DebugDrawLine(x1y1_, x0y1_, Color::Yellow);
ogreWorld->DebugDrawLine(x0y1_, x0y0_, Color::Yellow);
}
示例15: PROFILE
void PhysicsWorld::DrawDebugGeometry()
{
if (!IsDebugGeometryEnabled())
return;
PROFILE(PhysicsModule_DrawDebugGeometry);
// Draw debug only for the active (visible) scene
OgreWorldPtr ogreWorld = scene_.lock()->GetWorld<OgreWorld>();
cachedOgreWorld_ = ogreWorld.get();
if (!ogreWorld)
return;
if (!ogreWorld->IsActive())
return;
// Get all lines of the physics world
world_->debugDrawWorld();
}