void IntroScene::initScene() { mSceneMgr = mRoot->createSceneManager( ST_GENERIC , "intro" ); mCamera = mSceneMgr->createCamera("Cam1"); mVp = mWindow->addViewport(mCamera); mVp->setBackgroundColour(ColourValue(1.0f, 0.0f,0.0f)); mCamera->setAspectRatio(Real(mVp->getActualWidth())/mVp->getActualHeight()); mSceneMgr->setAmbientLight( ColourValue( 1, 1, 1 ) ); Ogre::MaterialManager *matMgr = Ogre::MaterialManager::getSingletonPtr(); Ogre::MaterialPtr mat = (Ogre::MaterialPtr )matMgr->create("intro2","General"); mat->getTechnique(0)->getPass(0)->createTextureUnitState("cybernetic.jpg"); mat->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); mat->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); mat->getTechnique(0)->getPass(0)->setLightingEnabled(false); Ogre::Rectangle2D *rect = new Ogre::Rectangle2D(true); rect->setCorners( -1.0 , 1.0 , 1.0 , -1.0 ); rect->setMaterial("intro2"); rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode("Background"); node->attachObject(rect); AxisAlignedBox aabInf; aabInf.setInfinite(); rect->setBoundingBox(aabInf); }
void GraphicsController::_initBackgroundHdr() { Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(false); rect->setCorners(-1.0f, 1.0f, 1.0f, -1.0f); rect->setMaterial("PRJZ/HDRBackground"); rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND + 1); rect->setBoundingBox(Ogre::AxisAlignedBox(-100000.0*Ogre::Vector3::UNIT_SCALE, 100000.0*Ogre::Vector3::UNIT_SCALE)); rect->setCastShadows(false); rect->setVisibilityFlags(0xf00000); Ogre::SceneNode* node = _scnMgr->getRootSceneNode()->createChildSceneNode("HdrBackground"); node->attachObject(rect); node->setVisible(true); }
void SplashScreenState::createScene() { // creation image splash screen Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("SplashScreen", "General"); material->getTechnique(0)->getPass(0)->createTextureUnitState("splash_screen.jpg"); material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); material->getTechnique(0)->getPass(0)->setLightingEnabled(false); // creation rect Ogre::Rectangle2D *rect = new Ogre::Rectangle2D(true); rect->setCorners(-1.0, 1.0, 1.0, -1.0); rect->setMaterial("SplashScreen"); // priorité chargement rect->setRenderQueueGroup(Ogre::RenderQueueGroupID::RENDER_QUEUE_BACKGROUND); // stay visible Ogre::AxisAlignedBox aabInf; aabInf.setInfinite(); rect->setBoundingBox(aabInf); // Ogre::SceneNode* node = m_pSceneMgr->getRootSceneNode()->createChildSceneNode("SplashScreen"); node->attachObject(rect); m_pSceneMgr->setAmbientLight(Ogre::ColourValue(1, 1, 1)); }
bool GUIRadarLayout::Load() { // rect = new Ogre::Rectangle2D(TRUE); rect->setMaterial("Radar/Background"); rect->getMaterial()->setDepthCheckEnabled(false); rect->getMaterial()->setDepthWriteEnabled(false); rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_6-3); //rect->setBoundingBox(Ogre::AxisAlignedBox(-1000000 * Ogre::Vector3::UNIT_SCALE, 1000000 * Ogre::Vector3::UNIT_SCALE)); //CommonDeclarations::GetSceneManager()->getRootSceneNode()->attachObject(rect); //rect->setCorners(0.5, -0.5, 1, -1); // // Create a manual object for 2D //char name[10]; Ogre::Rectangle2D *row = NULL; Ogre::Rectangle2D *obj = NULL; //Ogre::AxisAlignedBox aabInf; //aabInf.setInfinite(); if (!Ogre::MaterialManager::getSingleton().resourceExists("CompasMaterial")) { Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting"); CompasMaterial = mat->clone("CompasMaterial"); CompasMaterial->setDepthCheckEnabled(false); CompasMaterial->setDepthWriteEnabled(false); CompasMaterial->setLightingEnabled(true); CompasMaterial->setAmbient(Ogre::ColourValue::Green); } if (!Ogre::MaterialManager::getSingleton().resourceExists("RadarRowMaterial")) { Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting"); RadarRowMaterial = mat->clone("RadarRowMaterial"); RadarRowMaterial->setDepthCheckEnabled(false); RadarRowMaterial->setDepthWriteEnabled(false); RadarRowMaterial->setLightingEnabled(true); RadarRowMaterial->setAmbient(Ogre::ColourValue::Red); } /*if (!Ogre::MaterialManager::getSingleton().resourceExists("RadarObjMaterial")) { Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName("BaseWhiteNoLighting"); RadarObjMaterial = mat->clone("RadarObjMaterial"); RadarObjMaterial->setDepthCheckEnabled(false); RadarObjMaterial->setDepthWriteEnabled(false); RadarObjMaterial->setLightingEnabled(true); RadarObjMaterial->setAmbient(Ogre::ColourValue::Red); }*/ for (unsigned i=0;i<CommonDeclarations::RadarObjectsCount;++i) { // row = new Ogre::Rectangle2D(TRUE); row->setMaterial("RadarRowMaterial"); row->setRenderQueueGroup(Ogre::RENDER_QUEUE_6-2); //CommonDeclarations::GetSceneManager()->getRootSceneNode()->attachObject(row); //rect->setCorners(0.5, -0.5, 1, -1); Rows.Data[i] = row; // // obj = new Ogre::Rectangle2D(TRUE); obj->setMaterial("Radar/ObjMaterialUp"); obj->setRenderQueueGroup(Ogre::RENDER_QUEUE_6-2); //CommonDeclarations::GetSceneManager()->getRootSceneNode()->attachObject(obj); //rect->setCorners(0.5, -0.5, 1, -1); Objects.Data[i] = obj; // } InitCompasRect(CompasRect); InitCompasRect(CompasObj); return true; }
int initOgreAR(aruco::CameraParameters camParams, unsigned char* buffer, std::string resourcePath) { /// INIT OGRE FUNCTIONS #ifdef _WIN32 root = new Ogre::Root(resourcePath + "plugins_win.cfg", resourcePath + "ogre_win.cfg"); #elif __x86_64__ || __ppc64__ root = new Ogre::Root(resourcePath + "plugins_x64.cfg", resourcePath + "ogre.cfg"); #else root = new Ogre::Root(resourcePath + "plugins.cfg", resourcePath + "ogre.cfg"); #endif if (!root->showConfigDialog()) return -1; Ogre::SceneManager* smgr = root->createSceneManager(Ogre::ST_GENERIC); /// CREATE WINDOW, CAMERA AND VIEWPORT Ogre::RenderWindow* window = root->initialise(true); Ogre::Camera *camera; Ogre::SceneNode* cameraNode; camera = smgr->createCamera("camera"); camera->setNearClipDistance(0.01f); camera->setFarClipDistance(10.0f); camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); camera->setPosition(0, 0, 0); camera->lookAt(0, 0, 1); double pMatrix[16]; camParams.OgreGetProjectionMatrix(camParams.CamSize,camParams.CamSize, pMatrix, 0.05,10, false); Ogre::Matrix4 PM(pMatrix[0], pMatrix[1], pMatrix[2] , pMatrix[3], pMatrix[4], pMatrix[5], pMatrix[6] , pMatrix[7], pMatrix[8], pMatrix[9], pMatrix[10], pMatrix[11], pMatrix[12], pMatrix[13], pMatrix[14], pMatrix[15]); camera->setCustomProjectionMatrix(true, PM); camera->setCustomViewMatrix(true, Ogre::Matrix4::IDENTITY); window->addViewport(camera); cameraNode = smgr->getRootSceneNode()->createChildSceneNode("cameraNode"); cameraNode->attachObject(camera); /// CREATE BACKGROUND FROM CAMERA IMAGE int width = camParams.CamSize.width; int height = camParams.CamSize.height; // create background camera image mPixelBox = Ogre::PixelBox(width, height, 1, Ogre::PF_R8G8B8, buffer); // Create Texture mTexture = Ogre::TextureManager::getSingleton().createManual("CameraTexture",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,width,height,0,Ogre::PF_R8G8B8,Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE); //Create Camera Material Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("CameraMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); Ogre::Technique *technique = material->createTechnique(); technique->createPass(); material->getTechnique(0)->getPass(0)->setLightingEnabled(false); material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false); material->getTechnique(0)->getPass(0)->createTextureUnitState("CameraTexture"); Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true); rect->setCorners(-1.0, 1.0, 1.0, -1.0); rect->setMaterial("CameraMaterial"); // Render the background before everything else rect->setRenderQueueGroup(Ogre::RENDER_QUEUE_BACKGROUND); // Hacky, but we need to set the bounding box to something big, use infinite AAB to always stay visible Ogre::AxisAlignedBox aabInf; aabInf.setInfinite(); rect->setBoundingBox(aabInf); // Attach background to the scene Ogre::SceneNode* node = smgr->getRootSceneNode()->createChildSceneNode("Background"); node->attachObject(rect); /// CREATE SIMPLE OGRE SCENE // add sinbad.mesh Ogre::ResourceGroupManager::getSingleton().addResourceLocation(resourcePath + "Sinbad.zip", "Zip", "Popular"); Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); for(int i=0; i<MAX_MARKERS; i++) { Ogre::String entityName = "Marker_" + Ogre::StringConverter::toString(i); Ogre::Entity* ogreEntity = smgr->createEntity(entityName, "Sinbad.mesh"); Ogre::Real offset = ogreEntity->getBoundingBox().getHalfSize().y; ogreNode[i] = smgr->getRootSceneNode()->createChildSceneNode(); // add entity to a child node to correct position (this way, entity axis is on feet of sinbad) Ogre::SceneNode *ogreNodeChild = ogreNode[i]->createChildSceneNode(); ogreNodeChild->attachObject(ogreEntity); // Sinbad is placed along Y axis, we need to rotate to put it along Z axis so it stands up over the marker // first rotate along X axis, then add offset in Z dir so it is over the marker and not in the middle of it ogreNodeChild->rotate(Ogre::Vector3(1,0,0), Ogre::Radian(Ogre::Degree(90))); ogreNodeChild->translate(0,0,offset,Ogre::Node::TS_PARENT); // mesh is too big, rescale! const float scale = 0.006675f; ogreNode[i]->setScale(scale, scale, scale); // Init animation ogreEntity->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE); if(i==0) { baseAnim[i] = ogreEntity->getAnimationState("HandsClosed"); topAnim[i] = ogreEntity->getAnimationState("HandsRelaxed"); } else if(i==1) { baseAnim[i] = ogreEntity->getAnimationState("Dance"); topAnim[i] = ogreEntity->getAnimationState("Dance"); } else if(i==2) { baseAnim[i] = ogreEntity->getAnimationState("RunBase"); topAnim[i] = ogreEntity->getAnimationState("RunTop"); } else { baseAnim[i] = ogreEntity->getAnimationState("IdleBase"); topAnim[i] = ogreEntity->getAnimationState("IdleTop"); } baseAnim[i]->setLoop(true); topAnim[i]->setLoop(true); baseAnim[i]->setEnabled(true); topAnim[i]->setEnabled(true); } /// KEYBOARD INPUT READING size_t windowHnd = 0; window->getCustomAttribute("WINDOW", &windowHnd); im = OIS::InputManager::createInputSystem(windowHnd); keyboard = static_cast<OIS::Keyboard*>(im->createInputObject(OIS::OISKeyboard, true)); return 1; }