本文整理汇总了C++中ogre::SceneNode::getOrientation方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::getOrientation方法的具体用法?C++ SceneNode::getOrientation怎么用?C++ SceneNode::getOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::getOrientation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void OgreCharacterController::update(Ogre::Real elapsedTime, OIS::Keyboard * input)
{
Ogre::SceneNode * node = getMainNode();
OGRE_ANIMATION_STATE state = IDLE;
if(input->isKeyDown(OIS::KC_W)) {
node->translate(node->getOrientation() * Ogre::Vector3(0, 0, elapsedTime*100));
state = RUN;
}
if(input->isKeyDown(OIS::KC_S)) {
node->translate(node->getOrientation() * Ogre::Vector3(0, 0, elapsedTime*-50));
state = RUN;
}
if(input->isKeyDown(OIS::KC_A)) {
node->yaw(Ogre::Radian(2*elapsedTime));
}
if(input->isKeyDown(OIS::KC_D))
node->yaw(Ogre::Radian(-2*elapsedTime));
if(input->isKeyDown(OIS::KC_RETURN)) {
state = DRAWSWORDS;
}
if(input->isKeyDown(OIS::KC_SPACE)) {
state = SLICE;
}
if(input->isKeyDown(OIS::KC_PGUP)) {
//mRigidBody->setLinearVelocity(btVector3(0, 50, 0));
}
animate(elapsedTime, state);
}
示例2: 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);
}
示例3: setUpQuaternion
void GameState::setUpQuaternion()
{
//设置跑道标准开始方向
Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Vector3 dir = mSceneMgr->getSceneNode("R1PS")->_getDerivedPosition() - mSceneMgr->getSceneNode("R1P1")->_getDerivedPosition();
sn->setDirection(dir);
mStdQuaternion = sn->getOrientation();
}
示例4: 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());
}
示例5: 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();
}
}
示例6: 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());
}
示例7: 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());
}
示例8: 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;
}
示例9: rotateObject
void PhysicsSystem::rotateObject (const Ptr& ptr)
{
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
std::string handle = node->getName();
Ogre::Quaternion rotation = node->getOrientation();
if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle))
{
//Needs to be changed
act->setRotation(rotation);
}
if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle))
{
if(dynamic_cast<btBoxShape*>(body->getCollisionShape()) == NULL)
body->getWorldTransform().setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w));
else
mEngine->boxAdjustExternal(handleToMesh[handle], body, node->getScale().x, node->getPosition(), rotation);
}
}
示例10: createBlock
Entity Factory::createBlock(entityx::ptr<entityx::EntityManager> entityMgr, int x, int y, int z, std::string material)
{
Entity block = entityMgr->create();
Ogre::SceneManager* sceneMgr = RenderManager::getPtr()->getSceneManager();
Ogre::Entity* wall = sceneMgr->createEntity("Cube.mesh");
wall->setMaterialName(material);
Ogre::SceneNode* wallNode = sceneMgr->getRootSceneNode()->createChildSceneNode();
wallNode->attachObject(wall);
block.assign<Position>(x,y,z);
wallNode->setPosition(x,y,z);
block.assign<Orientation>(wallNode->getOrientation());
block.assign<Renderable>(wallNode);
block.assign<Name>("Block");
if(material == "Wall"){
block.assign<Destroyable>(200);
}
return block;
}
示例11: createAnimation
void MenuScene::createAnimation(void)
{
Ogre::SceneNode *titleNode = static_cast<Ogre::SceneNode *>(mSceneMgr->getRootSceneNode()->getChild("boomb_title"));
Ogre::Animation *anim = mSceneMgr->createAnimation("title_animation", 3);
anim->setInterpolationMode(Ogre::Animation::IM_SPLINE);
Ogre::NodeAnimationTrack *track = anim->createNodeTrack(0, titleNode);
Ogre::TransformKeyFrame *key = track->createNodeKeyFrame(0);
key->setTranslate(Ogre::Vector3(0,0,100));
Ogre::Quaternion q1 = titleNode->getOrientation();
Ogre::Quaternion q2(Ogre::Degree(45), Ogre::Vector3::UNIT_X);
key->setRotation(q2);
key = track->createNodeKeyFrame(1.5);
key->setTranslate(Ogre::Vector3(0,0,120));
key->setRotation(q2);
key = track->createNodeKeyFrame(3);
key->setTranslate(Ogre::Vector3(0,0,100));
key->setRotation(q2);
mTitleAnimState = mSceneMgr->createAnimationState("title_animation");
mTitleAnimState->setEnabled(true);
mTitleAnimState->setLoop(true);
Ogre::SceneNode *backgroundNode = static_cast<Ogre::SceneNode *>(mSceneMgr->getRootSceneNode()->getChild("boomb_background"));
anim = mSceneMgr->createAnimation("background_animation", 30);
anim->setInterpolationMode(Ogre::Animation::IM_SPLINE);
track = anim->createNodeTrack(0, backgroundNode);
key = track->createNodeKeyFrame(0);
key->setTranslate(Ogre::Vector3(20,0,20));
key = track->createNodeKeyFrame(15);
key->setTranslate(Ogre::Vector3(-20,0,-20));
key = track->createNodeKeyFrame(30);
key->setTranslate(Ogre::Vector3(20,0,20));
mBackgroundAnimState = mSceneMgr->createAnimationState("background_animation");
mBackgroundAnimState->setEnabled(true);
mBackgroundAnimState->setLoop(true);
}
示例12: evilShot
void TutorialApplication::evilShot(ShipProject::GameObject* enemy, double speed) {
Ogre::Entity* ball = mSceneMgr->createEntity("projectile");
ball->setMaterialName("Projectile/Red");
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Vector3 dir = player->entity()->getParentSceneNode()->getPosition() - enemy->entity()->getParentSceneNode()->getPosition();
dir.normalise();
Ogre::Quaternion orient = Ogre::Vector3::NEGATIVE_UNIT_Z.getRotationTo(dir);
node->setPosition(enemy->entity()->getParentSceneNode()->getPosition() );
node->setOrientation(orient);
node->translate( orient * (Ogre::Vector3::UNIT_Z * -0.5) );
node->attachObject(ball);
ShipProject::GameObject* oBall = new ShipProject::GameObject(ball, 0.25);
oBall->SetupCollision(new btSphereShape(PROJECTILE_RADIUS), CollisionGroup::PROJECTILES_BALLS, CollisionGroup::PLAYER | CollisionGroup::WALLS);
objects_.push_back( oBall );
// orientatation * (original model forward vector) = direction vector
oBall->body()->setLinearVelocity( BtOgre::Convert::toBullet(node->getOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z * speed));
oBall->body()->setRestitution(1.0);
oBall->body()->activate(true);
projectiles_[oBall->entity_name()] = Projectile(oBall, 3.0);
}
示例13: shoot
void TutorialApplication::shoot() {
//Ogre::InstancedEntity* ball = balls->createInstancedEntity("Ogre/Skin");
Ogre::Entity* ball = mSceneMgr->createEntity("projectile");
//ball->setCastShadows(true);
ball->setMaterialName("Projectile/Blue");
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::Quaternion orient = camera->actual_orientation();
node->setPosition(player->entity()->getParentSceneNode()->getPosition() );
node->setOrientation(orient);
node->translate( orient * (Ogre::Vector3::UNIT_Z * -0.5) );
node->attachObject(ball);
ShipProject::GameObject* oBall = new ShipProject::GameObject(ball, 0.25);
oBall->SetupCollision(new btSphereShape(PROJECTILE_RADIUS), CollisionGroup::PROJECTILES_PLAYER, CollisionGroup::BALLS | CollisionGroup::WALLS);
objects_.push_back( oBall );
// orientatation * (original model forward vector) = direction vector
oBall->body()->setLinearVelocity( BtOgre::Convert::toBullet(node->getOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z * 100));
oBall->body()->setRestitution(1.0);
oBall->body()->activate(true);
projectiles_[oBall->entity_name()] = Projectile(oBall, 3.0);
}
示例14: mouseMoveEvent
//-------------------------------------------------------------------------------------
void RollerCoaster::mouseMoveEvent( QMouseEvent *event )
{
lastPos=event->pos();
//bLMouseDown = true;
float RatioX = float (lastPos.x())/mCamera->getViewport()->getActualWidth();
float RatioY = float (lastPos.y())/mCamera->getViewport()->getActualWidth();
if(bLMouseDown){
using namespace Ogre;
Ray mouseRay=mCamera->getCameraToViewportRay(RatioX,RatioY);
std::pair<bool, Real>point =mouseRay.intersects(mPlane);
if(point.first)
{
Vector3 pos= mouseRay.getPoint(point.second);
SceneNode *tempSn = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Entity *tempEn = mSceneMgr->createEntity("ogrehead.mesh");
tempSn->attachObject(tempEn);
tempSn->setPosition(pos);
tempSn->setScale(0.1,0.1,0.1);
}
}
if( bLMouseDown )
{
mCurrentObjName = objControl->mouseDragged(
lastPos,
event->pos(),
mCamera->getViewport()->getActualWidth(),
mCamera->getViewport()->getActualHeight()
);
if( !mCurrentObjName.empty() )
{
Ogre::SceneNode *currObj = mSceneMgr->getSceneNode(mCurrentObjName);
if (currObj)
{
bReplan = true;
mTrack->mMove(currObj->getName(), currObj->getPosition());
mTrack->mRotate(currObj->getName(), currObj->getOrientation().yAxis());
}
}
}
//==== 當按下滑鼠右鍵 ====//
if( event->buttons().testFlag(Qt::RightButton) && lastPos != invalidMousePoint )
{
if( currCamType != eWorld ) return;
mCamWorldNode = mCamera->getParentSceneNode();
Ogre::Degree rotX(0);
Ogre::Degree rotY(0);
int dx = event->pos().x()-lastPos.x();
int dy = event->pos().y()-lastPos.y();
rotX += Ogre::Degree(-dx * 0.0025f * ROT_SCALE); // Rotate camera horizontaly
rotY += Ogre::Degree(-dy * 0.0025f * ROT_SCALE); // Rotate camera vertical
mCamWorldNode->yaw ( rotX, Ogre::Node::TS_WORLD );
mCamWorldNode->pitch( rotY, Ogre::Node::TS_LOCAL );
objControl->update();
}
lastPos = event->pos();
}
示例15: createTank
Entity Factory::createTank(entityx::ptr<entityx::EntityManager> entityMgr, std::string prefix,Ogre::Real velocity,Ogre::Real angularVelocity ,Ogre::Vector3 overHating,int health,bool ai)
{
DotSceneLoader loader;
Ogre::SceneManager* sceneMgr = RenderManager::getPtr()->getSceneManager();
loader.parseDotScene("tank.scene", "General", sceneMgr, 0, prefix);
Ogre::SceneNode* ctl = sceneMgr->getSceneNode(prefix + "TankControl");
Ogre::SceneNode* body = sceneMgr->getSceneNode(prefix + "TankBody");
Ogre::SceneNode* turret = sceneMgr->getSceneNode(prefix + "TankTurret");
Ogre::SceneNode* cannon = sceneMgr->getSceneNode(prefix +"TankCannon");
Entity tankEmptyControl = entityMgr->create();
Entity tankTurret = entityMgr->create();
Entity tankBody = entityMgr->create();
Entity tankCannon = entityMgr->create();
tankEmptyControl.assign<Position>(ctl->getPosition());
tankEmptyControl.assign<Orientation>(ctl->getOrientation());
tankEmptyControl.assign<Velocity>(0, 0, velocity);
tankEmptyControl.assign<AngularVelocity>(0, angularVelocity, 0);
tankEmptyControl.assign<Renderable>(ctl);
tankEmptyControl.assign<OverHeating>(overHating.x,overHating.y,overHating.z);
tankEmptyControl.assign<Destroyable>(health,health);
tankEmptyControl.assign<Collidable>();
tankEmptyControl.assign<Name>(prefix);
if(ai){
tankEmptyControl.assign<AI>();
Ogre::Entity *model = static_cast<Ogre::Entity*>(body->getAttachedObject(0));
model->getSubEntity(1)->setMaterialName("Red");
model = static_cast<Ogre::Entity*>(turret->getAttachedObject(0));
model->getSubEntity(1)->setMaterialName("Red");
model = static_cast<Ogre::Entity*>(cannon->getAttachedObject(0));
model->getSubEntity(1)->setMaterialName("Red");
}
ptr<Children> child = tankEmptyControl.assign<Children>();
child->children["body"] = tankBody;
child->children["turret"] = tankTurret;
//child->children.push_back(tankBody);
//child->children.push_back(tankTurret);
tankTurret.assign<Position>(turret->getPosition());
tankTurret.assign<Orientation>(turret->getOrientation());
tankTurret.assign<Renderable>(turret);
child = tankTurret.assign<Children>();
child->children["cannon"] = tankCannon;
tankBody.assign<Position>(body->getPosition());
tankBody.assign<Orientation>(body->getOrientation());
tankBody.assign<Renderable>(body);
tankCannon.assign<Position>(cannon->getPosition());
tankCannon.assign<Renderable>(cannon);
tankCannon.assign<Orientation>(cannon->getOrientation());
ctl->scale(.35, .55, .35);
return tankEmptyControl;
}