本文整理汇总了C++中ogre::SceneNode::rotate方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::rotate方法的具体用法?C++ SceneNode::rotate怎么用?C++ SceneNode::rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::rotate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Banderin::Banderin( Ogre::String nombre , Ogre::SceneManager* sm , float _x , float _y , float _z){
x = _x;
y = _y;
z = _z;
_sceneManager = sm;
nodoBanderin = _sceneManager->createSceneNode("Banderin"+nombre);
Ogre::SceneNode* nodoSuperiorIzq = _sceneManager->createSceneNode(nombre+"superiorIzq");
Ogre::SceneNode* nodoBandera = _sceneManager->createSceneNode(nombre+"bandera");
Ogre::SceneNode* nodoSuperiorDer = _sceneManager->createSceneNode(nombre+"superiorDer");
Ogre::SceneNode* nodoBaseDer = _sceneManager->createSceneNode(nombre+"baseDer");
Ogre::Entity* entBanderin = _sceneManager->createEntity("usb_cilindro.mesh");
Ogre::Entity* entSuperiorIzq = _sceneManager->createEntity("poly10.mesh");
Ogre::Entity* entBandera = _sceneManager->createEntity("usb_planocurvo.mesh");
Ogre::Entity* entSuperiorDer = _sceneManager->createEntity("poly10.mesh");
Ogre::Entity* entBaseDer = _sceneManager->createEntity("usb_cilindro.mesh");
entBanderin->setMaterialName("banderin");
entSuperiorIzq->setMaterialName("superior");
entBandera->setMaterialName("bandera");
entSuperiorDer->setMaterialName("superior");
entBaseDer->setMaterialName("banderin");
nodoSuperiorIzq->attachObject(entSuperiorIzq);
nodoSuperiorIzq->setScale(0.03,0.008,0.06);
nodoSuperiorIzq->translate(2.2,7.2,0.0);
nodoSuperiorIzq->rotate(Ogre::Vector3(0.0,0.0,1.0),Ogre::Radian(Ogre::Degree(180.0)));
nodoBandera->attachObject(entBandera);
nodoBandera->setScale(1.2,3.85,1.0);
nodoBandera->translate(-2.2,7.2,0.0);
nodoBandera->rotate(Ogre::Vector3(0.0,0.0,1.0),Ogre::Radian(Ogre::Degree(90.0)));
nodoSuperiorDer->attachObject(entSuperiorDer);
nodoSuperiorDer->setScale(0.03,0.008,0.06);
nodoSuperiorDer->translate(-152.2,7.2,0.0);
nodoBaseDer->attachObject(entBaseDer);
nodoBaseDer->translate(-150.0,0.0,0.0);
nodoBanderin->attachObject(entBanderin);
nodoBanderin->addChild(nodoSuperiorIzq);
nodoBanderin->addChild(nodoBandera);
nodoBanderin->addChild(nodoSuperiorDer);
nodoBanderin->addChild(nodoBaseDer);
nodoBanderin->setPosition(x,y,z);
nodoBanderin->setScale(60.0,600.0,60.0);
}
示例2: _updateLocatorPos
void VLogicModel::_updateLocatorPos()
{
for (VLocatorMap::iterator itr = mLocators.begin(); itr != mLocators.end(); ++itr)
{
VLocatorValue &tempValue = itr->second;
// 只更新创建出来的(已经使用的)locator node
if (tempValue.mLocatorNode != VNULL)
{
if (!tempValue.mBoneName.empty())
{
Ogre::Bone *bone = VNULL;
try
{
bone = mSkeleton->getBone(tempValue.mBoneName);
}
catch (const Ogre::Exception &e)
{
Ogre::LogManager::getSingleton().logMessage("LogicModel::_updateLocatorPos " + mName + e.getDescription());
continue;
}
assert(bone != VNULL);
Ogre::SceneNode *locatorNode = tempValue.mLocatorNode;
assert(locatorNode != VNULL);
locatorNode->setPosition(bone->_getDerivedPosition());
locatorNode->setOrientation(bone->_getDerivedOrientation());
if (tempValue.mTranslateFirst)
{
// 先平移,再旋转
locatorNode->translate(tempValue.mPosition, Ogre::Node::TS_LOCAL);
locatorNode->rotate(tempValue.mOrientation, Ogre::Node::TS_LOCAL);
}
else
{
// 先旋转,再平移
locatorNode->rotate(tempValue.mOrientation, Ogre::Node::TS_LOCAL);
locatorNode->translate(tempValue.mPosition, Ogre::Node::TS_LOCAL);
}
}
}
}
if (mLocators.size() != 0)
{
mModelMainNode->_update(true, false);
}
}
示例3:
void AWGraphics::SceneDirector::createPlayer()
{
// Add player entity to the scene
Ogre::Entity* ogreEntity = mSceneMgr->createEntity("ogrehead.mesh");
Ogre::SceneNode* parentNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
Ogre::SceneNode* ogreNode = parentNode->createChildSceneNode();
ogreNode->attachObject(ogreEntity);
ogreNode->rotate(Ogre::Vector3(0.0, 1.0, 0.0), Ogre::Radian(Ogre::Degree(180)));
ogreNode->setPosition(0, 80, 0);
mPlayerNode = parentNode;
// Initialize and add a light
mSceneMgr->setAmbientLight(Ogre::ColourValue(.5, .5, .5));
Ogre::Light* light = mSceneMgr->createLight("MainLight");
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDirection(Ogre::Vector3(0, -1, 1));
/*// Directional light
Ogre::Light* directionalLight = mSceneMgr->createLight("DirectionalLight");
directionalLight->setType(Ogre::Light::LT_DIRECTIONAL);
directionalLight->setDiffuseColour(Ogre::ColourValue(.8, .6, .2));
directionalLight->setSpecularColour(Ogre::ColourValue(.8, .6, .2));
*/
// Add skydome
mSceneMgr->setSkyDome(true, "CloudySky", 5, 8); // cannot find... :(
}
示例4: 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;
}
示例5: main
int main(int argc, char* argv[]){
cout << "Test Ogre Program blaha" << endl;
//Relative to where its executed from, not binary location
Ogre::Root *mRoot = new Ogre::Root("configs/plugins.cfg","configs/config.cfg","logs/main.log");
if(!(mRoot->restoreConfig() || mRoot->showConfigDialog())){
delete mRoot;
return -1;
}
// setup resources
// Only add the minimally required resource locations to load up the Ogre head mesh
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/programs/GLSL", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/scripts", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/materials/textures", "FileSystem", "General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("/Users/jgrey/OgreSDK/Media/models", "FileSystem", "General");
//Create the window
Ogre::RenderWindow *mWindow = mRoot->initialise(true, "initial Render Window");
Ogre::SceneManager *sceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC);
Ogre::Camera *camera = sceneManager->createCamera("PlayerCam");
camera->setPosition(Ogre::Vector3(0,0,80));
camera->lookAt(Ogre::Vector3(0,0,-300));
camera->setNearClipDistance(5);
Ogre::Viewport* vp = mWindow->addViewport(camera);
vp->setBackgroundColour(Ogre::ColourValue(0,0,0,0));
camera->setAspectRatio(Ogre::Real(vp->getActualWidth()) / Ogre::Real(vp->getActualHeight()));
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Ogre::Entity* ogreHead = sceneManager->createEntity("Head","ogreHead.mesh");
Ogre::SceneNode* headNode = sceneManager->getRootSceneNode()->createChildSceneNode();
headNode->attachObject(ogreHead);
sceneManager->setAmbientLight(Ogre::ColourValue(0.5,0.5,0.5));
//Run the system
bool continueRunning = true;
while(continueRunning){
mRoot->renderOneFrame();
headNode->rotate(Ogre::Vector3(0,1,0),Ogre::Radian(0.005));
if(mWindow->isClosed()){
continueRunning = false;
}
}
delete mRoot;
}
示例6: AddEntity
//---------------------------------------------------------------------------------------------
void TShowTankWoT_test::AddEntity(Ogre::Entity* pEnt, TOrient& orient, Ogre::SceneManager* pSM)
{
pEnt->setCastShadows(false);
Ogre::SceneNode* pNode = pSM->getRootSceneNode()->createChildSceneNode();
pNode->attachObject(pEnt);
pNode->setScale(orient.scale);
pNode->rotate(orient.axisRotate, orient.angleRotate);
pNode->setPosition(orient.pos);
}
示例7: rotateMesh
void ExteriorCellRender::rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements)
{
assert(mInsert);
Ogre::SceneNode *parent = mInsert;
//std::cout << "ELEMENTS:" << elements;
for (int i = 0; i < elements; i++){
if(sceneNodeName[i] != "" && parent->getChild(sceneNodeName[i]))
parent = dynamic_cast<Ogre::SceneNode*> (parent->getChild(sceneNodeName[i]));
}
parent->rotate(axis, angle);
}
示例8: frameRenderingQueued
// FrameListener callback (~ idleFunc). Perform animation here
bool frameRenderingQueued(const Ogre::FrameEvent& evt) {
float t = mTimer.getMilliseconds()*0.001;
// Do some simple animations by changing scene node transform parameters
Ogre::SceneNode* triangle = mScene->getSceneNode("Triangle");
triangle->resetToInitialState();
triangle->rotate(Ogre::Vector3(0, 0, 1), Ogre::Radian(t));
// Exercise 1: Use SceneNode to manipulate the object and create animation
// ...
return true; // Return false to quit
}
示例9: update
void HelloOgre::update(float){
static int move_dir = -1;
static float move_step = 2.0f;
static int move_count = 0;
static float move_offset = 0.0f;
if( move_count % 150 == 0 ){
move_dir *= -1;
}
move_offset = move_step * move_dir;
move_count++;
if( ogre_head_node ){
ogre_head_node->translate( Ogre::Vector3(move_offset, 0.0f, 0.0f));
ogre_head_node->rotate( Ogre::Vector3( 0.0f, 1.0f, 0.0f ), Ogre::Radian(0.1f) );
}
if( ogre_head_node2 ){
ogre_head_node2->translate( Ogre::Vector3(-move_offset, 0.0f, 0.0f));
ogre_head_node2->rotate( Ogre::Vector3( 0.0f, 1.0f, 0.0f ), Ogre::Radian(0.1f) );
}
size_t nsize = vec_ogre_head_node.size();
Ogre::SceneNode* pnode = NULL;
size_t half_size = nsize >> 1;
for( size_t i=0; i<half_size; ++i ){
pnode = vec_ogre_head_node[i];
pnode->translate( Ogre::Vector3((move_offset*i*0.1f), 0.0f, 0.0f));
pnode->rotate( Ogre::Vector3( 0.0f, 1.0f, 0.0f ), Ogre::Radian(0.1f) );
}
for( size_t i=0; i<half_size; ++i ){
pnode = vec_ogre_head_node[half_size+i];
pnode->translate( Ogre::Vector3(-(move_offset*i*0.1f), 0.0f, 0.0f));
pnode->rotate( Ogre::Vector3( 0.0f, 1.0f, 0.0f ), Ogre::Radian(0.1f) );
}
}
示例10: repositionSceneNode
void ModelRenderer::repositionSceneNode()
{
if (mModel) {
Ogre::SceneNode* node = mTexture->getRenderContext()->getSceneNode();
if (node) {
node->setOrientation(mDefaultRotation);
node->rotate(mModel->getDefinition()->getRotation());
//translate the scale node according to the translate defined in the model
node->setPosition(mDefaultTranslation);
node->translate(mModel->getDefinition()->getTranslate());
}
}
}
示例11: createCamera
void TutorialApplication::createCamera(void)
{
// Create the camera
ExampleApplication::createCamera();
SceneNode* camNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("CameraNode");
camNode->attachObject(mCamera);
// Create headlight
Light* light = mSceneMgr->createLight("headlight");
light->setType(Ogre::Light::LT_DIRECTIONAL);
light->setDiffuseColour(1,1,1);
Ogre::SceneNode* lightNode = camNode->createChildSceneNode("HeadlightNode");
lightNode->rotate( Ogre::Vector3::UNIT_Y, Ogre::Degree(180), Ogre::Node::TS_LOCAL );
lightNode->attachObject(light);
}
示例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: createPalms
void createPalms(Ogre::SceneManager *mSceneMgr)
{
const int NumberOfPalms = 12;
Ogre::SceneNode* mPalmsSceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
for (int k = 0; k < NumberOfPalms; k++)
{
Ogre::Vector3 RandomPos = Ogre::Vector3(rnd_(500,2500),
0,
rnd_(500,2500));
Ogre::RaySceneQuery * raySceneQuery = mSceneMgr->
createRayQuery(Ogre::Ray(RandomPos + Ogre::Vector3(0,1000000,0),
Ogre::Vector3::NEGATIVE_UNIT_Y));
Ogre::RaySceneQueryResult& qryResult = raySceneQuery->execute();
Ogre::RaySceneQueryResult::iterator i = qryResult.begin();
if (i != qryResult.end() && i->worldFragment)
{
if (i->worldFragment->singleIntersection.y>105 || i->worldFragment->singleIntersection.y<20)
{
k--;
continue;
}
RandomPos.y = i->worldFragment->singleIntersection.y;
}
else
{
k--;
continue;
}
Ogre::Entity *mPalmEnt = mSceneMgr->createEntity("Palm"+Ogre::StringConverter::toString(k), "Palm.mesh");
Ogre::SceneNode *mPalmSN = mPalmsSceneNode->createChildSceneNode();
mPalmSN->rotate(Ogre::Vector3(-1,0,rnd_(-0.3,0.3)), Ogre::Degree(90));
mPalmSN->attachObject(mPalmEnt);
Ogre::Real Scale = rnd_(50,75);
mPalmSN->scale(Scale,Scale,Scale);
mPalmSN->setPosition(RandomPos);
}
}
示例14: repositionSceneNode
void ModelRenderer::repositionSceneNode()
{
if (mModel) {
Ogre::SceneNode* node = mTexture->getRenderContext()->getSceneNode();
if (node) {
node->setOrientation(Ogre::Quaternion::IDENTITY);
//rotate node to fit with WF space
//perhaps this is something to put in the model spec instead?
// node->rotate(Ogre::Vector3::UNIT_Y,(Ogre::Degree)90);
node->rotate(mModel->getRotation());
//translate the scale node according to the translate defined in the model
node->setPosition(Ogre::Vector3::ZERO);
node->translate(mModel->getDefinition()->getTranslate());
}
}
}
示例15: createOgreScene
// ------------------------- Scene description ------------------------- //
SceneManager* createOgreScene() {
SceneManager* scene = mRoot->createSceneManager(ST_GENERIC);
// Initialize camera
Camera* camera = scene->createCamera("MainCamera");
camera->setPosition(Vector3(0, 10, 30));
camera->lookAt(Vector3(0, 0, 0));
camera->setNearClipDistance(0.5);
camera->setFOVy(Ogre::Degree(60.0));
camera->setAspectRatio((float) mWindow->getWidth() / mWindow->getHeight());
// Set up lighting (~ glEnable(GL_LIGHTING), glEnable(GL_LIGHT0), glLightfv(...)):
scene->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));
Light* light = scene->createLight("MainLight");
light->setType(Light::LT_POINT);
light->setDiffuseColour(1, 1, 1);
light->setSpecularColour(1, 1, 1);
light->setPosition(20.0f, 80.0f, 50.0f);
// Enable shadow computations
scene->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
// Scenery
Ogre::Entity* plane = scene->createEntity("Plane", Ogre::SceneManager::PT_PLANE);
Ogre::SceneNode* planeNode = scene->getRootSceneNode()->createChildSceneNode("PlaneNode");
planeNode->attachObject(plane);
planeNode->rotate(Ogre::Vector3(-1, 0, 0), Ogre::Degree(90));
plane->setCastShadows(false);
plane->setMaterialName("Floor/Marble");
// Load character mesh
mBodyNode = scene->getRootSceneNode()->createChildSceneNode(Vector3::UNIT_Y * 5);
mBodyEnt = scene->createEntity("SinbadBody", "Sinbad.mesh");
mBodyNode->attachObject(mBodyEnt);
// Load animations
// Exercise 5: Get pointer to animation state
// ...
return scene;
}