本文整理汇总了C++中ogre::SceneNode类的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode类的具体用法?C++ SceneNode怎么用?C++ SceneNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SceneNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateWater
void InputListener::updateWater(const Ogre::FrameEvent& evt)
{
float WaterFlow = FLOW_SPEED * evt.timeSinceLastFrame;
static float FlowAmount = 0.0f;
static bool FlowUp = true;
Ogre::SceneNode *pWaterNode = static_cast<Ogre::SceneNode*>(this->_currentScene->getCamera()->getSceneManager()->getRootSceneNode()->getChild("WaterNode"));
if (FlowUp)
FlowAmount += WaterFlow;
else
FlowAmount -= WaterFlow;
if (FlowAmount >= this->_currentScene->getWorld()->getWaterLevel() + FLOW_HEIGHT)
FlowUp = false;
else if (FlowAmount <=this->_currentScene->getWorld()->getWaterLevel())
FlowUp = true;
pWaterNode->translate(0, (FlowUp ? WaterFlow : -WaterFlow), 0);
if (this->_Game->getGameType() == Game::GameType::SUDDEN_DEATH)
this->_currentScene->getWorld()->riseWater();
this->_Game->killWormsUnderWater(pWaterNode);
}
示例2: position
//-------------------------------------------------------------------------------------
bool
PlayersManager::hidle(zappy::Player *p, int i)
{
OPlayer *OPlayer = this->mOPlayers.at(i);
if (OPlayer->stateHasChanged())
OPlayer->detachAnim();
Ogre::Vector3 position(p->getX() * Constants::SquareSize, 0, p->getY() * Constants::SquareSize);
Ogre::AnimationState *anim = OPlayer->getEntity()->
getAnimationState("Idle");
Ogre::SceneNode *node = OPlayer->getSceneNode();
anim->setEnabled(true);
if (position != node->getPosition())
node->setPosition(position);
anim->setLoop(true);
anim->setEnabled(true);
anim->addTime(this->tslf);
return true;
}
示例3: addActor
void OgreApplication::addActor(std::shared_ptr<OgreActor> actor)
{
try {
Ogre::Entity* ent;
ent = mSceneMgr->createEntity(actor->entName(), actor->meshName());
ent->setCastShadows(actor->castShadows());
Ogre::SceneNode *node;
node = mSceneMgr->getRootSceneNode()->createChildSceneNode(actor->nodeName());
node->setPosition(toOgreVector3(actor->position()));
node->setOrientation(toOgreQuaternion(actor->orientation()));
node->scale(actor->scale().x(),actor->scale().y(), actor->scale().z());
node->attachObject(ent);
}
catch (Ogre::ItemIdentityException e){
std::cerr << "OgreApplication::addActor, warning: Node " << actor->nodeName() << " already exists. Actor was not added." << std::endl;
}
}
示例4: Initialize
void Laser::Initialize(Ogre::SceneManager *sceneManager, Ogre::SceneNode* parentNode, PhysicsEngine &physicsEngine, unsigned int parentID)
{
PhysicsEntity::Initialize(sceneManager, parentNode, physicsEngine, parentID);
//setting our mass to 0
bodyType = ENTITY_BODY_METAPHYSICAL;
dynamic = false;
mass = 0.0f;
Ogre::Entity *laserEntity = sceneManager->createEntity("Cylinder");
laserEntity->setMaterialName("LaserMaterial");
Ogre::SceneNode *laserSceneNode = sceneNode->createChildSceneNode("Laser" + Ogre::StringConverter::toString(entityCount));
laserSceneNode->attachObject(laserEntity);
laserSceneNode->scale(0.3f, 1000.0f, 0.3f);
laserSceneNode->pitch(Ogre::Radian(-Ogre::Math::HALF_PI));
laserSceneNode->translate(0,0,-500.0f);
sceneNode->setVisible(false);
}
示例5: setShow
void NavigationMesh::setShow( bool show )
{
Ogre::Root *root = Ogre::Root::getSingletonPtr();
Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" );
Ogre::ManualObject* debug;
Ogre::SceneNode* debugNode;
mShow = show;
if( mgr->hasSceneNode( "debugDrawNode2" ) )
{
debugNode = mgr->getSceneNode( "debugDrawNode2" );
}
else
{
debugNode = mgr->getRootSceneNode()->createChildSceneNode( "debugDrawNode2" );
debugNode->translate( 0, 1, 0 ); // Move up slightly to see lines better.
}
if( mgr->hasManualObject( "debugDraw2" ) )
debug = mgr->getManualObject( "debugDraw2" );
else
{
debug = mgr->createManualObject( "debugDraw2" );
debugNode->attachObject( debug );
debug->setQueryFlags( 0 );
debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY );
}
if( !mShow )
{
mgr->destroyManualObject( debug );
return;
}
for( CellVector::iterator i = mCells.begin(); i != mCells.end(); i++ )
{
i->debugDrawCell( debug, "debug/yellow", "debug/blue" );
}
return;
}
示例6: RemoveAttachmentMesh
void EC_Mesh::RemoveAttachmentMesh(uint index)
{
if (renderer_.expired())
return;
RendererPtr renderer = renderer_.lock();
if (!entity_)
return;
if (index >= attachment_entities_.size())
return;
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
if (attachment_entities_[index] && attachment_nodes_[index])
{
// See if attached to a tagpoint or an ordinary node
Ogre::TagPoint* tag = dynamic_cast<Ogre::TagPoint*>(attachment_nodes_[index]);
if (tag)
{
entity_->detachObjectFromBone(attachment_entities_[index]);
}
else
{
Ogre::SceneNode* scenenode = dynamic_cast<Ogre::SceneNode*>(attachment_nodes_[index]);
if (scenenode)
{
scenenode->detachObject(attachment_entities_[index]);
scene_mgr->destroySceneNode(scenenode);
}
}
attachment_nodes_[index] = 0;
}
if (attachment_entities_[index])
{
if (attachment_entities_[index]->sharesSkeletonInstance())
attachment_entities_[index]->stopSharingSkeletonInstance();
scene_mgr->destroyEntity(attachment_entities_[index]);
attachment_entities_[index] = 0;
}
}
示例7: loop
// Manage physics from this loop
// Please don't alter the Ogre scene manager directly. Instead use the designated methods (setPositionX, setPositionY, setPositionZ, setRoll, setPitch, setYaw, animate)
void loop(Ogre::SceneManager* smgr){
int dir = 1;
int timeStep = 10;
while(true){
// If the message array has any elements, the render loop is applying changes from physics loop
// If so, abort this timestep
if((*::message).size() == 1){
continue;
}
Sleep(timeStep);
Ogre::SceneManager::MovableObjectIterator iterator = smgr->getMovableObjectIterator("Entity");
while(iterator.hasMoreElements()){
// If the message array has any elements, the render loop is applying changes from physics loop
// If so, abort this timestep
if((*::message).size() == 1){
continue;
}
Ogre::Entity* entity = static_cast<Ogre::Entity*>(iterator.getNext());
// <>< <>< Make the cute fishy swim <>< <><
// This only moves fish
if(entity->hasAnimationState("swim")){
Ogre::SceneNode* sceneNode = entity->getParentSceneNode();
// Update position
Ogre::Vector3 pos = sceneNode->getPosition();
if(pos.x > 120){
dir = -1;
setYaw(entity, 180);
}
if(pos.x < -120){
dir = 1;
setYaw(entity, 180);
}
setPositionX(entity, sceneNode->getPosition().x + dir);
animate(entity, "swim");
}
}
}
}
示例8:
OGRERendererRacer::OGRERendererRacer(Ogre::SceneManager* a_sceneMgr, Application* app, std::string aname) {
name = aname;
mpApp = app;
mSceneManager = a_sceneMgr;
//mpVehicle = app->mLocalPlayerRacer;
mRollAngle = 0;
mPitchAngle = 0;
mOrientation.FromAngleAxis(Ogre::Radian(0), Ogre::Vector3(1, 0, 0));
mVehicleNode = mSceneManager->getRootSceneNode()->createChildSceneNode();
mVehicleMeshNode = mVehicleNode->createChildSceneNode();
//mVehicleMeshNode->setScale(0.05,0.05,0.05);
//Ogre::Entity* entVehicle = mSceneManager->getEntity("Vehicle");
// Racer model:
mMeshEntity = mSceneManager->createEntity("Vehicle.mesh");
mVehicleMeshNode->attachObject(mMeshEntity);
// TODO 1: Reimplement
// Set up engine flame particle system:
mEngineFlameParticleSystem = mSceneManager->createParticleSystem(name + "_flame", "SpaceRoads/EngineFlame");
Ogre::SceneNode* particleNode = mVehicleMeshNode->createChildSceneNode();
particleNode->setPosition(0, -1.5, 3);
particleNode->attachObject((Ogre::ParticleSystem*) mEngineFlameParticleSystem);
// Set up engine flame particle system:
mEngineSmokeParticleSystem = mSceneManager->createParticleSystem(name + "_smoke", "SpaceRoads/EngineSmoke");
particleNode = mVehicleMeshNode->createChildSceneNode();
particleNode->setPosition(0, -1.5, 3);
particleNode->attachObject((Ogre::ParticleSystem*) mEngineSmokeParticleSystem);
}
示例9: createScene
void createScene()
{
// Create the Entity
Ogre::Entity* robot = mSceneMgr->createEntity("Robot", "robot.mesh");
// Attach robot to scene graph
Ogre::SceneNode* RobotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Robot");
//RobotNode->setPosition((Ogre::Real)-0.3, (Ogre::Real)0.2, (Ogre::Real)0);
RobotNode->attachObject(robot);
RobotNode->scale((Ogre::Real)0.001,(Ogre::Real)0.001,(Ogre::Real)0.001);
RobotNode->pitch(Ogre::Degree(180));
RobotNode->yaw(Ogre::Degree(-90));
// The animation
// Set the good animation
mAnimationState = robot->getAnimationState( "Idle" );
// Start over when finished
mAnimationState->setLoop( true );
// Animation enabled
mAnimationState->setEnabled( true );
}
示例10:
//-------------------------------------------------------------------------------------
void ProjectO3d::createScene(void)
{
// create your scene here :)
// Set the scene's ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
// Create an Entity
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
// Create a SceneNode and attach the Entity to it
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode");
headNode->attachObject(ogreHead);
// Create a Light and set its position
Ogre::Light* light = mSceneMgr->createLight("MainLight");
light->setPosition(20.0f, 80.0f, 50.0f);
// here we will load a forsaken model when the loader is finished
//MXloader* mxl = new MXloader("titan.mx");
}
示例11:
/**
* @brief Dtor.
*/
~EntityPointMarker()
{
if (mMarkerEntity) {
mMarkerEntity->_getManager()->destroyEntity(mMarkerEntity);
}
if (mMarkerNode) {
mMarkerNode->getCreator()->destroySceneNode(mMarkerNode);
}
delete mMarkerDirectionIndicator;
}
示例12: createChildren
void Replicator::createChildren(int value)
{
Ogre::Entity *childEnt = _sceneManager->createEntity(_meshType);
Ogre::SceneNode* childNode = _node->createChildSceneNode();
if ( _materialName != "" ) {
childEnt->setMaterialName(_materialName);
}
childNode->attachObject(childEnt);
Ogre::Real childMinSize = getScale().x * 5;
Ogre::Real childMaxSize = getScale().x * 10;
Ogre::Real size = Ogre::Math::RangeRandom(childMinSize, childMaxSize);
childNode->setScale(size + (value / 1.5), size + (value / 1.5), size + (value / 1.5));
Ogre::Real x = Ogre::Math::RangeRandom(-300,300);
Ogre::Real z = Ogre::Math::RangeRandom(-300,300);
Ogre::Real y = Ogre::Math::RangeRandom(-300,300);
childNode->setPosition(x, y, z);
children.push_back(childEnt);
}
示例13: LocalToWorld
float3x4 EC_Mesh::LocalToWorld() const
{
if (!entity_)
{
LogError(QString("EC_Mesh::LocalToWorld failed! No entity exists in mesh \"%1\" (entity: \"%2\")!").arg(meshRef.Get().ref).arg(ParentEntity() ? ParentEntity()->Name() : "(EC_Mesh with no parent entity)"));
return float3x4::identity;
}
Ogre::SceneNode *node = entity_->getParentSceneNode();
if (!node)
{
LogError(QString("EC_Mesh::LocalToWorld failed! Ogre::Entity is not attached to a Ogre::SceneNode! Mesh \"%1\" (entity: \"%2\")!").arg(meshRef.Get().ref).arg(ParentEntity() ? ParentEntity()->Name() : "(EC_Mesh with no parent entity)"));
return float3x4::identity;
}
assume(!float3(node->_getDerivedScale()).IsZero());
float3x4 tm = float3x4::FromTRS(node->_getDerivedPosition(), node->_getDerivedOrientation(), node->_getDerivedScale());
assume(tm.IsColOrthogonal());
return tm;
}
示例14: updateNodes
void OgreApplication::updateNodes(std::list<std::shared_ptr<OgreActor> > newActors, std::list<std::shared_ptr<DiffActor> > diffActor)
{
for(std::shared_ptr<OgreActor> actor : newActors){
addActor(actor);
}
for (std::shared_ptr<DiffActor> actor : diffActor)
{
Ogre::SceneNode *node;
try {
node = getSceneManager()->getSceneNode(actor->nodeName());
node->setPosition(toOgreVector3(actor->position()));
node->setOrientation(toOgreQuaternion(actor->orientation()));
}
catch (Ogre::ItemIdentityException e){
std::cerr << "OgreApplication::updateNodes, warning: Node " << actor->nodeName() << " was not found. DiffActor was ignored." << std::endl;
}
}
}
示例15: onSetTarget
void Camera::onSetTarget(const GameHandle& target)
{
//! \hack const offset for camera
v3 offset(0.0f, 3.0f, -14);
Ogre::SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManager(BFG_SCENEMANAGER);
if (!sceneMgr->hasSceneNode(stringify(target)))
{
errlog << "Target (" << stringify(target) << ") for camera (" << mHandle << ") does not exist!";
return;
}
Ogre::SceneNode* newParent = sceneMgr->getSceneNode(stringify(target));
Ogre::SceneNode* oldParent = mCameraNode->getParentSceneNode();
oldParent->removeChild(mCameraNode);
newParent->addChild(mCameraNode);
mCameraNode->setPosition(toOgre(offset));
}