Exemplo n.º 1
0
glm::vec4 LightManager::GetSunlightDirection() const
{
	float angle = 2.0f * 3.14159f * m_sunTimer.GetAlpha();
	glm::vec4 sunDirection(0.0f);
	sunDirection[0] = sinf(angle);
	sunDirection[1] = cosf(angle);

	//Keep the sun from being perfectly centered overhead.
	sunDirection = glm::rotate(glm::mat4(1.0f), 5.0f, glm::vec3(0.0f, 1.0f, 0.0f)) * sunDirection;

	return sunDirection;
}
Exemplo n.º 2
0
Orbit::Orbit(Main* _main)
  : main(_main), planetFrontBuffer(NULL), planetBackBuffer(NULL), frameTime(0.1), meshGeneration(0), station(NULL), mExclusiveInput(false)
{
  for(int iProt = 0; iProt < 5; ++iProt) quickPrototypes[iProt] = NULL;

  LoadingScreen::tick(L"Orbit::SceneManager");
  Root& ogreRoot = Root::getSingleton();
  sceneManager = static_cast<OctreeSceneManager*>(ogreRoot.getSceneManager(ST_GENERIC));
  sceneManager->_setDestinationRenderSystem(ogreRoot.getRenderSystem());
  sceneManager->setSkyBox(true, "ShortHike/Orbit/Skybox_Stars");
  // Make this a display option
//   sceneManager->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);
  sceneManager->setAmbientLight(ColourValue(0.35, 0.35, 0.35));

  rootNode = sceneManager->getRootSceneNode();

  LoadingScreen::tick(L"Orbit::Lights");
  Light* sunLight = sceneManager->createLight("SunLight");
  sunLight->setType(Light::LT_DIRECTIONAL);
  Vector sunDirection(-80, -4, -100);
  sunDirection.normalise();
  sunLight->setPosition(80, 4, 100);
  sunLight->setDirection(sunDirection);
  sunLight->setDiffuseColour(.9f, .9f, .9f);
  sunLight->setSpecularColour(1.0f, 1.0f, 1.0f);
  rootNode->attachObject(sunLight);

  Light* earthLight = sceneManager->createLight("EarthLight");
  earthLight->setType(Light::LT_DIRECTIONAL);
  Vector earthDirection(0, 0, 50);
  earthDirection.normalise();
  earthLight->setPosition(0, 0, -50);
  earthLight->setDirection(earthDirection);
  earthLight->setDiffuseColour(0.55f, 0.55f, 0.70f);
  earthLight->setSpecularColour(0, 0, 0);
  rootNode->attachObject(earthLight);

  trackBallCamera = new TrackBallCamera(sceneManager);

  LoadingScreen::tick(L"Orbit::setPlanetResolution");
  setPlanetResolution(MAGIC_DEFAULT_PLANET_RESOLUTION, false);

  LoadingScreen::tick(L"Orbit::UI - BottomFrame");
  
  // New UI
  {
    interfaceContainer = new Widget();
    Widget* rootContainer = rGUIManager()->getRootContainer();
    rootContainer->add(interfaceContainer);
    interfaceContainer->setPosition(0, 0);
    interfaceContainer->setSize(rootContainer->getSize());
    GridLayout* interfaceLayout = new GridLayout(interfaceContainer, 24, 18);    
    interfaceLayout->set_padding(0);
    interfaceLayout->set_borders(0);
    
    {
      stationInfo = new Label(L"Station information");
      stationInfo->setVerticalAlignment(Label::TOP);
      
      Frame* stationInfoFrame = new Frame("Orbit/StationInfoFrame");
      stationInfoFrame->setLayoutManager(new BorderLayout());
      stationInfoFrame->setBackground(new FrameBackground());
      stationInfoFrame->add(stationInfo, "center");
      interfaceLayout->add(stationInfoFrame, 0, 15, 4, 3);
    }
    
    {
      toolInfo = new Label(L"Tool/Module information");
      toolInfo->setVerticalAlignment(Label::TOP);

      Frame* toolInfoFrame = new Frame("Orbit/ToolInfoFrame");
      toolInfoFrame->setLayoutManager(new BorderLayout());
      toolInfoFrame->setBackground(new FrameBackground());
      toolInfoFrame->add(toolInfo, "center");

      interfaceLayout->add(toolInfoFrame, 20, 15, 4, 3);
    }    
    
    {
      int mapWidth = 300;
      int mapHeight = 150;
      orbitMap = new OrbitMap(this, "user_interface/EarthMap.png");
      orbitMap->setPreferredSize(mapWidth, mapHeight);
      layerDock = new LayerDock(this, orbitMap);
    }

    interfaceLayout->add(ModuleDock::getSingletonPtr(), 0, 1, 4, 14);
    interfaceLayout->add(ControlDock::getSingletonPtr(), 0, 0, 24, 1);
    interfaceLayout->add(layerDock, 4, 15, 16, 3);

    // DEBUG:
//     Frame* debugFrame = new Frame("DEBUGFRAME");
//     debugFrame->setLayoutManager(new BorderLayout());
//     mDebugLabel = new Label();
//     debugFrame->add(mDebugLabel, "center");
//     interfaceLayout->add(debugFrame, 18, 1, 6, 15);
  }

  LoadingScreen::tick(L"Orbit::UI - States");
  readyState = new OrbitReadyState(this);
  addState = new OrbitAddState(this);
  selectedState = new OrbitSelectedState(this);

  stateManager.addState(READY_STATE, readyState);
  stateManager.addState(ADD_STATE, addState);
  stateManager.addState(SELECTED_STATE, selectedState);

  LoadingScreen::tick(L"Randomizing Orbit");
  randomizeOrbit(true);
}