本文整理汇总了C++中ogre::SceneNode::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::getPosition方法的具体用法?C++ SceneNode::getPosition怎么用?C++ SceneNode::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::getPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addActor
void PhysicsSystem::addActor (const Ptr& ptr)
{
std::string mesh = MWWorld::Class::get(ptr).getModel(ptr);
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
//TODO:optimize this. Searching the std::map isn't very efficient i think.
mEngine->addCharacter(node->getName(), mesh, node->getPosition(), node->getScale().x, node->getOrientation());
}
示例2: getBase
Ogre::SceneNode * WheelAnimalSceneObj::getBaseCenter()
{
if(_sn == NULL)
{
_sn = Orz::OgreGraphicsManager::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(getCenterPoint());
//_sn->yaw(Ogre::Radian(Ogre::Math::PI));
for(int i=0 ; i<(BASE_ALL-BASE_0); ++i)
{
Ogre::SceneNode * base = getBase(i);
Ogre::Node * parent = base->getParent();
Ogre::Vector3 p = base->getPosition();
if(parent)
{
parent->removeChild(base);
}
base->translate(-getCenterPoint());
_sn->addChild(base);
Ogre::SceneManager * sm = OgreGraphicsManager::getSingleton().getSceneManager();
Ogre::Entity * ent = sm->createEntity("ring"+Ogre::StringConverter::toString(i), "zp_dwdzgh.mesh");
Ogre::SceneNode * node = base->createChildSceneNode("ring"+Ogre::StringConverter::toString(i),Ogre::Vector3(0.f, 10.f, 0.f));
node->setScale(0.6f,0.6f,0.6f);
node->attachObject(ent);
Orz::OgreGraphicsManager::getSingleton().getSceneManager()->getSceneNode("ring"+Ogre::StringConverter::toString(i))->setVisible(false);
}
}
return _sn;
}
示例3: mouseMoved
bool TutorialApplication::mouseMoved(const OIS::MouseEvent& me)
{
// Move the camera around an origin point if the user is holding the right mouse button
if(me.state.buttonDown(OIS::MB_Right))
{
int relativeX = me.state.X.rel;
int relativeY = me.state.Y.rel;
int relativeZ = me.state.Z.rel;
Ogre::SceneNode* positionNode = mSceneMgr->getSceneNode("CAMERA_POSITION");
Ogre::Vector3 pos = positionNode->getPosition();
Ogre::Vector3 origin = Ogre::Vector3(0,0,0);
Ogre::Vector3 scale = origin - pos;
scale.normalise();
//if(pos.z > 50.0f)
//{
positionNode->setPosition(pos+(scale*relativeZ));
//}
//currentDegree += ;
if(currentDegree > maxDegree){ currentDegree = maxDegree; }
if(currentDegree < minDegree){ currentDegree = minDegree; }
Ogre::SceneNode* rotationNode = mSceneMgr->getSceneNode("CAMERA_ROTATION");
rotationNode->rotate(Ogre::Quaternion(Ogre::Degree(relativeX*0.1f), Ogre::Vector3(0,1,0)) , Ogre::Node::TransformSpace::TS_WORLD);
rotationNode->rotate(Ogre::Quaternion(Ogre::Degree(relativeY*0.1f), Ogre::Vector3(1,0,0)) , Ogre::Node::TransformSpace::TS_LOCAL);
}
return true;
}
示例4: save
void Cube::save(Ogre::String file)
{
if (rndCounter == 0)
{
std::ofstream output(file.c_str());
// Write cube size
output << size << std::endl;
for (int i = 0; i < size; ++i)
for (int j = 0; j < size; ++j)
for (int k = 0; k < size; ++k)
{
CubeElement *e = data[i][j][k];
Ogre::Entity *ent = static_cast<Ogre::Entity*>(e->node->getAttachedObject(0));
Ogre::SceneNode *node = e->node;
// Write name, indexes and position
output << node->getName() << "\n"
<< "\t" << i << " " << j << " " << k << "\n" // index in data array
<< "\t" << node->getPosition().x << " " << node->getPosition().y << " " << node->getPosition().z << "\n"; // position
// Write orientation
Ogre::Vector3 orient_axis;
Ogre::Degree orient_angle;
node->getOrientation().ToAngleAxis(orient_angle, orient_axis);
output << "\t" << orient_axis.x << " " << orient_axis.y << " " << orient_axis.z << " " // orientation axis
<< orient_angle.valueDegrees() << "\n"; // orientation angle
output << "\t" << ent->getSubEntity(0)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(1)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(2)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(3)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(4)->getMaterialName() << "\n"
<< "\t" << ent->getSubEntity(5)->getMaterialName() << "\n";
// Write pivot info
output << "\t" << e->isPivot << "\n";
if (e->isPivot)
{
// pivot indexes
output << "\t" << e->pivotArrays[0] << " " << e->pivotArrayIndexes[0] << "\n"
<< "\t" << e->pivotArrays[1] << " " << e->pivotArrayIndexes[1] << "\n";
}
// flush
output << std::endl;
}
output.close();
}
}
示例5: insertObjectPhysics
void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
// unused
//Ogre::Vector3 objPos = node->getPosition();
addObject (node->getName(), model, node->getOrientation(),
node->getScale().x, node->getPosition());
}
示例6: 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");
}
}
}
}
示例7:
AnimatPosition::AnimatPosition(Ogre::String sNodeName, Ogre::Vector3 newPos, float durationSeconds) {
this->SceneNodeName = sNodeName;
this->AnimatType = AnimatTypePosition;
Ogre::SceneNode* node = LG::RendererOgre::Instance()->m_sceneMgr->getSceneNode(this->SceneNodeName);
m_originalPosition = node->getPosition();
m_targetPosition = newPos;
m_durationSeconds = durationSeconds;
m_distanceVector = m_targetPosition - m_originalPosition;
m_progress = 0.0f;
};
示例8: show
void Board::show(Ogre::SceneNode* const node)
{
// corner node of a level
Ogre::SceneNode* levNode = 0;
Ogre::SceneNode* rowNode = 0;
Ogre::SceneNode* colNode = 0;
// index of the square in the vector of squares
unsigned int i = 0;
for(unsigned int level = 0; level < m_model->getLevels(); ++level)
{
levNode = (levNode == 0) ? node : levNode->createChildSceneNode();
for(unsigned int row = 0; row < m_model->getRows(); ++row)
{
rowNode = (rowNode == 0 || row == 0) ? levNode : rowNode->createChildSceneNode();
for(unsigned int col = 0; col < m_model->getCols(); ++col, ++i)
{
colNode = (col == 0) ? rowNode : colNode->createChildSceneNode();
Ogre::Vector3 squareOrigin = colNode->getPosition();
Color squareColor = ((row + col + level) % 2 == 0) ? COLOR_WHITE : COLOR_BLACK;
m_squares[i] = new Square(colNode, squareColor);
// correctly position the node
if(level > 0 && row == 0 && col == 0)
// raise the square
squareOrigin.y += LEVEL_MARGIN;
else if(row > 0 && col == 0)
// add a row to the board
squareOrigin.z -= m_squares[i]->getEntity()->getBoundingBox().getSize().z;
else
// add a cell to a column of the board
squareOrigin.x += m_squares[i]->getEntity()->getBoundingBox().getSize().x;
// update the node's position accordingly
colNode->setPosition(squareOrigin);
}
}
}
// finally we center the entire board over the x and z axis
// take a single square for reference
Square* refSquare = m_squares[0];
Ogre::Vector3 boardOrigin = node->getPosition();
boardOrigin.x -= (refSquare->getEntity()->getBoundingBox().getSize().x * m_model->getCols()) / 2.0;
boardOrigin.z += (refSquare->getEntity()->getBoundingBox().getSize().z * m_model->getRows()) / 2.0;
node->setPosition(boardOrigin);
}
示例9: Fly
void TranslationAnm::Fly()
{
Ogre::SceneNode* node = m_pGameObj->getNode();
Ogre::Vector3 pos = node->getPosition();
if(m_pAnmState->getEnabled())
return;
Ogre::TransformKeyFrame* k_t0_0=m_pAnmTrack->getNodeKeyFrame(ANM_KEYFRAME_0);
k_t0_0->setRotation(node->getOrientation());
Ogre::TransformKeyFrame* k_t0_2=m_pAnmTrack->getNodeKeyFrame(ANM_KEYFRAME_1);
k_t0_2->setRotation(node->getOrientation());
m_pAnmState->setTimePosition(0);
m_pAnmState->setEnabled(true);
}
示例10: LocalToParent
float3x4 EC_Mesh::LocalToParent() const
{
if (!entity_)
{
LogError("EC_Mesh::LocalToParent failed! No entity exists in this mesh!");
return float3x4::identity;
}
Ogre::SceneNode *node = entity_->getParentSceneNode();
if (!node)
{
LogError("EC_Mesh::LocalToParent failed! Ogre::Entity is not attached to a Ogre::SceneNode!");
return float3x4::identity;
}
return float3x4::FromTRS(node->getPosition(), node->getOrientation(), node->getScale());
}
示例11: LocalToParent
float3x4 EC_Mesh::LocalToParent() const
{
if (!entity_)
{
LogError(QString("EC_Mesh::LocalToParent 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::LocalToParent 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;
}
return float3x4::FromTRS(node->getPosition(), node->getOrientation(), node->getScale());
}
示例12: destination
//-------------------------------------------------------------------------------------
bool
PlayersManager::moving(zappy::Player *p, int i)
{
OPlayer *OPlayer = this->mOPlayers.at(i);
this->speed = Constants::SquareSize /
((Constants::timeUnit / static_cast<Ogre::Real>(time)));
Ogre::SceneNode *node = OPlayer->getSceneNode();
Ogre::Vector3 &direction = OPlayer->getDirection();
Ogre::Real &distance = OPlayer->getDistance();
Ogre::Real move = this->speed * this->tslf;
Ogre::Vector3 destination(p->getX() * Constants::SquareSize, 0, p->getY() * Constants::SquareSize);
Ogre::AnimationState *anim = OPlayer->getEntity()->
getAnimationState(distance <= 0.0f ? "Idle" : "Walk");
anim->setLoop(true);
anim->setEnabled(true);
if (direction == Ogre::Vector3::ZERO)
{
Ogre::Vector3 src = node->getOrientation() * Ogre::Vector3::UNIT_X;
direction = destination - node->getPosition();
distance = direction.normalise();
if ((1.0f + src.dotProduct(direction)) < 0.0001f)
node->yaw(Ogre::Degree(180));
else
node->rotate(src.getRotationTo(direction));
if (distance > Constants::SquareSize)
distance = 0.0f;
}
else
{
distance -= move;
if (distance <= 0.0f)
{
node->setPosition(destination);
direction = Ogre::Vector3::ZERO;
}
else
node->translate(direction * move);
}
if (OPlayer->stateHasChanged())
OPlayer->detachAnim();
anim->addTime(this->tslf);
return true;
}
示例13: reset
void Player::reset() {
Ogre::String floorTileName = "N" + Ogre::StringConverter::toString(4-position[1]) + Ogre::StringConverter::toString(position[0]);
Ogre::SceneNode* floorTile = mSceneMgr->getSceneNode(floorTileName);
Ogre::Vector3 floorTilePos = floorTile->getPosition();
floorTilePos.y = 0;
floorTile->setPosition(floorTilePos);
mPlayerNode->setPosition(Ogre::Vector3(-400, 0, 400));
rotated = false;
position[0] = 0;
position[1] = 0;
mRotating = false;
mRotatingLeft = false;
walking = false;
dying = false;
dyingProgress = 1.0;
nextKey = 0;
}
示例14: position
//-------------------------------------------------------------------------------------
bool
PlayersManager::dying(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("Die");
Ogre::SceneNode *node = OPlayer->getSceneNode();
if (position != node->getPosition())
node->setPosition(position);
anim->setEnabled(true);
anim->setLoop(false);
anim->addTime(this->tslf);
return true;
}
示例15: createProjectile
entityx::Entity Factory::createProjectile(entityx::ptr<EntityManager> where, Ogre::Vector3 pos, Ogre::Quaternion ori, Ogre::Real velocity, std::string materialName)
{
Ogre::Entity *projMesh;
Ogre::SceneManager *sceneMgr = RenderManager::getPtr()->getSceneManager();
projMesh = sceneMgr->createEntity("ProjectileMesh.mesh");
projMesh->setMaterialName(materialName);
Entity proj = where->create();
Ogre::SceneNode *projNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
projNode->attachObject(projMesh);
Ogre::Light *light = sceneMgr->createLight();
if(materialName == "RedLaser")
light->setDiffuseColour(Ogre::ColourValue(.8, .2, .2));
else
light->setDiffuseColour(Ogre::ColourValue(.2, .2, .8));
light->setType(Ogre::Light::LT_POINT);
projNode->attachObject(light);
projNode->setPosition(pos);
projNode->setOrientation(ori);
//projNode->translate(0, 0, -2, Ogre::SceneNode::TS_LOCAL);
proj.assign<Position>(projNode->getPosition());
proj.assign<Orientation>(ori);
proj.assign<Velocity>(0, 0, velocity);
proj.component<Velocity>()->direction.z = -1;
proj.assign<Renderable>(projNode);
proj.assign<AngularVelocity>(0, 0, 10);
proj.assign<Name>("proiettile");
proj.assign<LightComponent>(light);
return proj;
}