本文整理汇总了C++中ogre::SceneNode::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::setPosition方法的具体用法?C++ SceneNode::setPosition怎么用?C++ SceneNode::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::setPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createProjectile
void ProjectileManager::createProjectile(const Ogre::Vector3& tankPosition, const Ogre::Quaternion& turretOrientation,
const Ogre::Degree& angle, const float& velocity, const float& dmg){
std::ostringstream oss;
oss << "Projectile" << time(0) << projectiles.size() << counter++;
Ogre::ParticleSystem* particleSystem = mSceneMgr->createParticleSystem(oss.str(), "Examples/PurpleFountain");
scaleBy(1.f, particleSystem);
Ogre::SceneNode* parentParticleSn = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::SceneNode* particleSn = parentParticleSn->createChildSceneNode();
Ogre::Vector3 start(-115.f, 10.f, 0.f);
parentParticleSn->setPosition(tankPosition);
particleSn->setPosition(start);
parentParticleSn->yaw(turretOrientation.getYaw());
particleSn->attachObject(particleSystem);
particleSn->roll(Ogre::Degree(-90.f));
particleSn->scale(Ogre::Vector3(0.1f));
projectiles.insert(new Projectile(start, particleSn, angle, velocity, dmg));
}
示例2: createEntities
void DemoKeeper::createEntities()
{
#ifdef MYGUI_OGRE_PLATFORM
Ogre::Entity* entity = getSceneManager()->createEntity("friend", "Mikki.mesh");
Ogre::SceneNode* node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
node->attachObject(entity);
node->setPosition(0, 0, 300);
entity = getSceneManager()->createEntity("enemy", "Robot.mesh");
node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
node->attachObject(entity);
node->setPosition(0, 0, -300);
//node->showBoundingBox(true);
Ogre::MeshManager::getSingleton().createPlane(
"FloorPlane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::Plane(Ogre::Vector3::UNIT_Y, 0), 2000, 2000, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Z);
entity = getSceneManager()->createEntity("floor", "FloorPlane");
entity->setMaterialName("Ground");
node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
node->attachObject(entity);
gRaySceneQuery = getSceneManager()->createRayQuery(Ogre::Ray());
#else
MyGUI::LayoutManager::getInstance().loadLayout("Wallpaper.layout");
#endif
}
示例3: setupContent
void StencilShadowTest::setupContent()
{
// turn ambient light off
mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0));
// turn on stencil shadows
mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
// add a couple lights
Ogre::Light* light = mSceneMgr->createLight("Light1");
light->setDiffuseColour(0.5f,0.4f,0.35f);
light->setSpecularColour(0, 0, 0);
light->setAttenuation(8000,1,0.0005,0);
light->setPosition(220,100,0);
light->setCastShadows(true);
light->setType(Light::LT_POINT);
light = mSceneMgr->createLight("Light2");
light->setDiffuseColour(0.5f,0.4f,0.35f);
light->setSpecularColour(0, 0, 0);
light->setAttenuation(8000,1,0.0005,0);
light->setPosition(220,100,-200);
light->setCastShadows(true);
light->setType(Light::LT_POINT);
// create a ground plane to receive some shadows
Plane pln = MovablePlane("plane");
pln.normal = Vector3::UNIT_Y;
pln.d = 107;
MeshManager::getSingleton().createPlane("ground_plane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, pln,
1500,1500,50,50,true,1,5,5,Vector3::UNIT_Z);
Ogre::Entity* groundPlane = mSceneMgr->createEntity( "plane", "ground_plane" );
groundPlane->setMaterialName("Examples/Rocky");
groundPlane->setCastShadows(false);
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundPlane);
// and a couple objects to cast the shadows
Ogre::Entity* bar = mSceneMgr->createEntity( "barrel", "Barrel.mesh" );
bar->setCastShadows(true);
Ogre::SceneNode* barNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
barNode->attachObject(bar);
barNode->setScale(7,7,7);
barNode->setPosition(Ogre::Vector3(0,-85,-320));
Ogre::Entity* head = mSceneMgr->createEntity( "ogrehead", "ogrehead.mesh" );
head->setCastShadows(true);
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
headNode->attachObject(head);
headNode->setPosition(Ogre::Vector3(-100,-80,-320));
Ogre::Entity* torus = mSceneMgr->createEntity( "torus", "knot.mesh" );
torus->setCastShadows(true);
torus->setMaterialName("Examples/RustySteel");
Ogre::SceneNode* torusNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
torusNode->setScale(0.5,0.5,0.5);
torusNode->attachObject(torus);
torusNode->setPosition(Ogre::Vector3(100,-60,-320));
// point the camera down a bit
mCamera->pitch(Ogre::Degree(-20.f));
}
示例4: createCanvasCube
void OgreAppLogic::createCanvasCube(void)
{
Ogre::SceneNode* mClockNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mClockNode->setPosition(-1.0, 0.5, 0);
mClockNode->attachObject(createCubeMesh("ClockCube1", "CanvasClock1"));
mClockNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
mClockNode->setPosition(1.0, 0.5, 0);
mClockNode->attachObject(createCubeMesh("ClockCube2", "CanvasClock2"));
}
示例5: keyPressed
bool SimonSays::keyPressed( const OIS::KeyEvent &arg ) {
bool ret = BaseApplication::keyPressed( arg );
if (arg.key == KEY_START ) {
if( !gameStarted ) {
restartGame( true );
gameStarted = true;
}
// (re-)starts the game
if( turnEnded ) {
restartGame( !correctOrder ); // if the order is correct, NO restart
}
}
if( !showMode && !turnEnded ) {
if (arg.key == KEY_YELLOW) {
Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
playerNode->setPosition(0,20,0);
} else if (arg.key == KEY_RED) {
Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
playerNode->setPosition(65,20,0);
} else if (arg.key == KEY_BLUE) {
Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
playerNode->setPosition(0,20,65);
} else if (arg.key == KEY_GREEN) {
Ogre::SceneNode* playerNode = mSceneMgr->getSceneNode("PlayerNode");
playerNode->setPosition(65,20,65);
}
// check key after moving the player
if( playerOrder.size() > 0 ) {
if( !checkKey(arg.key) ) {
mSceneMgr->getLight("yellowSpot")->setVisible( false );
mSceneMgr->getLight("redSpot")->setVisible( false );
mSceneMgr->getLight("blueSpot")->setVisible( false );
mSceneMgr->getLight("greenSpot")->setVisible( false );
mSceneMgr->setAmbientLight(Ogre::ColourValue(1,0.2,0.2));
};
}
if( playerOrder.size() < 1 ) {
mSceneMgr->getLight("yellowSpot")->setVisible( false );
mSceneMgr->getLight("redSpot")->setVisible( false );
mSceneMgr->getLight("blueSpot")->setVisible( false );
mSceneMgr->getLight("greenSpot")->setVisible( false );
mSceneMgr->getEntity("Player")->setVisible( false );
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2,1,0.2));
}
} // eof !showMode
return ret;
}
示例6: createScene
void GameState::createScene()
{
// --- Objects
m_pNpc01 = new BaseNpc("Blacksmith", m_pSceneMgr, Ogre::Vector3(50.0f, 0.0f, 50.0f));
m_pNpc01->ChangeState(Work::Instance());
//m_pNpc02 = new BaseNpc("Woman", m_pSceneMgr, Ogre::Vector3(-50.0f, 0.0f, -50.0f));
//m_pNpc01->addLocation(Ogre::Vector3(-100.0f,0.0f,-100.0f));
// --- World
// Light
m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7));
// Objects
// Home
Ogre::Entity* home = m_pSceneMgr->createEntity("Home", "tudorhouse.mesh");
//home->setCastShadows(true);
Ogre::SceneNode* homeNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("HomeNode");
homeNode->attachObject(home);
homeNode->setPosition(Ogre::Vector3(-400.0f,220.0f,-400.0f));
homeNode->setScale(0.4f, 0.4f, 0.4f);
// Work
Ogre::Entity* work = m_pSceneMgr->createEntity("Work", "tudorhouse.mesh");
//work->setCastShadows(true);
Ogre::SceneNode* workNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("WorkNode");
workNode->attachObject(work);
workNode->setPosition(Ogre::Vector3(400.0f,220.0f,400.0f));
workNode->setScale(0.4f, 0.4f, 0.4f);
workNode->yaw(Ogre::Degree(180));
// Tavern
Ogre::Entity* tavern = m_pSceneMgr->createEntity("Tavern", "tudorhouse.mesh");
//tavern->setCastShadows(true);
Ogre::SceneNode* tavernNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("TavernNode");
tavernNode->attachObject(tavern);
tavernNode->setPosition(Ogre::Vector3(-400.0f,220.0f,400.0f));
tavernNode->setScale(0.4f, 0.4f, 0.4f);
tavernNode->yaw(Ogre::Degree(180));
// Ground
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane, 1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity* entGround = m_pSceneMgr->createEntity("GroundEntity", "ground");
m_pSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);
entGround->setMaterialName("Examples/Rockwall");
entGround->setCastShadows(false);
}
示例7: make
GameEntity* SphereFactory::make(const rapidjson::Value& jsonobj, SpaceObject*spaceobj){
// Create the sphere
Ogre::Entity* entity = game_manager->GetSceneManager()->createEntity(jsonobj["name"].GetString(), Ogre::SceneManager::PT_SPHERE);
entity->setMaterialName(jsonobj["material"].GetString());
// Create a SceneNode and attach the Entity to it
Ogre::SceneNode *node = game_manager->GetSceneManager()->getRootSceneNode()->createChildSceneNode(jsonobj["name"].GetString());
node->attachObject(entity);
// Set the node's position
Eigen::Vector3f positionVec=spaceobj->position.cast<float>();
node->setPosition(Ogre::Vector3( static_cast<Ogre::Real*>(positionVec.data()) ));
// Set the node's orientation
Eigen::Vector4f attitudeVec=spaceobj->attitude.coeffs().cast<float>();
node->setOrientation(Ogre::Quaternion(static_cast<Ogre::Real*>(attitudeVec.data()) ));
// Scale the sphere
node->scale( jsonobj["scale"][0u].GetDouble(), jsonobj["scale"][1u].GetDouble(),jsonobj["scale"][2u].GetDouble() );
GameEntity*game_entity=new GameEntity(spaceobj,entity,node);
this->game_manager->add_allocated_object(game_entity);
return game_entity;
}
示例8: createScene
void QOgreWindow::createScene()
{
// Put anything in here, I'll just put a plane and a dragon here for testing purposes. Go crazy.
// Plane
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::MeshManager::getSingleton().createPlane(
"ground",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane,
1500,1500,20,20,
true,
1,5,5,
Ogre::Vector3::UNIT_Z);
Ogre::Entity* ground = oSceneMgr->createEntity("ground");
oSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ground);
ground->setCastShadows(false);
ground->setMaterialName("Examples/Rockwall");
// Dragon Mesh
oSceneMgr->setAmbientLight(Ogre::ColourValue(0.5,0.5,0.5));
Ogre::Entity* ogreHead = oSceneMgr->createEntity("Icosphere.mesh");
Ogre::SceneNode* node = oSceneMgr->getRootSceneNode()->createChildSceneNode();
node->attachObject(ogreHead);
node->setPosition(0.0,70.0,0.0);
Ogre::Light* light = oSceneMgr->createLight("MainLight");
light->setPosition(20, 80, 50);
}
示例9: frameStarted
bool BallApp::frameStarted(const Ogre::FrameEvent &evt) {
bool result = BaseApplication::frameStarted(evt);
if (mPhysics != NULL) {
btDiscreteDynamicsWorld* world = mPhysics->getDynamicsWorld();
world->stepSimulation(1.0f/60.0f);
btAlignedObjectArray<btCollisionObject*> objs = world->getCollisionObjectArray();
for (int i = 0; i < objs.size(); i++) {
btCollisionObject *obj = objs[i];
btRigidBody *body = btRigidBody::upcast(obj);
if (body && body->getMotionState()) {
btTransform trans;
body->getMotionState()->getWorldTransform(trans);
void *userPointer = body->getUserPointer();
if (userPointer) {
btQuaternion orientation = trans.getRotation();
Ogre::SceneNode *sceneNode = static_cast<Ogre::SceneNode *>(userPointer);
sceneNode->setPosition(Ogre::Vector3(trans.getOrigin().getX(), trans.getOrigin().getY(), trans.getOrigin().getZ()));
sceneNode->setOrientation(Ogre::Quaternion(orientation.getW(), orientation.getX(), orientation.getY(), orientation.getZ()));
}
}
}
}
return result;
}
示例10: addNode
void OgreBase::addNode(const std::string &name, const std::string &mesh, Ogre::Real x, Ogre::Real y, Ogre::Real z){
// "ogrehead.mesh"
Ogre::Entity* entity = mSceneMgr->createEntity(name, mesh);
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->setPosition(x, y, z);
node->attachObject(entity);
}
示例11: summonEvilBall
void TutorialApplication::summonEvilBall() {
Ogre::Entity* ball = mSceneMgr->createEntity("evilBall");
ball->setMaterialName("Ogre/Skin");
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
node->setPosition(Ogre::Vector3(Ogre::Math::SymmetricRandom() * (AREA_RANGE/2),
Ogre::Math::SymmetricRandom() * (AREA_RANGE/2),
Ogre::Math::SymmetricRandom() * (AREA_RANGE/2)));
node->attachObject(ball);
ShipProject::GameObject* oBall = new ShipProject::GameObject(ball, 2);
oBall->SetupCollision(new btSphereShape(BALL_RADIUS), CollisionGroup::BALLS, CollisionGroup::PLAYER | CollisionGroup::WALLS
| CollisionGroup::BALLS | CollisionGroup::PROJECTILES_PLAYER);
objects_.push_back( oBall );
if (Ogre::Math::UnitRandom() < 0.5) {
oBall->body()->setLinearVelocity( btVector3(Ogre::Math::SymmetricRandom(),
Ogre::Math::SymmetricRandom(),
Ogre::Math::SymmetricRandom()) * Ogre::Math::RangeRandom(0.0, 70.0) );
}
oBall->body()->setRestitution(1.0);
oBall->body()->activate(true);
enemies_[oBall->entity_name()] = Enemy(oBall, Ogre::Math::UnitRandom() * 5);
}
示例12:
void Application::createSceneSet1()
{
int sNumber = 0;
Ogre::Entity* groundEntity = m_sceneManager->createEntity( "Ground1", "ground.mesh" );
Ogre::SceneNode* groundSceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
groundSceneNode->attachObject( groundEntity );
groundSceneNode->setPosition(Ogre::Vector3(0, 0, DISTANCE_TO_ANOTHER * sNumber * -1));
groundSceneNode->setScale( ROW_WIDTH, 1, ROW_HEIGHT );
/*
Ogre::ParticleSystem* pTest1 = m_sceneManager->createParticleSystem("pFireworks", "Examples/Fireworks");
Ogre::SceneNode* pTest1SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
pTest1SceneNode->attachObject(pTest1);
pTest1SceneNode->setPosition(Ogre::Vector3(150, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));
*/
ParticleUniverse::ParticleSystem * pTest1 =
ParticleUniverse::ParticleSystemManager::getSingleton().createParticleSystem("pTest1", "PUMediaPack/Teleport", m_sceneManager);
Ogre::SceneNode* pTest1SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
pTest1SceneNode->attachObject(pTest1);
pTest1SceneNode->setPosition(Ogre::Vector3(150, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));
Ogre::ParticleSystem* pTest2 = m_sceneManager->createParticleSystem("pSmoke1", "Examples/Smoke");
Ogre::SceneNode* pTest2SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
pTest2SceneNode->attachObject(pTest2);
pTest2SceneNode->setPosition(Ogre::Vector3(-100, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));
Ogre::ParticleSystem* pTest3 = m_sceneManager->createParticleSystem("pGreeny", "Examples/GreenyNimbus");
Ogre::SceneNode* pTest3SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode();
pTest3SceneNode->attachObject(pTest3);
pTest3SceneNode->setPosition(Ogre::Vector3(-350, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1));
}
示例13:
Ogre::SceneNode* AWGraphics::SceneDirector::createPlane(float x, float y, float z)
{
Ogre::Plane plane = Ogre::Plane(Ogre::Vector3::UNIT_Y, 0);
// Initialize a ground entity for later use
Ogre::MeshManager::getSingleton().createPlane(
"ground",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane,
1500, 1500, 20, 20,
true,
1, 5, 5,
Ogre::Vector3::UNIT_Z);
//Ogre::MeshManager::getSingleton().createPlane()
Ogre::Entity* groundEntity = mSceneMgr->createEntity("ground");
groundEntity->setMaterialName("Rockwall");
groundEntity->setCastShadows(false);
Ogre::SceneNode* ogreNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
ogreNode->attachObject(groundEntity);
ogreNode->setPosition(x, y, z);
ogreNode->setOrientation(Ogre::Quaternion::IDENTITY); // hope this is a good reference
return ogreNode;
}
示例14: srand
void OBTutorial2::createBoxShape(Ogre::Entity* entity, Ogre::Vector3 position, bool bStatic)
{
Ogre::SceneNode *node = entity->getParentSceneNode();
Vector3 size = node->_getDerivedScale()*entity->getBoundingBox().getHalfSize();
float mass = bStatic ? 0.0f : 1.0f;
srand( (unsigned)time( NULL ) );
node->setPosition(position);
node->setOrientation(Quaternion(Degree(Ogre::Math::RangeRandom(0.0,60.0)), Vector3::UNIT_Y));
btBoxShape *sceneBoxShape = new btBoxShape(toBulletVector(size)); // konvertovat vektor size
// and the Bullet rigid body
MyMotionState * defaultMotionState = new MyMotionState(btTransform(btQuaternion(btScalar(0),btScalar(0),btScalar(0),btScalar(1))), node);
btRigidBody *defaultBody = new btRigidBody(btScalar(1), defaultMotionState, sceneBoxShape);
/* defaultBody->setShape(node,
sceneBoxShape,
0.6f, // dynamic body restitution
0.6f, // dynamic body friction
mass, // dynamic bodymass
node->_getDerivedPosition(), // starting position of the box
node->_getDerivedOrientation()); // orientation of the box**/
mShapes.push_back(sceneBoxShape);
mBodies.push_back(defaultBody);
mNumEntitiesInstanced++;
}
示例15:
void DrivingSimulatorV1::createScene1() // city
{
// create world node
Ogre::SceneNode* worldNode = sceneManager->getRootSceneNode()->createChildSceneNode();
Ogre::Entity* cityWorld = sceneManager->createEntity("CityWorld.mesh");
worldNode->scale(0.05, 0.05, 0.05);
worldNode->attachObject(cityWorld);
// create ETH Node
Ogre::SceneNode* ethNode = sceneManager->getRootSceneNode()->createChildSceneNode();
Ogre::Entity* eth = sceneManager->createEntity("ETH.mesh");
ethNode->attachObject(eth);
ethNode->scale(1.3, 1.3, 1.3);
ethNode->setPosition(428, 0, 235);
ethNode->yaw(Ogre::Degree(210));
// create ambient light
sceneManager->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7));
// create sun light
Ogre::Light* sunLight = sceneManager->createLight();
sunLight->setType(Ogre::Light::LT_DIRECTIONAL);
sunLight->setDirection(Ogre::Vector3(-0.5, -0.5, 0.5));
sunLight->setDiffuseColour(Ogre::ColourValue(1, 1, 1));
sunLight->setSpecularColour(Ogre::ColourValue(0.7, 0.7, 0.7));
// set car to initial position and orientation
carNode->setPosition(584, 0, 121);
carNode->setOrientation(Ogre::Quaternion(Ogre::Degree(-4.5), Ogre::Vector3::UNIT_Y));
}