void TestGame::DrawNewCore(Logic::CoreBuiltEvnt *evnt){ Ogre::Entity* drop= mSceneMgr->createEntity("Mesh"+evnt->building->mSysName, "BaseDropNew.mesh"); drop->setCastShadows(true); const Ogre::AxisAlignedBox test =drop->getBoundingBox(); Control::ClickHelper* helpr = new Control::ClickHelper(Logic::CHT_BUILDING); helpr->target = evnt->building; drop->setUserAny(Ogre::Any(helpr)); Ogre::SceneNode *coreNode = evnt->country->mNode->createChildSceneNode(); Ogre::Vector3 tempvect = calculateActualPointFromCenter(evnt->country->mCapital.mPosition,evnt->tile->mPosition); tempvect= tempvect*TILESIZE; coreNode->attachObject(drop); coreNode->translate(tempvect); coreNode->pitch(Ogre::Degree(90)); coreNode->scale(0.5,0.5,0.5); Ogre::AnimationState* temp= drop->getAnimationState("drop"); temp->setLoop(false); temp->setEnabled(true); mAllAnimation .insert(temp); Ogre::Entity* basePlane= mSceneMgr->createEntity("MeshBaseFloor"+evnt->building->mSysName, "BaseCloseLook.mesh"); basePlane->setMaterialName("BaseCloseLook/Rockwall"); Ogre::SceneNode *BaseDraw = evnt->country->mNode->createChildSceneNode(),*camspot; BaseDraw->attachObject(basePlane); BaseDraw->translate(2000*evnt->building->mSlot,0,0); camspot = BaseDraw->createChildSceneNode("CamPoint_"+evnt->building->mSysName); camspot->setPosition(0,45,45); camspot->lookAt(Ogre::Vector3(0,0,0), Ogre::Node::TS_PARENT); helpr = new Control::ClickHelper(Logic::CHT_EMPTYSPACE); helpr->target = evnt->building; basePlane->setUserAny(Ogre::Any(helpr)); }
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); }
//----------------------------------------------------------------------------- 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)); }
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); }
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); } }
void NavigationCell::debugDrawClassification( Ogre::Vector3 start, Ogre::Vector3 end ) { Ogre::Root *root = Ogre::Root::getSingletonPtr(); Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" ); Ogre::ManualObject* debug; Ogre::SceneNode* node; if( mgr->hasManualObject( "debugDrawClassification" ) ) debug = mgr->getManualObject( "debugDrawClassification" ); else { debug = mgr->createManualObject( "debugDrawClassification" ); node = mgr->getRootSceneNode()->createChildSceneNode(); node->attachObject( debug ); node->translate( 0, 1, 0 ); debug->setQueryFlags( 0 ); debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY ); } debug->begin( "debug/blue", Ogre::RenderOperation::OT_LINE_LIST ); debug->position( start ); debug->position( end ); debug->end(); // debugDrawCell( debug, "debug/yellow", "debug/blue" ); }
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; }
// Create the scene node for the terrain. We don't need to make the mesh as the later calls // will do that. Ogre::SceneNode* Region::CreateTerrain(Ogre::SceneNode* regionNode, const float width, const float length, Ogre::String terrainName) { LG::Log("Region::CreateTerrain: r=%s, w=%f, l=%f, n=%s", this->Name.c_str(), width, length, terrainName.c_str()); Ogre::SceneNode* terrainNode = regionNode->createChildSceneNode("TerrainSceneNode/" + terrainName); terrainNode->setInheritOrientation(true); terrainNode->setInheritScale(false); terrainNode->translate(0.0, 0.0, 0.0); return terrainNode; }
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; }
/* "15000,700000,x,y,0", "false,false,barren,2500,1", "false,co2,barren,6000,2", "h2o,n2/o2,gaia,6300,3", "false,co2,barren,3400,4", "false,h2/he,gasgiant,71000,5", "false,h2/he,gasgiant,60000,6", "false,h2/he,gasgiant,25000,7", "false,h2/he,gasgiant,25000,8", "false,n-ice,ice,1100,9" */ StarSystem::StarSystem(Ogre::SceneManager *sceneMgr, std::string *bodyDefinition) { Ogre::SceneNode *systemNode = sceneMgr->getRootSceneNode()->createChildSceneNode(Ogre::Vector3(0,0,0)); createOrbits(systemNode, sceneMgr, bodyDefinition); float PositionOffset = 0.0; float distance = -1000.0; systemNode->translate(0, PositionOffset, distance); }
//-------------------------------------------------------------------------------------- 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); }
void CharacterManager::createExitPoint( Ogre::Vector3 position ) { Ogre::SceneNode* mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "ExitPoint" + Ogre::StringConverter::toString( ++mExitPointCount ) ); Ogre::Entity* mEntity = mSceneMgr->createEntity( "ExitPoint" + Ogre::StringConverter::toString( ++mExitPointCount ), "Cylinder.mesh" ); mEntity->setMaterialName( "Cylinder/Yellow" ); mNode->attachObject( mEntity ); mNode->setPosition( position ); mNode->translate( 0, -position.y, 0 ); mNode->setScale( 50, 15, 50 ); mExitPointList.push_back( mNode ); }
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) ); } }
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()); } } }
void NavigationCell::debugDrawCellAndNeigbours() { Ogre::Root *root = Ogre::Root::getSingletonPtr(); Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" ); Ogre::ManualObject* debug; Ogre::SceneNode* debugNode; if( mgr->hasSceneNode( "debugDrawNode" ) ) { debugNode = mgr->getSceneNode( "debugDrawNode" ); } else { debugNode = mgr->getRootSceneNode()->createChildSceneNode( "debugDrawNode" ); debugNode->translate( 0, 1, 0 ); // Move up slightly to see lines better. } if( mgr->hasManualObject( "debugDraw" ) ) debug = mgr->getManualObject( "debugDraw" ); else { debug = mgr->createManualObject( "debugDraw" ); debugNode->attachObject( debug ); debug->setQueryFlags( 0 ); debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY ); } for( int i = 0; i < 3; i++ ) { if( mLinks[i] ) { debug->begin( "debug/blue", Ogre::RenderOperation::OT_LINE_STRIP ); debug->position( mLinks[i]->mVertices[0] ); debug->position( mLinks[i]->mVertices[1] ); debug->position( mLinks[i]->mVertices[2] ); debug->position( mLinks[i]->mVertices[0] ); debug->end(); } } debug->begin( "debug/yellow", Ogre::RenderOperation::OT_LINE_STRIP ); debug->position( mVertices[0].x, mVertices[0].y+1, mVertices[0].z ); debug->position( mVertices[1].x, mVertices[1].y+1, mVertices[1].z ); debug->position( mVertices[2].x, mVertices[2].y+1, mVertices[2].z ); debug->position( mVertices[0].x, mVertices[0].y+1, mVertices[0].z ); debug->end(); }
void CameraComponent::createCamera(void) { mCamera = mSceneMgr->createCamera("CarCam"); /* Attach the camera to our car and place it in the correct position */ CarOgreComponent* ogreComp = (CarOgreComponent*)parentEntity->getComponent(COMPONENT_OGRE); Ogre::SceneNode* carRootNode = ogreComp->getNode(); Ogre::SceneNode* camNode = carRootNode->createChildSceneNode("CamNode"); camNode->translate(currentPos); camNode->attachObject(mCamera); //mCamera->setPosition(Ogre::Vector3(0,15,30)); mCamera->lookAt(Ogre::Vector3(0,0,80)); mCamera->setNearClipDistance(5); //mCameraMan = new OgreBites::SdkCameraMan(mCamera); }
//------------------------------------------------------------------------------------- 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; }
void CsCameraManager::Orbit(float timeStep) { static float theta = 0; Ogre::SceneNode* camNode = mCameraList[mCurrentCamera].second; float radius = 100; if (mTargetObject) { btVector3 min, max; mTargetObject->GetRigidBody()->getAabb(min, max); radius = (max - min).length(); } camNode->setPosition(0,0,0); //camNode->translate(cosf(theta) * 100.0f, 90.0f, sinf(theta) * 100.0f, Ogre::Node::TS_PARENT); camNode->translate(cosf(theta) * radius * ORBIT_CAM_DISTANCE, sinf(theta) * radius * ORBIT_CAM_DISTANCE, ORBIT_CAM_HEIGHT * radius, Ogre::Node::TS_PARENT); theta += mOrbitSpeed * timeStep; }
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()); } } }
Ogre::SceneNode* SideVerifier::createSceneNode(Ogre::SceneNode* parent, std::string name, Ogre::Vector3 defaultTranslate) { Ogre::SceneNode* node = parent->createChildSceneNode(name); node->translate(defaultTranslate); Ogre::ManualObject* myManualObject = new Ogre::ManualObject("manual1" + name); myManualObject->begin("manual1Material", Ogre::RenderOperation::OT_LINE_LIST); myManualObject->position(0, 0, 0); myManualObject->position(0, 0, -1); myManualObject->end(); //DEBUG // node->attachObject(myManualObject); return node; }
void Laser::Initialize(Ogre::SceneManager *sceneManager, Ogre::SceneNode* parentNode, PhysicsEngine &physicsEngine, unsigned int parentID) { PhysicsEntity::Initialize(sceneManager, parentNode, physicsEngine, parentID); //setting our mass to 0 bodyType = ENTITY_BODY_METAPHYSICAL; dynamic = false; mass = 0.0f; Ogre::Entity *laserEntity = sceneManager->createEntity("Cylinder"); laserEntity->setMaterialName("LaserMaterial"); Ogre::SceneNode *laserSceneNode = sceneNode->createChildSceneNode("Laser" + Ogre::StringConverter::toString(entityCount)); laserSceneNode->attachObject(laserEntity); laserSceneNode->scale(0.3f, 1000.0f, 0.3f); laserSceneNode->pitch(Ogre::Radian(-Ogre::Math::HALF_PI)); laserSceneNode->translate(0,0,-500.0f); sceneNode->setVisible(false); }
void InputListener::updateWater(const Ogre::FrameEvent& evt) { float WaterFlow = FLOW_SPEED * evt.timeSinceLastFrame; static float FlowAmount = 0.0f; static bool FlowUp = true; Ogre::SceneNode *pWaterNode = static_cast<Ogre::SceneNode*>(this->_currentScene->getCamera()->getSceneManager()->getRootSceneNode()->getChild("WaterNode")); if (FlowUp) FlowAmount += WaterFlow; else FlowAmount -= WaterFlow; if (FlowAmount >= this->_currentScene->getWorld()->getWaterLevel() + FLOW_HEIGHT) FlowUp = false; else if (FlowAmount <=this->_currentScene->getWorld()->getWaterLevel()) FlowUp = true; pWaterNode->translate(0, (FlowUp ? WaterFlow : -WaterFlow), 0); if (this->_Game->getGameType() == Game::GameType::SUDDEN_DEATH) this->_currentScene->getWorld()->riseWater(); this->_Game->killWormsUnderWater(pWaterNode); }
void NavigationMesh::setShow( bool show ) { Ogre::Root *root = Ogre::Root::getSingletonPtr(); Ogre::SceneManager* mgr = root->getSceneManager( "SceneManagerInstance" ); Ogre::ManualObject* debug; Ogre::SceneNode* debugNode; mShow = show; if( mgr->hasSceneNode( "debugDrawNode2" ) ) { debugNode = mgr->getSceneNode( "debugDrawNode2" ); } else { debugNode = mgr->getRootSceneNode()->createChildSceneNode( "debugDrawNode2" ); debugNode->translate( 0, 1, 0 ); // Move up slightly to see lines better. } if( mgr->hasManualObject( "debugDraw2" ) ) debug = mgr->getManualObject( "debugDraw2" ); else { debug = mgr->createManualObject( "debugDraw2" ); debugNode->attachObject( debug ); debug->setQueryFlags( 0 ); debug->setRenderQueueGroup( Ogre::RENDER_QUEUE_OVERLAY ); } if( !mShow ) { mgr->destroyManualObject( debug ); return; } for( CellVector::iterator i = mCells.begin(); i != mCells.end(); i++ ) { i->debugDrawCell( debug, "debug/yellow", "debug/blue" ); } return; }
// Create the scene node for the ocean. We create a plane, add the ocean material, create a scene node // and add the plane to the scene node and return that scene node. // BETWEEN FRAME OPERATION Ogre::SceneNode* Region::CreateOcean(Ogre::SceneNode* regionNode, const float width, const float length, const float waterHeight, Ogre::String waterName) { Ogre::Plane* oceanPlane = new Ogre::Plane(0.0, 0.0, 1.0, 0); Ogre::MeshPtr oceanMesh = Ogre::MeshManager::getSingleton().createPlane(waterName, OLResourceGroupName, *oceanPlane, width, length, 2, 2, true, 2, 2.0, 2.0, Ogre::Vector3::UNIT_Y); Ogre::String oceanMaterialName = LG::GetParameter("Renderer.Ogre.OceanMaterialName"); LG::Log("Region::CreateOcean: r=%s, h=%f, n=%s, m=%s", regionNode->getName().c_str(), waterHeight, waterName.c_str(), oceanMaterialName.c_str()); oceanMesh->getSubMesh(0)->setMaterialName(oceanMaterialName); Ogre::Entity* oceanEntity = LG::RendererOgre::Instance()->m_sceneMgr->createEntity("WaterEntity/" + waterName, oceanMesh->getName()); oceanEntity->addQueryFlags(Ogre::SceneManager::WORLD_GEOMETRY_TYPE_MASK); oceanEntity->setCastShadows(false); Ogre::SceneNode* oceanNode = regionNode->createChildSceneNode("WaterSceneNode/" + waterName); oceanNode->setInheritOrientation(true); oceanNode->setInheritScale(false); oceanNode->translate(width/2.0f, length/2.0f, waterHeight); oceanNode->attachObject(oceanEntity); return oceanNode; }
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); }
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); }
void createScene() { mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0, 1.0, 1.0)); /* Ogre::Entity* entMesh01 = mSceneMgr->createEntity("MyEntity1","ogrehead.mesh"); Ogre::SceneNode* nodeMesh01 = mSceneMgr->createSceneNode("NodeMesh01"); mSceneMgr->getRootSceneNode()->addChild(nodeMesh01); nodeMesh01->setPosition(0.0,0.0,0.0); nodeMesh01->attachObject(entMesh01); */ Ogre::Entity* ent01 = mSceneMgr->createEntity("MyEntity1","ejes01.mesh"); Ogre::SceneNode* node01 = mSceneMgr->createSceneNode("Node01"); mSceneMgr->getRootSceneNode()->addChild(node01); node01->attachObject(ent01); Ogre::Entity* ent02 = mSceneMgr->createEntity("MyEntity2","cuadriculaX01.mesh"); Ogre::SceneNode* node02 = mSceneMgr->createSceneNode("Node02"); mSceneMgr->getRootSceneNode()->addChild(node02); node02->attachObject(ent02); Ogre::SceneNode* nodeSinbad = mSceneMgr->createSceneNode("NodeSinbad"); Ogre::SceneNode* nodeEjeSinbad = mSceneMgr->createSceneNode("NodeEjeSinbad"); Ogre::SceneNode* nodeNinja = mSceneMgr->createSceneNode("NodeNinja"); Ogre::Entity* entSinbad = mSceneMgr->createEntity("MyEntitySinbad","sinbad.mesh"); Ogre::Entity* entEjeSinbad = mSceneMgr->createEntity("MyEntityEjeSinbad","ejes01.mesh"); Ogre::Entity* entNinja = mSceneMgr->createEntity("MyEntityNinja","ninja.mesh"); mSceneMgr->getRootSceneNode()->addChild(nodeEjeSinbad); nodeEjeSinbad->attachObject(entEjeSinbad); nodeEjeSinbad->addChild(nodeSinbad); nodeEjeSinbad->addChild(nodeNinja); nodeSinbad->attachObject(entSinbad); nodeNinja->attachObject(entNinja); //eje nodeEjeSinbad->setScale(0.6,0.6,0.6); nodeEjeSinbad->setPosition(5.0,0.0,0.0); nodeEjeSinbad->translate(2.0,0.0,2.0); nodeEjeSinbad->yaw(Ogre::Degree(45.0f)); //rota en Y //nodeEjeSinbad->pitch(Ogre::Degree(45.0f));//rota en X //nodeEjeSinbad->roll(Ogre::Degree(45.0f));//rota en Z //Hijo Sinbad nodeSinbad->setScale(0.8,0.8,0.8); nodeSinbad->translate(0.0,0.0,8.0,Ogre::Node::TS_WORLD); //Hijo Ninja nodeNinja->setScale(0.04,0.04,0.04); nodeNinja->yaw(Ogre::Degree(180.0f)); nodeNinja->setPosition(4.0,-4.0,5.0); /*nodeSinbad->attachObject(entEjeSinbad); nodeSinbad->attachObject(ejeSinbad); */ }
void GameState::createScene() { graphics = new Graphics(m_pSceneMgr); physics = new Physics(graphics); graphics->setPhysics(physics); physics->initialize(); PenguinNode = m_pSceneMgr->getSceneNode("penguin"); m_pSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8); // Create a snowstorm Ogre::ParticleSystem* snow = m_pSceneMgr->createParticleSystem("snow", "Examples/Snow"); Ogre::SceneNode* sNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("snowNode"); sNode->translate(0, 1200, 2000); sNode->attachObject(snow); snow->fastForward(100); CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *gameWindow = wmgr.createWindow("DefaultWindow", "CEGUI/GameGUI"); // penguin portrait face = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage", "FacePng"); face->setSize(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.13, 0))); face->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0))); face->setProperty("Image","set:Face image:full_image"); face->setProperty("FrameEnabled", "False"); face->setProperty("BackgroundEnabled", "False"); gameWindow->addChildWindow(face); // life life = wmgr.createWindow("TaharezLook/StaticText", "CEGUI/Life"); stringstream s; s << physics->getLives(); life->setText("x"+s.str()); life->setSize(CEGUI::UVector2(CEGUI::UDim(0.04, 0), CEGUI::UDim(0.05, 0))); life->setPosition(CEGUI::UVector2(CEGUI::UDim(0.08, 0), CEGUI::UDim(0.048, 0))); life->setProperty("FrameEnabled", "False"); life->setProperty("BackgroundEnabled", "False"); // life->setProperty("Font", "Jura-18"); gameWindow->addChildWindow(life); // health bar for certain stages hp = 1.0f; showHealth = false; health = wmgr.createWindow("TaharezLook/ProgressBar", "CEGUI/Health"); health->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.04, 0))); health->setPosition(CEGUI::UVector2(CEGUI::UDim(0.08, 0), CEGUI::UDim(0.01, 0))); health->setProperty("Visible", "False"); gameWindow->addChildWindow(health); // Pause menu pauseWindow = wmgr.createWindow("TaharezLook/StaticText", "CEGUI/PauseWindow"); pauseWindow->setSize(CEGUI::UVector2(CEGUI::UDim(0.4, 0), CEGUI::UDim(0.35, 0))); pauseWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0.3, 0), CEGUI::UDim(0.35, 0))); pauseWindow->setProperty("Visible", "False"); gameWindow->addChildWindow(pauseWindow); CEGUI::Window *ret = wmgr.createWindow("TaharezLook/Button", "CEGUI/ReturnToGameButton"); ret->setText("Resume Game"); ret->setSize(CEGUI::UVector2(CEGUI::UDim(0.8, 0), CEGUI::UDim(0.2, 0))); ret->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.25, 0))); pauseWindow->addChildWindow(ret); CEGUI::Window *bac = wmgr.createWindow("TaharezLook/Button", "CEGUI/BackToTitleButton"); bac->setText("Back to Title"); bac->setSize(CEGUI::UVector2(CEGUI::UDim(0.8, 0), CEGUI::UDim(0.2, 0))); bac->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.55, 0))); pauseWindow->addChildWindow(bac); CEGUI::System::getSingleton().setGUISheet(gameWindow); // event calls ret->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GameState::returnToGame, this)); bac->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GameState::backToTitle, this)); }
//------------------------------------------------------------------------------------- void SimonSays::createScene(void) { // set up the basics mSceneMgr->setAmbientLight(Ogre::ColourValue(0.3,0.3,0.3)); /*Ogre::Light *light = mSceneMgr->createLight("MainLight"); light->setPosition(20.0f, 80.0f, 50.0f);*/ // put in a floor ;) Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0); Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 1500, 1500, 40, 40, true, 1, 5, 5, Ogre::Vector3::UNIT_Z); Ogre::Entity* floor = mSceneMgr->createEntity("GroundEntity", "ground"); mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(floor); floor->setMaterialName("Examples/Rockwall"); floor->setCastShadows(false); // for now, use a pinguin, character selection will be added later Ogre::Entity *player = mSceneMgr->createEntity("Player", "penguin.mesh"); Ogre::SceneNode *playerNode = mSceneMgr->getRootSceneNode()-> createChildSceneNode("PlayerNode"); playerNode->attachObject(player); playerNode->translate(35,20,-65); player->setVisible( false ); // use spots placed in 2x2 field to show the order // // yellow | red keys: u | i // ---------------- ---------- // blue | green j | k Ogre::SceneNode *lightNode = mSceneMgr->getRootSceneNode()-> createChildSceneNode("LightNode"); lightNode->setPosition(0,80,0); Ogre::Light *yellow = mSceneMgr->createLight("yellowSpot"); yellow->setType(Ogre::Light::LT_SPOTLIGHT); yellow->setDiffuseColour(.5,.5,0); yellow->setSpecularColour(.5,.5,0); yellow->setDirection(0,-1,0); //yellow->setSpotlightInnerAngle(Ogre::Degree(5.0f)); //yellow->setSpotlightOuterAngle(Ogre::Degree(45.0f)); //yellow->setSpotlightFalloff(0.0f); //yellow->setPosition(Ogre::Vector3(0,0,0)); //yellow->setSpotlightFalloff(0.0f); yellow->setSpotlightRange(Ogre::Degree(15), Ogre::Degree(15)); lightNode->attachObject(yellow); yellow->setVisible( false ); Ogre::Light *red = mSceneMgr->createLight("redSpot"); red->setType(Ogre::Light::LT_SPOTLIGHT); red->setDiffuseColour(1,0,0); red->setSpecularColour(1,0,0); red->setDirection(1,-1,0); //red->setPosition(Ogre::Vector3(0,0,0)); //red->setSpotlightFalloff(0.0f); red->setSpotlightRange(Ogre::Degree(15), Ogre::Degree(15)); lightNode->attachObject(red); red->setVisible( false ); Ogre::Light *blue = mSceneMgr->createLight("blueSpot"); blue->setType(Ogre::Light::LT_SPOTLIGHT); blue->setDiffuseColour(0,0,1.0); blue->setSpecularColour(0,0,1.0); blue->setDirection(0,-1,1); //blue->setPosition(Ogre::Vector3(0,100,0)); blue->setSpotlightRange(Ogre::Degree(15), Ogre::Degree(15)); lightNode->attachObject(blue); blue->setVisible( false ); Ogre::Light *green = mSceneMgr->createLight("greenSpot"); green->setType(Ogre::Light::LT_SPOTLIGHT); green->setDiffuseColour(0,1,0); green->setSpecularColour(0,1,0); green->setDirection(1,-1,1); //green->setPosition(Ogre::Vector3(100,100,0)); green->setSpotlightRange(Ogre::Degree(15), Ogre::Degree(15)); lightNode->attachObject(green); green->setVisible( false ); // everything's set up, let's get the game and the streaming started! mSceneMgr->getLight("yellowSpot")->setVisible( true ); mSceneMgr->getLight("redSpot")->setVisible( true ); mSceneMgr->getLight("blueSpot")->setVisible( true ); mSceneMgr->getLight("greenSpot")->setVisible( true ); turnEnded = false; gameStarted = false; correctOrder = true; pause = false; // set pause to false // --> game ist started by user input!! frameCounter = 1; // set up streaming setUpStream(); }
void CsCameraManager::Update() { static clock_t prevTime = clock(); static Ogre::Vector3 lerpPos; static Ogre::Quaternion slerpRot; static float linLerpStep; static float angLerpStep; clock_t curTime = clock(); float timeStep = (curTime - prevTime) / (float) CLOCKS_PER_SEC; Ogre::SceneNode* camNode = mCameraList[mCurrentCamera].second; // the interpolation ---------------------------------------- // the current camera is not actually used, the default camera is used to approximate // the current camera posA = mDefaultCamNode->_getDerivedPosition(); rotA = mDefaultCamNode->_getDerivedOrientation(); posB = camNode->_getDerivedPosition(); rotB = camNode->_getDerivedOrientation(); linLerpStep = 0.5 * timeStep / 0.12; // reaches half i 0.3 seconds angLerpStep = 0.5 * timeStep / 0.12; // for fast moving targets if (mTargetObject) { float linear = mTargetObject->GetLinearVelocity().length(); float angular = mTargetObject->GetAngularVelocity().length(); if (linear > 200.0f) { linLerpStep += (linear - 150) / 300.0f; angLerpStep += (linear - 150) / 300.0f; } if (angular > 3.0f) { linLerpStep += (angular - 2.0f) / 8.0f; angLerpStep += (angular - 2.0f) / 8.0f; } } if (linLerpStep > 1.0f) linLerpStep = 0.90f; if (angLerpStep > 1.0f) angLerpStep = 0.90f; if (linLerpStep < 0.0f) linLerpStep = 0.1f; if (angLerpStep < 0.0f) angLerpStep = 0.1f; lerpPos = (posB - posA) * linLerpStep + posA; slerpRot = Ogre::Quaternion::Slerp(angLerpStep, rotA, rotB, true); mDefaultCamNode->setPosition(lerpPos); mDefaultCamNode->setOrientation(slerpRot); // ---------------------------------------------------------- if (mCameraType[mCurrentCamera] == Chaos::ORBIT_CAMERA) { Orbit(timeStep); } else if (mCameraType[mCurrentCamera] == Chaos::FREE_CAMERA) { if ( mButtonState[Chaos::ARROW_UP]) camNode->translate(0,0,-timeStep * MOVE_SPEED, Ogre::Node::TS_LOCAL); if ( mButtonState[Chaos::ARROW_DOWN]) camNode->translate(0,0,timeStep * MOVE_SPEED, Ogre::Node::TS_LOCAL); if ( mButtonState[Chaos::ARROW_LEFT]) camNode->translate(-timeStep * MOVE_SPEED,0,0, Ogre::Node::TS_LOCAL); if ( mButtonState[Chaos::ARROW_RIGHT]) camNode->translate(timeStep * MOVE_SPEED,0,0, Ogre::Node::TS_LOCAL); if (xrel) camNode->yaw(Ogre::Radian(Ogre::Degree(-LOOK_SPEED * xrel * timeStep)), Ogre::Node::TS_WORLD); if (yrel) camNode->pitch(Ogre::Radian(Ogre::Degree(-LOOK_SPEED * yrel * timeStep)), Ogre::Node::TS_LOCAL); } xrel = yrel = zrel = 0; prevTime = curTime; }