本文整理汇总了C++中ogre::Entity::isVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::isVisible方法的具体用法?C++ Entity::isVisible怎么用?C++ Entity::isVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::isVisible方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collision
Object* ObjectManager::collision(const Ogre::Vector3& fromPoint, const Ogre::Vector3& toPoint,
float collisionRadius, int queryMask)
{
Ogre::Entity* entity = mCollision->collidesWithObject(fromPoint, toPoint, collisionRadius, queryMask);
if (entity && entity->isVisible())
return getObject(entity->getName());
return 0;
}
示例2: appFrameStarted
//.........这里部分代码省略.........
// Check for object type.
if (std::string::npos != s.rfind("box"))
{
outputString += " box";
type = OBJECT_TYPE_BOX;
makeObject = true;
}
else if (std::string::npos != s.rfind("sphere"))
{
outputString += " sphere";
type = OBJECT_TYPE_SPHERE;
makeObject = true;
}
else if (std::string::npos != s.rfind("wall"))
{
outputString += " wall";
type = OBJECT_TYPE_WALL;
makeObject = true;
}
else if (std::string::npos != s.rfind("tower"))
{
outputString += " tower";
type = OBJECT_TYPE_TOWER;
makeObject = true;
}
else if (std::string::npos != s.rfind("character"))
{
outputString += " character";
type = OBJECT_TYPE_RAGDOLL;
makeObject = true;
}
if (makeObject)
{
voce::synthesize(outputString);
createObject(material, type);
}
}
// Update the grasping spring line.
if (mPhysicalCamera->isGrasping())
{
Ogre::Entity* pickingSphere =
mSceneMgr->getEntity("pickingSphere");
if (!pickingSphere->isVisible())
{
pickingSphere->setVisible(true);
}
Ogre::Entity* springLine =
mSceneMgr->getEntity("springLine");
if (!springLine->isVisible())
{
springLine->setVisible(true);
}
opal::Point3r desiredPos =
mPhysicalCamera->getGraspGlobalPos();
Ogre::Vector3 point0(desiredPos[0], desiredPos[1], desiredPos[2]);
opal::Point3r attachPos = mPhysicalCamera->getAttachGlobalPos();
Ogre::Vector3 point1(attachPos[0], attachPos[1], attachPos[2]);
pickingSphere->getParentSceneNode()->setPosition(point1);
Ogre::Vector3 lineVec = point0 - point1;
if (!lineVec.isZeroLength())
{
Ogre::SceneNode* springLineNode =
springLine->getParentSceneNode();
springLineNode->setPosition(0.5 * (point0 + point1));
springLineNode->setDirection(lineVec);
springLineNode->setScale(0.1, 0.1, lineVec.length());
}
else
{
springLine->setVisible(false);
}
}
else
{
Ogre::Entity* pickingSphere =
mSceneMgr->getEntity("pickingSphere");
if (pickingSphere->isVisible())
{
pickingSphere->setVisible(false);
}
Ogre::Entity* springLine =
mSceneMgr->getEntity("springLine");
if (springLine->isVisible())
{
springLine->setVisible(false);
}
}
// Return true to continue looping.
return keepLooping;
}
示例3: appFrameStarted
bool PlaypenApp::appFrameStarted(opal::real dt)
{
// Do per-frame application-specific things here.
// Update the grasping spring line.
if (mPhysicalCamera->isGrasping())
{
Ogre::Entity* pickingSphere =
mSceneMgr->getEntity("pickingSphere");
if (!pickingSphere->isVisible())
{
pickingSphere->setVisible(true);
}
Ogre::Entity* springLine =
mSceneMgr->getEntity("springLine");
if (!springLine->isVisible())
{
springLine->setVisible(true);
}
opal::Point3r desiredPos =
mPhysicalCamera->getGraspGlobalPos();
Ogre::Vector3 point0(desiredPos[0], desiredPos[1], desiredPos[2]);
opal::Point3r attachPos = mPhysicalCamera->getAttachGlobalPos();
Ogre::Vector3 point1(attachPos[0], attachPos[1], attachPos[2]);
pickingSphere->getParentSceneNode()->setPosition(point1);
Ogre::Vector3 lineVec = point0 - point1;
if (!lineVec.isZeroLength())
{
Ogre::SceneNode* springLineNode =
springLine->getParentSceneNode();
springLineNode->setPosition(0.5 * (point0 + point1));
springLineNode->setDirection(lineVec, Ogre::Node::TS_WORLD);
springLineNode->setScale(0.1, 0.1, lineVec.length());
}
else
{
springLine->setVisible(false);
}
}
else
{
Ogre::Entity* pickingSphere =
mSceneMgr->getEntity("pickingSphere");
if (pickingSphere->isVisible())
{
pickingSphere->setVisible(false);
}
Ogre::Entity* springLine =
mSceneMgr->getEntity("springLine");
if (springLine->isVisible())
{
springLine->setVisible(false);
}
}
// Return true to continue looping.
return true;
}
示例4: calculateEntityVisibility
// BETWEEN FRAME OPERATION
void VisCalcFrustDist::calculateEntityVisibility(Ogre::Node* regionNode, Ogre::Node* node, bool recurse) {
if (recurse && node->numChildren() > 0) {
// if node has more children nodes, visit them recursivily
Ogre::SceneNode::ChildNodeIterator nodeChildIterator = node->getChildIterator();
while (nodeChildIterator.hasMoreElements()) {
Ogre::Node* nodeChild = nodeChildIterator.getNext();
// 'false' causes it to not visit sub-children which are included in parent and pos relative to parent
calculateEntityVisibility(regionNode, nodeChild, false);
visChildren++;
}
}
visNodes++;
// children taken care of... check fo attached objects to this node
Ogre::SceneNode* snode = (Ogre::SceneNode*)node;
// the camera needs to be made relative to the region
// Ogre::Vector3 relCameraPos = LG::RendererOgre::Instance()->m_camera->getPosition() - regionNode->getPosition();
// float snodeDistance = LG::RendererOgre::Instance()->m_camera->getPosition().distance(snode->_getWorldAABB().getCenter());
// float snodeDistance = relCameraPos.distance(snode->getPosition());
float snodeDistance = LG::RendererOgre::Instance()->m_camera->getDistanceFromCamera(regionNode, snode->getPosition());
Ogre::SceneNode::ObjectIterator snodeObjectIterator = snode->getAttachedObjectIterator();
while (snodeObjectIterator.hasMoreElements()) {
Ogre::MovableObject* snodeObject = snodeObjectIterator.getNext();
if (snodeObject->getMovableType() == "Entity") {
visEntities++;
Ogre::Entity* snodeEntity = (Ogre::Entity*)snodeObject;
// check it's visibility if it's not world geometry (terrain and ocean)
if ((snodeEntity->getQueryFlags() & Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK) == 0) {
// computation if it should be visible
// Note: this call is overridden by derived classes that do fancier visibility rules
bool shouldBeVisible = this->CalculateVisibilityImpl(LG::RendererOgre::Instance()->m_camera, snodeEntity, snodeDistance);
if (snodeEntity->isVisible()) {
// we currently think this object is visible. make sure it should stay that way
if (shouldBeVisible) {
// it should stay visible
visVisToVis++;
}
else {
// not visible any more... make invisible nad unload it`
/*
Ogre::Vector3 cPos = LG::RendererOgre::Instance()->m_camera->getPosition();
Ogre::Vector3 rPos = regionNode->getPosition();
Ogre::Vector3 sPos = snode->getPosition();
LG::Log("VisToInVis: cPos=<%f,%f,%f>, rPos=<%f,%f,%f>, sPos(%s)=<%f,%f,%f>, d=%f",
cPos.x, cPos.y, cPos.z,
rPos.x, rPos.y, rPos.z,
snode->getName().c_str(),
sPos.x, sPos.y, sPos.z,
snodeDistance);
*/
snodeEntity->setVisible(false);
snode->needUpdate(true);
visVisToInvis++;
if (!snodeEntity->getMesh().isNull()) {
queueMeshUnload(snodeEntity->getMesh());
}
}
}
else {
// the entity currently thinks it's not visible.
// check to see if it should be visible by checking a fake bounding box
if (shouldBeVisible) {
// it should become visible again
if (!snodeEntity->getMesh().isNull()) {
// queueMeshLoad(snodeEntity, snodeEntity->getMesh());
LG::OLMeshTracker::Instance()->MakeLoaded(snodeEntity->getMesh()->getName(),
Ogre::String(""), Ogre::String("visible"), snodeEntity);
}
// snodeEntity->setVisible(true); // must happen after mesh loaded
visInvisToVis++;
}
else {
visInvisToInvis++;
}
}
}
}
}
}