本文整理汇总了C++中ogre::Entity类的典型用法代码示例。如果您正苦于以下问题:C++ Entity类的具体用法?C++ Entity怎么用?C++ Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createBall
Ball* Application::createBall(Ogre::String nme, GameObject::objectType tp, Ogre::String meshName, int x, int y, int z, Ogre::Real scale, Ogre::SceneManager* scnMgr, GameManager* ssm, Ogre::Real mss, Ogre::Real rest, Ogre::Real frict, bool kinematic, Simulator* mySim) {
createRootEntity(nme, meshName, x, y, z);
Ogre::SceneNode* sn = mSceneManager->getSceneNode(nme);
Ogre::Entity* ent = SceneHelper::getEntity(mSceneManager, nme, 0);
const btTransform pos;
OgreMotionState* ms = new OgreMotionState(pos, sn);
sn->setScale(scale,scale,scale);
ent->setMaterialName("ball");
Ball* obj = new Ball(nme, tp, mSceneManager, ssm, sn, ent, ms, mySim, mss, rest, frict, scale, kinematic);
obj->addToSimulator();
return obj;
}
示例2: createBox
Ogre::SceneNode* createBox(Ogre::SceneManager* sceneMgr, Ogre::String name)
{
// create an ordinary Ogre mesh with texture
Ogre::Entity* boxEnt = sceneMgr->createEntity(name , "cube.mesh");
// we need the bounding box of the cube.mesh to set the size of the Bullet box
Ogre::AxisAlignedBox boxBb = boxEnt->getBoundingBox();
//Ogre::Vector3 size = boxBb.getSize();
boxEnt->setMaterialName("Examples/BumpyMetal");
// create the node
Ogre::SceneNode* boxNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
boxNode->attachObject( boxEnt );
return boxNode;
}
示例3: setNode
Penguin::Penguin(Ogre::SceneManager* sceneMgr, std::string name) {
Ogre::Entity* entPenguin = sceneMgr->createEntity(name, "penguin.mesh");
mAnimationState = entPenguin->getAnimationState("amuse");
mAnimationState->setLoop(true);
mAnimationState->setEnabled(true);
entPenguin->setCastShadows(true);
Ogre::SceneNode* penguinNode = sceneMgr->getRootSceneNode()->createChildSceneNode(name, Ogre::Vector3(0,30,0));
penguinNode->attachObject(entPenguin);
penguinNode->scale(60 / 63.0057, 50 / 47.99059, 50 / 49.27139);
Ogre::Camera* cam = sceneMgr->getCamera("GameCam");
cameraNode = penguinNode->createChildSceneNode("CameraNode");
cameraNode->attachObject(cam);
setNode(penguinNode);
}
示例4:
void
RenderEntityComp::_create(const ZEntityResource* res, Ogre::SceneManager* scnMgr, Ogre::SceneNode* node)
{
Ogre::Entity* ent = scnMgr->createEntity(res->getKey(), res->getResourceName());
ent->setMaterialName("PRJZ/MinecraftCharacter");
auto scale = World::WorldScale::computeAWorldScale();
if(!ent)
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Failed to create Entity", "RenderEntityComp::_create");
//Assume the center is is at units / 2.0
_node = node->createChildSceneNode();
_node->attachObject(ent);
_node->setScale(scale.metersPerUnit, scale.metersPerUnit, scale.metersPerUnit);
// childNode->translate(0.0f, -scale.unitsPerMeter / 2.0, 0.0f);
_node->setVisible(false);
}
示例5: performSelection
void SelectionBox::performSelection(std::list<AgentId> &selection, Ogre::Camera *mCamera)
{
if((mRight - mLeft) * (mBottom - mTop) < 0.0001)
return;
float left = (mLeft + 1.f) / 2.f;
float right = (mRight + 1.f) / 2.f;
float top = (1.f - mBottom) / 2.f;
float bottom = (1.f - mTop) / 2.f;
Ogre::Ray topLeft = mCamera->getCameraToViewportRay(left, top);
Ogre::Ray topRight = mCamera->getCameraToViewportRay(right, top);
Ogre::Ray bottomLeft = mCamera->getCameraToViewportRay(left, bottom);
Ogre::Ray bottomRight = mCamera->getCameraToViewportRay(right, bottom);
// These planes have now defined an "open box" which extends to infinity in front of the camera. You can think of
// the rectangle we drew with the mouse as being the termination point of the box just in front of the camera.
Ogre::PlaneBoundedVolume vol;
const Ogre::Real min = .1, max = 500;
vol.planes.push_back(Ogre::Plane(topLeft.getPoint(min), topRight.getPoint(min), bottomRight.getPoint(min))); // front plane
vol.planes.push_back(Ogre::Plane(topLeft.getOrigin(), topLeft.getPoint(max), topRight.getPoint(max))); // top plane
vol.planes.push_back(Ogre::Plane(topLeft.getOrigin(), bottomLeft.getPoint(max), topLeft.getPoint(max))); // left plane
vol.planes.push_back(Ogre::Plane(bottomLeft.getOrigin(), bottomRight.getPoint(max), bottomLeft.getPoint(max))); // bottom plane
vol.planes.push_back(Ogre::Plane(topRight.getOrigin(), topRight.getPoint(max), bottomRight.getPoint(max))); // right plane
Ogre::PlaneBoundedVolumeList volList;
volList.push_back(vol);
mVolQuery->setVolumes(volList);
Ogre::SceneQueryResult result = mVolQuery->execute();
// Finally we need to handle the results of the query. First we will deselect all previously selected objects,
// then we will select all objects which were found by the query.
std::list<Ogre::SceneNode *> nodes;
Ogre::SceneQueryResultMovableList::iterator iter;
for(iter = result.movables.begin(); iter != result.movables.end(); ++iter)
{
Ogre::MovableObject *movable = *iter;
if(movable->getMovableType().compare("Entity") == 0)
{
Ogre::Entity *pentity = static_cast<Ogre::Entity *>(movable);
nodes.push_back(pentity->getParentSceneNode());
}
}
mEngine->level()->getAgentsIdsFromSceneNodes(nodes, selection);
}
示例6: while
void RttManager::CDepthReflectionListener::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
Hydrax *mHydrax = mRttManager->mHydrax;
mHydrax->getMesh()->getEntity()->setVisible(false);
Ogre::SceneManager::MovableObjectIterator EntityIterator =
mHydrax->getSceneManager()->getMovableObjectIterator("Entity");
Ogre::Entity* CurrentEntity;
unsigned int k;
mMaterials.empty();
while (EntityIterator.hasMoreElements())
{
CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue());
for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
{
mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());
CurrentEntity->getSubEntity(k)->setMaterialName(mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_DEPTH)->getName());
}
EntityIterator.moveNext();
}
mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->translate(0,-mHydrax->getPlanesError(),0);
bool IsInUnderwaterError = false;
if (mHydrax->getCamera()->getDerivedPosition().y > mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->getPosition().y)
{
mCameraPlaneDiff = 0;
IsInUnderwaterError = true;
}
else
{
mCameraPlaneDiff = 0;
}
mHydrax->getCamera()->enableReflection(mRttManager->mPlanes[RTT_DEPTH_REFLECTION]);
if (!IsInUnderwaterError)
{
mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[RTT_DEPTH_REFLECTION]);
}
}
示例7: updateOGRE
void MainWindow::updateOGRE()
{
QMutexLocker locker(&mutex);
static bool updateGUI=true;
Ogre::Root* mRoot = Ogre::Root::getSingletonPtr();
mRoot->_fireFrameStarted();
// loop through ogre widgets and update animation
QList<OgreWidget*> rendlist = this->findChildren<OgreWidget*>();
foreach (OgreWidget* w, rendlist)
{
// update animation for OgreWidget's sceneManager
if (w->mRenderWindow && w->updatesEnabled())
{
// update OgreWidget
w->update();
//emit w->paintEvent(new QPaintEvent(w->rect()));
for (Ogre::SceneManager::MovableObjectIterator mit = w->getSceneManager()->getMovableObjectIterator("Entity");
mit.hasMoreElements(); mit.moveNext() )
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
if (updateGUI) {
updateGUI = false;
}
// check has skeleton to avoid crash for non animable entities
if (entity->hasSkeleton())
{
for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator();
animIt.hasMoreElements(); animIt.moveNext() )
{
Ogre::AnimationState *animState = animIt.peekNextValue();
if ( animState->getEnabled() )
{
//std::cout << entity->getName() << " ZZZZZZZZZZZ " << animState->getAnimationName();
animState->addTime(w->getRenderWindow()->getBestFPS()/10000);
}
}
}
}
}
}
mRoot->_fireFrameRenderingQueued();
mRoot->_fireFrameEnded();
}
示例8: _loadMesh
//-----------------------------------------------------------------------------
Ogre::SceneNode* SSAOApp::_loadMesh(const Ogre::String &_name, const Ogre::Vector3 &_pos)
{
std::string entityName = _name+Ogre::StringConverter::toString(mScenePairs.size());
Ogre::Entity *ent = mSceneMgr->createEntity(entityName, _name+".mesh");
Ogre::SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode(ent->getName()+"Node", _pos);
ent->setMaterialName("SSAO/DiffuseLight_GBuffer");
node->attachObject(ent);
mScenePairs.push_back(SSAOApp::ScenePair(ent, node));
return node;
}
示例9: CharacterController
OgreCharacterController::OgreCharacterController(Ogre::Camera * Camera, const Ogre::String& name, const Ogre::Vector3& position)
: CharacterController(Camera, position, name, "Sinbad.mesh", Ogre::Vector3(3, 3, 3)), lastTop(0), lastBase(0),
mSword1(0), mSword2(0), swordsOut(false), sliceDir(false), animTimer(0)
{
Ogre::SceneManager * smgr = Camera->getSceneManager();
Ogre::Entity * ent = getEntity();
ent->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
mSword1 = smgr->createEntity("Sword1", "Sword.mesh");
mSword2 = smgr->createEntity("Sword2", "Sword.mesh");
ent->attachObjectToBone("Sheath.L", mSword1);
ent->attachObjectToBone("Sheath.R", mSword2);
getTargetNode()->setFixedYawAxis(true);
}
示例10: createBackGround
/*
* Create a fake Plane for Drag and Drop
*/
void MyFrameListener::createBackGround() {
Ogre::SceneManager* mSceneMgr = Ogre::Root::getSingleton().
getSceneManager("mainSM");
Ogre::Plane *mPlane = new Ogre::Plane(Ogre::Vector3::UNIT_Z, -2);
Ogre::MeshManager::getSingleton().createPlane("backPlane",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
*mPlane,800, 800, 20, 20, true, 1, 5, 5
, Ogre::Vector3::UNIT_Y);
Ogre::Entity* plane = mSceneMgr->createEntity("backPlane");
plane->setQueryFlags(PLANE_DRAG_DROP);
plane->setMaterialName("sheet");
Ogre::Root::getSingleton().
getSceneManager("mainSM")->getRootSceneNode()->
attachObject(plane);
}
示例11: placeObjectOnTerrain
void OgreWidget::placeObjectOnTerrain(const QString meshName, const Ogre::Vector3 position, const float rotationY, const Ogre::Vector3 scale)
{
Ogre::Quaternion rotation;
QString name(meshName);
name.replace(".mesh", "");
Ogre::Entity* entity = mSceneManager->createEntity(name.toStdString(), meshName.toStdString());
entity->setQueryFlags(0xFFFFFFFF);
rotation.FromAngleAxis(Ogre::Degree(rotationY), Ogre::Vector3::UNIT_Y);
Ogre::SceneNode* sceneNode = mSceneManager->getRootSceneNode()->createChildSceneNode(
position + Ogre::Vector3(0, mTerrainGroup->getHeightAtWorldPosition(position) + mTerrainPos.y - 0.2, 0),
rotation);
sceneNode->setScale(scale);
sceneNode->attachObject(entity);
addMeshInformation(entity, sceneNode);
}
示例12: createMesh
Mesh* OgreSubsystem::createMesh(String mesh,String name)
{
String nombre = name;
if(name=="AUTO_NAME_ME")
{
nombre = "OryxSceneNodeAutoNamed"+StringUtils::toString(mAutoNameIndex);
++mAutoNameIndex;
}
Ogre::Entity* ent = mSceneManager->createEntity(nombre,mesh);
Ogre::SceneNode* node = mSceneManager->createSceneNode(nombre);
node->attachObject(ent);
ent->setCastShadows(false);
Mesh* m = new Mesh(nombre,node,ent);
mSceneNodes.push_back(m);
return m;
}
示例13: SceneManager
void
Player::stopAnimation(std::string anim)
{
Ogre::SceneManager::MovableObjectIterator iterator = SceneManager()->getMovableObjectIterator("Entity");
while(iterator.hasMoreElements())
{
Ogre::Entity* e = static_cast<Ogre::Entity*>(iterator.getNext());
if (e->hasSkeleton())
{
Ogre::AnimationState *animation = e->getAnimationState(anim);
animation->setEnabled(false);
animation->setTimePosition(0);
}
}
}
示例14: createWall
void SceneLoader::createWall( Ogre::Vector3 pos, Ogre::Real scale )
{
Ogre::Entity* ent = mSceneMgr->createEntity("atd_cube.mesh");
// Ogre::MeshPtr mesh = ent->getMesh();
// mesh->freeEdgeList();
// mesh->buildEdgeList();
ent->setCastShadows(true);
ent->setQueryFlags(AugmentedTowerDefense::MASK_WALLS);
Ogre::SceneNode* node = mSceneRootNode->createChildSceneNode("Wall_" + AugmentedTowerDefense::HelperClass::ToString(mWallCount));
node->setPosition(pos);
node->setScale(Ogre::Vector3::UNIT_SCALE*scale);
node->attachObject(ent);
mWallCount++;
}
示例15: createScene
//-------------------------------------------------------------------------------------
void GameMain::createScene(void)
{
createCamera(); // Camera
createViewports(); // Viewport
createEnvir(); // Environment: Light, Sky, etc.
//-------------------------
// 地平面
Ogre::MeshManager::getSingleton().createPlane("floor", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::Plane(Ogre::Vector3::UNIT_Y, 0), 100, 100, 10, 10, true, 1, 10, 10, Ogre::Vector3::UNIT_Z);
// create a floor entity, give it a material, and place it at the origin
Ogre::Entity* floor = mSceneMgr->createEntity("Floor", "floor");
floor->setMaterialName("Examples/Rockwall");
floor->setCastShadows(false);
mSceneMgr->getRootSceneNode()->attachObject(floor);
//-------------------------
// 创建障碍物分布地图
//-------------------------
// 创建障碍物
/*Ogre::SceneNode * boxNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Entity * boxEntity = mSceneMgr->createEntity("Box","cube.mesh");
boxEntity->setMaterialName("Examples/BumpyMetal");
boxNode->attachObject( boxEntity );
boxNode->scale( 0.01f, 0.01f, 0.01f );
boxNode->setPosition( 0,0.5,0 );
boxNodes.push_back( boxNode );
boxEntitys.push_back( boxEntity );*/
Ogre::SceneNode * ogreHeadNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Entity * ogreHeadEntity = mSceneMgr->createEntity("OgreHead","ogrehead.mesh");
ogreHeadNode->attachObject( ogreHeadEntity );
ogreHeadNode->scale( 0.02f, 0.02f, 0.02f );
//ogreHeadNode->setPosition( 1, 0, 1 );
ogreHeadNode->setPosition( 15, 0.5, -20 );
boxNodes.push_back( ogreHeadNode );
boxEntitys.push_back( ogreHeadEntity );
//-------------------------
// 创建角色
mPlayer = new GamePlayer( mCamera, ogreHeadNode );
}