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()); }
void StencilShadowTest::setupContent() { // turn ambient light off mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0)); // turn on stencil shadows mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE); // add a couple lights Ogre::Light* light = mSceneMgr->createLight("Light1"); light->setDiffuseColour(0.5f,0.4f,0.35f); light->setSpecularColour(0, 0, 0); light->setAttenuation(8000,1,0.0005,0); light->setPosition(220,100,0); light->setCastShadows(true); light->setType(Light::LT_POINT); light = mSceneMgr->createLight("Light2"); light->setDiffuseColour(0.5f,0.4f,0.35f); light->setSpecularColour(0, 0, 0); light->setAttenuation(8000,1,0.0005,0); light->setPosition(220,100,-200); light->setCastShadows(true); light->setType(Light::LT_POINT); // create a ground plane to receive some shadows Plane pln = MovablePlane("plane"); pln.normal = Vector3::UNIT_Y; pln.d = 107; MeshManager::getSingleton().createPlane("ground_plane", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, pln, 1500,1500,50,50,true,1,5,5,Vector3::UNIT_Z); Ogre::Entity* groundPlane = mSceneMgr->createEntity( "plane", "ground_plane" ); groundPlane->setMaterialName("Examples/Rocky"); groundPlane->setCastShadows(false); mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(groundPlane); // and a couple objects to cast the shadows Ogre::Entity* bar = mSceneMgr->createEntity( "barrel", "Barrel.mesh" ); bar->setCastShadows(true); Ogre::SceneNode* barNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); barNode->attachObject(bar); barNode->setScale(7,7,7); barNode->setPosition(Ogre::Vector3(0,-85,-320)); Ogre::Entity* head = mSceneMgr->createEntity( "ogrehead", "ogrehead.mesh" ); head->setCastShadows(true); Ogre::SceneNode* headNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); headNode->attachObject(head); headNode->setPosition(Ogre::Vector3(-100,-80,-320)); Ogre::Entity* torus = mSceneMgr->createEntity( "torus", "knot.mesh" ); torus->setCastShadows(true); torus->setMaterialName("Examples/RustySteel"); Ogre::SceneNode* torusNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); torusNode->setScale(0.5,0.5,0.5); torusNode->attachObject(torus); torusNode->setPosition(Ogre::Vector3(100,-60,-320)); // point the camera down a bit mCamera->pitch(Ogre::Degree(-20.f)); }
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 GameState::createScene() { // --- Objects m_pNpc01 = new BaseNpc("Blacksmith", m_pSceneMgr, Ogre::Vector3(50.0f, 0.0f, 50.0f)); m_pNpc01->ChangeState(Work::Instance()); //m_pNpc02 = new BaseNpc("Woman", m_pSceneMgr, Ogre::Vector3(-50.0f, 0.0f, -50.0f)); //m_pNpc01->addLocation(Ogre::Vector3(-100.0f,0.0f,-100.0f)); // --- World // Light m_pSceneMgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7)); // Objects // Home Ogre::Entity* home = m_pSceneMgr->createEntity("Home", "tudorhouse.mesh"); //home->setCastShadows(true); Ogre::SceneNode* homeNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("HomeNode"); homeNode->attachObject(home); homeNode->setPosition(Ogre::Vector3(-400.0f,220.0f,-400.0f)); homeNode->setScale(0.4f, 0.4f, 0.4f); // Work Ogre::Entity* work = m_pSceneMgr->createEntity("Work", "tudorhouse.mesh"); //work->setCastShadows(true); Ogre::SceneNode* workNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("WorkNode"); workNode->attachObject(work); workNode->setPosition(Ogre::Vector3(400.0f,220.0f,400.0f)); workNode->setScale(0.4f, 0.4f, 0.4f); workNode->yaw(Ogre::Degree(180)); // Tavern Ogre::Entity* tavern = m_pSceneMgr->createEntity("Tavern", "tudorhouse.mesh"); //tavern->setCastShadows(true); Ogre::SceneNode* tavernNode = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("TavernNode"); tavernNode->attachObject(tavern); tavernNode->setPosition(Ogre::Vector3(-400.0f,220.0f,400.0f)); tavernNode->setScale(0.4f, 0.4f, 0.4f); tavernNode->yaw(Ogre::Degree(180)); // Ground Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0); 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::Entity* entGround = m_pSceneMgr->createEntity("GroundEntity", "ground"); m_pSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround); entGround->setMaterialName("Examples/Rockwall"); entGround->setCastShadows(false); }
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); }
void np::ConnectionDisplaySystem::onAddedEntity( ac::es::EntityPtr e) { np::ConnectionComponent* connection = e->getComponent<np::ConnectionComponent>(); np::GraphicComponent* graphics = e->getComponent<np::GraphicComponent>(); //OgreFramework::getSingletonPtr()->m_pLog->logMessage( "Connection to be displayed!"); double mx = ( connection->target1->position.x + connection->target2->position.x) * 0.5; //OgreFramework::getSingletonPtr()->m_pLog->logMessage( Ogre::StringConverter::toString( (Ogre::Real)mx)); double mz = ( connection->target1->position.z + connection->target2->position.z) * 0.5; //OgreFramework::getSingletonPtr()->m_pLog->logMessage( Ogre::StringConverter::toString( (Ogre::Real)mz)); double dx = connection->target2->position.x - connection->target1->position.x; double dz = connection->target2->position.z - connection->target1->position.z; double d = std::sqrt( dx * dx + dz * dz) / 100.0; Ogre::Vector3 position( mx, 0.0, mz); double rads = std::atan2( dx, dz); Ogre::Quaternion rotation( Ogre::Radian( rads), Ogre::Vector3::UNIT_Y); Ogre::SceneNode* newNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( position, rotation); newNode->setScale( 1.0, 1.0, d); for (std::list<Ogre::Entity*>::iterator it = graphics->entities.begin(); it != graphics->entities.end(); it++) newNode->attachObject( (*it)); graphics->node = newNode; }
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); }
OgreVehicle* OgreVehicle::createOgreVehicle(Ogre::SceneNode* parNode, std::string name, Ogre::Vector3 pos) { if (parNode) { OgreVehicle* vehicle = new OgreVehicle(); vehicle->mName = name; vehicle->mParNode = parNode; Ogre::SceneManager* sceneMgr = vehicle->mParNode->getCreator(); Ogre::String nodeName = "User_" + name; vehicle->mNode = vehicle->mParNode->createChildSceneNode(nodeName); Ogre::SceneNode* pNodeBody = vehicle->mNode->createChildSceneNode("Body" + nodeName); Ogre::SceneNode* pNodeCam = vehicle->mNode->createChildSceneNode("Cam" + nodeName); Ogre::Entity* eBody = sceneMgr->createEntity("eBody"+nodeName, OGRE_VEHICLE_FILE); pNodeBody->attachObject(eBody); pNodeBody->setScale(0.0002*SCALE_TERRAIN, 0.0002*SCALE_TERRAIN, 0.0002*SCALE_TERRAIN); vehicle->mNode->setPosition(pos); vehicle->mWheels[0] = OgreWheel::createOgreWheel(pNodeBody, Ogre::Vector3(1.02f, -0.3622f, 1.26)); vehicle->mWheels[1] = OgreWheel::createOgreWheel(pNodeBody, Ogre::Vector3(1.12f, -0.3622f,-1.54)); vehicle->mWheels[2] = OgreWheel::createOgreWheel(pNodeBody, Ogre::Vector3(-1.02f, -0.3622f, 1.26)); vehicle->mWheels[3] = OgreWheel::createOgreWheel(pNodeBody, Ogre::Vector3(-1.12f, -0.3622f,-1.54)); return vehicle; } return NULL; }
void DPSHelper::throwSphere(void) { Ogre::Vector3 pos = mCamera->getDerivedPosition() + mCamera->getDerivedDirection().normalisedCopy() * 10; Ogre::Quaternion rot = Ogre::Quaternion::IDENTITY; Ogre::Entity *ent = mSceneMgr->createEntity("sphere.mesh"); //Ogre::Entity *ent = mSceneMgr->createEntity("cube.mesh"); ent->setCastShadows(true); //ent->setMaterialName("Examples/BumpyMetal"); Ogre::SceneNode* sphereNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(pos,rot); setColor(ent, Ogre::Vector3(0.3021f,0.3308f,0.3671f)); sphereNode->attachObject(ent); sphereNode->setScale(Ogre::Vector3(0.1f,0.1f,0.1f)); BtOgre::StaticMeshToShapeConverter converter(ent); btCollisionShape* entShape = converter.createSphere(); //btCollisionShape* entShape = converter.createTrimesh(); //Calculate inertia. btScalar mass = 1; btVector3 inertia(0,0,0); entShape->calculateLocalInertia(mass, inertia); //Create BtOgre MotionState (connects Ogre and Bullet). BtOgre::RigidBodyState* entState = new BtOgre::RigidBodyState(sphereNode); //Create the Body. btRigidBody* entBody = new btRigidBody(mass, entState, entShape, inertia); Ogre::Vector3 thro = mCamera->getRealDirection() * 800; entBody->applyCentralForce(btVector3(pos.x,pos.y,pos.z) * 50000); entBody->setLinearVelocity(btVector3(thro.x,thro.y,thro.z)); phyWorld->addRigidBody(entBody); }
void DPSHelper::createOgreHead(void) { Ogre::Vector3 pos = Ogre::Vector3(0,100,0); Ogre::Quaternion rot = Ogre::Quaternion::IDENTITY; //Create Ogre stuff. Ogre::Entity* ogreHeadEntity = mSceneMgr->createEntity("ogrehead.mesh"); Ogre::SceneNode* ogreHeadNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(pos, rot); ogreHeadNode->attachObject(ogreHeadEntity); ogreHeadNode->setScale(Ogre::Vector3(1,1,1)); ogreHeadEntity->setCastShadows(true); //setColor(mNinjaEntity, Ogre::Vector3(0.3021,0.3308,0.3671)); //mNinjaEntity->setMaterialName("Examples/Rockwall"); //Create shape. BtOgre::StaticMeshToShapeConverter converter(ogreHeadEntity); //BtOgre::AnimatedMeshToShapeConverter converter(mNinjaEntity); //mNinjaShape = converter.createTrimesh(); btCollisionShape* ogreHeadShape = converter.createConvex(); //mNinjaShape = converter.createConvex(); //Calculate inertia. btScalar mass = 1; btVector3 inertia; ogreHeadShape->calculateLocalInertia(mass, inertia); //Create BtOgre MotionState (connects Ogre and Bullet). BtOgre::RigidBodyState *ogreheadState = new BtOgre::RigidBodyState(ogreHeadNode); //Create the Body. btRigidBody* ogreHeadBody = new btRigidBody(mass, ogreheadState, ogreHeadShape, inertia); phyWorld->addRigidBody(ogreHeadBody); }
void Sample::setupScene() { mSceneMgr->setSkyBox(true, "spaceSkyBox"); // Set the scene's ambient light mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5f, 0.5f, 0.5f)); Ogre::Entity* pEntity = mSceneMgr->createEntity("SinbadInstance", "Sinbad.mesh"); Ogre::SceneNode* pNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); pNode->attachObject(pEntity); pNode->setScale(Ogre::Vector3(3.0f)); mDance = pEntity->getAnimationState("Dance"); mDance->setEnabled(true); mDance->setLoop(true); mDance->setTimePosition(0); Ogre::Light* pDirLight = mSceneMgr->createLight(); pDirLight->setDirection(Ogre::Vector3(0,-1,0)); pDirLight->setType(Ogre::Light::LT_DIRECTIONAL); pNode->attachObject(pDirLight); mCamera->setNearClipDistance(1.0f); mCamera->setFarClipDistance(100000.0f); mCamera->setPosition(0,0,30.0f); mCamera->lookAt(0,0,0); mCamera->setAutoAspectRatio(true); Ogre::Viewport* vp = mWindow->addViewport(mCamera); vp->setBackgroundColour(Ogre::ColourValue(1,0,0)); }
void Replicator::update(float value) { //logFile << getFrequentcyRange() << " :\t " << value << "\n"; Ogre::Vector3 currentScale = getScale(); this->setThreshold(0.7*this->getThreshold() + 0.4*value); float result = value / this->getThreshold(); int numOfChildrenToGenerate = result > 1.0 ? (result - value) * 2 : 0; //logFile << value / this->getThreashold() << "\t" << (result - value) * 10 << "\t" << numOfChildrenToGenerate << "\n"; for ( int i = 0; i < numOfChildrenToGenerate; i++ ) { createChildren(numOfChildrenToGenerate); } for(std::vector<Ogre::Entity*>::size_type i = 0; i < children.size(); ) { Ogre::SceneNode* childNode = children[i]->getParentSceneNode(); Ogre::Real res = childNode->getScale().length(); if ( res < 0.1 ) { children[i]->setVisible(false); childNode->setVisible(false); childNode->detachObject(children[i]->getName()); _sceneManager->destroyEntity(children[i]->getName()); // entity is now destroyed, don't try to use the pointer anymore! // optionally destroy node _sceneManager->destroySceneNode(childNode->getName()); children.erase( children.begin() + i ); } else { Ogre::Vector3 currScale = childNode->getScale(); childNode->setScale(Ogre::Vector3(currScale.x - currScale.x/3, currScale.y - currScale.y/3, currScale.z - currScale.z/3)); i++; } } }
void OgreModel::attachTo(Ogre::SceneNode* node) const { std::string name(original->getName()); OgreRenderer* renderer(OgreRenderer::getInstance()); Ogre::SceneManager* sceneManager(renderer->getOgreSceneManager()); Ogre::Entity* ogreEntity; if (0 == name.compare("cube")) { ogreEntity = sceneManager->createEntity(renderer->createUniqueString("cube-Entity"), "cube"); } else { ogreEntity = sceneManager->createEntity(renderer->createUniqueString(name + "-Entity"), name + ".mesh"); } if (!PURGE::CoordinateSystem::get().isLeftHanded()) { node->attachObject(ogreEntity); } else { Ogre::SceneNode* modelNode = node->createChildSceneNode(name + "-Node"); modelNode->setScale(1, 1, -1); modelNode->attachObject(ogreEntity); } }
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; }
void Application::createSceneSet3() { int sNumber = 2; Ogre::Entity* groundEntity = m_sceneManager->createEntity( "Ground3", "ground.mesh" ); Ogre::SceneNode* groundSceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); groundSceneNode->attachObject( groundEntity ); groundSceneNode->setPosition(Ogre::Vector3(0, 0, DISTANCE_TO_ANOTHER * sNumber * -1)); groundSceneNode->setScale( ROW_WIDTH, 1, ROW_HEIGHT ); Ogre::ParticleSystem* pTest1 = m_sceneManager->createParticleSystem("pBlast", "PEExamples/blast"); Ogre::SceneNode* pTest1SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); pTest1SceneNode->attachObject(pTest1); pTest1SceneNode->setPosition(Ogre::Vector3(150, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1)); Ogre::ParticleSystem* pTest2 = m_sceneManager->createParticleSystem("pBlast2", "PEExamples/blast2"); Ogre::SceneNode* pTest2SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); pTest2SceneNode->attachObject(pTest2); pTest2SceneNode->setPosition(Ogre::Vector3(-100, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1)); Ogre::ParticleSystem* pTest3 = m_sceneManager->createParticleSystem("pFloaty", "PEExamples/floatyGreeny"); Ogre::SceneNode* pTest3SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); pTest3SceneNode->attachObject(pTest3); pTest3SceneNode->setPosition(Ogre::Vector3(-350, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1)); }
// Just override the mandatory create scene method void setupContent(void) { // Check capabilities const RenderSystemCapabilities* caps = Root::getSingleton().getRenderSystem()->getCapabilities(); if (!caps->hasCapability(RSC_GEOMETRY_PROGRAM)) { OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, "Your render system / hardware does not support geometry programs, " "so cannot run this demo. Sorry!", "Sample_Isosurf::setupContent"); } int maxOutputVertices = caps->getGeometryProgramNumOutputVertices(); Ogre::LogManager::getSingleton().getDefaultLog()->stream() << "Num output vertices per geometry shader run : " << maxOutputVertices; mCamera->setPosition(0, 0, -40); mCamera->lookAt(0,0,0); mCamera->setNearClipDistance(0.1); mCamera->setFarClipDistance(100); MeshPtr tetrahedraMesh = ProceduralTools::generateTetrahedra(); //Create tetrahedra and add it to the root scene node tetrahedra = mSceneMgr->createEntity("TetrahedraEntity", tetrahedraMesh->getName()); //tetraHedra->setDebugDisplayEnabled(true); Ogre::SceneNode* parentNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(); parentNode->attachObject(tetrahedra); parentNode->setScale(10,10,10); }
void LagomPlayerBase::AddConstructionCapability(LagomActorFactory* f) { if(!f) return; if(_actorFactories.find(f) != _actorFactories.end()) return; Ogre::SceneManager* manager = _state.GetSceneManager(); Ogre::SceneNode* node = manager->createSceneNode(); Ogre::Entity* constructionObject = manager->createEntity(f->Mesh.c_str()); Ogre::MaterialPtr materialPtr = Ogre::MaterialManager::getSingleton().getByName(getIntFactory().ConstructingMaterial); materialPtr->setSelfIllumination(1.0f,1.0f,1.0f); constructionObject->setCastShadows(false); constructionObject->setRenderQueueGroup(RENDER_QUEUE_SKIES_LATE); constructionObject->setMaterialName(getIntFactory().ConstructingMaterial); node->attachObject(constructionObject); node->setScale( f->MeshScale ); _actorFactories.insert(FactoryMap::value_type(f,node)); if( _selectedActorFactory ==_actorFactories.end()) _selectedActorFactory=_actorFactories.begin(); }
void Application::createSceneSet1() { int sNumber = 0; Ogre::Entity* groundEntity = m_sceneManager->createEntity( "Ground1", "ground.mesh" ); Ogre::SceneNode* groundSceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); groundSceneNode->attachObject( groundEntity ); groundSceneNode->setPosition(Ogre::Vector3(0, 0, DISTANCE_TO_ANOTHER * sNumber * -1)); groundSceneNode->setScale( ROW_WIDTH, 1, ROW_HEIGHT ); /* Ogre::ParticleSystem* pTest1 = m_sceneManager->createParticleSystem("pFireworks", "Examples/Fireworks"); Ogre::SceneNode* pTest1SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); pTest1SceneNode->attachObject(pTest1); pTest1SceneNode->setPosition(Ogre::Vector3(150, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1)); */ ParticleUniverse::ParticleSystem * pTest1 = ParticleUniverse::ParticleSystemManager::getSingleton().createParticleSystem("pTest1", "PUMediaPack/Teleport", m_sceneManager); Ogre::SceneNode* pTest1SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); pTest1SceneNode->attachObject(pTest1); pTest1SceneNode->setPosition(Ogre::Vector3(150, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1)); Ogre::ParticleSystem* pTest2 = m_sceneManager->createParticleSystem("pSmoke1", "Examples/Smoke"); Ogre::SceneNode* pTest2SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); pTest2SceneNode->attachObject(pTest2); pTest2SceneNode->setPosition(Ogre::Vector3(-100, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1)); Ogre::ParticleSystem* pTest3 = m_sceneManager->createParticleSystem("pGreeny", "Examples/GreenyNimbus"); Ogre::SceneNode* pTest3SceneNode = m_sceneManager->getRootSceneNode()->createChildSceneNode(); pTest3SceneNode->attachObject(pTest3); pTest3SceneNode->setPosition(Ogre::Vector3(-350, DISTANCE_TO_FLOOR, DISTANCE_TO_ANOTHER * sNumber * -1)); }
//----------------------------------------------------------------------- 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)); } }
//! //! Processes the node's input data to generate the node's output table. //! void Model2SceneNode::processScene() { // load the input vtk parameter VTKTableParameter * inputParameter = dynamic_cast<VTKTableParameter*>(getParameter(m_inputVTKTableParameterName)); if (!inputParameter || !inputParameter->isConnected()) return; // get the source parameter (output of source node) connected to the input parameter VTKTableParameter * sourceParameter = dynamic_cast<VTKTableParameter*>(inputParameter->getConnectedParameter()); inputParameter->setVTKTable(sourceParameter->getVTKTable()); vtkTable * xyzTable = inputParameter->getVTKTable(); if (!m_sceneNode) createSceneNode(); if (!m_entity || !xyzTable || !m_sceneNode) return; //Get columns named "NodeID", "X", "Y" and "Z" vtkIdTypeArray *colNodeId = dynamic_cast<vtkIdTypeArray*>(xyzTable->GetColumnByName("NodeId")); vtkDoubleArray *colX = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("X")); vtkDoubleArray *colY = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("Y")); vtkDoubleArray *colZ = dynamic_cast<vtkDoubleArray*>(xyzTable->GetColumnByName("Z")); destroyAllAttachedMovableObjects(m_sceneNode); destroyAllChildren(m_sceneNode); Ogre::String idPrefix(QString(m_name + ":").toStdString()); Ogre::SceneManager *sceneManager = OgreManager::getSceneManager(); for (int i=0; i<xyzTable->GetNumberOfRows(); i++) { int colIDValue = colNodeId->GetValue(i); Ogre::String nodeID(idPrefix + Ogre::StringConverter::toString(colIDValue)); // create new scene node for each item Ogre::SceneNode *sceneItem = sceneManager->createSceneNode(nodeID); // create new entity for each item Ogre::Entity *entityItem = m_entity->clone(nodeID); sceneItem->attachObject(entityItem); double x = colX->GetValue(i); double y = colY->GetValue(i); double z = colZ->GetValue(i); sceneItem->setPosition(Ogre::Real(x), Ogre::Real(y), Ogre::Real(z)); sceneItem->setScale(m_size); m_sceneNode->addChild(sceneItem); } }
//--------------------------------------------------------------------------------------------- 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); }
//----------------------------------------------------------------------------- void IntermediateTutorial1::createScene(void) { // Set the default lighting. mSceneMgr->setAmbientLight(Ogre::ColourValue(1.0f, 1.0f, 1.0f)); // Create the entity mEntity = mSceneMgr->createEntity("Robot", "robot.mesh"); // Create the scene node mNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("RobotNode", Ogre::Vector3(0.0f, 0.0f, 25.0f)); mNode->attachObject(mEntity); // Create the walking list mWalkList.push_back(Ogre::Vector3(550.0f, 0.0f, 50.0f )); mWalkList.push_back(Ogre::Vector3(-100.0f, 0.0f, -200.0f)); // Create objects so we can see movement Ogre::Entity *ent; Ogre::SceneNode *node; ent = mSceneMgr->createEntity("Knot1", "knot.mesh"); node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Knot1Node", Ogre::Vector3(0.0f, -10.0f, 25.0f)); node->attachObject(ent); node->setScale(0.1f, 0.1f, 0.1f); ent = mSceneMgr->createEntity("Knot2", "knot.mesh"); node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Knot2Node", Ogre::Vector3(550.0f, -10.0f, 50.0f)); node->attachObject(ent); node->setScale(0.1f, 0.1f, 0.1f); ent = mSceneMgr->createEntity("Knot3", "knot.mesh"); node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Knot3Node", Ogre::Vector3(-100.0f, -10.0f,-200.0f)); node->attachObject(ent); node->setScale(0.1f, 0.1f, 0.1f); // Set the camera to look at our handiwork mCamera->setPosition(90.0f, 280.0f, 535.0f); mCamera->pitch(Ogre::Degree(-30.0f)); mCamera->yaw(Ogre::Degree(-15.0f)); }
void JunctionPoints::reshape(void) { // Adjust scale mScale = getSceneManipulator()->getBaseScale() / (7 * mBaseMesh->getBoundingSphereRadius()); for (DisplayNodes::const_iterator it = mDisplayNodes.begin(); it != mDisplayNodes.end(); ++it) { Ogre::SceneNode* node = it->second; node->setScale(mScale, mScale, mScale); } }
void BubbleController::Update(float dt){ if (m_apply_impulse){ Ogre::Vector3 impulse = (m_impulse_direction * m_velocity) * dt; m_messenger->Notify(MSG_RIGIDBODY_APPLY_IMPULSE, &impulse, "body"); m_apply_impulse = false; if (m_owner->GetType() == GAME_OBJECT_PINK_BUBBLE){ m_distance -= impulse.squaredLength(); } } if (m_owner->GetType() == GAME_OBJECT_PINK_BUBBLE){ float percent = m_max_distance * 0.5f; if (m_distance < percent){ Ogre::SceneNode* node = NULL; m_messenger->Notify(MSG_NODE_GET_NODE, &node); if (node){ float scale_inc = (m_scale_increment * (percent / m_distance)) * dt; if (m_scale_state == 0) { // increase size Ogre::Vector3 scale = node->getScale() + scale_inc; node->setScale(scale); if (node->getScale().y > m_max_scale){ node->setScale(Ogre::Vector3(m_max_scale)); m_scale_state = 1; } } else if (m_scale_state == 1){ // decrease size Ogre::Vector3 scale = node->getScale() - scale_inc; node->setScale(scale); if (node->getScale().y < m_original_scale){ node->setScale(Ogre::Vector3(m_original_scale)); m_scale_state = 0; } } } } if (m_distance <= 0.0f){ SoundData2D pop_sound = m_owner->GetGameObjectManager()->GetSoundManager()->Create2DData("Bubble_Burst", false, false, false, false, 1.0, 1.0); m_owner->GetGameObjectManager()->GetGameObject("Player")->GetComponentMessenger()->Notify(MSG_SFX2D_PLAY, &pop_sound); m_owner->RemoveGameObject(m_owner); } } }
void EffectManager::addEffect(const std::string &model, std::string textureOverride, const Ogre::Vector3 &worldPosition, float scale) { Ogre::SceneNode* sceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(worldPosition); sceneNode->setScale(scale,scale,scale); // fix texture extension to .dds if (textureOverride.size() > 4) { textureOverride[textureOverride.size()-3] = 'd'; textureOverride[textureOverride.size()-2] = 'd'; textureOverride[textureOverride.size()-1] = 's'; } NifOgre::ObjectScenePtr scene = NifOgre::Loader::createObjects(sceneNode, model); // TODO: turn off shadow casting MWRender::Animation::setRenderProperties(scene, RV_Misc, RQG_Main, RQG_Alpha, 0.f, false, NULL); for(size_t i = 0;i < scene->mControllers.size();i++) { if(scene->mControllers[i].getSource().isNull()) scene->mControllers[i].setSource(Ogre::SharedPtr<EffectAnimationTime> (new EffectAnimationTime())); } if (!textureOverride.empty()) { for(size_t i = 0;i < scene->mParticles.size(); ++i) { Ogre::ParticleSystem* partSys = scene->mParticles[i]; Ogre::MaterialPtr mat = scene->mMaterialControllerMgr.getWritableMaterial(partSys); for (int t=0; t<mat->getNumTechniques(); ++t) { Ogre::Technique* tech = mat->getTechnique(t); for (int p=0; p<tech->getNumPasses(); ++p) { Ogre::Pass* pass = tech->getPass(p); for (int tex=0; tex<pass->getNumTextureUnitStates(); ++tex) { Ogre::TextureUnitState* tus = pass->getTextureUnitState(tex); tus->setTextureName("textures\\" + textureOverride); } } } } } mEffects.push_back(std::make_pair(sceneNode, scene)); }
void World::_LoadObjects( rapidxml::xml_node<>* node ) { size_t count = Ogre::StringConverter::parseUnsignedInt(node->first_attribute("count")->value()); rapidxml::xml_node<>* curObjNode = node->first_node(); for (size_t i=0; i< count; ++i) { const STRING strMesh = curObjNode->first_attribute("meshname")->value(); const STRING strPos = curObjNode->first_attribute("position")->value(); const STRING strOrient = curObjNode->first_attribute("orientation")->value(); const STRING strScale = curObjNode->first_attribute("scale")->value(); const bool bIsBuilding = Ogre::StringConverter::parseBool(curObjNode->first_attribute("isbuilding")->value()); const bool bIsResource = Ogre::StringConverter::parseBool(curObjNode->first_attribute("isresource")->value()); const POS& pos = Ogre::StringConverter::parseVector3(strPos); const ORIENT& orient = Ogre::StringConverter::parseQuaternion(strOrient); const SCALE& scale = Ogre::StringConverter::parseVector3(strScale); if (bIsBuilding || bIsResource) { Object* pObject = ObjectManager::GetSingleton().CreateObject(bIsBuilding ? eObjectType_Building : eObjectType_Resource); if(bIsBuilding) { const STRING strBuildingName = curObjNode->first_attribute("buildingname")->value(); Building* pBuilding = static_cast<Building*>(pObject); pBuilding->SetName(strBuildingName); pBuilding->Init(pos, orient, scale); } else { Resource* pRes = static_cast<Resource*>(pObject); pRes->SetMeshName(strMesh); pRes->SetPosition(pos); pRes->SetOrientation(orient); pRes->SetScale(scale); } } else { //非游戏对象,不纳入逻辑管理,只渲染 Ogre::Entity* entity = m_pRenderSystem->m_pSceneMgr->createEntity(strMesh); assert(entity); Ogre::SceneNode* pNode = m_pRenderSystem->m_pSceneMgr->getRootSceneNode()->createChildSceneNode(pos, orient); pNode->setScale(scale); pNode->attachObject(entity); } curObjNode = curObjNode->next_sibling(); } }
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 GraphicsImpl::addNode(const boost::shared_ptr<ObjectToCreate>& object) { Ogre::Entity* ent; Ogre::SceneNode* node; //Dout << "Creating object with specification: " + object.specification; ent = sceneMgr->createEntity(ObjectRegistry::Instance().getNameForID(object->node.ID) + boost::lexical_cast<std::string>(object->node.ID), object->specification); node = sceneMgr->getRootSceneNode()->createChildSceneNode(); node->attachObject(ent); node->setPosition(object->node.pos); node->setOrientation(object->node.orient); node->setScale(object->scale); nodes[object->node.ID] = node; }
Paddle* Application::createPaddle(Ogre::String nme, GameObject::objectType tp, Ogre::String meshName, int x, int y, int z, Ogre::Real scale, 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); sn->setScale(scale,scale,scale); const btTransform pos; OgreMotionState* ms = new OgreMotionState(pos, sn); Paddle* obj = new Paddle(nme, tp, mSceneManager, ssm, sn, ent, ms, mySim, mss, rest, frict, scale, kinematic); obj->addToSimulator(); return obj; }
void DrawToolOGRE::drawSphere( const Vector3 &p, float radius) { std::ostringstream s; s << "entity[" << mEntityName++ <<"]"; Ogre::Entity* sph = pSceneMgr->createEntity( s.str(), "mesh/ball.mesh" );//pSceneMgr->createEntity(s.str().c_str(), Ogre::SceneManager::PT_SPHERE ); s.str(""); s << "material[" << mMaterialName-1 << "]" ; sph->setMaterialName(s.str()); Ogre::SceneNode* node = pSceneMgr->getRootSceneNode()->createChildSceneNode(); node->setScale(radius,radius,radius); node->setPosition(p[0],p[1],p[2]); node->attachObject(sph); }