void ShaderToonBuilding::Initialize()
{
	InitializeWorldViewProjection(_effect_handle_holder->effect_handle());
	InitializeWorld(_effect_handle_holder->effect_handle());
	InitializeLightDirection(_effect_handle_holder->effect_handle());
	InitializeEyePosition(_effect_handle_holder->effect_handle());
	InitializeAmbientColor(_effect_handle_holder->effect_handle());
	InitializeDiffuseCubeMap(_effect_handle_holder->effect_handle());
	InitializeAlbedoTexture(_effect_handle_holder->effect_handle());
	InitializeDirtyTexture(_effect_handle_holder->effect_handle());
	InitializeNormalTexture(_effect_handle_holder->effect_handle());
	InitializeToonTexture(_effect_handle_holder->effect_handle());
	InitializeTexcoordMove(_effect_handle_holder->effect_handle());
	InitializeView(_effect_handle_holder->effect_handle());
}
Ejemplo n.º 2
0
void SFMLWorld::RunWorld(void)
{
	window = new sf::RenderWindow(sf::VideoMode(windowWidth, windowHeight), "World window");
	Clock cl = Clock();

	totalElapsedSeconds = 0.0f;
	worldOver = false;
	float elapsed;
	sf::Event windowEvent;

	InitializeWorld();

	cl.restart();

	while (window->isOpen() && !worldOver)
	{
		//Handle window events first.
		while (window->pollEvent(windowEvent))
		{
			if (windowEvent.type == sf::Event::Closed)
			{
				OnCloseWindow();
			}
			else if (windowEvent.type == sf::Event::Resized)
			{
				OnWindowResized(windowEvent.size.width, windowEvent.size.height);
			}
			else
			{
				OnOtherWindowEvent(windowEvent);
			}
		}

		//Get elapsed time.
		elapsed = cl.getElapsedTime().asSeconds();
		totalElapsedSeconds += elapsed;
		cl.restart();

		//Call functions.
		if (elapsed > 0.0f)
		{
			UpdateWorld(elapsed);
			RenderWorld(elapsed);
		}
	}

	OnWorldEnd();
}
Stage_001::Stage_001()
{
    m_pView->SetAlpha(1.0f);
    m_pView->SetSize(APPSCREEN_SIZE);
    
    m_drawSize = APPSCREEN_SIZE;
    
    m_pWorld = new CWorld(CVector(0.0f, 1.0f, 0.0f));
    
    InitializeWorld();
    
    CreatePlayer(CPoint(300.0f, 100.0f));
    
    for (int i = 0; i < MAX_MULTI_PLAYER; i++) {
        m_pOtherPlayers[i] = 0;
    }
    
    m_pConnection = new Connection(this);
    
    m_frame = 0;
}
Ejemplo n.º 4
0
void SFMLWorld::RunWorld(void)
{
    contextSettings = GenerateContext();
	window = new sf::RenderWindow(GetModeToUse(windowWidth, windowHeight),
                                  GetWindowTitle().c_str(),
                                  GetSFStyleFlags(), contextSettings);
	Clock cl = Clock();

	totalElapsedSeconds = 0.0f;
	worldOver = false;
	float elapsed;
	sf::Event windowEvent;

	InitializeWorld();
    windowHasFocus = true;

	cl.restart();

	while (window->isOpen() && !worldOver)
	{
		//Handle window events first.
		while (window->pollEvent(windowEvent))
		{
			if (windowEvent.type == sf::Event::Closed)
			{
				OnCloseWindow();

			}
			else if (windowEvent.type == sf::Event::Resized)
			{
				OnWindowResized(windowEvent.size.width, windowEvent.size.height);
			}
            else if (windowEvent.type == sf::Event::LostFocus)
            {
                windowHasFocus = false;
                OnWindowLostFocus();
            }
            else if (windowEvent.type == sf::Event::GainedFocus)
            {
                windowHasFocus = true;
                OnWindowGainedFocus();
            }
			else
			{
				OnOtherWindowEvent(windowEvent);
			}
		}

		//Get elapsed time.
		elapsed = cl.getElapsedTime().asSeconds();
		cl.restart();
		totalElapsedSeconds += elapsed;

        //Update various managers.
        Input.Update(elapsed, totalElapsedSeconds);
        Timers.UpdateTimers(elapsed);

		//Update and render.
		if (elapsed > 0.0f)
		{
			UpdateWorld(elapsed);

			RenderWorld(elapsed);
		}
	}

	OnWorldEnd();

    delete window;
    window = 0;
}
Ejemplo n.º 5
0
/*virtual*/ void EldritchFramework::Initialize() {
  XTRACE_FUNCTION;

  XTRACE_BEGIN(PreFramework3D);
  ReverseHash::Initialize();

  PackStream::StaticAddPackageFile("eldritch-base.cpk");
  FrameworkUtil::MinimalLoadConfigFiles("Config/default.ccf");

  InitializePackages();

  InitializeDLC();

  // Load prefs over anything in the defaults.
  LoadPrefsConfig();

  LOADPRINTLEVELS;

  STATICHASH(Version);
  STATICHASH(ContentSyncer);
  SimpleString LocalVersion =
      ConfigManager::GetString(sVersion, "", sContentSyncer);
  PRINTF("Version: %s\n", LocalVersion.CStr());

  XTRACE_BEGIN(InitializeFactories);
  PRINTF("Initializing factories...\n");

  PRINTF("Initializing SDP factories.\n");
  SDPFactory::InitializeBaseFactories();
#define ADDSDPFACTORY(type) \
  SDPFactory::RegisterSDPFactory(#type, SDP##type::Factory);
#include "eldritchsdps.h"
#undef ADDSDPFACTORY

  PRINTF("Initializing UI factories.\n");
  UIFactory::InitializeBaseFactories();
#define ADDUISCREENFACTORY(type) \
  UIFactory::RegisterUIScreenFactory(#type, UIScreen##type::Factory);
#include "eldritchuiscreens.h"
#undef ADDUISCREENFACTORY

  PRINTF("Initializing anim event factories.\n");
#define ADDANIMEVENTFACTORY(type) \
  AnimEventFactory::GetInstance()->Register(#type, AnimEvent##type::Factory);
#include "eldritchanimevents.h"
#undef ADDANIMEVENTFACTORY

  PRINTF("Initializing PE factories.\n");
  WBParamEvaluatorFactory::InitializeBaseFactories();
#define ADDWBPEFACTORY(type) \
  WBParamEvaluatorFactory::RegisterFactory(#type, WBPE##type::Factory);
#include "rodinwbpes.h"
#include "eldritchwbpes.h"
#undef ADDWBPEFACTORY

  PRINTF("Initializing action factories.\n");
  WBActionFactory::InitializeBaseFactories();
#define ADDWBACTIONFACTORY(type) \
  WBActionFactory::RegisterFactory(#type, WBAction##type::Factory);
#include "uiwbactions.h"
#include "rodinwbactions.h"
#include "eldritchwbactions.h"
#undef ADDWBPEFACTORY

  PRINTF("Initializing BT factories.\n");
  RodinBTNodeFactory::InitializeBaseFactories();
#define ADDRODINBTNODEFACTORY(type) \
  RodinBTNodeFactory::RegisterFactory(#type, RodinBTNode##type::Factory);
#include "eldritchrodinbtnodes.h"
#undef ADDRODINBTNODEFACTORY

  // Initialize core and Eldritch Workbench component factories.
  PRINTF("Initializing component factories.\n");
  WBComponent::InitializeBaseFactories();
#define ADDWBCOMPONENT(type) \
  WBComponent::RegisterWBCompFactory(#type, WBComp##type::Factory);
#include "rodinwbcomponents.h"
#include "eldritchwbcomponents.h"
#undef ADDWBCOMPONENT
  XTRACE_END;

  PRINTF("Factories initialized.\n");

  // Create input system before framework so it will exist for UI. But don't
  // attach devices yet, as they don't exist.
  PRINTF("Initializing input system.\n");
  m_InputSystem = new InputSystem;
  m_InputSystem->Initialize("EldritchInput");
  XTRACE_END;

  Framework3D::Initialize();

  STATICHASH(DisplayWidth);
  STATICHASH(DisplayHeight);
  m_DisplayWidth = ConfigManager::GetInt(sDisplayWidth);
  m_DisplayHeight = ConfigManager::GetInt(sDisplayHeight);

#if BUILD_WINDOWS
  m_CheckForUpdates = new CheckForUpdates(m_UIManager);
#endif

  m_Controller = new XInputController;

  m_TargetManager = new EldritchTargetManager(m_Renderer);
  m_TargetManager->CreateTargets(m_Display->m_Width, m_Display->m_Height);

  m_Audio3DListener = new EldritchSound3DListener;
  m_Audio3DListener->Initialize();

  ASSERT(m_AudioSystem);
  m_AudioSystem->Set3DListener(m_Audio3DListener);

  STATICHASH(FOV);
  const float FOV = ConfigManager::GetFloat(sFOV, 90.0f);

  STATICHASH(ForegroundFOV);
  const float FGFOV = ConfigManager::GetFloat(sForegroundFOV, 60.0f);

  STATICHASH(NearClip);
  const float NearClip = ConfigManager::GetFloat(sNearClip, 0.1f);

  STATICHASH(FarClip);
  const float FarClip = ConfigManager::GetFloat(sFarClip, 0.1f);

  const float fDisplayWidth = static_cast<float>(m_DisplayWidth);
  const float fDisplayHeight = static_cast<float>(m_DisplayHeight);
  const float AspectRatio = fDisplayWidth / fDisplayHeight;

  m_MainView =
      new View(Vector(), Angles(), FOV, AspectRatio, NearClip, FarClip);
  m_FGView =
      new View(Vector(), Angles(), FGFOV, AspectRatio, NearClip, FarClip);
  CreateHUDView();
  CreateMirrorView();
  CreateMinimapView();

  CreateBuckets();

  m_InputSystem->SetKeyboard(m_Keyboard);
  m_InputSystem->SetMouse(m_Mouse);
  m_InputSystem->SetController(m_Controller);
  m_InputSystem->SetClock(m_Clock);

  WBActionStack::Initialize();

  PRINTF("Initializing Eldritch.\n");

  InitializeWorld(HashedString(), false);

  m_Game = new EldritchGame;
  m_Game->RefreshRTDependentSystems();
  m_Game->Initialize();

  // Initialize config stuff
  {
    STATICHASH(InvertY);
    const bool InvertY = ConfigManager::GetBool(sInvertY);

    STATIC_HASHED_STRING(TurnY);
    m_InputSystem->SetMouseInvert(sTurnY, InvertY);
    m_InputSystem->SetControllerInvert(sTurnY, InvertY);

    STATICHASH(ControllerPower);
    const float ControllerPower = ConfigManager::GetFloat(sControllerPower);

    STATIC_HASHED_STRING(MoveX);
    m_InputSystem->SetControllerPower(sMoveX, ControllerPower);
    STATIC_HASHED_STRING(MoveY);
    m_InputSystem->SetControllerPower(sMoveY, ControllerPower);
    STATIC_HASHED_STRING(TurnX);
    m_InputSystem->SetControllerPower(sTurnX, ControllerPower);
    m_InputSystem->SetControllerPower(sTurnY, ControllerPower);
  }

  // Initialize UI sliders. This could be neater.
  // This also pushes the initial values to their respective systems, which is
  // pret-ty terrible design.
  {
    WBEventManager* pEventManager = WBWorld::GetInstance()->GetEventManager();

    {
      STATICHASH(MouseSpeed);
      const float MouseSpeed = ConfigManager::GetFloat(sMouseSpeed, 1.0f);

      STATIC_HASHED_STRING(ControlsOptionsScreen);
      STATIC_HASHED_STRING(MouseSpeedSlider);
      WB_MAKE_EVENT(SetUISliderValue, NULL);
      WB_SET_AUTO(SetUISliderValue, Hash, Screen, sControlsOptionsScreen);
      WB_SET_AUTO(SetUISliderValue, Hash, Widget, sMouseSpeedSlider);
      WB_SET_AUTO(SetUISliderValue, Float, SliderValue,
                  GetSliderValueFromMouseSpeed(MouseSpeed));
      WB_DISPATCH_EVENT(pEventManager, SetUISliderValue, NULL);
    }

    {
      STATICHASH(ControllerSpeed);
      const float ControllerSpeed =
          ConfigManager::GetFloat(sControllerSpeed, 1.0f);

      STATIC_HASHED_STRING(ControlsOptionsScreen);
      STATIC_HASHED_STRING(ControllerSpeedSlider);
      WB_MAKE_EVENT(SetUISliderValue, NULL);
      WB_SET_AUTO(SetUISliderValue, Hash, Screen, sControlsOptionsScreen);
      WB_SET_AUTO(SetUISliderValue, Hash, Widget, sControllerSpeedSlider);
      WB_SET_AUTO(SetUISliderValue, Float, SliderValue,
                  GetSliderValueFromControllerSpeed(ControllerSpeed));
      WB_DISPATCH_EVENT(pEventManager, SetUISliderValue, NULL);
    }

    {
      STATICHASH(Brightness);
      const float Brightness = ConfigManager::GetFloat(sBrightness, 1.0f);

      STATIC_HASHED_STRING(BrightnessScreen);
      STATIC_HASHED_STRING(BrightnessSlider);
      WB_MAKE_EVENT(SetUISliderValue, NULL);
      WB_SET_AUTO(SetUISliderValue, Hash, Screen, sBrightnessScreen);
      WB_SET_AUTO(SetUISliderValue, Hash, Widget, sBrightnessSlider);
      WB_SET_AUTO(SetUISliderValue, Float, SliderValue,
                  GetSliderValueFromBrightness(Brightness));
      WB_DISPATCH_EVENT(pEventManager, SetUISliderValue, NULL);
    }

    {
      STATIC_HASHED_STRING(DisplayOptionsScreen);
      STATIC_HASHED_STRING(FOVSlider);
      WB_MAKE_EVENT(SetUISliderValue, NULL);
      WB_SET_AUTO(SetUISliderValue, Hash, Screen, sDisplayOptionsScreen);
      WB_SET_AUTO(SetUISliderValue, Hash, Widget, sFOVSlider);
      WB_SET_AUTO(SetUISliderValue, Float, SliderValue,
                  GetSliderValueFromFOV(FOV));
      WB_DISPATCH_EVENT(pEventManager, SetUISliderValue, NULL);
    }

    {
      STATICHASH(MasterVolume);
      const float MasterVolume = ConfigManager::GetFloat(sMasterVolume);

      STATIC_HASHED_STRING(AudioOptionsScreen);
      STATIC_HASHED_STRING(VolumeSlider);
      WB_MAKE_EVENT(SetUISliderValue, NULL);
      WB_SET_AUTO(SetUISliderValue, Hash, Screen, sAudioOptionsScreen);
      WB_SET_AUTO(SetUISliderValue, Hash, Widget, sVolumeSlider);
      WB_SET_AUTO(SetUISliderValue, Float, SliderValue, MasterVolume);
      WB_DISPATCH_EVENT(pEventManager, SetUISliderValue, NULL);
    }

    {
      STATICHASH(MusicVolume);
      const float MusicVolume = ConfigManager::GetFloat(sMusicVolume);

      STATIC_HASHED_STRING(AudioOptionsScreen);
      STATIC_HASHED_STRING(MusicVolumeSlider);
      WB_MAKE_EVENT(SetUISliderValue, NULL);
      WB_SET_AUTO(SetUISliderValue, Hash, Screen, sAudioOptionsScreen);
      WB_SET_AUTO(SetUISliderValue, Hash, Widget, sMusicVolumeSlider);
      WB_SET_AUTO(SetUISliderValue, Float, SliderValue, MusicVolume);
      WB_DISPATCH_EVENT(pEventManager, SetUISliderValue, NULL);
    }
  }

  // Initialize UI callbacks
  {
    UIScreenEldSetRes* pSetRes =
        m_UIManager->GetScreen<UIScreenEldSetRes>("SetResScreen");
    pSetRes->SetUICallback(SUICallback(EldritchFramework::OnSetRes, nullptr));

    UIScreenFade* pFade = m_UIManager->GetScreen<UIScreenFade>("Fade");
    pFade->SetFadeCallback(
        SUICallback(EldritchFramework::OnFadeFinished, nullptr));
  }

  WB_MAKE_EVENT(ResetToInitialScreens, NULL);
  WB_DISPATCH_EVENT(WBWorld::GetInstance()->GetEventManager(),
                    ResetToInitialScreens, NULL);

  {
    // HACK: Too content aware
    STATIC_HASHED_STRING(MKGLogoScreen);
    WB_MAKE_EVENT(PushUIScreen, NULL);
    WB_SET_AUTO(PushUIScreen, Hash, Screen, sMKGLogoScreen);
    WB_DISPATCH_EVENT(WBWorld::GetInstance()->GetEventManager(), PushUIScreen,
                      NULL);
  }

  // Tick world once to pump the event queue. Fixes title screen bugs.
  m_World->Tick(0.0f);

  // All done, show the window finally.
  SafeDelete(m_SplashWindow);
#if BUILD_WINDOWS_NO_SDL
  m_Window->Show(m_CmdShow);
#elif BUILD_SDL
  m_Window->Show();
#endif

  // Reattach GL context if needed.
  m_Renderer->Refresh();

  PRINTF("Eldritch initialization complete.\n");
}
Ejemplo n.º 6
0
void EldritchFramework::GoToLevel(const HashedString& WorldDef) {
  InitializeWorld(WorldDef, true);
}
Ejemplo n.º 7
0
void EldritchFramework::RegenerateWorld() {
  ASSERT(m_World);
  InitializeWorld(m_World->GetCurrentWorld(), true);
}
Ejemplo n.º 8
0
UINT32 InitializeJA2(void)
{ 

#ifdef LASERLOCK_ENABLED
	HandleLaserLockResult( PrepareLaserLockSystem() );
#endif

  HandleJA2CDCheck( );

	gfWorldLoaded = FALSE;

	// Load external text
	LoadAllExternalText();

	// Init JA2 sounds
	InitJA2Sound( );

	gsRenderCenterX = 805;
	gsRenderCenterY = 805;
 

	// Init data
	InitializeSystemVideoObjects( );

	// Init animation system
	if ( !InitAnimationSystem( ) )
	{
		return( ERROR_SCREEN );
	}

	// Init lighting system
	InitLightingSystem();

	// Init dialog queue system
	InitalizeDialogueControl();

	if ( !InitStrategicEngine( ) )
	{
		return( ERROR_SCREEN );
	}
	
	//needs to be called here to init the SectorInfo struct
	InitStrategicMovementCosts( );

	// Init tactical engine
	if ( !InitTacticalEngine( ) )
	{
		return( ERROR_SCREEN );
	}

	// Init timer system
	//Moved to the splash screen code.
	//InitializeJA2Clock( );

	// INit shade tables
	BuildShadeTable( );

	// INit intensity tables
	BuildIntensityTable( );
	
	// Init Event Manager
	if ( !InitializeEventManager( ) )
	{
		return( ERROR_SCREEN );
	}

	// Initailize World
	if ( !InitializeWorld( ) )
	{
		return( ERROR_SCREEN );
	}

	InitTileCache( );

	InitMercPopupBox( );

	// Set global volume
	MusicSetVolume( gGameSettings.ubMusicVolumeSetting );

	DetermineRGBDistributionSettings();

#ifdef JA2BETAVERSION
	#ifdef JA2EDITOR

	//UNCOMMENT NEXT LINE TO ALLOW FORCE UPDATES...
	//LoadGlobalSummary();
	if( gfMustForceUpdateAllMaps )
	{
		ApologizeOverrideAndForceUpdateEverything();
	}
	#endif
#endif
	
#ifdef JA2BETAVERSION
	if( ProcessIfMultilingualCmdLineArgDetected( gzCommandLine ) )
	{ //If the multilingual text code generator has activated, quit now.
		gfProgramIsRunning = FALSE;
		return( INIT_SCREEN );
	}
#endif

#ifdef JA2BETAVERSION
	// CHECK COMMANDLINE FOR SPECIAL UTILITY
	if ( strcmp( gzCommandLine, "-DOMAPS" ) == 0 )
	{
		return( MAPUTILITY_SCREEN );
	}
#endif

#ifdef JA2BETAVERSION
	//This allows the QuickSave Slots to be autoincremented, ie everytime the user saves, there will be a new quick save file
	if ( _stricmp( gzCommandLine, "-quicksave" ) == 0 )
	{
		gfUseConsecutiveQuickSaveSlots = TRUE;
	}
#endif

#ifdef JA2BETAVERSION
	#ifdef JA2EDITOR
		// CHECK COMMANDLINE FOR SPECIAL UTILITY
		if( !strcmp( gzCommandLine, "-EDITORAUTO" ) )
		{
			OutputDebugString( "Beginning JA2 using -EDITORAUTO commandline argument...\n" );
			//For editor purposes, need to know the default map file.
			sprintf( gubFilename, "none");
			//also set the sector
			gWorldSectorX = 0;
			gWorldSectorY = 0;
			gfAutoLoadA9 = TRUE;
			gfIntendOnEnteringEditor = TRUE;
			gGameOptions.fGunNut = TRUE;
			return( GAME_SCREEN );
		}
		if ( strcmp( gzCommandLine, "-EDITOR" ) == 0 )
		{
			OutputDebugString( "Beginning JA2 using -EDITOR commandline argument...\n" );
			//For editor purposes, need to know the default map file.
			sprintf( gubFilename, "none");
			//also set the sector
			gWorldSectorX = 0;
			gWorldSectorY = 0;
			gfAutoLoadA9 = FALSE;
			gfIntendOnEnteringEditor = TRUE;
			gGameOptions.fGunNut = TRUE;
			return( GAME_SCREEN );
		}
	#endif
#endif

	return( INIT_SCREEN );
}
Ejemplo n.º 9
0
//Basically a convenience function over InitializeWorld.
World* MakeWorld(unsigned int width, unsigned int height)
{
	World* w = malloc(sizeof(World));
	InitializeWorld(w, width, height);
	return w;
}