本文整理汇总了C++中ogre::SceneNode::roll方法的典型用法代码示例。如果您正苦于以下问题:C++ SceneNode::roll方法的具体用法?C++ SceneNode::roll怎么用?C++ SceneNode::roll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::SceneNode
的用法示例。
在下文中一共展示了SceneNode::roll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _buildRoom
//-----------------------------------------------------------------------------
void SSAOApp::_buildRoom()
{
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0.0f);
Ogre::MeshPtr planeMesh =
Ogre::MeshManager::getSingleton().createPlane("Plane.mesh"
,Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
,plane
, 1000, 1000
, 1, 1, true
, 1, 5, 5
, Ogre::Vector3::UNIT_Z );
Ogre::SceneNode *wallNode;
wallNode = _makeWall("Plane.mesh", "ground");
wallNode = _makeWall("Plane.mesh", "left wall");
wallNode->translate(-500, 500, 0);
wallNode->roll(Ogre::Radian(-Ogre::Math::PI / 2));
wallNode = _makeWall("Plane.mesh", "back wall");
wallNode->translate(0, 500, -500);
wallNode->pitch(Ogre::Radian(Ogre::Math::PI / 2));
wallNode = _makeWall("Plane.mesh", "right wall");
wallNode->translate(500, 500, 0);
wallNode->roll(Ogre::Radian(Ogre::Math::PI / 2));
}
示例2: initOgreEntity
void Room::initOgreEntity(Ogre::SceneManager* mSceneMgr){
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::MeshManager::getSingleton().createPlane(
"wall",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane,
WALL_SIZE, WALL_SIZE, 20, 20,
true,
1, 5, 5,
Ogre::Vector3::UNIT_Z);
Ogre::Entity* walls[NUM_WALLS];
for(int i = 0; i < NUM_WALLS; i++){
walls[i] = mSceneMgr->createEntity("wall");
walls[i]->setMaterialName("Examples/Rockwall");
walls[i]->setCastShadows(true);
}
//FLOOR
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(walls[0]);
//CEILING
Ogre::SceneNode* sceneForManip = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, WALL_SIZE, 0));
sceneForManip->attachObject(walls[1]);
sceneForManip->roll(Ogre::Degree(180));
//LEFT WALL
sceneForManip = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(-WALL_SIZE/2, WALL_SIZE/2, 0));
sceneForManip->attachObject(walls[2]);
sceneForManip->roll(Ogre::Degree(-90));
//RIGHT WALL
sceneForManip = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(WALL_SIZE/2, WALL_SIZE/2, 0));
sceneForManip->attachObject(walls[3]);
sceneForManip->roll(Ogre::Degree(90));
//BACK WALL
sceneForManip = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, WALL_SIZE/2, -WALL_SIZE/2));
sceneForManip->attachObject(walls[4]);
sceneForManip->pitch(Ogre::Degree(90));
//FRONT WALL
sceneForManip = mSceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0, WALL_SIZE/2, WALL_SIZE/2));
sceneForManip->attachObject(walls[5]);
sceneForManip->pitch(Ogre::Degree(-90));
targetWall = sceneForManip;
}
示例3: testModelMountScaling
void ModelMountTestCase::testModelMountScaling()
{
Ogre::Root root;
Ogre::SceneManager* sceneManager = root.createSceneManager(Ogre::ST_GENERIC);
TestModel model(*sceneManager);
//First test with a straight forward case.
Ogre::SceneNode* node = sceneManager->getRootSceneNode()->createChildSceneNode();
//We get an error when it's destroyed. So we don't destroy it.
SceneNodeProvider* nodeProvider = new SceneNodeProvider(node, nullptr);
Model::ModelMount mount(model, nodeProvider);
scaleAndTestMount(model, mount, nodeProvider->getNode());
//Test with the parent node being scaled
node->setScale(Ogre::Vector3(3.0f, 0.2f, 200.0f));
Ogre::SceneNode* subNode = node->createChildSceneNode();
nodeProvider = new SceneNodeProvider(subNode, nullptr);
Model::ModelMount mount2(model, nodeProvider);
scaleAndTestMount(model, mount2, nodeProvider->getNode());
//Test with the parent node being scaled and rotated
node->setScale(Ogre::Vector3(3.0f, 0.2f, 200.0f));
node->yaw(Ogre::Degree(42));
node->pitch(Ogre::Degree(76));
node->roll(Ogre::Degree(98));
subNode = node->createChildSceneNode();
nodeProvider = new SceneNodeProvider(subNode, nullptr);
Model::ModelMount mount3(model, nodeProvider);
scaleAndTestMount(model, mount3, nodeProvider->getNode());
}
示例4: createScene
void Hundir::createScene() {
Ogre::Entity* inicio = _sceneManager->createEntity("Inicio.mesh");
Ogre::SceneNode* ninicio = _sceneManager->createSceneNode("ninicio");
_sceneManager->getRootSceneNode()->addChild(ninicio);
ninicio->attachObject(inicio);
ninicio->yaw(Ogre::Degree(-15));
ninicio->pitch(Ogre::Degree(50));
ninicio->roll(Ogre::Degree(90));
ninicio->setScale(1,1.5,1.2);
ninicio->setPosition(0,0,-2);
/* Sombras */
_sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
_sceneManager->setShadowColour(Ogre::ColourValue(0.5, 0.5, 0.5) );
_sceneManager->setAmbientLight(Ogre::ColourValue(0.9, 0.9, 0.9));
_sceneManager->setShadowTextureCount(2);
_sceneManager->setShadowTextureSize(512);
/* Iluminacion */
Ogre::Light *light = _sceneManager->createLight("Light");
light->setType(Ogre::Light::LT_SPOTLIGHT);
light->setDirection(Ogre::Vector3(0,-1,0));
light->setSpotlightInnerAngle(Ogre::Degree(25.0f));
light->setSpotlightOuterAngle(Ogre::Degree(200.0f));
light->setPosition(0, 150, 0);
light->setSpecularColour(1, 1, 1);
light->setDiffuseColour(1, 1, 1);
light->setSpotlightFalloff(5.0f);
light->setCastShadows(true);
}
示例5: 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));
}
示例6: setAnimation
// Fix for Simon in regards to animation mesh's orientation
void Player::setAnimation(DynamicObject *p)
{
// makes a child node of parent node
Ogre::SceneNode *childNode = mPlayerObject->mSceneNode->createChildSceneNode("child");
childNode->flipVisibility(true); // makes this entire thing visible since parent node is invisible
for (Ogre::String name : p->meshNames) {
Ogre::Entity *newEnt = mSceneManager->createEntity(name);
//mEntity->setCastShadows(true);
childNode->attachObject(newEnt);
childNode->setPosition(0, -125, 0);
childNode->setOrientation(Ogre::Quaternion(0, 0, 1, -1)); // does the rotation
childNode->roll(Ogre::Radian(Ogre::Math::PI)); // fixes it so player's back faces us
}
}
示例7: createWall
Wall* Application::createWall(Ogre::String nme, GameObject::objectType tp, Ogre::String meshName, int x, int y, int z, Ogre::Vector3 scale, Ogre::Degree pitch, Ogre::Degree yaw, Ogre::Degree roll, Ogre::SceneManager* scnMgr, GameManager* ssm, Ogre::Real mss, Ogre::Real rest, Ogre::Real frict, bool kinematic, Simulator* mySim) {
createRootEntity(nme, meshName, x, y, z);
Ogre::SceneNode* sn = mSceneManager->getSceneNode(nme);
Ogre::Entity* ent = SceneHelper::getEntity(mSceneManager, nme, 0);
const btTransform pos;
OgreMotionState* ms = new OgreMotionState(pos, sn);
sn->setScale(scale.x, scale.y, scale.z);
sn->pitch(pitch);
sn->yaw(yaw);
sn->roll(roll);
Wall* obj = new Wall(nme, tp, mSceneManager, ssm, sn, ent, ms, mySim, mss, rest, frict, scale, kinematic);
obj->addToSimulator();
return obj;
}
示例8: plane
Agent::Agent(Ogre::SceneManager* SceneManager, std::string name, std::string filename, float height, float scale)
{
using namespace Ogre;
mSceneMgr = SceneManager; // keep a pointer to where this agent will be
if (mSceneMgr == NULL)
{
std::cout << "ERROR: No valid scene manager in Agent constructor" << std::endl;
return;
}
this->height = height;
this->scale = scale;
mBodyNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); // create a new scene node
mBodyEntity = mSceneMgr->createEntity(name, filename); // load the model
mBodyNode->attachObject(mBodyEntity); // attach the model to the scene node
mBodyNode->translate(0,height,0); // make the Ogre stand on the plane (almost)
mBodyNode->scale(scale,scale,scale); // Scale the figure
// Lecture 16: Movable text
//Ogre::MovableText* msg = new Ogre::MovableText("TXT_001", "this is the caption");
//msg->setTextAlignment(Ogre::MovableText::H_CENTER, Ogre::MovableText::V_ABOVE); // Center horizontally and display above the node
//mBodyNode->attachObject(msg);
projectile = false; // lecture 12
mass = 1.0;
ParticleSystem::setDefaultNonVisibleUpdateTimeout(5); // set nonvisible timeout
ps = mSceneMgr->createParticleSystem("Fountain1", "Examples/PurpleFountain");
Ogre::SceneNode* mnode = mBodyNode->createChildSceneNode();
mnode->roll(Degree(180));
mnode->attachObject(ps);
ps->setVisible(false);
//initPos = Ogre::Vector3::ZERO; //default position if none given
initPos = this->mBodyNode->getPosition(); //save starting position
vel = Ogre::Vector3::ZERO;
}
示例9: AddCollisionEntity
ObjectEditHandler::ObjectEditHandler(SceneDoc *Owner)
{
mOwner = Owner;
mMode = OEM_NONE;
mAxisMode = AM_NONE;
mTarget = NULL;
mObjectEditNode = mOwner->getSceneManager()->getRootSceneNode()->createChildSceneNode();
mRayQuery = mOwner->getSceneManager()->createRayQuery(Ogre::Ray());
mMaterials[0] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/RedMat");
mMaterials[1] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/GreenMat");
mMaterials[2] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/BlueMat");
mMaterials[3] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/ObjectIndicatorWhiteMat");
mMaterials[4] = Ogre::MaterialManager::getSingletonPtr()->getByName("Editor/ObjectIndicatorYellowMat");
//////////////////////////////////////////////////
// 碰撞检测
//////////////////////////////////////////////////
mCollisionManager = new OgreOpcode::CollisionManager(Owner->getSceneManager());
mCollisionManager->addCollClass("Object");
mCollisionManager->addCollType("Object", "Object", OgreOpcode::COLLTYPE_IGNORE);
mCollisionContext = mCollisionManager->createContext("SceneObject");
Ogre::MovableObjectFactory* Factory =
Ogre::Root::getSingleton().getMovableObjectFactory(Ogre::EntityFactory::FACTORY_TYPE_NAME);
Ogre::NameValuePairList Params;
//////////////////////////////////////////////////
// 平移放缩指示器
//////////////////////////////////////////////////
mIndicatorContext = mCollisionManager->createContext("TransScale");
mTransScaleNode = mObjectEditNode->createChildSceneNode("TransScaleIndicator");
mTransScaleNode->setScale(200.0f, 200.0f, 200.0f);
// x
Ogre::SceneNode *SubNode = mTransScaleNode->createChildSceneNode();
SubNode->roll(Ogre::Degree(-90.0f));
Ogre::Entity *Entity = Owner->getSceneManager()->createEntity("TransScaleXLine", "MoveArrowLineVisible.mesh");
//Entity->setQueryFlags(0); // 参与查询
Entity->setCastShadows(false);
Entity->setMaterial(mMaterials[0]);
Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
SubNode->attachObject(Entity);
mTransformEntities[AM_TRANS_SCALE_X] = Entity;
Entity = Owner->getSceneManager()->createEntity("TransScaleXCone", "MoveArrowConeVisible.mesh");
Entity->setQueryFlags(0);
Entity->setCastShadows(false);
Entity->setMaterial(mMaterials[0]);
Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
SubNode->attachObject(Entity);
Params["mesh"] = "MoveArrowCollision.mesh";
Entity = (Ogre::Entity*)Factory->createInstance("TransScaleXCol", Owner->getSceneManager(), &Params);
Entity->setQueryFlags(0);
Entity->setCastShadows(false);
Entity->setVisible(false);
SubNode->attachObject(Entity);
OgreOpcode::CollisionObject *CollisionObject =
AddCollisionEntity(mIndicatorContext, Entity);
mCollisionObjectToAxisMode[CollisionObject] = AM_TRANS_SCALE_X;
// y
SubNode = mTransScaleNode;
Entity = Owner->getSceneManager()->createEntity("TransScaleYLine", "MoveArrowLineVisible.mesh");
//Entity->setQueryFlags(0);
Entity->setCastShadows(false);
Entity->setMaterial(mMaterials[1]);
Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
SubNode->attachObject(Entity);
mTransformEntities[AM_TRANS_SCALE_Y] = Entity;
Entity = Owner->getSceneManager()->createEntity("TransScaleYCone", "MoveArrowConeVisible.mesh");
Entity->setQueryFlags(0);
Entity->setCastShadows(false);
Entity->setMaterial(mMaterials[1]);
Entity->setRenderQueueGroup(Ogre::RENDER_QUEUE_8);
SubNode->attachObject(Entity);
Params["mesh"] = "MoveArrowCollision.mesh";
Entity = (Ogre::Entity*)Factory->createInstance("TransScaleYCol", Owner->getSceneManager(), &Params);
Entity->setQueryFlags(0);
Entity->setCastShadows(false);
Entity->setVisible(false);
SubNode->attachObject(Entity);
CollisionObject = AddCollisionEntity(mIndicatorContext, Entity);
mCollisionObjectToAxisMode[CollisionObject] = AM_TRANS_SCALE_Y;
// z
SubNode = mTransScaleNode->createChildSceneNode();
SubNode->pitch(Ogre::Degree(90));
//.........这里部分代码省略.........
示例10: aabb
//.........这里部分代码省略.........
{
Bone bone;
bone.parent_id = ( i != 0 ) ? ( s8 )GetU8( offset_to_bones + i * 0x04 + 0x03 ) : -1;
bone.length = ( s16 )GetU16LE( offset_to_bones + i * 0x04 + 0x00 );
m_Skeleton.push_back(bone);
Ogre::Bone* bone1 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 2 ), i * 2 + 2 );
Ogre::Bone* bone2 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 3 ), i * 2 + 3 );
LOGGER->Log( "Add skeleton bone: bone_id = " + Ogre::StringConverter::toString( i ) + ", length = " + Ogre::StringConverter::toString( bone.length ) + ", parent = " + Ogre::StringConverter::toString( bone.parent_id ) + ".\n" );
if( bone.parent_id == -1 )
{
skeleton->getBone( 1 )->addChild( bone1 );
}
else
{
skeleton->getBone( bone.parent_id * 2 + 3 )->addChild( bone1 );
}
bone1->addChild( bone2 );
}
AnimationExtractor( skeleton, info, m_Skeleton );
// draw skeleton
{
//DrawSkeleton( m_Skeleton, mesh );
}
for( int i = 0; i < number_of_parts; ++i )
{
MeshExtractor( info.data, "ffix/field_model/" + info.data.name, this, offset_to_parts + i * 0x28, textures, mesh );
}
// <OGRE> ///////////////////////////////
skeleton->optimiseAllAnimations();
Ogre::SkeletonSerializer skeleton_serializer;
skeleton_serializer.exportSkeleton( skeleton.getPointer(), "exported/models/field/units/" + info.data.name + ".skeleton" );
// Update bounds
Ogre::AxisAlignedBox aabb( -999, -999, -999, 999, 999, 999 );
mesh->_setBounds( aabb, false );
mesh->_setBoundingSphereRadius( 999 );
mesh->setSkeletonName( "models/field/units/" + info.data.name + ".skeleton" );
Ogre::MeshSerializer ser;
ser.exportMesh( mesh.getPointer(), "exported/models/field/units/" + info.data.name + ".mesh" );
// create and export textures for model
//if (textures.size() > 0)
{
Vram* vram = new Vram();
File* tex = new File( "./data/field/5/1b/2/4/1.tim" );
LoadTimFileToVram( tex, 0, vram );
delete tex;
tex = new File( "./data/field/5/1b/2/4/2.tim" );
LoadTimFileToVram( tex, 0, vram );
delete tex;
vram->Save( "1.jpg" );
CreateTexture( vram, info.data, "exported/models/field/units/" + info.data.name + ".png", textures );
delete vram;
}
CreateMaterial( "ffix/field_model/" + info.data.name, "exported/models/field/units/" + info.data.name + ".material", ( textures.size() > 0 ) ? "models/field/units/" + info.data.name + ".png" : "", "", "" );
Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/field/units/" + info.data.name + ".mesh" );
//thisEntity->setDisplaySkeleton(true);
//thisEntity->setDebugDisplayEnabled(true);
thisEntity->setVisible( false );
thisEntity->getAnimationState( info.animations_name[ 0 ] )->setEnabled(true);
thisEntity->getAnimationState( info.animations_name[ 0 ] )->setLoop(true);
Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
thisSceneNode->setPosition( 0, 0, 0 );
thisSceneNode->roll( Ogre::Radian( Ogre::Degree( 180.0f ) ) );
thisSceneNode->yaw( Ogre::Radian( Ogre::Degree( 120.0f ) ) );
thisSceneNode->pitch( Ogre::Radian( Ogre::Degree(90.0f ) ) );
thisSceneNode->attachObject( thisEntity );
return thisEntity;
}
示例11: createScene
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
// Set the scene's ambient light
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f));
// Create an Entity
Ogre::Entity* ogreHead = mSceneMgr->createEntity("Head", "ogrehead.mesh");
// Create a SceneNode and attach the Entity to it
Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("HeadNode");
headNode->attachObject(ogreHead);
headNode->setPosition(0, 25, 0);
headNode->roll(Ogre::Radian(0.5));
Ogre::ManualObject* myManualObject = mSceneMgr->createManualObject("manual1");
Ogre::ManualObject* myManualObject2 = mSceneMgr->createManualObject("manual2");
Ogre::SceneNode* myManualObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("manual1_node");
Ogre::SceneNode* myManualObjectNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("manual2_node");
// NOTE: The second parameter to the create method is the resource group the material will be added to.
// If the group you name does not exist (in your resources.cfg file) the library will assert() and your program will crash
Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("blueMaterial","General");
myManualObjectMaterial->setReceiveShadows(false);
myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(0,0,1,0);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(0,0,1);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1);
myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("greenMaterial","General");
myManualObjectMaterial->setReceiveShadows(false);
myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(0,1,0,0);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(0,1,0);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(0,1,0);
myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("redMaterial","General");
myManualObjectMaterial->setReceiveShadows(false);
myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,0,0,0);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,0,0);
myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,0,0);
myManualObject->begin("blueMaterial", Ogre::RenderOperation::OT_LINE_LIST);
myManualObject->position(0, 0, 0);
myManualObject->position(50, 0, 0);
myManualObject->end();
myManualObject->begin("greenMaterial", Ogre::RenderOperation::OT_LINE_LIST);
myManualObject->position(0, 0, 0);
myManualObject->position(0, 70, 0);
myManualObject->end();
myManualObject->begin("redMaterial", Ogre::RenderOperation::OT_LINE_LIST);
myManualObject->position(0, 0, 0);
myManualObject->position(0, 0, 50);
myManualObject->end();
myManualObjectNode->attachObject(myManualObject);
myManualObject2->begin("blueMaterial", Ogre::RenderOperation::OT_LINE_LIST);
myManualObject2->position(0, 0, 0);
myManualObject2->position(50, 0, 0);
myManualObject2->end();
myManualObject2->begin("greenMaterial", Ogre::RenderOperation::OT_LINE_LIST);
myManualObject2->position(0, 0, 0);
myManualObject2->position(0, 70, 0);
myManualObject2->end();
myManualObject2->begin("redMaterial", Ogre::RenderOperation::OT_LINE_LIST);
myManualObject2->position(0, 0, 0);
myManualObject2->position(0, 0, 50);
myManualObject2->end();
myManualObjectNode2->attachObject(myManualObject2);
myManualObjectNode2->roll(Ogre::Radian(0.5));
// Create a Light and set its position
Ogre::Light* light = mSceneMgr->createLight("MainLight");
light->setPosition(20.0f, 80.0f, 50.0f);
}
示例12:
void CViewManagerView::On3dViews()
{
int ViewIndex = CMFCRibbonGallery::GetLastSelectedItem(ID_3DVIEWS);
CEngine *Engine = ((CViewManagerApp*)AfxGetApp())->m_Engine;
Ogre::Root *Root = Engine->GetRoot();
m_SceneManager->_updateSceneGraph(m_Camera);
Ogre::SceneNode *CubeNode = m_SceneManager->getSceneNode("Cube");
Ogre::AxisAlignedBox Box = m_SceneManager->getRootSceneNode()->_getWorldAABB();
Ogre::Vector3 Center = Box.getCenter();
Ogre::Vector3 Position;
Ogre::Vector3 Destination;
switch (ViewIndex)
{
case 0: //top
Position = Center;
Position.y += 4.0 * Box.getSize().y;
Destination = Center;
break;
case 1://bottom
Position = Center;
Position.y -= 4.0 * Box.getSize().y;
Destination = Center;
break;
case 2:
Position = Center;
Position.x += 4.0 * Box.getSize().x;
Destination = Center;
break;
case 3:
Position = Center;
Position.x -= 4.0 * Box.getSize().x;
Destination = Center;
break;
case 4:
Position = Center;
Position.z -= 4.0 * Box.getSize().z;
Destination = Center;
break;
case 5:
Position = Center;
Position.z += 4.0 * Box.getSize().z;
Destination = Center;
break;
case 9:
CubeNode->roll(Ogre::Radian(-atan(sin(Ogre::Math::PI/4.0))));
CubeNode->yaw(Ogre::Radian(Ogre::Math::PI/4.0));
Destination = Center;
Position = m_Camera->getPosition();
break;
}
m_Camera->setPosition(Position);
m_Camera->lookAt(Destination);
Root->renderOneFrame();
}
开发者ID:southerlies,项目名称:OGRE-3D-1.7-Application-Development-Cookbook-Code,代码行数:72,代码来源:ViewManagerView.cpp
示例13: createScene
void CameraApp::createScene()
{
/***************************************************************************/
/* This create a scene with a textured plane and a penguin. The camera */
/* is placed directly behind the penguin. Both the camera and the penguin */
/* are attached to the same scene node. As a result, when the node is */
/* moved or rotated, the camera and the penguin move or rotate exactly the */
/* same. This gives you a first person camera that is always looking over */
/* the shoulder of your character. */
/***************************************************************************/
sceneMgr->setAmbientLight( Ogre::ColourValue( 1, 1, 1 ) );
Ogre::Light *l = sceneMgr->createLight("MainLight");
Ogre::Camera *camera = sceneMgr->createCamera("MainCam");
camNode = sceneMgr->getRootSceneNode()->createChildSceneNode( "CameraNode" );
camNode->attachObject(camera);
camera->setPosition(0.0, 0.0, 0.0);
int originX = -15;
int distancebetween = 10;
for (int i = 0; i < 4; i++)
{
Ogre::Entity *sinbadEntity = sceneMgr->createEntity("Sinbad" + i, "Sinbad.mesh");
Ogre::SceneNode *sinbadNode = sceneMgr->getRootSceneNode()->createChildSceneNode("SinbadNode" + i);
sinbadNode->attachObject(sinbadEntity);
sinbadNode->setScale(1,1,1);
sinbadNode->translate(originX + (distancebetween * i), 0, -40);
switch (i)
{
case 1:
sinbadNode->yaw(Ogre::Degree(90.0f));
break;
case 2:
sinbadNode->pitch(Ogre::Degree(90.0f));
break;
case 3:
sinbadNode->roll(Ogre::Degree(90.0f));
break;
}
}
Ogre::Entity *sinbadEntity = sceneMgr->createEntity("SinbadScaled", "Sinbad.mesh");
Ogre::SceneNode *sinbadNode = sceneMgr->getRootSceneNode()->createChildSceneNode("SinbadScaledNode");
sinbadNode->attachObject(sinbadEntity);
sinbadNode->setScale(5,5,5);
//sinbadNode->rotate(Ogre::Vector3(1,0,0), Ogre::Degree(90));
//sinbadNode->rotate(Ogre::Vector3(0,0,1), Ogre::Degree(-90));
sinbadNode->translate(0, 0, -60);
Ogre::Viewport *vp = window->addViewport(camera);
vp->setDimensions(0.0f, 0.0f, 1.0f, 1.0f);
camera->setAspectRatio((float)vp->getActualWidth() / (float) vp->getActualHeight());
camera->setFarClipDistance(1000.0f);
camera->setNearClipDistance(5.0f);
camera->lookAt(0,0,-10);
setActiveCamera(camera);
/*Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -10);
Ogre::MeshManager::getSingleton().createPlane("plane",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
1500, 1500, 20, 20, true, 1, 5, 5, Ogre::Vector3::UNIT_Z);
Ogre::Entity *planeEntity = sceneMgr->createEntity("PlaneEntity", "plane");
sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(planeEntity);
planeEntity->setMaterialName("Examples/BeachStones");*/
}
示例14: createScene
void createScene() {
Ogre::SceneNode* nroca = mSceneMgr->createSceneNode("nroca");
Ogre::Entity *roca = mSceneMgr->createEntity("roca", "cube.mesh");
nroca->attachObject(roca);
mSceneMgr->getRootSceneNode()->addChild(nroca);
Ogre::SceneNode* ntronco = mSceneMgr->createSceneNode("ntronco");
Ogre::Entity *tronco = mSceneMgr->createEntity("tronco", "cube.mesh");
ntronco->attachObject(tronco);
mSceneMgr->getRootSceneNode()->addChild(ntronco);
Ogre::SceneNode* ncabeza = mSceneMgr->createSceneNode("ncabeza");
Ogre::Entity *cabeza = mSceneMgr->createEntity("cabeza", "cube.mesh");
ncabeza->attachObject(cabeza);
ntronco->addChild(ncabeza);
Ogre::SceneNode* nbase = mSceneMgr->createSceneNode("nbase");
Ogre::Entity *base = mSceneMgr->createEntity("base", "cube.mesh");
nbase->attachObject(base);
ncabeza->addChild(nbase);
Ogre::SceneNode* nsombrero = mSceneMgr->createSceneNode("nsombrero");
Ogre::Entity *sombrero = mSceneMgr->createEntity("sombrero", "cube.mesh");
nsombrero->attachObject(sombrero);
nbase->addChild(nsombrero);
Ogre::SceneNode* nbrazoizq = mSceneMgr->createSceneNode("nbrazoizq");
Ogre::Entity *brazoizq = mSceneMgr->createEntity("brazoizq", "cube.mesh");
nbrazoizq->attachObject(brazoizq);
ntronco->addChild(nbrazoizq);
Ogre::SceneNode* nbrazoder = mSceneMgr->createSceneNode("nbrazoder");
Ogre::Entity *brazoder = mSceneMgr->createEntity("brazoder", "cube.mesh");
nbrazoder->attachObject(brazoder);
ntronco->addChild(nbrazoder);
Ogre::SceneNode* npiernaizq = mSceneMgr->createSceneNode("npiernaizq");
Ogre::Entity *piernaizq = mSceneMgr->createEntity("piernaizq", "cube.mesh");
npiernaizq->attachObject(piernaizq);
ntronco->addChild(npiernaizq);
Ogre::SceneNode* npiernader = mSceneMgr->createSceneNode("npiernader");
Ogre::Entity *piernader = mSceneMgr->createEntity("piernader", "cube.mesh");
npiernader->attachObject(piernader);
ntronco->addChild(npiernader);
Ogre::SceneNode* npieder = mSceneMgr->createSceneNode("npieder");
Ogre::Entity *pieder = mSceneMgr->createEntity("pieder", "cube.mesh");
npieder->attachObject(pieder);
npiernader->addChild(npieder);
nroca->setPosition(0,7,0);
nroca->setScale(7,7,7);
nroca->pitch(Degree(30));
nroca->roll(Degree(-45));
ntronco->setPosition(-20,4,0);
ntronco->setScale(1,3,1);
ntronco->roll(Degree(17));
ncabeza->setPosition(0.25,1.35,0);
ncabeza->setScale(1,0.33,1);
ncabeza->roll(Degree(-10));
nbase->setPosition(0.25,2,0);
nbase->setScale(1,0.15,1);
nbase->roll(Degree(-30));
nsombrero->setPosition(0,2.5,0);
nsombrero->setScale(0.5,3.5,0.5);
nbrazoder->setScale(0.5,1,0.5);
nbrazoder->setPosition(-2,0.65,-2.25);
nbrazoder->roll(Degree(90));
nbrazoder->pitch(Degree(-30));
nbrazoizq->setScale(0.5,1,0.5);
nbrazoizq->setPosition(-2,0.65,2.25);
nbrazoizq->roll(Degree(100));
nbrazoizq->pitch(Degree(30));
npiernaizq->setPosition(-1.75,-1.75,-0.25);
npiernaizq->setScale(0.5,1,0.5);
npiernaizq->roll(Degree(-45));
npiernader->setPosition(1,-1.35,0.5);
npiernader->setScale(0.5,0.5,0.5);
npiernader->roll(Degree(35));
npieder->setPosition(2.25,-1.25,1.75);
npieder->roll(Degree(90));
Ogre::Plane pl1(Ogre::Vector3::UNIT_Y, -5);
Ogre::MeshManager::getSingleton().createPlane("pl1",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,pl1,200,200,1,1,true,1,20,20,Ogre::Vector3::UNIT_Z);
Ogre::SceneNode* nground = mSceneMgr->createSceneNode("ground");
Ogre::Entity *ground = mSceneMgr->createEntity("pEnt","pl1");
ground->setMaterialName("Ground");
nground->attachObject(ground);
mSceneMgr->getRootSceneNode()->addChild(nground);
mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
}
示例15: go
//.........这里部分代码省略.........
// Variables for render loop
bool render(true);
ovrFrameTiming hmdFrameTiming;
ovrTrackingState ts;
OVR::Posef pose;
ovrLayerHeader* layers;
// Create event listener for handling user input
createEventListener();
//Run physics loop in a new thread
std::map<Ogre::Entity*, Ogre::Vector3> positionRequests;
std::map<Ogre::Entity*, std::string> animationRequests;
std::map<Ogre::Entity*, std::vector<int>> rotationRequests;
std::map<std::string, std::string> message;
std::thread physicsThread(physicsLoop, smgr, &message, &positionRequests, &animationRequests, &rotationRequests);
// Render loop
while(render)
{
// Suspend physics loop and perform requested movement/rotations/animations
if(positionRequests.size() > 0 || animationRequests.size() > 0 || rotationRequests.size() > 0){
message.insert(std::pair<std::string, std::string>("", ""));
for(auto const &request : positionRequests) {
Ogre::Vector3 pos = request.second;
Ogre::SceneNode* sceneNode = request.first->getParentSceneNode();
sceneNode->setPosition(pos);
}
for(auto const &request : animationRequests) {
request.first->getAnimationState(request.second)->addTime(0.1);
}
for(auto const &request : rotationRequests) {
Ogre::SceneNode* sceneNode = request.first->getParentSceneNode();
sceneNode->roll(Ogre::Degree(request.second[0]));
sceneNode->pitch(Ogre::Degree(request.second[1]));
sceneNode->yaw(Ogre::Degree(request.second[2]));
}
positionRequests.clear();
animationRequests.clear();
rotationRequests.clear();
// Resume physics loop
message.clear();
}
// Update Ogre window
Ogre::WindowEventUtilities::messagePump();
// Advance textureset index
textureSet->CurrentIndex = (textureSet->CurrentIndex + 1) % textureSet->TextureCount;
// Capture user input
mKeyboard->capture();
mMouse->capture();
// Movement calculations
mPlayerNode->translate(mDirection, Ogre::Node::TS_LOCAL);
hmdFrameTiming = ovr_GetFrameTiming(hmd, 0);
ts = ovr_GetTrackingState(hmd, hmdFrameTiming.DisplayMidpointSeconds);
pose = ts.HeadPose.ThePose;
ovr_CalcEyePoses(pose, offset, layer.RenderPose);
oculusOrient = pose.Rotation;
oculusPos = pose.Translation;
mHeadNode->setOrientation(Ogre::Quaternion(oculusOrient.w, oculusOrient.x, oculusOrient.y, oculusOrient.z) * initialOculusOrientation.Inverse());
// Apply head tracking
mHeadNode->setPosition(headPositionTrackingSensitivity * Ogre::Vector3(oculusPos.x, oculusPos.y,oculusPos.z));
// Update Ogre viewports
root->_fireFrameRenderingQueued();
vpts[left]->update();
vpts[right]->update();
// Copy the rendered image to the Oculus Swap Texture
glCopyImageSubData(renderTextureID, GL_TEXTURE_2D, 0, 0, 0, 0,
((ovrGLTexture*)(&textureSet->Textures[textureSet->CurrentIndex]))->OGL.TexId, GL_TEXTURE_2D, 0, 0, 0, 0,
bufferSize.w,bufferSize.h, 1);
layers = &layer.Header;
// Submit new frame to the Oculus and update window
ovr_SubmitFrame(hmd, 0, nullptr, &layers, 1);
window->update();
// Exit loop when window is closed
if(window->isClosed()) render = false;
}
// Shud down Oculus
ovr_Destroy(hmd);
ovr_Shutdown();
// Delete Ogre root and return
delete root;
return EXIT_SUCCESS;
}