本文整理汇总了C++中ogre::MovableObject类的典型用法代码示例。如果您正苦于以下问题:C++ MovableObject类的具体用法?C++ MovableObject怎么用?C++ MovableObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MovableObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DumpNodes
void GameBodyObject::DumpNodes(NxOgre::StringPairList &l, Ogre::Node *n, int level, int nid)
{
Ogre::SceneNode::ObjectIterator object_it = ((Ogre::SceneNode *)n)->getAttachedObjectIterator();
Ogre::Node::ChildNodeIterator node_it = n->getChildIterator();
Ogre::MovableObject *m;
Ogre::Entity *e;
if (level != 0)
{
l.insert(
"Node" +
Ogre::StringConverter::toString(nid) +
"-Position",
Ogre::StringConverter::toString(n->getPosition()));
}
int i=0;
while(object_it.hasMoreElements())
{
m = object_it.getNext();
if (m->getMovableType() == "Entity")
{
e = static_cast<Ogre::Entity*>(m);
NxOgre::NxString entitySuffix = "";
if (i > 0)
{
entitySuffix = Ogre::StringConverter::toString(i);
}
if (level == 0)
{
l.insert("Entity" + entitySuffix, e->getMesh()->getName());
}
else
{
l.insert(
"Node" +
Ogre::StringConverter::toString(nid) +
"-Entity" +
entitySuffix,
e->getMesh()->getName()
);
}
}
i++;
}
while(node_it.hasMoreElements())
{
DumpNodes(l, node_it.getNext(), level + 1, nid++);
}
}
示例2: collisionAABB
Object* ObjectManager::collisionAABB(const Ogre::Vector3& fromPoint, const Ogre::Vector3& toPoint, int queryMask)
{
Ogre::Vector3 direction = toPoint - fromPoint;
Ogre::Ray ray(fromPoint, direction);
mRayQuery->setRay(ray);
mRayQuery->setQueryMask(queryMask);
// The rays are sorted by the distance query set, [very important]
mRayQuery->setSortByDistance(true);
Ogre::RaySceneQueryResult& result = mRayQuery->execute();
Ogre::RaySceneQueryResult::iterator itr = result.begin();
// Just get the nearest object
if (itr != result.end() && itr->movable)
{
Ogre::MovableObject *object = itr->movable;
Ogre::Vector3 pos = object->getParentSceneNode()->getPosition();
// If the current starting point of an object in the distance is less than a predetermined range
// then return this obj
// Avoid using the square root operation squaredLength
if ((pos - fromPoint).squaredLength() <= direction.squaredLength())
return getObject(itr->movable->getName());
}
return NULL;
}
示例3: UpdateSubNodes
void OLMeshTracker::UpdateSubNodes(Ogre::Node* regionNode, Ogre::Node* node, bool recurse, Ogre::MeshPtr meshP) {
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
UpdateSubNodes(regionNode, nodeChild, true, meshP);
}
}
// children taken care of... check for attached objects to this node
Ogre::SceneNode* snode = (Ogre::SceneNode*)node;
Ogre::SceneNode::ObjectIterator snodeObjectIterator = snode->getAttachedObjectIterator();
while (snodeObjectIterator.hasMoreElements()) {
Ogre::MovableObject* snodeObject = snodeObjectIterator.getNext();
if (snodeObject->getMovableType() == "Entity") {
Ogre::Entity* snodeEntity = (Ogre::Entity*)snodeObject;
Ogre::MeshPtr entityMesh = snodeEntity->getMesh();
if (entityMesh == meshP) {
snode->needUpdate(true);
// LG::Log("OLMeshTracker::UpdateSubNodes: setting node update for %s", snode->getName().c_str());
}
}
}
return;
}
示例4: _setSkydomeActive
//-----------------------------------------------------------------------------------------
bool CSceneManagerEditor::_setSkydomeActive(OgitorsPropertyBase* property, const bool& value)
{
if(value && mSkyBoxActive->get())
mSkyBoxActive->set(false);
if(value && mSkyDomeMaterial->get() == "")
{
mSystem->DisplayMessageDialog(OTR("You must first define a SkyDome Material!"), DLGTYPE_OK);
return false;
}
if(mHandle)
{
try
{
mHandle->setSkyDome(value ,mSkyDomeMaterial->get());
if(value)
{
Ogre::SceneNode *node = mHandle->getSkyDomeNode();
Ogre::SceneNode::ObjectIterator it = node->getAttachedObjectIterator();
while(it.hasMoreElements())
{
Ogre::MovableObject *object = it.getNext();
object->setVisibilityFlags(0x7F000000);
}
}
}
catch(...)
{
mSystem->DisplayMessageDialog(OTR("The Material supplied is not compatible with Sky Dome!"), DLGTYPE_OK);
return false;
}
}
return true;
}
示例5: changeState
void CObject::changeState(EEntityStateTypes eState) {
switch (m_uiType) {
case OBJECT_GREEN_BUSH:
case OBJECT_LIGHT_STONE:
if (eState == EST_LIFTED) {
btRigidBody *pRB = btRigidBody::upcast(this->getCollisionObject());
ASSERT(pRB);
m_pMap->getPhysicsManager()->getWorld()->removeCollisionObject(pRB);
m_pMap->getPhysicsManager()->getWorld()->addRigidBody(pRB, COL_DAMAGE_P, MASK_DAMAGE_P_COLLIDES_WITH);
// Entities now cast shadows
Ogre::SceneNode::ObjectIterator itObject = this->getSceneNode()->getAttachedObjectIterator();
while (itObject.hasMoreElements()) {
Ogre::MovableObject* pObject = static_cast<Ogre::MovableObject*>(itObject.getNext());
pObject->setCastShadows(true);
}
}
else if (eState == EST_THROWN) {
btRigidBody *pRB = btRigidBody::upcast(this->getCollisionObject());
ASSERT(pRB);
pRB->setLinearFactor(btVector3(1, 1, 1));
pRB->setAngularFactor(0);
pRB->activate();
}
break;
}
CWorldEntity::changeState(eState);
}
示例6: while
void OGRE3DPointRenderable::destroyNode(Ogre::SceneNode* node)
{
if (node == 0)
return;
Ogre::SceneNode::ObjectIterator object_it = node->getAttachedObjectIterator();
Ogre::MovableObject *m;
while(object_it.hasMoreElements())
{
m = object_it.getNext();
// Move Cameras to RootSceneNodes
if (m->getMovableType() == "Camera")
{
node->detachObject(m);
mRenderSystem->getSceneManager()->getRootSceneNode()->attachObject(m);
}
// Everything else gets destroyed.
else
mRenderSystem->getSceneManager()->destroyMovableObject(m);
}
node->detachAllObjects();
node->removeAndDestroyAllChildren();
mRenderSystem->getSceneManager()->destroySceneNode(node);
}
示例7: clearSceneNode
void Objects::clearSceneNode (Ogre::SceneNode *node)
{
for (int i=node->numAttachedObjects()-1; i>=0; --i)
{
Ogre::MovableObject *object = node->getAttachedObject (i);
// for entities, destroy any objects attached to bones
if (object->getTypeFlags () == Ogre::SceneManager::ENTITY_TYPE_MASK)
{
Ogre::Entity* ent = static_cast<Ogre::Entity*>(object);
Ogre::Entity::ChildObjectListIterator children = ent->getAttachedObjectIterator ();
while (children.hasMoreElements())
{
mRenderer.getScene ()->destroyMovableObject (children.getNext ());
}
}
node->detachObject (object);
mRenderer.getScene()->destroyMovableObject (object);
}
Ogre::Node::ChildNodeIterator it = node->getChildIterator ();
while (it.hasMoreElements ())
{
clearSceneNode(static_cast<Ogre::SceneNode*>(it.getNext ()));
}
}
示例8: getFirstEntityInHierarchy
boolean COgreObject::getFirstEntityInHierarchy(Ogre::SceneNode* pNode, Ogre::Entity*& pEntity) const
{
for(uint32 i=0; i<pNode->numAttachedObjects(); i++)
{
Ogre::MovableObject* pMovableObject = pNode->getAttachedObject(0);
if(pMovableObject->getMovableType() == Ogre::EntityFactory::FACTORY_TYPE_NAME)
{
pEntity = dynamic_cast<Ogre::Entity*>(pMovableObject);
return true;
}
}
for(uint32 i=0; i<pNode->numChildren(); i++)
{
Ogre::SceneNode* l_pChildNode = dynamic_cast<Ogre::SceneNode*>(pNode->getChild(i));
if(l_pChildNode != NULL && getFirstEntityInHierarchy(l_pChildNode, pEntity) == true)
{
return true;
}
}
m_rKernelContext.getLogManager() << LogLevel_Trace << "Failed to retrieve Entity\n";
return false;
}
示例9: NodeMaterial
//=============================================================================
// NodeMaterialOrig
//=============================================================================
NodeMaterialOrig::NodeMaterialOrig( Ogre::SceneNode* sceneNode )
: NodeMaterial(),
_sceneNode( sceneNode )
{
for( Ogre::SceneNode::ObjectIterator it = sceneNode->getAttachedObjectIterator() ;
it.hasMoreElements() ;
it.moveNext() )
{
Ogre::MovableObject * currentMO = it.peekNextValue() ;
if ( currentMO->getMovableType() == Ogre::EntityFactory::FACTORY_TYPE_NAME )
{
//OMTRACEID( "DEBUG", "Create entity " << currentMO->getName() ) ;
_entities[ it.peekNextKey() ] = new EntityMaterialOrig( static_cast< Ogre::Entity *> ( currentMO ) ) ;
}
}
for( Ogre::Node::ChildNodeIterator it = sceneNode->getChildIterator() ;
it.hasMoreElements() ;
it.moveNext() )
{
Ogre::SceneNode* childSceneNode = static_cast< Ogre::SceneNode* >( it.peekNextValue() ) ;
//OMTRACEID( "DEBUG", "Create ChildSceneNode " << childSceneNode->getName() ) ;
NodeMaterialOrig* child = new NodeMaterialOrig( childSceneNode ) ;
_childs.push_back( child ) ;
}
}
示例10: findFirstObject
//!
//! Returns the first movable object of the given type name contained in
//! the given scene node.
//!
//! \param sceneNode The scene node to find the first object in.
//! \param typeName The name of the type of objects to look for.
//! \return The first movable object of the given type name contained in the given scene node.
//!
Ogre::MovableObject * OgreTools::findFirstObject ( Ogre::SceneNode *sceneNode, const QString &typeName )
{
// make sure the given scene node is valid
if (!sceneNode) {
Log::error("The given scene node is invalid.", "OgreTools::findFirstObject");
return 0;
}
// iterate over the list of attached objects
Ogre::SceneNode::ObjectIterator objectIterator = sceneNode->getAttachedObjectIterator();
while (objectIterator.hasMoreElements()) {
Ogre::MovableObject *movableObject = objectIterator.getNext();
if (movableObject && QString::compare(movableObject->getMovableType().c_str(), typeName) == 0)
return movableObject;
}
// iterate over the list of child nodes
Ogre::SceneNode::ChildNodeIterator childIter = sceneNode->getChildIterator();
while( childIter.hasMoreElements() ) {
Ogre::SceneNode *childSceneNode = (Ogre::SceneNode *) childIter.getNext();
return findFirstObject(childSceneNode, typeName);
}
return 0;
}
示例11: DumpNodes
/*dumper*/ /*TODO: humanize*/
void DumpNodes(std::stringstream &ss, Ogre::Node *n, int level)
{
for(int i = 0; i < level; i++)
{
ss << " ";
}
ss << "SceneNode: " << n->getName() << " (parent: " << n->getParent()->getName() << ")" << std::endl;
Ogre::SceneNode::ObjectIterator object_it = ((Ogre::SceneNode *)n)->getAttachedObjectIterator();
Ogre::Node::ChildNodeIterator node_it = n->getChildIterator();
Ogre::MovableObject *m;
while(object_it.hasMoreElements())
{
for(int i = 0; i < level + 2; i++)
{
ss << " ";
}
m = object_it.getNext();
ss << "parent(" << m->getParentSceneNode()->getName() << ") type " << m->getMovableType() << ": " << m->getName() << std::endl;
}
while(node_it.hasMoreElements())
{
DumpNodes(ss, node_it.getNext(), level + 2);
}
}
示例12: restoreCustom
void GameBodyObject::restoreCustom(NxOgre::StringPairList spl)
{
mNode = mpScene->getOgreSceneManager()->getRootSceneNode()->createChildSceneNode();
for (NxOgre::StringPairList::StringPair sp = spl.begin();spl.hasNext();)
{
sp = spl.next();
/*
std::stringstream ss;
ss << sp.first;
ss << " => ";
ss << sp.second;
ss << std::endl;
NxDebug(ss.str());
*/
NxOgre::NxString key = sp.first;
Ogre::StringUtil::toLowerCase(key);
if (key == "entity" || key == "node")
{
Ogre::Entity* entity = mpScene->getOgreSceneManager()->createEntity(
mName + "-" + sp.second + "-" + Ogre::StringConverter::toString(mNode->numAttachedObjects()),
sp.second
);
mNode->attachObject(entity);
}
if (key == "node-scale")
{
mNode->setScale(Ogre::StringConverter::parseVector3(sp.second));
}
}
// Assign first Attached Object that is an entity to mEntity
Ogre::SceneNode::ObjectIterator object_it = mNode->getAttachedObjectIterator();
Ogre::MovableObject *m;
while(object_it.hasMoreElements())
{
m = object_it.getNext();
if (m->getMovableType() == "Entity")
{
mEntity = (Ogre::Entity*) m;
break;
}
}
mNode->setPosition(getGlobalPosition());
mNode->setOrientation(getGlobalOrientation());
}
示例13: setCastShadows
void Actor::setCastShadows(bool hasShadows)
{
assert(mNode);
Ogre::SceneNode::ObjectIterator it = mNode->getAttachedObjectIterator();
while(it.hasMoreElements())
{
Ogre::MovableObject* obj = static_cast<Ogre::MovableObject*>(it.getNext());
obj->setCastShadows(hasShadows);
}
}
示例14: processPickResult
void PolygonPointPickListener::processPickResult(bool& continuePicking, Ogre::RaySceneQueryResultEntry& entry, Ogre::Ray& cameraRay, const MousePickerArgs& mousePickerArgs)
{
if (entry.movable) {
Ogre::MovableObject* pickedMovable = entry.movable;
if (pickedMovable->isVisible() && pickedMovable->getUserAny().getType() == typeid(PolygonPointUserObject*)) {
//TODO: make sure that it's a point which belongs to our polygon
mPickedUserObject = Ogre::any_cast<PolygonPointUserObject*>(pickedMovable->getUserAny());
continuePicking = false;
}
}
}
示例15: mo
VideoVisual::VideoVisual(
const std::string &name, rendering::VisualPtr parent,
int height, int width) :
rendering::Visual(name, parent), height_(height), width_(width)
{
texture_ = Ogre::TextureManager::getSingleton().createManual(
name + "__VideoTexture__",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
width_, height_,
0,
Ogre::PF_BYTE_BGRA,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
Ogre::MaterialPtr material =
Ogre::MaterialManager::getSingleton().create(
name + "__VideoMaterial__", "General");
material->getTechnique(0)->getPass(0)->createTextureUnitState(
name + "__VideoTexture__");
material->setReceiveShadows(false);
double factor = 1.0;
Ogre::ManualObject mo(name + "__VideoObject__");
mo.begin(name + "__VideoMaterial__",
Ogre::RenderOperation::OT_TRIANGLE_LIST);
mo.position(-factor / 2, factor / 2, 0.51);
mo.textureCoord(0, 0);
mo.position(factor / 2, factor / 2, 0.51);
mo.textureCoord(1, 0);
mo.position(factor / 2, -factor / 2, 0.51);
mo.textureCoord(1, 1);
mo.position(-factor / 2, -factor / 2, 0.51);
mo.textureCoord(0, 1);
mo.triangle(0, 3, 2);
mo.triangle(2, 1, 0);
mo.end();
mo.convertToMesh(name + "__VideoMesh__");
Ogre::MovableObject *obj = (Ogre::MovableObject*)
this->GetSceneNode()->getCreator()->createEntity(
name + "__VideoEntity__",
name + "__VideoMesh__");
obj->setCastShadows(false);
this->AttachObject(obj);
}