예제 #1
0
//-------------------------------------------------------------------------------------
void UndeadLand::createScene(void)
{
  mCamera->setPosition(Ogre::Vector3(1683, 50, 2116));
  mCamera->lookAt(Ogre::Vector3(1963, 50, 1660));
  mCamera->setNearClipDistance(0.1);
  mCamera->setFarClipDistance(50000);

  if( mRoot->getRenderSystem()->getCapabilities()->hasCapability( Ogre::RSC_INFINITE_FAR_PLANE ) )
    mCamera->setFarClipDistance(0);
    
  Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
  lightdir.normalise();

  Ogre::Light* light = mSceneMgr->createLight("tstLight");
  light->setType(Ogre::Light::LT_DIRECTIONAL);
  light->setDirection(lightdir);
  light->setDiffuseColour(Ogre::ColourValue::White);
  light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));

  mSceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
  
  if( soundeng ) {
    //soundeng->play2D( "dist/media/sounds/Pong_Beat_100_bpm_www.loopartists.com.wav", true );
    soundeng->play2D( "dist/media/sounds/looperman-loop-00500098-00050813-shortbusmusic-piano-in-bm7-a-e.wav", true );
  }

  terrain = new TerrainEngine( "this is a ridiculously long string", mRoot, mSceneMgr, mCamera, light );
}
예제 #2
0
void CEditor::Create( HWND hWnd,int width,int height )
{
	GetCurrentDirectory(MAX_PATH, mCurDir);

	mpEntityMgr = new CEntityManager;
	mpPhysicsMgr = new CPhysicsManager;

	Ogre::NameValuePairList parms;
	parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)hWnd);
	mRenderWindow = mRoot->createRenderWindow("TerrainEditor", width, height, false, &parms);
	mhWnd = hWnd;
	mSceneManager = mRoot->createSceneManager(Ogre::ST_GENERIC, "MainScene");

	// Create the camera
	mCamera = mSceneManager->createCamera("PlayerCam");

	mCamera->setPosition(mTerrainPos + Ogre::Vector3(200, 400, 0));
	mCamera->lookAt(Ogre::Vector3(0, 50, 0));
	mCamera->setNearClipDistance(1);
	mCamera->setFarClipDistance(12000);

	mViewport = mRenderWindow->addViewport(mCamera);
	mViewport->setBackgroundColour(Ogre::ColourValue(0.5f,0.5f,0.5f));

	//SetupInput();
	loadResources();

	mGuiMgr = new OgreBites::GuiManager("BrowserControls", mRenderWindow, this);
	//mGuiMgr->showBackdrop("SdkTrays/Bands");
	mGuiMgr->getTrayContainer(OgreBites::TL_NONE)->hide();

	Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
	Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);

	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();

	Ogre::Light* l = mSceneManager->createLight("terrainLight");
	l->setType(Ogre::Light::LT_DIRECTIONAL);
	Ogre::Vector3 lightdir(0.1f, -0.3f, 0.1f);
	lightdir.normalise();
	l->setDirection(lightdir);
	l->setDiffuseColour(Ogre::ColourValue::White);
	l->setSpecularColour(Ogre::ColourValue(0.4f, 0.4f, 0.4f));
	mTerrainLight = l;
	mSceneManager->setAmbientLight(Ogre::ColourValue(0.2f, 0.2f, 0.2f));

	Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
	mRoot->addFrameListener(this);

	mGuiMgr->showFrameStats(OgreBites::TL_TOPRIGHT);

	mpEntityMgr->Create();
	mpPhysicsMgr->Create();

	// Alter the camera aspect ratio to match the viewport
	mCamera->setAspectRatio(
		Ogre::Real(mViewport->getActualWidth()) / Ogre::Real(mViewport->getActualHeight()));

	SetEditTool(NULL);
}
예제 #3
0
void DotSceneLoader::processTerrain(rapidxml::xml_node<>* XMLNode)
{
    Ogre::Real worldSize = getAttribReal(XMLNode, "worldSize");
    int mapSize = Ogre::StringConverter::parseInt(XMLNode->first_attribute("mapSize")->value());
    int rows = Ogre::StringConverter::parseInt(XMLNode->first_attribute("rows")->value());
    int columns = Ogre::StringConverter::parseInt(XMLNode->first_attribute("columns")->value());
    bool colourmapEnabled = getAttribBool(XMLNode, "colourmapEnabled");
    int colourMapTextureSize = Ogre::StringConverter::parseInt(XMLNode->first_attribute("colourMapTextureSize")->value());

    Ogre::Vector3 lightdir(0, -0.3, 0.75);
    lightdir.normalise();
    Ogre::Light* l = mSceneMgr->createLight("tstLight");
    l->setType(Ogre::Light::LT_DIRECTIONAL);
    l->setDirection(lightdir);
    l->setDiffuseColour(Ogre::ColourValue(1.0, 1.0, 1.0));
    l->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.6, 0.6, 0.6));

    mTerrainGlobalOptions->setMaxPixelError(1);
    mTerrainGlobalOptions->setCompositeMapDistance(2000);
    mTerrainGlobalOptions->setLightMapDirection(lightdir);
    mTerrainGlobalOptions->setCompositeMapAmbient(mSceneMgr->getAmbientLight());
    mTerrainGlobalOptions->setCompositeMapDiffuse(l->getDiffuseColour());

    mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, mapSize, worldSize);
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);

    rapidxml::xml_node<>* pElement;
    rapidxml::xml_node<>* pPageElement;

    // Process terrain pages (*)
    pElement = XMLNode->first_node("terrainPages");
    while(pElement)
    {
        pPageElement = pElement->first_node("terrainPage");
        while(pPageElement)
        {
            processTerrainPage(pPageElement);
            pPageElement = pPageElement->next_sibling("terrainPage");
        }
        pElement = pElement->next_sibling("terrainPages");
    }
    mTerrainGroup->loadAllTerrains(true);

    // process blendmaps
    pElement = XMLNode->first_node("terrainPages");
    while(pElement)
    {
        pPageElement = pElement->first_node("terrainPage");
        while(pPageElement)
        {
            processBlendmaps(pPageElement);
            pPageElement = pPageElement->next_sibling("terrainPage");
        }
        pElement = pElement->next_sibling("terrainPages");
    }
    mTerrainGroup->freeTemporaryResources();
    //mTerrain->setPosition(mTerrainPosition);
}
예제 #4
0
//-------------------------------------------------------------------------------------
void BasicTutorial3::createScene(void)
{
    mCamera->setPosition(Ogre::Vector3(1683, 50, 2116));
    mCamera->lookAt(Ogre::Vector3(1963, 50, 1660));
    mCamera->setNearClipDistance(0.1);
    mCamera->setFarClipDistance(50000);
 
    if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
    {
        mCamera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }
 
    Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
    Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);
 
    Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();
 
    Ogre::Light* light = mSceneMgr->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
 
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
 
    mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
 
    mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
    mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);
 
    configureTerrainDefaults(light);
 
    for (long x = 0; x <= 0; ++x)
        for (long y = 0; y <= 0; ++y)
            defineTerrain(x, y);
 
    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains(true);
 
    if (mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }
 
    mTerrainGroup->freeTemporaryResources();
 
}
예제 #5
0
//-------------------------------------------------------------------------------------
void TutorialApplication::createScene(void)
{
    /*Setting up the Camera*/
    mCamera->setPosition(Ogre::Vector3(1683,50,2116));
    mCamera->lookAt(Ogre::Vector3(1963,50,1660));
    mCamera->setNearClipDistance(0.1);
    bool infiniteClip = mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE);
    if(infiniteClip)
      mCamera->setFarClipDistance(0);
    else
      mCamera->setFarClipDistance(50000);
    
    /*Setting up a Light*/
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2,0.2,0.2));
    Ogre::Vector3 lightdir(0.55,-0.3,0.75);
    lightdir.normalise();
    Ogre::Light* light = mSceneMgr->createLight("TestLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4,0.4,0.4));
    
    /*Configuring the Terrain*/
    mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
    mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr,Ogre::Terrain::ALIGN_X_Z,513,12000.0);
    mTerrainGroup->setFilenameConvention(Ogre::String("terrain"),Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);
    configureTerrainDefaults(light);
    for(long x=0; x<=0; ++x)
      for(long y=0; y<=0; ++y)
         defineTerrain(x,y);
   mTerrainGroup->loadAllTerrains(true);
   if(mTerrainsImported)
   {
      Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
      while(ti.hasMoreElements())
      {
         Ogre::Terrain* t = ti.getNext()->instance;
         initBlendMaps(t);
      }
   }
   mTerrainGroup->freeTemporaryResources();
   
   /*Writing configureTerrainDefaults*/
   /*Writing defineTerrain*/
   /*Writing getTerrainImage*/
   /*Writing initBlendMaps*/
   //LE TEST MARCHE PAS :D //
   /*Terrain Loading Label*/
   /*Cleaning Up*/
   /*TODO SkyBoxes*/
}
예제 #6
0
void TerrainManager::createLight()
{
	Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
	lightdir.normalise();

	_Light = _OgreManager->getSceneManager()->createLight("GameLight");
	_Light->setType(Ogre::Light::LT_DIRECTIONAL);
	_Light->setDirection(lightdir);
	_Light->setDiffuseColour(Ogre::ColourValue::White);
	_Light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));

	_OgreManager->getSceneManager()->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
}
예제 #7
0
void Viewer::createScene()
{
    ogreRoot->loadPlugin("Plugin_BSPSceneManager");
    ogreRoot->loadPlugin("Plugin_CgProgramManager");
    ogreRoot->loadPlugin("Plugin_OctreeSceneManager");
//    ogreRoot->loadPlugin("Plugin_OctreeZone");
    ogreRoot->loadPlugin("Plugin_ParticleFX");
    ogreRoot->loadPlugin("Plugin_PCZSceneManager");
    loadResourses();
    Ogre::Vector3 lightdir(-0.55, -0.3, -0.75);
    lightdir.normalise();
    Ogre::Light* light = ogreSceneManager->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
    ogreSceneManager->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
    ogreCamera = ogreSceneManager->createCamera("myCamera");
    ogreCamera->setPosition(Ogre::Vector3(0,0,0));
    ogreCamera->lookAt(Ogre::Vector3(0,0,0));
    ogreCamera->setNearClipDistance(0.1);
    ogreCamera->setFarClipDistance(50000);


if (ogreRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
    {
        ogreCamera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }
ogreViewport = ogreRenderWindow->addViewport(ogreCamera);
setBackgroundColor(QColor(100,100,100));

ogreCamera->setAspectRatio(Ogre::Real(this->parentWidget()->width()) / Ogre::Real(this->parentWidget()->height()));
    Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);

    Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
        plane, 1500, 1500, 5, 5, true, 1, 30, 30, Ogre::Vector3::UNIT_Z);

    Ogre::Entity* entGround = ogreSceneManager->createEntity("GroundEntity", "ground");
    ogreSceneManager->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);

    entGround->setMaterialName("Examples/Rockwall");
    entGround->setCastShadows(false);
    ogreCamNode = ogreSceneManager->getRootSceneNode()->createChildSceneNode("CamNode1");
    ogreCamNode->attachObject(ogreCamera);
    mainNode = ogreSceneManager->getRootSceneNode()->createChildSceneNode("MainNode");
    updateCamPos();

//    Ogre::ResourceGroupManager::getSingleton().unloadUnreferencedResourcesInGroup("General",true);
//    Ogre::ResourceGroupManager::getSingleton().unloadUnreferencedResourcesInGroup("Popular",true);
//    Ogre::ResourceGroupManager::getSingleton().unloadUnreferencedResourcesInGroup("Essential",true);
}
예제 #8
0
void App::createScene(void)
{
	//change the gui
	m_pQuit->setPosition( CEGUI::UVector2( CEGUI::UDim(0.75f,0), CEGUI::UDim(0.05f,0) ) );
	//
	m_pHostServer->setVisible(false);
	m_pFindServer->setVisible(false);
	m_pTitle->setVisible(false);
	m_pDisconnect->setVisible(true);

	// Set the scene's lighting
	Ogre::Vector3 lightdir(0.55f, -0.3f, 0.75f);
	lightdir.normalise();
 
	m_pMainlight = mSceneMgr->createLight("MainLight");
	m_pMainlight->setType(Ogre::Light::LT_DIRECTIONAL);
	m_pMainlight->setDirection(lightdir);
	m_pMainlight->setDiffuseColour(Ogre::ColourValue::White);
	m_pMainlight->setSpecularColour(Ogre::ColourValue(0.4f, 0.4f, 0.4f));
 
	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2f, 0.2f, 0.2f));
	
	// World geometry
	mSceneMgr->setWorldGeometry("terrain.cfg");
 
	//create a player entity
	m_pPlayerEntity = new PlayerEntity("Player", m_NetworkManager.GetNodeUID(), *mSceneMgr, mCamera);

    Ogre::ColourValue fadeColour(0.9f, 0.9f, 0.9f);
    mSceneMgr->setFog(Ogre::FOG_LINEAR, fadeColour, 0.0f, 10, 1200);
    mWindow->getViewport(0)->setBackgroundColour(fadeColour);
 
    Ogre::Plane plane;
    plane.d = 100;
    plane.normal = Ogre::Vector3::NEGATIVE_UNIT_Y;
 
    //mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8, 500);
    mSceneMgr->setSkyPlane(true, plane, "Examples/CloudySky", 500, 20, true, 0.5, 150, 150);

	m_SceneSetup = true;
}
예제 #9
0
파일: main.cpp 프로젝트: Jordangc/Project
void masterFunc() {
	Octree t;
	
	vector3 cam(-0.5,-0.5, -800);
	vector3 camX(1,0,0);
	vector3 camY(0,1,0);
	vector3 camZ(0,0,1);
	
	BITMAP32 render(512,512);
	vector3 p;
	vector3 lightdir(-1,-1,1);
	vector3 lightdir2(0,1,0);
	lightdir.normalize();
	
	int treeSize;
	char * treeBuffer;
	
	//t.loadFromBitmaps("./dicom/IM_0001%03d.bmp", 200);
	//t.writeToFile("octree.dat");
	cout << "Loading octree data" << endl;
	t.readFromFile("octree.dat", treeBuffer, treeSize);
	
	MPI_Bcast (&treeSize, 1, MPI_INT, MASTER, MPI_COMM_WORLD);					//Broadcast header with tree size
	MPI_Bcast (treeBuffer,  treeSize, MPI_BYTE, MASTER, MPI_COMM_WORLD);      	//Broadcast tree
	cout << "Data sent from master node." << endl;
	int frames = 1;
	time_t startTime = time(0);
	for(int i = 0; i < frames; i++) {
		double xcenter = 30, zcenter = -25, radius = 500;
		RaytraceCamera camera(vector3(xcenter+radius*cos(i*2*PI/frames)+1,-9,zcenter+radius*sin(i*2*PI/frames)+1), vector3(xcenter,-10,zcenter));
		cout << "Generating rays..." << endl;
		vector<RayPixel> rays = camera.generateRays(512,512);
		cout << rays.size() << " rays generated." << endl;
		traceRays(rays, t, render);
		cout << "Loop " << i << ": done tracing rays!" << endl;
		time_t seconds = time(0);
		cout << "Frame " << i << " done at " << difftime(seconds, startTime) << endl;
		exportBMP(render,"render" + toString(i) + ".bmp");
	}

}
예제 #10
0
void BaseApplication::createScene(void)
{
	// Sky
	/**Ogre::Plane plane;
	plane.d = 100;
	plane.normal = Ogre::Vector3::NEGATIVE_UNIT_Y;

	mSceneMgr->setSkyPlane(true, plane, "Examples/CloudySky", 500, 20, true, 0.5, 150, 150);*/

	// Light
	Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
	lightdir.normalise();

	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3));

	mLight = mSceneMgr->createLight("TestLight");
	mLight->setType(Ogre::Light::LT_DIRECTIONAL);
	mLight->setDirection(lightdir);
	mLight->setDiffuseColour(Ogre::ColourValue::White);
	mLight->setSpecularColour(Ogre::ColourValue(0.5, 0.5, 0.5));
}
예제 #11
0
//-------------------------------------------------------------------------------------
void GameMain::createEnvir(void)
{
	// Light
    Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();

    Ogre::Light* light = mSceneMgr->createLight("tstLight");
    light->setType( Ogre::Light::LT_DIRECTIONAL );
    light->setDirection( lightdir );
    light->setDiffuseColour( Ogre::ColourValue::White );
    light->setSpecularColour( Ogre::ColourValue(0.4, 0.4, 0.4) );

	// 环境光
    mSceneMgr->setAmbientLight( Ogre::ColourValue(0.5, 0.5, 0.5) );

	// Sky
    Ogre::Plane plane;
    plane.d = 100;
    plane.normal = Ogre::Vector3::NEGATIVE_UNIT_Y;
    mSceneMgr->setSkyPlane(true, plane, "Examples/CloudySky", 500, 20, true, 0.5, 150, 150);
}
예제 #12
0
void CSceneEditorView::EngineSetup(void)
{
	Ogre::Root *Root = ((CSceneEditorApp*)AfxGetApp())->m_Engine->GetRoot();
	m_SceneManager = Root->createSceneManager(Ogre::ST_GENERIC, "SceneEditor");
 
    //
    // Create a render window
    // This window should be the current ChildView window using the externalWindowHandle
    // value pair option.
    //

    Ogre::NameValuePairList parms;
    parms["externalWindowHandle"] = Ogre::StringConverter::toString((long)m_hWnd);
    parms["vsync"] = "true";

	CRect   rect;
    GetClientRect(&rect);
	Ogre::RenderTarget *RenderWindow = Root->getRenderTarget("SceneEditor");

	if (RenderWindow == NULL)
	{
	try
	{
		m_RenderWindow = Root->createRenderWindow("SceneEditor", rect.Width(), rect.Height(), false, &parms);
	}
    catch(...)
	{
		MessageBox("Cannot initialize\nCheck that graphic-card driver is up-to-date", "Initialize Render System", MB_OK | MB_ICONSTOP);
		exit(EXIT_SUCCESS);
	}
	}
// Load resources
	Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

    // Create the camera
	m_Camera = m_SceneManager->createCamera("Camera");
	m_Camera->setPosition(Ogre::Vector3(1683, 50, 2116));
    m_Camera->lookAt(Ogre::Vector3(0, 0, 0));
    m_Camera->setNearClipDistance(0.1);
    m_Camera->setFarClipDistance(50000);
 
    if (m_Root->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
    {
        m_Camera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }

	m_Camera->setAutoTracking(false);
	m_Camera->setFixedYawAxis(true);
	m_Camera->yaw(Ogre::Radian(0));
	m_Camera->pitch(Ogre::Radian(0));

	Ogre::SceneNode *CameraNode = NULL;
	CameraNode = m_SceneManager->getRootSceneNode()->createChildSceneNode("CameraNode");
 
	m_SceneManager->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));

	//Create viewport
	Ogre::Viewport* Viewport = NULL;
	
	if (0 == m_RenderWindow->getNumViewports())
	{
		Viewport = m_RenderWindow->addViewport(m_Camera);
		Viewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
	}

    // Alter the camera aspect ratio to match the viewport
    m_Camera->setAspectRatio(Ogre::Real(rect.Width()) / Ogre::Real(rect.Height()));
	
	m_SceneManager->setSkyDome(true, "Examples/CloudySky", 5, 8);
	Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
    Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);
 
    Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();
 
	Ogre::Light* light = m_SceneManager->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
 
	m_SceneManager->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
	
	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
	mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(m_SceneManager, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
    mTerrainGroup->setFilenameConvention(Ogre::String("Terrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);
 
    configureTerrainDefaults(light);
 
    for (long x = 0; x <= 0; ++x)
        for (long y = 0; y <= 0; ++y)
            defineTerrain(x, y);
 
    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains(true);
 
    if (mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }
 
    mTerrainGroup->freeTemporaryResources();
}
예제 #13
0
파일: Geometry.cpp 프로젝트: WofloW/ZooTrip
Geometry::Geometry()
	: mTerrainGroup(0)
	, mTerrainPaging(0)
	, mPageManager(0)
	, mPagedWorld(0)
	, mTerrainPagedWorldSection(0)
	, mTerrainPos(0, 0, 0) {
		
		setupView();
		m_TrayMgr = InputHandler::getSingleton()->getSdkTrayMgr();
		mInfoLabel = m_TrayMgr->createLabel(OgreBites::TL_TOP, "TInfo", "", 350);

		mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();

		//setDragLook(true);

		MaterialManager::getSingleton().setDefaultTextureFiltering(TFO_ANISOTROPIC);
		MaterialManager::getSingleton().setDefaultAnisotropy(7);

		//OgreTrip::getSceneMgr()->setFog(FOG_LINEAR, ColourValue(0.7, 0.7, 0.8), 0, 4000, 10000);

		LogManager::getSingleton().setLogDetail(LL_BOREME);

		Vector3 lightdir(0.55, -0.3, 0.75);
		lightdir.normalise();

		Light * l = OgreTrip::getSceneMgr()->createLight("tstLight");
		l->setType(Light::LT_DIRECTIONAL);
		l->setDirection(lightdir);
		l->setDiffuseColour(ColourValue::White);
		l->setSpecularColour(ColourValue(0.4, 0.4, 0.4));

		OgreTrip::getSceneMgr()->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));

		mTerrainGroup = OGRE_NEW TerrainGroup(OgreTrip::getSceneMgr(), Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE);
		mTerrainGroup->setFilenameConvention(ENDLESS_TERRAIN_FILE_PREFIX, ENDLESS_TERRAIN_FILE_SUFFIX);
		mTerrainGroup->setOrigin(mTerrainPos);
		mTerrainGroup->setAutoUpdateLod( TerrainAutoUpdateLodFactory::getAutoUpdateLod(BY_DISTANCE) );

		configureTerrainDefaults(l);

		// Paging setup
		mPageManager = OGRE_NEW PageManager();
		// Since we're not loading any pages from .page files, we need a way just
		// to say we've loaded them without them actually being loaded
		mPageManager->setPageProvider( & mDummyPageProvider);
		mPageManager->addCamera(OgreTrip::getCamera());
		mPageManager->setDebugDisplayLevel(0);
		mTerrainPaging = OGRE_NEW TerrainPaging(mPageManager);
		mPagedWorld = mPageManager->createWorld();
		mTerrainPagedWorldSection = mTerrainPaging->createWorldSection(mPagedWorld, mTerrainGroup, 400, 500,
			ENDLESS_PAGE_MIN_X, ENDLESS_PAGE_MIN_Y,
			ENDLESS_PAGE_MAX_X, ENDLESS_PAGE_MAX_Y);

		//      mPerlinNoiseTerrainGenerator = OGRE_NEW PerlinNoiseTerrainGenerator;
		//      mTerrainPagedWorldSection->setDefiner( mPerlinNoiseTerrainGenerator );
		mTerrainPagedWorldSection->setDefiner( OGRE_NEW SimpleTerrainDefiner );
		TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
		while(ti.hasMoreElements())
		{
			Terrain* t = ti.getNext()->instance;
			initBlendMaps(t);
		}
		mTerrainGroup->freeTemporaryResources();

		OgreTrip::getSceneMgr()->setSkyBox(true, "Examples/CloudyNoonSkyBox");
		


}
예제 #14
0
void OgreWidget::setupTerrain()
{
    //    bool blankTerrain = false;


    mTerrainPos = Ogre::Vector3(1.0, -75.1, 1.0);

    //    mEditMarker = ogreSceneManager->createEntity("editMarker", "sphere.mesh");
    //    mEditNode = ogreSceneManager->getRootSceneNode()->createChildSceneNode();
    //    mEditNode->attachObject(mEditMarker);
    //    mEditNode->setScale(0.05, 0.05, 0.05);

    // These two lines makes the terrain textures look nicer:
    Ogre::MaterialManager::getSingleton().setDefaultTextureFiltering(Ogre::TFO_ANISOTROPIC);
    Ogre::MaterialManager::getSingleton().setDefaultAnisotropy(7);

    //mSceneManager->setFog(Ogre::FOG_EXP, Ogre::ColourValue(0.1, 0.1, 0.1), 0.01, 500, 1000);

    Ogre::LogManager::getSingleton().setLogDetail(Ogre::LL_BOREME);

    // Set up directional and ambient lights
    // THis first light is used for terrain shadows
    Ogre::Vector3 lightdir(-0.55, -0.3, 0.75);
    lightdir.normalise();
    Ogre::Light* light = mSceneManager->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue(1.0, 1.0, 1.0));
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));

    mSceneManager->setAmbientLight(Ogre::ColourValue(0.3, 0.3, 0.3));

    Ogre::Vector3 lightdir2(-0.55, -0.3, -0.75);
    lightdir2.normalise();
    Ogre::Light* light2 = mSceneManager->createLight("tstLight2");
    light2->setType(Ogre::Light::LT_DIRECTIONAL);
    light2->setDirection(lightdir2);
    light2->setDiffuseColour(Ogre::ColourValue(0.4, 0.4, 0.4));
    light2->setSpecularColour(Ogre::ColourValue(0.2, 0.2, 0.2));

    Ogre::Vector3 lightdir3(0.55, -0.2, -0.75);
    lightdir3.normalise();
    Ogre::Light* light3 = mSceneManager->createLight("tstLight3");
    light3->setType(Ogre::Light::LT_DIRECTIONAL);
    light3->setDirection(lightdir3);
    light3->setDiffuseColour(Ogre::ColourValue(0.5, 0.5, 0.5));
    light3->setSpecularColour(Ogre::ColourValue(0.1, 0.1, 0.1));

    Ogre::Vector3 lightdir4(-0.55, -0.2, 0.75);
    lightdir4.normalise();
    Ogre::Light* light4 = mSceneManager->createLight("tstLight4");
    light4->setType(Ogre::Light::LT_DIRECTIONAL);
    light4->setDirection(lightdir4);
    light4->setDiffuseColour(Ogre::ColourValue(0.3, 0.3, 0.3));
    light4->setSpecularColour(Ogre::ColourValue(0.2, 0.2, 0.2));


    mTerrainGroup = new Ogre::TerrainGroup(mSceneManager, Ogre::Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE);
    mTerrainGroup->setFilenameConvention(Ogre::String("cachedterrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(mTerrainPos);

    mTerrainGlobals = new Ogre::TerrainGlobalOptions();
    configureTerrainDefaults(light);

    for(long x = TERRAIN_PAGE_MIN_X; x <= TERRAIN_PAGE_MAX_X; ++x)
        for (long y = TERRAIN_PAGE_MIN_Y; y <= TERRAIN_PAGE_MAX_Y; ++y)
            defineTerrain(x, y);

    // sync load since we NEED everything in place when we start
    mTerrainGroup->loadAllTerrains(true);

    // calculate the blend maps of all terrains
    if(mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }

    mTerrainGroup->freeTemporaryResources();

    // create a few entities on the terrain
    placeObjectOnTerrain("tudorhouse.mesh", Ogre::Vector3(10, 6.4, -10), 0, Ogre::Vector3(0.012, 0.012, 0.012));
    placeObjectOnTerrain("church.mesh", Ogre::Vector3(-7, 0, 22), 90);
    placeObjectOnTerrain("house1.mesh", Ogre::Vector3(-23, 0, -10), 20);
    placeObjectOnTerrain("house2.mesh", Ogre::Vector3(22, 3, 20), -120);
    placeObjectOnTerrain("windmill.mesh", Ogre::Vector3(-35, -0.2, 20), 120);

    // palmtree placeObjectOnTerrain("tree1.mesh", Ogre::Vector3(0, 0, 10), 00, Ogre::Vector3(0.002, 0.002, 0.002));

    placeObjectOnTerrain("tree2.mesh", Ogre::Vector3(0, 0, -30), 10, Ogre::Vector3(0.01, 0.01, 0.01));

    // big wind-skewed guy
    placeObjectOnTerrain("tree3.mesh", Ogre::Vector3(10, 0, 35), 20, Ogre::Vector3(0.01, 0.01, 0.01));

    // ???
    placeObjectOnTerrain("tree4.mesh", Ogre::Vector3(33, 0, -15), 30, Ogre::Vector3(0.01, 0.01, 0.01));

    // ???
    placeObjectOnTerrain("tree5.mesh", Ogre::Vector3(-40, 0, -25), 40, Ogre::Vector3(0.01, 0.01, 0.01));

    // the bald tree goes into the center
    placeObjectOnTerrain("tree6.mesh", Ogre::Vector3(-3, 0, -2), 50, Ogre::Vector3(0.008, 0.008, 0.008));

    // tanne
    placeObjectOnTerrain("tree7.mesh", Ogre::Vector3(-22, 0, 28), 60, Ogre::Vector3(0.003, 0.003, 0.003));

    mSceneManager->setSkyBox(true, "Examples/CloudyNoonSkyBox");
}
예제 #15
0
void begin_terrain(BATB& batb)
{
// http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Basic+Tutorial+3
// http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Ogre+Terrain+System
// libs/ogre/Samples/EndlessWorld/include/EndlessWorld.h

#ifdef USE_SAMPLE_TERRAIN
    if (!Ogre::ResourceGroupManager::getSingleton().resourceGroupExists("Terrain"))
        Ogre::ResourceGroupManager::getSingleton().createResourceGroup("Terrain");
#endif

    // create object, which becomes a singleton
    // Terrain::setResourceGroup overrides this (??)
    terrain_globals = OGRE_NEW TerrainGlobalOptions();


    MaterialManager::getSingleton().setDefaultTextureFiltering(TFO_ANISOTROPIC);
    MaterialManager::getSingleton().setDefaultAnisotropy(7);

#ifdef USE_SAMPLE_ENDLESSWORLD
    scenemgr->setFog(FOG_LINEAR, ColourValue(0.7, 0.7, 0.8), 0, 4000, 10000);
#endif
#ifdef USE_SAMPLE_TERRAIN
    scenemgr->setFog(FOG_LINEAR, ColourValue(0.7, 0.7, 0.8), 0, 10000, 25000); // Terrain
#endif


    //LogManager::getSingleton().setLogDetail(LL_BOREME); // ??

    Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();

    Light* l = scenemgr->createLight("tstLight");
    l->setType(Light::LT_DIRECTIONAL);
    l->setDirection(lightdir);
    l->setDiffuseColour(ColourValue::White);
#ifdef USE_SAMPLE_ENDLESSWORLD
    l->setSpecularColour(ColourValue(0.1, 0.1, 0.1));
#endif
#ifdef USE_SAMPLE_TERRAIN
    l->setSpecularColour(ColourValue(0.4, 0.4, 0.4));
#endif

    scenemgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

    terrain_group = OGRE_NEW TerrainGroup(scenemgr, Terrain::ALIGN_X_Z, TERRAIN_SIZE, TERRAIN_WORLD_SIZE);
#ifdef USE_SAMPLE_ENDLESSWORLD
    terrain_group->setFilenameConvention(ENDLESS_TERRAIN_FILE_PREFIX, ENDLESS_TERRAIN_FILE_SUFFIX);
    terrain_group->setAutoUpdateLod( TerrainAutoUpdateLodFactory::getAutoUpdateLod(BY_DISTANCE) );
#endif
#ifdef USE_SAMPLE_TERRAIN
    terrain_group->setFilenameConvention(TERRAIN_FILE_PREFIX, TERRAIN_FILE_SUFFIX);
    terrain_group->setResourceGroup("Terrain");
#endif


////////////////////////////////////////////////////////////////////////////////
// configureTerrainDefaults
//
    // Configure global
    terrain_globals->setMaxPixelError(8);
    // testing composite map
    terrain_globals->setCompositeMapDistance(3000);
    //terrain_globals->setUseRayBoxDistanceCalculation(true);
    terrain_globals->getDefaultMaterialGenerator()->setLightmapEnabled(false);

    terrain_globals->setCompositeMapAmbient(scenemgr->getAmbientLight());
    terrain_globals->setCompositeMapDiffuse(l->getDiffuseColour());    terrain_globals->setLightMapDirection(l->getDerivedDirection());

    // Configure default import settings for if we use imported image
    Terrain::ImportData& defaultimp = terrain_group->getDefaultImportSettings();
    defaultimp.terrainSize = TERRAIN_SIZE;
    defaultimp.worldSize = TERRAIN_WORLD_SIZE;
    defaultimp.inputScale = 600;
    defaultimp.minBatchSize = 33;
    defaultimp.maxBatchSize = 65;
    // textures
    // see 'initBlendMaps' below 
    defaultimp.layerList.resize(3);
    defaultimp.layerList[0].worldSize = 100; // scale layer
    defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_diffusespecular.dds");
    defaultimp.layerList[0].textureNames.push_back("dirt_grayrocky_normalheight.dds");
    defaultimp.layerList[1].worldSize = 30; // scale layer
    defaultimp.layerList[1].textureNames.push_back("grass_green-01_diffusespecular.dds");
    defaultimp.layerList[1].textureNames.push_back("grass_green-01_normalheight.dds");
    defaultimp.layerList[2].worldSize = 200; // scale layer
    defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_diffusespecular.dds");
    defaultimp.layerList[2].textureNames.push_back("growth_weirdfungus-03_normalheight.dds");
////////////////////////////////////////////////////////////////////////////////

    // Paging setup
#ifndef USE_SAMPLE_TERRAIN
    page_manager = OGRE_NEW PageManager();
    // Since we're not loading any pages from .page files, we need a way just 
    // to say we've loaded them without them actually being loaded
    page_manager->setPageProvider(&dummy_page_provider);
    page_manager->addCamera(camera);
    page_manager->setDebugDisplayLevel(0);
    terrain_paging = OGRE_NEW TerrainPaging(page_manager);
    paged_world = page_manager->createWorld();
    paged_world_section = terrain_paging->createWorldSection(paged_world, terrain_group, 
#ifdef USE_SAMPLE_ENDLESSWORLD
            400, 500, 
            ENDLESS_PAGE_MIN_X, ENDLESS_PAGE_MIN_Y, 
            ENDLESS_PAGE_MAX_X, ENDLESS_PAGE_MAX_Y);
#endif
#ifdef USE_SAMPLE_TERRAIN
            400, 500, 
            ENDLESS_PAGE_MIN_X, ENDLESS_PAGE_MIN_Y, 
            ENDLESS_PAGE_MAX_X, ENDLESS_PAGE_MAX_Y);
            //2000, 3000,
            //TERRAIN_PAGE_MIN_X, TERRAIN_PAGE_MIN_Y,
            //TERRAIN_PAGE_MAX_X, TERRAIN_PAGE_MAX_Y);
#endif
#endif

#ifdef USE_SAMPLE_ENDLESSWORLD
    perlin_noise = OGRE_NEW PerlinNoiseTerrainGenerator( 3.3, 2.2, 10, 128, 0.4 );
    paged_world_section->setDefiner( perlin_noise );
//		paged_world_section->setDefiner( OGRE_NEW SimpleTerrainDefiner );

        TerrainGroup::TerrainIterator ti = terrain_group->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }

#endif
#ifdef USE_SAMPLE_TERRAIN
    bool blankTerrain = false;
    for (long x = TERRAIN_PAGE_MIN_X; x <= TERRAIN_PAGE_MAX_X; ++x)
        for (long y = TERRAIN_PAGE_MIN_Y; y <= TERRAIN_PAGE_MAX_Y; ++y)
            defineTerrain(x, y, blankTerrain);
    // sync load since we want everything in place when we start
    terrain_group->loadAllTerrains(true);
    // ^FIXME:
    //  loadAllTerrains does something to our GL context/state, causing wrong output until
    //  OGRE::output called. the error is caused in OgreTerrainGroup::loadTerrainImpl when
    //  a work request is added to Ogre. The request handler is OgreTerrainGroup, but I 
    //  have not tracked the error there and further down.

    if (terrains_imported)
    {
        TerrainGroup::TerrainIterator ti = terrain_group->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }
#endif

    terrain_group->freeTemporaryResources();

    scenemgr->setSkyBox(true, "Examples/CloudyNoonSkyBox");

#ifdef USE_SAMPLE_TERRAIN
    camera->setPosition(terrain_pos + Vector3(1683, 50, 2116));
    camera->lookAt(Vector3(1963, 50, 1660));
    camera->setNearClipDistance(0.1);
    camera->setFarClipDistance(50000);
#endif
#ifdef USE_SAMPLE_ENDLESSWORLD
    // view
    Vector3 worldCenter(
            (ENDLESS_PAGE_MAX_X+ENDLESS_PAGE_MIN_X) / 2 * TERRAIN_WORLD_SIZE,
            0,
            -(ENDLESS_PAGE_MAX_Y+ENDLESS_PAGE_MIN_Y) / 2 * TERRAIN_WORLD_SIZE
            );
    camera->setPosition(terrain_pos +worldCenter);
    camera->lookAt(terrain_pos);
    camera->setNearClipDistance(0.1);
    camera->setFarClipDistance(50000);

#endif

    if (batb.ogre.ogre_root->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE))
    {
        camera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }
               
}
예제 #16
0
void MyGame::createScene(void)
{   
	//tutorial 3
	mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5, 8); // um coubo em volta da camera com textura

	mCamera->setPosition(Ogre::Vector3(100, 400, 100));
    mCamera->lookAt(Ogre::Vector3(10, 400, 0));
    mCamera->setNearClipDistance(0.1);
    mCamera->setFarClipDistance(50000);
 
    if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
    {
        mCamera->setFarClipDistance(0);   // enable infinite far clip distance if we can
    }

	Ogre::Vector3 lightdir(0.55, -0.3, 0.75);
    lightdir.normalise();
 
    Ogre::Light* light = mSceneMgr->createLight("tstLight");
    light->setType(Ogre::Light::LT_DIRECTIONAL);
    light->setDirection(lightdir);
    light->setDiffuseColour(Ogre::ColourValue::White);
    light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));
 
    mSceneMgr->setAmbientLight(Ogre::ColourValue(0.2, 0.2, 0.2));
	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions();
	mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(mSceneMgr, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f);
    mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
    mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);

	configureTerrainDefaults(light);
	for (long x = 0; x <= 0; ++x)
        for (long y = 0; y <= 0; ++y)
            defineTerrain(x, y);
 
    // sync load since we want everything in place when we start
    mTerrainGroup->loadAllTerrains(true);

	if (mTerrainsImported)
    {
        Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
        while(ti.hasMoreElements())
        {
            Ogre::Terrain* t = ti.getNext()->instance;
            initBlendMaps(t);
        }
    }

	mTerrainGroup->freeTemporaryResources();

	//ate o tutorial 2
//	//== faz o chao =================================================
//	Ogre::Plane plane(Ogre::Vector3::UNIT_Y, -10);
//	Ogre::MeshManager::getSingleton().createPlane("plane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
//1500,1500,20,20,true,1,5,5,Ogre::Vector3::UNIT_Z);// até aqui é como se eu criasse a .mesh do plano
//	Ogre::Entity* floor = mSceneMgr->createEntity("floor", "plane");
//	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(floor);
//	floor->setMaterialName("Examples/BeachStones"); //põe uma textura no plano/chão
//
/*	//== coloca um boneco na cena  ==================================
	Ogre::Entity* someGuy = mSceneMgr->createEntity("someGuy","Sinbad.mesh");
	Ogre::SceneNode* node_someGuy = mSceneMgr->createSceneNode("node_someGuy"); //criei um nó para o someGuy
	mSceneMgr->getRootSceneNode()->addChild(node_someGuy);// colocoquei o nó do someGuy no nó raiz
	node_someGuy->attachObject(someGuy); //coloquei o someGuy (entidade) no nó correspondente
	node_someGuy->setPosition(10,450,0);
	node_someGuy->scale(8,8,8);
*/
	
	Ogre::Entity *sphere = mSceneMgr->createEntity("sphere", "Sinbad.mesh");
	Ogre::SceneNode* node_sphere = mSceneMgr->createSceneNode("node_sphere"); //criei um nó para o someGuy
	
	mSceneMgr->getRootSceneNode()->addChild(node_sphere);// colocoquei o nó do someGuy no nó raiz
	node_sphere->attachObject(sphere); //coloquei o someGuy (entidade) no nó correspondente
	node_sphere->setPosition(-10,450,0);
	node_sphere->scale(5,5,5);	
	
	physicsManager.createGround();
	physicsManager.createSphere();

	
//	Ogre::SceneNode* node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode(name);
     
//    btRigidBody &body = mPhysics.createBody(btTransform(btQuaternion::getIdentity(), btVector3(pos.x, pos.y, pos.z)), mass, shape);
     
//    mObjects.push_back(new SceneObject(*node1, body));
     
//    Ogre::Entity *entity = mSceneMgr->createEntity(name, "Prefab_Cube");
//    node1->attachObject(entity);
 
//    node1->setScale(size.x / 100.0f, size.y / 100.0f, size.z / 100.0f);
	
//	//== outro boneco na cena  =======================================
//	Ogre::Entity* anotherGuy = mSceneMgr->createEntity("anotherGuy","ninja.mesh");
//	Ogre::SceneNode* node_anotherGuy = mSceneMgr->createSceneNode("node_anotherGuy"); //criei um nó para o anotherGuy
//	mSceneMgr->getRootSceneNode()->addChild(node_anotherGuy);// colocoquei o nó do anotherGuy no nó raiz
//	node_anotherGuy->attachObject(anotherGuy); //coloquei o anotherGuy (entidade) no nó correspondente
//	node_anotherGuy->setPosition(10,-10,20);
//	node_anotherGuy->scale(0.15,0.15,0.15);
//	
//	//== luz =========================================================
//	Ogre::SceneNode* node_light = mSceneMgr->createSceneNode("node_light");
//	mSceneMgr->getRootSceneNode()->addChild(node_light);
//	Ogre::Light* light1 = mSceneMgr->createLight("light1");
//	light1->setType(Ogre::Light::LT_DIRECTIONAL);//
//	//light1->setPosition(0,20,0);
//    light1->setDiffuseColour(1.0f,1.0f,1.0f);// cor em RGB de 0 a 1
//	light1->setDirection(Ogre::Vector3(1,-1,0));
//	mSceneMgr->setAmbientLight(Ogre::ColourValue(0.7, 0.7, 0.7)); // alterea aqui pra clarear ou escurecer a tela
//	mSceneMgr->setShadowTechnique(Ogre:: SHADOWTYPE_STENCIL_ADDITIVE);// ativa sombra dos 3d no plano
	//btBroadphaseInterface* broadphase = new btDbvtBroadphase();
}
예제 #17
0
파일: Game.cpp 프로젝트: soullem/Dawn
void Game::initialize(Ogre::Camera *camera, EventManager *handler)
{
	_handler = handler;
	_camera = camera;
	
	gSceneManager->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));
	gSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_MODULATIVE);
	
	Ogre::Vector3 lightdir(0.55, -0.3, 0.75); lightdir.normalise();  
	Ogre::Light* light = gSceneManager->createLight("tstLight"); 
	light->setType(Ogre::Light::LT_DIRECTIONAL); 
	light->setDirection(lightdir); 
	light->setDiffuseColour(Ogre::ColourValue::White); 
	light->setSpecularColour(Ogre::ColourValue(0.4, 0.4, 0.4));

	mTerrainGlobals = OGRE_NEW Ogre::TerrainGlobalOptions(); 
	mTerrainGroup = OGRE_NEW Ogre::TerrainGroup(gSceneManager, Ogre::Terrain::ALIGN_X_Z, 513, 12000.0f); 
	mTerrainGroup->setFilenameConvention(Ogre::String("BasicTutorial3Terrain"), Ogre::String("dat"));
	mTerrainGroup->setOrigin(Ogre::Vector3::ZERO);  
	configureTerrainDefaults(light); 

	for (long x = 0; x <= 0; ++x) 
		for (long y = 0; y <= 0; ++y) 
			defineTerrain(x, y);
	
	// sync load since we want everything in place when we start 
	mTerrainGroup->loadAllTerrains(true);
	if (mTerrainsImported) { 
		Ogre::TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
		while(ti.hasMoreElements()) { 
			Ogre::Terrain* t = ti.getNext()->instance; 
			initBlendMaps(t);
		}
	}
	mTerrainGroup->freeTemporaryResources();

	_werewolf.create("Werewolf");
	_werewolf.setMesh("Werewolf", "WereVixen.mesh");
	_werewolf.setPosition(Ogre::Vector3(1693, 20, 2090));
	_werewolf.setScale(Ogre::Vector3(5, 5, 5));
	_werewolf.rotate(Ogre::Radian(1.57), Ogre::Radian(3.14), Ogre::Radian(0));

	_monster.create("Mobbie");
	_monster.setMesh("Mobbie", "Spider.mesh", Action::ACT_IDLE | Action::ACT_WALK);
	_monster.setPosition(Ogre::Vector3(1708, 20, 2005));
	_monster.setScale(Ogre::Vector3(2, 2, 2));
	_monster.rotate(Ogre::Radian(0), Ogre::Radian(3.14), Ogre::Radian(0));
	
	_streetLamp.create("StreetLamp");
	_streetLamp.setMesh("StreetLamp", "StreetLamp1.mesh");
	_streetLamp.setPosition(Ogre::Vector3(1703, mTerrainGroup->getHeightAtWorldPosition(Ogre::Vector3(1703, 0, 1110)), 1110));
	_streetLamp.setScale(Ogre::Vector3(2.5, 2.5, 2.5));
	_streetLamp.setRotation(Ogre::Radian(0), Ogre::Radian(1.57), Ogre::Radian(0));

	_sellingHouse.create("SellingHouse");
	_sellingHouse.setMesh("SellingHouse", "SellingHouse.mesh");
	_sellingHouse.setPosition(Ogre::Vector3(1803,mTerrainGroup->getHeightAtWorldPosition(Ogre::Vector3(1903, 0, 1870)), 1570));
	_sellingHouse.setScale(Ogre::Vector3(2.0, 2.0, 2.0));

	Ogre::Plane skybox;
	skybox.d = 100; 
	skybox.normal = Ogre::Vector3::NEGATIVE_UNIT_Y;  
	gSceneManager->setSkyPlane(true, skybox, "Examples/CloudySky", 500, 20, true, 0.5, 150, 150); 

	// set camera
	_camera->setPosition(_werewolf.position()+Ogre::Vector3(0, 10, 100)); 
	_camera->lookAt(_werewolf.position());
	_camera->setNearClipDistance(5);  
	_camera->setFarClipDistance(0);
}