本文整理汇总了C++中ogre::SceneNode::setOrientation方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::setOrientation方法的具体用法?C++ SceneNode::setOrientation怎么用?C++ SceneNode::setOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::setOrientation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _updateRenderQueue
//-----------------------------------------------------------------------
void EntityRenderer::_updateRenderQueue(Ogre::RenderQueue* queue, ParticlePool* pool)
{
// Always perform this one
ParticleRenderer::_updateRenderQueue(queue, pool);
if (!mVisible)
return;
// Fast check to determine whether there are visual particles
if (pool->isEmpty(Particle::PT_VISUAL))
return;
VisualParticle* particle = static_cast<VisualParticle*>(pool->getFirst(Particle::PT_VISUAL));
while (!pool->end(Particle::PT_VISUAL))
{
if (particle)
{
if (!particle->visualData && !mVisualData.empty())
{
particle->visualData = mVisualData.back();
mVisualData.pop_back();
}
if (particle->visualData)
{
Ogre::SceneNode* node = (static_cast<EntityRendererVisualData*>(particle->visualData))->node;
if (node)
{
node->_setDerivedPosition(particle->position);
if (mEntityOrientationType == ENT_ORIENTED_SHAPE)
{
// Use the orientation of the particle itself
node->setOrientation(particle->orientation);
}
else if (mEntityOrientationType == ENT_ORIENTED_SELF)
{
// Rotate towards the direction
node->setOrientation(Vector3::UNIT_X.getRotationTo(particle->direction));
}
else if (mEntityOrientationType == ENT_ORIENTED_SELF_MIRRORED)
{
// Rotate towards the negative direction
node->setOrientation(Vector3::UNIT_X.getRotationTo(-particle->direction));
}
node->setVisible(true);
node->setScale(particle->width / mBoxWidth, particle->height / mBoxHeight, particle->depth / mBoxDepth);
if (mZRotated)
{
_rotateTexture(particle, static_cast<Ogre::Entity*>(node->getAttachedObject(0))); // We know for sure there is only one and it is an Entity*
}
}
}
}
particle = static_cast<VisualParticle*>(pool->getNext(Particle::PT_VISUAL));
}
}
示例2: createWebcamPlane
void GPUSurfApplication::createWebcamPlane(Real _distanceFromCamera)
{
// Create a prefab plane dedicated to display video
Vector2 videoDim = mVideo->getDimensions();
float videoAspectRatio = videoDim.x / videoDim.y;
float planeHeight = 2 * _distanceFromCamera * Ogre::Math::Tan(Degree(26.53)*0.5);
float planeWidth = planeHeight * videoAspectRatio;
Plane p(Vector3::UNIT_Z, 0.0);
MeshManager::getSingleton().createPlane("VerticalPlane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, p , planeWidth, planeHeight, 1, 1, true, 1, 1, 1, Vector3::UNIT_Y);
Entity* planeEntity = mSceneMgr->createEntity("VideoPlane", "VerticalPlane");
planeEntity->setMaterialName("WebcamVideoMaterial");
planeEntity->setRenderQueueGroup(RENDER_QUEUE_WORLD_GEOMETRY_1);
// Create a node for the plane, inserts it in the scene
Ogre::SceneNode* node = mCameraNode->createChildSceneNode("planeNode");
node->attachObject(planeEntity);
// Update position
Vector3 planePos = mCamera->getPosition() + mCamera->getDirection() * _distanceFromCamera;
node->setPosition(planePos);
// Update orientation
node->setOrientation(mCamera->getOrientation());
}
示例3: 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;
}
示例4: createCameraPlane
void OgreARAppLogic::createCameraPlane(int width, int height, Ogre::Real _distanceFromCamera)
{
// Create a prefab plane dedicated to display video
float videoAspectRatio = width / (float) height;
float planeHeight = 2 * _distanceFromCamera * Ogre::Math::Tan(Degree(26)*0.5); //FOVy webcam = 26° (intrinsic param)
float planeWidth = planeHeight * videoAspectRatio;
Plane p(Vector3::UNIT_Z, 0.0);
MeshManager::getSingleton().createPlane("VerticalPlane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, p , planeWidth, planeHeight, 1, 1, true, 1, 1, 1, Vector3::UNIT_Y);
Entity* planeEntity = mSceneMgr->createEntity("VideoPlane", "VerticalPlane");
planeEntity->setMaterialName("CameraMaterial");
planeEntity->setRenderQueueGroup(RENDER_QUEUE_WORLD_GEOMETRY_1);
// Create a node for the plane, inserts it in the scene
Ogre::SceneNode* node = mCameraNode->createChildSceneNode("planeNode");
node->attachObject(planeEntity);
// Update position
Vector3 planePos = mCamera->getPosition() + mCamera->getDirection() * _distanceFromCamera;
node->setPosition(planePos);
// Update orientation
node->setOrientation(mCamera->getOrientation());
}
示例5:
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;
}
示例6: 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++;
}
示例7: 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;
}
示例8: insertBegin
void Actors::insertBegin(const MWWorld::Ptr &ptr)
{
Ogre::SceneNode* cellnode;
CellSceneNodeMap::const_iterator celliter = mCellSceneNodes.find(ptr.getCell());
if(celliter != mCellSceneNodes.end())
cellnode = celliter->second;
else
{
//Create the scenenode and put it in the map
cellnode = mRootNode->createChildSceneNode();
mCellSceneNodes[ptr.getCell()] = cellnode;
}
Ogre::SceneNode* insert = cellnode->createChildSceneNode();
const float *f = ptr.getRefData().getPosition().pos;
insert->setPosition(f[0], f[1], f[2]);
insert->setScale(ptr.getCellRef().mScale, ptr.getCellRef().mScale, ptr.getCellRef().mScale);
// Convert MW rotation to a quaternion:
f = ptr.getCellRef().mPos.rot;
// Rotate around X axis
Ogre::Quaternion xr(Ogre::Radian(-f[0]), Ogre::Vector3::UNIT_X);
// Rotate around Y axis
Ogre::Quaternion yr(Ogre::Radian(-f[1]), Ogre::Vector3::UNIT_Y);
// Rotate around Z axis
Ogre::Quaternion zr(Ogre::Radian(-f[2]), Ogre::Vector3::UNIT_Z);
// Rotates first around z, then y, then x
insert->setOrientation(xr*yr*zr);
ptr.getRefData().setBaseNode(insert);
}
示例9: update
bool Game::update( float deltaSec ) {
m_pDynamicsWorld->stepSimulation(deltaSec);
btCollisionObjectArray objArray = m_pDynamicsWorld->getCollisionObjectArray();
for( int i = 0; i < objArray.size(); i++ ) {
btCollisionObject* obj = objArray[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()));
}
}
}
// m_pPlayerSceneNode->translate(m_PlayerVelocity * deltaSec );
// Ogre::Vector3 src = m_pPlayerSceneNode->getOrientation() * Ogre::Vector3::UNIT_X;
// Ogre::Quaternion quat = src.getRotationTo(m_PlayerVelocity);
// m_pPlayerSceneNode->rotate(quat);
return true;
}//Game::update
示例10:
Ogre::SceneNode *VLogicModel::_createLocatorSceneNode(const Ogre::Vector3 &pos, const Ogre::Quaternion &ori)
{
static VUINT32 count = 0;
Ogre::StringUtil::StrStreamType str;
str<<"Locator_"<<std::setw(5)<<std::setfill('0')<<count++<<std::ends;
Ogre::SceneNode *locatorNode = mModelMainNode->createChildSceneNode(str.str());
locatorNode->translate(pos);
locatorNode->setOrientation(ori);
return locatorNode;
}
示例11: multMatrix
void DrawToolOGRE::multMatrix(float* glTransform)
{
Ogre::Matrix4 t( glTransform[0], glTransform[1], glTransform[2], glTransform[3],
glTransform[4], glTransform[5], glTransform[6], glTransform[7],
glTransform[8], glTransform[9], glTransform[10], glTransform[11],
glTransform[12], glTransform[13], glTransform[14], glTransform[15]);
t = t.transpose();
Ogre::SceneNode* currentSceneNode = sceneNodeStack.top();
currentSceneNode->setOrientation(t.extractQuaternion());
currentSceneNode->setPosition(t.getTrans());
}
示例12: createScene
//--------------------------------------------------------------------------------------
void LapTrainer::createScene(void)
{
//Create right stick
Ogre::Entity* StickRight = mSceneMgr->createEntity("StickRight", "instrument_stick.mesh");
StickRight -> setCastShadows(true);
Ogre::SceneNode* RightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("RightNode", Ogre::Vector3(0,0,0),Ogre::Quaternion(1,0,0,0));
//RightNode->setPosition(Ogre::Vector3(300, 100, 100));
RightNode->setPosition(Ogre::Vector3(300, 500, 500));//alex
RightNode->setOrientation(0.383022, -0.383022, 0.821394, -0.178606);//alex
RightNode->scale( 1, 1, 1);
Ogre::SceneNode* child = RightNode->createChildSceneNode("MoveNodeRight");
child->attachObject(StickRight);
child->translate(0,0,0);
//Create left stick
Ogre::Entity* entPenguin2 = mSceneMgr->createEntity("StickLeft", "instrument_stick.mesh");
entPenguin2 -> setCastShadows(true);
Ogre::SceneNode* nodPenguin2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("LeftNode", Ogre::Vector3(0,0,0),Ogre::Quaternion(1,0,0,0));
//nodPenguin2->setPosition(Ogre::Vector3(-300, 100, 100));
nodPenguin2->setPosition(Ogre::Vector3(-300, 500, 500));//alex
//nodPenguin2->setOrientation(0.821394, -0.178606, 0.383022, -0.383022);//alex //this stick is not working
nodPenguin2->setOrientation(0.821394, -0.178606, 0.383022, -0.383022);//alex //this stick is not working
nodPenguin2->scale( 1, 1, 1);
Ogre::SceneNode* child2 = nodPenguin2->createChildSceneNode("MoveNodeLeft");
child2->attachObject(entPenguin2);
child2->translate(0,0,0);
Ogre::Entity* Element1 = mSceneMgr->createEntity("Element1", "exercise1.mesh");//Place your mesh here
Element1 -> setCastShadows(true);
Ogre::SceneNode* Element1Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element1Node", Ogre::Vector3(0, -200, 200));//X-Y-Z
Element1Node->scale( 400, 400, 400);
Element1Node->attachObject(Element1);
Ogre::Entity* Element2 = mSceneMgr->createEntity("Element2", "Sphere002.mesh");//Place your mesh here
Element2 -> setCastShadows(true);
//Ogre::SceneNode* Element2Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element2Node", Ogre::Vector3(0, 50, 100));//X-Y-Z
Ogre::SceneNode* Element2Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element2Node", Ogre::Vector3(0,0,0),Ogre::Quaternion(1,0,0,0));
Element2Node->setPosition(Ogre::Vector3(300, 500, 500));
Element2Node->setOrientation(0.383022, -0.383022, 0.821394, -0.178606);
Element2Node->scale( 60, 60, 60);
Element2Node->attachObject(Element2);
Ogre::Entity* Element3 = mSceneMgr->createEntity("Element3", "Sphere002.mesh");//Place your mesh here
Element3 -> setCastShadows(true);
//Ogre::SceneNode* Element2Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element2Node", Ogre::Vector3(0, 50, 100));//X-Y-Z
Ogre::SceneNode* Element3Node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Element3Node", Ogre::Vector3(0,0,0),Ogre::Quaternion(1,0,0,0));
Element3Node->setPosition(Ogre::Vector3(-300, 500, 500));
Element3Node->setOrientation(0.821394, -0.178606, 0.383022, -0.383022);
Element3Node->scale( 60, 60, 60);
Element3Node->attachObject(Element3);
}
示例13: processMessage
void SparseOccupancyGridArrayDisplay::processMessage(
const jsk_recognition_msgs::SparseOccupancyGridArray::ConstPtr& msg)
{
allocateCloudsAndNodes(msg->grids.size()); // not enough
for (size_t i = 0; i < msg->grids.size(); i++) {
Ogre::SceneNode* node = nodes_[i];
rviz::PointCloud* cloud = clouds_[i];
const jsk_recognition_msgs::SparseOccupancyGrid grid = msg->grids[i];
Ogre::Vector3 position;
Ogre::Quaternion quaternion;
if(!context_->getFrameManager()->transform(grid.header, grid.origin_pose,
position,
quaternion)) {
ROS_ERROR( "Error transforming pose '%s' from frame '%s' to frame '%s'",
qPrintable( getName() ), grid.header.frame_id.c_str(),
qPrintable( fixed_frame_ ));
return; // return?
}
node->setPosition(position);
node->setOrientation(quaternion);
cloud->setDimensions(grid.resolution, grid.resolution, 0.0);
std::vector<rviz::PointCloud::Point> points;
for (size_t ci = 0; ci < grid.columns.size(); ci++) {
const jsk_recognition_msgs::SparseOccupancyGridColumn column = grid.columns[ci];
const int column_index = column.column_index;
for (size_t ri = 0; ri < column.cells.size(); ri++) {
const jsk_recognition_msgs::SparseOccupancyGridCell cell = column.cells[ri];
const int row_index = cell.row_index;
rviz::PointCloud::Point point;
if (!axis_color_) {
QColor color = gridColor(cell.value);
Ogre::ColourValue ogre_color = rviz::qtToOgre(color);
point.color = ogre_color;
}
else {
QColor color = axisColor(quaternion, Ogre::Vector3(1, 0, 0));
Ogre::ColourValue ogre_color = rviz::qtToOgre(color);
point.color = ogre_color;
}
point.position.x = grid.resolution * (column_index + 0.5);
point.position.y = grid.resolution * (row_index + 0.5);
point.position.z = 0.0;
points.push_back(point);
}
}
cloud->clear();
cloud->setAlpha(alpha_);
if (!points.empty()) {
cloud->addPoints(&points.front(), points.size());
}
}
context_->queueRender();
}
示例14: constraintZ
void OgreWidget::constraintZ(bool value)
{
Ogre::SceneNode * node = m_sceneManager->getSceneNode("grid");
m_constraintedZ = value;
if (value)
{
node->setOrientation(1, 1, 0, 0);
update();
}
}
示例15: updateVehicle
void OgreVehicle::updateVehicle(const AllVehicleInfoOgre& allv)
{
//INITLOG;
//PRINTLOG(allv.vepos.y);
Ogre::SceneNode* pNode = (Ogre::SceneNode*)(mNode->getChild("Body" + mNode->getName()));
pNode->setOrientation(allv.verot);
mNode->setPosition(allv.vepos - mParNode->getWorldPosition());
if (allv.campos != Ogre::Vector3(0, 0, 0))
{
Ogre::SceneNode* pCamNode = (Ogre::SceneNode*)(mNode->getChild("Cam" + mNode->getName()));
pCamNode->setOrientation(allv.camrot);
pCamNode->setPosition(allv.campos);
}
mWheels[0]->updateWheel(allv.angle0);
mWheels[1]->updateWheel(allv.angle1);
mWheels[2]->updateWheel(allv.angle2);
mWheels[3]->updateWheel(allv.angle3);
}