本文整理汇总了C++中ogre::Entity::getMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::getMesh方法的具体用法?C++ Entity::getMesh怎么用?C++ Entity::getMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Entity
的用法示例。
在下文中一共展示了Entity::getMesh方法的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: 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;
}
示例3: GetEntity
Ogre::Entity* EC_OgreAnimationController::GetEntity()
{
if (!mesh_entity_)
return 0;
OgreRenderer::EC_OgreMesh &mesh = *checked_static_cast<OgreRenderer::EC_OgreMesh*>(mesh_entity_.get());
Ogre::Entity* entity = mesh.GetEntity();
if (!entity)
return 0;
if (entity->getMesh()->getName() != mesh_name_)
{
mesh_name_ = entity->getMesh()->getName();
ResetState();
}
return entity;
}
示例4: loadMesh
Ogre::Entity *VLogicModel::_createEntity(const VString &meshName)
{
Ogre::Entity *entity = VNULL;
loadMesh(meshName, Ogre::StringUtil::BLANK, Ogre::StringUtil::BLANK, DEFAULT_RESOURCE_GROUP_NAME);
VString entityName = mModelMainNode->getName() + "_Entity" + "_" + meshName +
Ogre::StringConverter::toString(mCreatedEntityCount++);
VGraphicsSystem *system = VENGINE.getGfxSystem();
entity = system->getSceneManager()->createEntity(entityName, meshName);
mModelMainNode->attachObject(entity);
if (!entity->getMesh()->getSkeleton().isNull())
{
if (VNULL == mSkeletonEntity)
{
const Ogre::MeshPtr &originMesh = entity->getMesh();
assert(!originMesh.isNull());
const Ogre::SkeletonPtr &originSke = originMesh->getSkeleton();
assert(!originSke.isNull());
_createSkeletonEntity(originSke);
}
assert(mSkeletonEntity);
entity->shareSkeletonInstanceWith(mSkeletonEntity);
}
// _convertEntityToCharacterMaterial(entity);
if (mSkeletonEntity && !mSkeleton)
{
mSkeleton = mSkeletonEntity->getSkeleton();
mSkeleton->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
}
entity->setCastShadows(mShadowCastable && !isShadowUncastable(meshName));
return entity;
}
示例5: OnFrameMove
void ManipulatorEffect::OnFrameMove( float dt )
{
Ogre::Entity* ent = ManipulatorSystem.GetObject().GetSelection();
if (ent && ent->hasSkeleton())
{
auto iter = m_effectTemplates.find(ent->getMesh()->getName());
if (iter != m_effectTemplates.end())
{
Kratos::EffectController* controller = iter->second;
controller->Update(dt);
}
}
}
示例6:
CollisionModel3D *EditorFrameHandler::GetCollisionModel(const char *modelname)
{
CollisionModel3D *hashres=NULL, *CollisionModel = NULL;
bool bres = CollisionModels.Find(modelname, &hashres);
if (!bres)
{
CollisionModel = newCollisionModel3D(false);
size_t vertex_count,index_count;
Ogre::Vector3* vertices;
unsigned long* indices;
Ogre::SceneManager *SceneMgr = CommonDeclarations::GetSceneManager();
Ogre::Entity *entity = SceneMgr->createEntity("tmpcollis", modelname);
Collidable::getMeshInformation(entity->getMesh().getPointer(),vertex_count,vertices,index_count,indices,Ogre::Vector3(0,0,0),Ogre::Quaternion::IDENTITY,Ogre::Vector3(1,1,1));
SceneMgr->destroyEntity(entity);
size_t index;
int numTris = (int)index_count / 3;
CollisionModel->setTriangleNumber(numTris);
for (unsigned i=0;i<index_count;i+=3)
{
index = indices[i];
CollisionModel->addTriangle(vertices[indices[i+0]].x,vertices[indices[i+0]].y,vertices[indices[i+0]].z,
vertices[indices[i+1]].x,vertices[indices[i+1]].y,vertices[indices[i+1]].z,
vertices[indices[i+2]].x,vertices[indices[i+2]].y,vertices[indices[i+2]].z);
}
CollisionModel->finalize();
delete[] vertices;
delete[] indices;
CollisionModels.Insert(modelname,CollisionModel);
} else
{
CollisionModel = hashres;
}
return CollisionModel;
}
示例7: move
std::vector<std::wstring> ManipulatorEffect::GetLocatorNames() const
{
Ogre::Entity* ent = ManipulatorSystem.GetObject().GetSelection();
assert(ent);
std::vector<std::wstring> ret;
//M3模型从max导出时locator命名为Ref_xxx形式
Ogre::SkeletonPtr skel = ent->getMesh()->getSkeleton();
Ogre::Skeleton::BoneIterator iter = skel->getBoneIterator();
while (iter.hasMoreElements())
{
Ogre::Bone* pBone = iter.peekNext();
if(pBone->getName().find("Ref_") != Ogre::String::npos)
ret.push_back(Utility::EngineToUnicode(pBone->getName()));
iter.getNext();
}
return std::move(ret);
}
示例8: Serialize
void ManipulatorObject::Serialize( rapidxml::xml_document<>* doc, rapidxml::xml_node<>* XMLNode )
{
using namespace rapidxml;
const String count = Ogre::StringConverter::toString(m_objects.size());
XMLNode->append_attribute(doc->allocate_attribute("count", doc->allocate_string(count.c_str())));
for (auto iter=m_objects.begin(); iter!=m_objects.end(); ++iter)
{
Ogre::Entity* pObj = iter->first;
xml_node<>* objNode = doc->allocate_node(node_element, "entity");
//meshname
const String& strMesh = pObj->getMesh()->getName();
objNode->append_attribute(doc->allocate_attribute("meshname", doc->allocate_string(strMesh.c_str())));
//add to navmesh
const String& strIsNavMesh = Ogre::StringConverter::toString((iter->second)->m_bAddToNavmesh);
objNode->append_attribute(doc->allocate_attribute("isnavmesh", doc->allocate_string(strIsNavMesh.c_str())));
//is building
const String& strIsBuilding = Ogre::StringConverter::toString((iter->second)->m_bIsBuilding);
objNode->append_attribute(doc->allocate_attribute("isbuilding", doc->allocate_string(strIsBuilding.c_str())));
//building name
if(strIsBuilding == "true")
objNode->append_attribute(doc->allocate_attribute("buildingname", doc->allocate_string((iter->second)->m_buildingName.c_str())));
//is resource
const String& strIsResource = Ogre::StringConverter::toString((iter->second)->m_bIsResource);
objNode->append_attribute(doc->allocate_attribute("isresource", doc->allocate_string(strIsResource.c_str())));
//position
String strPos = Ogre::StringConverter::toString(pObj->getParentSceneNode()->_getDerivedPosition());
objNode->append_attribute(doc->allocate_attribute("position", doc->allocate_string(strPos.c_str())));
//orientation
String strOrient = Ogre::StringConverter::toString(pObj->getParentSceneNode()->_getDerivedOrientation());
objNode->append_attribute(doc->allocate_attribute("orientation", doc->allocate_string(strOrient.c_str())));
//scale
String strScale = Ogre::StringConverter::toString(pObj->getParentSceneNode()->_getDerivedScale());
objNode->append_attribute(doc->allocate_attribute("scale", doc->allocate_string(strScale.c_str())));
XMLNode->append_node(objNode);
}
}
示例9: checkMesh
void BoneCollisionManager::checkMesh(Ogre::String outFileName, Ogre::SceneNode* node)
{
std::ofstream file(outFileName.c_str());
if (file)
{
Ogre::Entity* ent = (Ogre::Entity*)node->getAttachedObject(0);
Ogre::SkeletonInstance* skeletonInst = ent->getSkeleton();
Ogre::Skeleton::BoneIterator boneI=skeletonInst->getBoneIterator();
//file<<"Creating bone length information from:\n";
file<<"Mesh name: "<<ent->getMesh()->getName()<<"\n";
file<<"Skeleton name: "<<skeletonInst->getName()<<"\n\n";
while(boneI.hasMoreElements())
{
Ogre::Bone* bone=boneI.getNext();
Ogre::String bName=bone->getName();
if (bone->getChild(0))
{
Ogre::Vector3 curr = bone->_getDerivedPosition();
Ogre::Vector3 next = bone->getChild(0)->_getDerivedPosition();
Ogre::Vector3 difference = next-curr;
//length of bone
Ogre::Real lenght = difference.length();
file<<bName<<":\nLength\t\t\t=\t"<<Ogre::StringConverter::toString(lenght,3)<<"\n"<<
"Position"<<"\t\t=\t"<<Ogre::StringConverter::toString(curr.x,1)<<", "<<
Ogre::StringConverter::toString(curr.y,1)<<", "<<
Ogre::StringConverter::toString(curr.z,1)<<"\n";
if (!bone->getParent())
file<<bName<<" is a Root Bone!\n\n";
else
file<<"\n\n";
}
}
}
}
示例10: saveCustom
NxOgre::StringPairList GameBodyObject::saveCustom()
{
NxOgre::StringPairList l;
l.insert("ActorType", "Body");
if (mNode == 0)
{
return l;
}
if (mNode->numChildren() > 0)
{
DumpNodes(l, mNode, 0, 1);
}
else
{
Ogre::Entity* entity = static_cast<Ogre::Entity*>(mNode->getAttachedObject(0));
l.insert("Entity", entity->getMesh()->getName());
}
return l;
}
示例11: Entity
RegionEntity::RegionEntity(const char *name, const char *meshName)
: Entity(name, meshName) {
Ogre::Entity *physicsEnt = Core::GetInstance().ogreSceneMgr->createEntity(name, meshName);
size_t vertexCount, indexCount;
Ogre::Vector3* vertices;
unsigned* indices;
Utils::GetMeshInformation(physicsEnt->getMesh(), vertexCount, vertices, indexCount, indices);
btTriangleIndexVertexArray *vertexArray = new btTriangleIndexVertexArray(
indexCount / 3,
(int *)(indices),
12,
vertexCount,
(btScalar *)(vertices),
12
);
collisionShape = new btBvhTriangleMeshShape(vertexArray, true);
btDefaultMotionState *levelMotionState = new btDefaultMotionState(
btTransform(btQuaternion(0,0,0,1),btVector3(0,0,0))
);
ghostObject = new btPairCachingGhostObject();
ghostObject->setWorldTransform(btTransform(btQuaternion(0,0,0,1),btVector3(0,0,0)));
ghostObject->setCollisionShape(collisionShape);
ghostObject->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
Core::GetInstance().bulWorld->addCollisionObject(ghostObject,
btBroadphaseProxy::SensorTrigger | btBroadphaseProxy::StaticFilter,
btBroadphaseProxy::AllFilter);
Core::GetInstance().ogreSceneMgr->destroyEntity(physicsEnt);
callback = NULL;
}
示例12: updateData
void SceneObject::updateData()
{
clear();
Ogre::Entity* entity = getSceneManager()->getEntity(mEntityName);
if (entity != nullptr && !mMaterialName.empty())
{
mVertexCount = 0;
mIndexCount = 0;
GetMeshInformation(entity->getMesh(), mVertexCount, mVertices, mIndexCount, mIndices, mTextureCoords, Ogre::Vector3::ZERO, Ogre::Quaternion::IDENTITY, Ogre::Vector3::UNIT_SCALE, mMaterialName);
Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().getByName(mMaterialName);
if (!material.isNull())
{
mTextureUnit = material->getTechnique(0)->getPass(0)->getTextureUnitState("gui");
if (mTextureUnit)
{
mTextureUnit->setTextureName(mTextureName);
mUScale = mTextureUnit->getTextureUScale();
mVScale = mTextureUnit->getTextureVScale();
}
}
}
}
示例13: raycast
bool CollisionTools::raycast(const Ray &ray, Vector3 &result,unsigned long &target,float &closest_distance, const uint32 queryMask)
{
target = NULL;
// check we are initialised
if (mRaySceneQuery != NULL)
{
// create a query object
mRaySceneQuery->setRay(ray);
mRaySceneQuery->setSortByDistance(true);
mRaySceneQuery->setQueryMask(queryMask);
// execute the query, returns a vector of hits
if (mRaySceneQuery->execute().size() <= 0)
{
// raycast did not hit an objects bounding box
return (false);
}
}
else
{
//LOG_ERROR << "Cannot raycast without RaySceneQuery instance" << ENDLOG;
return (false);
}
// at this point we have raycast to a series of different objects bounding boxes.
// we need to test these different objects to see which is the first polygon hit.
// there are some minor optimizations (distance based) that mean we wont have to
// check all of the objects most of the time, but the worst case scenario is that
// we need to test every triangle of every object.
//Ogre::Real closest_distance = -1.0f;
closest_distance = -1.0f;
Ogre::Vector3 closest_result;
Ogre::RaySceneQueryResult &query_result = mRaySceneQuery->getLastResults();
for (size_t qr_idx = 0; qr_idx < query_result.size(); qr_idx++)
{
// stop checking if we have found a raycast hit that is closer
// than all remaining entities
if ((closest_distance >= 0.0f) &&
(closest_distance < query_result[qr_idx].distance))
{
break;
}
// only check this result if its a hit against an entity
if ((query_result[qr_idx].movable != NULL) &&
(query_result[qr_idx].movable->getMovableType().compare("Entity") == 0))
{
// get the entity to check
Ogre::Entity *pentity = static_cast<Ogre::Entity*>(query_result[qr_idx].movable);
// mesh data to retrieve
size_t vertex_count;
size_t index_count;
Ogre::Vector3 *vertices;
unsigned long *indices;
// get the mesh information
GetMeshInformation(pentity->getMesh(), vertex_count, vertices, index_count, indices,
pentity->getParentNode()->_getDerivedPosition(),
pentity->getParentNode()->_getDerivedOrientation(),
pentity->getParentNode()->getScale());
// test for hitting individual triangles on the mesh
bool new_closest_found = false;
for (int i = 0; i < static_cast<int>(index_count); i += 3)
{
// check for a hit against this triangle
std::pair<bool, Ogre::Real> hit = Ogre::Math::intersects(ray, vertices[indices[i]],
vertices[indices[i+1]], vertices[indices[i+2]], true, false);
// if it was a hit check if its the closest
if (hit.first)
{
if ((closest_distance < 0.0f) ||
(hit.second < closest_distance))
{
// this is the closest so far, save it off
closest_distance = hit.second;
new_closest_found = true;
}
}
}
// free the verticies and indicies memory
delete[] vertices;
delete[] indices;
// if we found a new closest raycast for this object, update the
// closest_result before moving on to the next object.
if (new_closest_found)
{
target = (unsigned long)pentity;
closest_result = ray.getPoint(closest_distance);
}
}
}
// return the result
if (closest_distance >= 0.0f)
{
//.........这里部分代码省略.........
示例14: RaycastToPolygon
Ogre::Entity* RaycastToPolygon( const Ogre::Real& x, const Ogre::Real& y,
Ogre::RaySceneQuery* Query, Ogre::Camera* Camera )
{
Ogre::Ray MouseRay = Camera->getCameraToViewportRay( x, y );
Query->setRay( MouseRay );
Query->setSortByDistance( true );
Ogre::RaySceneQueryResult& QueryResult = Query->execute();
if( QueryResult.size() == 0 )
{
return NULL;
}
// at this point we have raycast to a series of different objects bounding boxes.
// we need to test these different objects to see which is the first polygon hit.
// there are some minor optimizations (distance based) that mean we wont have to
// check all of the objects most of the time, but the worst case scenario is that
// we need to test every triangle of every object.
Ogre::Real ClosestDistance = -1.0f;
Ogre::Entity* ClosestResult;
for( size_t QRIndex = 0; QRIndex < QueryResult.size(); QRIndex++ )
{
// stop checking if we have found a raycast hit that is closer
// than all remaining entities
if( ( ClosestDistance >= 0.0f ) &&
( ClosestDistance < QueryResult[QRIndex].distance ) )
break;
// only check this result if its a hit against an entity
if( ( QueryResult[QRIndex].movable != NULL ) &&
( QueryResult[QRIndex].movable->getMovableType().compare("Entity") == 0 ) &&
QueryResult[QRIndex].movable->getName() != OVISE_SelectionBoxName )
{
// get the entity to check
Ogre::Entity* PEntity = static_cast<Ogre::Entity*>(QueryResult[QRIndex].movable);
// mesh data to retrieve
size_t VertexCount;
size_t IndexCount;
Ogre::Vector3* Vertices;
unsigned long* Indices;
// get the mesh information
GetMeshInformation( PEntity->getMesh(),
VertexCount,
Vertices,
IndexCount,
Indices,
PEntity->getParentSceneNode()->_getDerivedPosition(),
PEntity->getParentSceneNode()->_getDerivedOrientation(),
PEntity->getParentSceneNode()->_getDerivedScale() );
// test for hitting individual triangles on the mesh
bool NewClosestFound = false;
if( IndexCount == 0 ) // no triangles, e.g. pointcloud
{
NewClosestFound = true;
ClosestDistance = QueryResult[QRIndex].distance;
}
else
{
for( int i = 0; i < static_cast<int>(IndexCount); i += 3 )
{
// check for a hit against this triangle
std::pair<bool, Ogre::Real> Hit =
Ogre::Math::intersects( MouseRay,
Vertices[Indices[i]],
Vertices[Indices[i+1]],
Vertices[Indices[i+2]],
true, false);
// if it was a hit check if its the closest
if( Hit.first )
{
if( ( ClosestDistance < 0.0f ) ||
( Hit.second < ClosestDistance ) )
{
// this is the closest so far, save it off
ClosestDistance = Hit.second;
NewClosestFound = true;
}
}
}
}
// free the verticies and indicies memory
delete[] Vertices;
delete[] Indices;
// if we found a new closest raycast for this object, update the
// closest_result before moving on to the next object.
if( NewClosestFound )
ClosestResult = PEntity;
}
}
if( ClosestDistance < 0.0f )
{
// raycast failed
//.........这里部分代码省略.........
示例15: synchronizeSceneNode
void RenderBoxWrap::synchronizeSceneNode(Ogre::SceneNode* _newNode, Ogre::SceneNode* _fromNode)
{
if (_newNode == nullptr || _fromNode == nullptr)
{
MYGUI_ASSERT(_newNode == nullptr || _fromNode == nullptr,"Synchronize scene node error.");
return;
}
_newNode->setPosition(_fromNode->getPosition());
_newNode->setOrientation(_fromNode->getOrientation());
int i = 0;
while (i < _newNode->numAttachedObjects())
{
Ogre::MovableObject * object = _newNode->getAttachedObject(i);
Ogre::Entity* entity = object->getMovableType() == "Entity" ? static_cast<Ogre::Entity*>(object) : nullptr;
if(entity)
{
object = findMovableObject(_fromNode, entity->getName());
Ogre::Entity* oldEntity = (object != nullptr && object->getMovableType() == "Entity") ? static_cast<Ogre::Entity*>(object) : nullptr;
if(!oldEntity)
{
removeEntity(entity->getName());
continue;
}
}
i++;
}
for(i = 0; i < _fromNode->numAttachedObjects(); i++)
{
Ogre::MovableObject * object = _fromNode->getAttachedObject(i);
Ogre::Entity* entity = object->getMovableType() == "Entity" ? static_cast<Ogre::Entity*>(object) : nullptr;
if(entity)
{
object = findMovableObject(_newNode, entity->getName());
Ogre::Entity* newEntity = (object != nullptr && object->getMovableType() == "Entity") ? static_cast<Ogre::Entity*>(object) : nullptr;
if(!newEntity)
{
//System::Console::WriteLine("create new entity {0}", gcnew System::String(entity->getName().c_str()));
newEntity = mScene->createEntity(entity->getName(), entity->getMesh()->getName());//new Ogre::Entity(entity->getName(), (Ogre::MeshPtr)entity->getMesh().get()->getHandle());
_newNode->attachObject(newEntity);
mVectorEntity.push_back(newEntity);
if(mEntity == nullptr)
{
mEntity = newEntity;
}
}
}
}
i = 0;
while (i < _newNode->numChildren())
{
Ogre::SceneNode* oldNode = findSceneNodeObject(_fromNode, _newNode->getChild(i)->getName());
if(!oldNode)
{
Ogre::SceneNode* forDelete = (Ogre::SceneNode*)_newNode->getChild(i);
removeNode(forDelete);
}else
{
i++;
}
}
for(i = 0; i < _fromNode->numChildren(); i++)
{
if(_fromNode->getChild(i)->numChildren() != 0 &&
((Ogre::SceneNode*)_fromNode->getChild(i))->numAttachedObjects() != 0)
{
Ogre::SceneNode* newChildNode = findSceneNodeObject(_newNode, _fromNode->getChild(i)->getName());
if(!newChildNode)
{
//System::Console::WriteLine("create new node {0}", gcnew System::String(_fromNode->getChild(i)->getName().c_str()));
newChildNode = _newNode->createChildSceneNode(_fromNode->getChild(i)->getName(), _fromNode->getChild(i)->getPosition(), _fromNode->getChild(i)->getOrientation());
}
synchronizeSceneNode(newChildNode, (Ogre::SceneNode*)_fromNode->getChild(i));
}
}
}