コード例 #1
0
ファイル: IntroScene.cpp プロジェクト: charuwat/code
	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);
	
	}
コード例 #2
0
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);
}
コード例 #3
0
void Ogre3DRendererPlugin::setupRTT() {
  if(!SBS) return;

  rtt_texture = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
  renderTexture = rtt_texture->getBuffer()->getRenderTarget();

  renderTexture->addViewport(mCamera2);
  renderTexture->getViewport(0)->setClearEveryFrame(true);
  renderTexture->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
  renderTexture->getViewport(0)->setOverlaysEnabled(false);

  rtt_texture2 = Ogre::TextureManager::getSingleton().createManual("RttTex2", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
  renderTexture2 = rtt_texture2->getBuffer()->getRenderTarget();

  renderTexture2->addViewport(mCamera2);
  renderTexture2->getViewport(0)->setClearEveryFrame(true);
  renderTexture2->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
  renderTexture2->getViewport(0)->setOverlaysEnabled(false);

  Ogre::Rectangle2D *mMiniScreen = new Ogre::Rectangle2D(true);
  mMiniScreen->setCorners(0.0f, 1.0f, 1.0f, -1.0f);//mMiniScreen->setCorners(0.5f, -0.5f, 1.0f, -1.0f);
  mMiniScreen->setBoundingBox(Ogre::AxisAlignedBox(-100000.0f * Ogre::Vector3::UNIT_SCALE, 100000.0f * Ogre::Vector3::UNIT_SCALE));

  Ogre::SceneNode* miniScreenNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("MiniScreenNode");
  miniScreenNode->attachObject(mMiniScreen);
  Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("BarrelDistort");
  material->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("RttTex");
  mMiniScreen->setMaterial("BarrelDistort");



  Ogre::Rectangle2D *mMiniScreen2 = new Ogre::Rectangle2D(true);
  mMiniScreen2->setCorners(-1.0f, 1.0f, 0.0f, -1.0f);
  mMiniScreen2->setBoundingBox(Ogre::AxisAlignedBox(-100000.0f * Ogre::Vector3::UNIT_SCALE, 100000.0f * Ogre::Vector3::UNIT_SCALE));
  Ogre::SceneNode* miniScreenNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("MiniScreenNode2");
  miniScreenNode2->attachObject(mMiniScreen2);
  Ogre::MaterialPtr material2 = Ogre::MaterialManager::getSingleton().getByName("BarrelDistort");
  material2->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("RttTex2");
  mMiniScreen2->setMaterial("BarrelDistort");
}
コード例 #4
0
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));
}
コード例 #5
0
ファイル: ar_ogre_sample.cpp プロジェクト: jwatte/orsens
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;
}