Commit cf7246f7 authored by engineer_apple's avatar engineer_apple

xbox update.

example 21.update. save/load game data on driver change

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2157 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a8e2b236
......@@ -28,17 +28,49 @@ Copyright 2006-2009 Burningwater, Thomas Alten
*/
struct GameData
{
GameData ( const string<c16> &startupDir)
{
GameData ( const string<c16> &startupDir);
void setDefault ();
s32 save ();
s32 debugState;
s32 gravityState;
s32 flyTroughState;
s32 wireFrame;
s32 guiActive;
s32 guiInputActive;
f32 GammaValue;
s32 retVal;
s32 sound;
string<c16> StartupDir;
stringw CurrentMapName;
array < string<c16> > CurrentArchiveList;
vector3df PlayerPosition;
vector3df PlayerRotation;
Q3LevelLoadParameter loadParam;
SIrrlichtCreationParameters deviceParam;
funcptr_createDeviceEx createExDevice;
IrrlichtDevice *Device;
};
/*!
*/
GameData::GameData ( const string<c16> &startupDir)
{
retVal = 0;
createExDevice = 0;
Device = 0;
StartupDir = startupDir;
setDefault ();
}
}
void setDefault ()
{
/*!
set default settings
*/
void GameData::setDefault ()
{
debugState = EDS_OFF;
gravityState = 1;
flyTroughState = 0;
......@@ -48,12 +80,12 @@ struct GameData
GammaValue = 1.f;
// default deviceParam;
deviceParam.DriverType = EDT_OPENGL;
deviceParam.DriverType = EDT_DIRECT3D9;
deviceParam.WindowSize.Width = 800;
deviceParam.WindowSize.Height = 600;
deviceParam.Fullscreen = false;
deviceParam.Bits = 32;
deviceParam.ZBufferBits = 24;
deviceParam.ZBufferBits = 32;
deviceParam.Vsync = false;
deviceParam.AntiAlias = false;
......@@ -73,28 +105,37 @@ struct GameData
CurrentArchiveList.clear ();
CurrentArchiveList.push_back ( StartupDir + "../../media/" );
CurrentArchiveList.push_back ( StartupDir + "../../media/map-20kdm2.pk3" );
}
s32 debugState;
s32 gravityState;
s32 flyTroughState;
s32 wireFrame;
s32 guiActive;
s32 guiInputActive;
f32 GammaValue;
s32 retVal;
s32 sound;
}
core::string<c16> StartupDir;
stringw CurrentMapName;
array < core::string<c16> > CurrentArchiveList;
/*!
Store the current game State
*/
s32 GameData::save ()
{
if ( 0 == Device )
return 0;
Q3LevelLoadParameter loadParam;
SIrrlichtCreationParameters deviceParam;
funcptr_createDeviceEx createExDevice;
IrrlichtDevice *Device;
};
u32 i;
// Store current Archive for restart
CurrentArchiveList.clear();
io::IFileSystem *fs = Device->getFileSystem();
for ( i = 0; i != fs->getFileArchiveCount(); ++i )
{
CurrentArchiveList.push_back ( fs->getFileArchive ( i )->getArchiveName() );
}
// Store Player Position
ICameraSceneNode * camera = Device->getSceneManager()->getActiveCamera ();
if ( camera )
{
PlayerPosition = camera->getPosition ();
PlayerRotation = camera->getRotation ();
}
return 1;
}
/*!
Representing a player
......@@ -108,6 +149,8 @@ struct Q3Player : public IAnimationEndCallBack
memset(Anim, 0, sizeof(TimeFire)*4);
}
virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node);
void create ( IrrlichtDevice *device,
IQ3LevelMesh* mesh,
ISceneNode *mapNode,
......@@ -116,7 +159,7 @@ struct Q3Player : public IAnimationEndCallBack
void shutdown ();
void setAnim ( const c8 *name );
void respawn ();
virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node);
void setpos ( const vector3df &pos, const vector3df& rotation );
ISceneNodeAnimatorCollisionResponse * cam() { return camCollisionResponse ( Device ); }
......@@ -267,6 +310,22 @@ void Q3Player::respawn ()
}
}
/*
set Player position from saved coordinates
*/
void Q3Player::setpos ( const vector3df &pos, const vector3df &rotation )
{
Device->getLogger()->log( "setpos" );
ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera();
if ( camera )
{
camera->setPosition ( pos );
camera->setRotation ( rotation );
//! New. FPSCamera and animators catches reset on animate 0
camera->OnAnimate ( 0 );
}
}
/*!
*/
......@@ -384,6 +443,7 @@ public:
void LoadMap ( const stringw& mapName, s32 collision );
void CreatePlayers();
void AddSky( u32 dome, const c8 *texture );
Q3Player *GetPlayer ( u32 index ) { return &Player[index]; }
void CreateGUI();
void SetGUIActive( s32 command);
......@@ -456,6 +516,8 @@ CQuake3EventHandler::~CQuake3EventHandler ()
Player[0].shutdown ();
sound_shutdown ();
Game->save();
Game->Device->drop();
}
......@@ -721,10 +783,10 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
if ( !exists )
{
fs->registerFileArchive ( archiveName, true, false );
Game->CurrentMapName = "";
}
}
// store the current archives in game data
// show the attached Archive in proper order
if ( gui.ArchiveList )
{
......@@ -738,9 +800,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
gui.ArchiveList->setCellText ( index, 0, archive->getArchiveType () );
gui.ArchiveList->setCellText ( index, 1, archive->getArchiveName () );
}
}
......@@ -1158,8 +1218,9 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve)
printf ( "Loading map %ls\n", loadMap.c_str() );
LoadMap ( loadMap , 1 );
if ( 0 == Game->loadParam.loadSkyShader )
{
AddSky ( 1, "skydome2" );
//AddSky ( 0, "env/ssky" );
}
CreatePlayers ();
CreateGUI ();
SetGUIActive ( 0 );
......@@ -1474,25 +1535,6 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve)
gui.Visible_Unresolved->setChecked ( v );
}
}
/*
else
if (eve.KeyInput.Key == KEY_KEY_P)
{
ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera();
const core::vector3df &p = camera->getPosition();
const core::vector3df &r = camera->getRotation();
printf ( "core::vector3df (%ff,%ff,%ff)\ncore::vector3df (%ff,%ff,%ff)\n", p.X, p.Y, p.Z, r.X, r.Y, r.Z );
}
else
if (eve.KeyInput.Key == KEY_KEY_G)
{
ICameraSceneNode* camera = Device->getSceneManager()->getActiveCamera();
camera->setPosition ( core::vector3df ( 635.673767f,79.271515f,159.270813f ) );
camera->setRotation ( core::vector3df ( 349.166565f,126.624962f,0.000000f ) );
camera->OnAnimate ( 0 );
}
*/
}
// check if user presses the key C ( for crouch)
......@@ -1836,18 +1878,39 @@ void runGame ( GameData *game )
eventHandler->AddArchive ( game->CurrentArchiveList[i] );
}
// Load a Map or startup to the GUI
if ( game->CurrentMapName.size () )
{
eventHandler->LoadMap ( game->CurrentMapName, 1 );
if ( 0 == game->loadParam.loadSkyShader )
eventHandler->AddSky ( 1, "skydome2" );
eventHandler->CreatePlayers ();
eventHandler->CreateGUI ();
eventHandler->SetGUIActive ( 0 );
// set player to last position on restart
if ( game->retVal == 2 )
{
eventHandler->GetPlayer( 0 )->setpos ( game->PlayerPosition, game->PlayerRotation );
}
}
else
{
// start up empty
eventHandler->AddSky ( 1, "skydome2" );
eventHandler->CreatePlayers ();
eventHandler->CreateGUI ();
eventHandler->SetGUIActive ( 1 );
background_music ( "IrrlichtTheme.ogg" );
}
game->retVal = 3;
while( game->Device->run() )
{
eventHandler->Animate ();
eventHandler->Render ();
if (! game->Device->isWindowActive())
if ( !game->Device->isWindowActive() )
game->Device->yield();
}
......
......@@ -48,6 +48,8 @@
//#define _IRR_USE_WINDOWS_DEVICE_
#undef _IRR_USE_WINDOWS_DEVICE_
//#define _IRR_USE_SDL_DEVICE_
#include <xtl.h>
#endif
#if defined(__APPLE__) || defined(MACOSX)
......
......@@ -14,10 +14,6 @@
#include <windows.h>
#endif
#ifdef _IRR_XBOX_PLATFORM_
#include <xtl.h>
#endif
// always included for static createDriver function
#include "CNullDriver.h"
#include "IMaterialRendererServices.h"
......
......@@ -172,6 +172,9 @@ bool CD3D8ShaderMaterialRenderer::createPixelShader(const c8* pxsh)
if (!pxsh)
return true;
#if defined( _IRR_XBOX_PLATFORM_)
return false;
#else
// compile shader
LPD3DXBUFFER code = 0;
......@@ -198,9 +201,7 @@ bool CD3D8ShaderMaterialRenderer::createPixelShader(const c8* pxsh)
fclose(f);
D3DXAssembleShaderFromFile(tmp, D3DXASM_DEBUG, 0, &code, &errors);
#endif
if (errors)
{
// print out compilation errors.
......@@ -223,6 +224,8 @@ bool CD3D8ShaderMaterialRenderer::createPixelShader(const c8* pxsh)
code->Release();
return true;
#endif
}
......@@ -233,6 +236,9 @@ bool CD3D8ShaderMaterialRenderer::createVertexShader(const char* vtxsh, E_VERTEX
return true;
// compile shader
#if defined( _IRR_XBOX_PLATFORM_)
return false;
#else
LPD3DXBUFFER code = 0;
LPD3DXBUFFER errors = 0;
......@@ -314,6 +320,7 @@ bool CD3D8ShaderMaterialRenderer::createVertexShader(const char* vtxsh, E_VERTEX
code->Release();
return true;
#endif
}
......
......@@ -11,9 +11,6 @@
#include "ITexture.h"
#include "IImage.h"
#ifdef _IRR_XBOX_PLATFORM_
#include <xtl.h>
#endif
#include <d3d8.h>
namespace irr
......
......@@ -13,9 +13,6 @@ static const char* const copyright = "Irrlicht Engine (c) 2002-2009 Nikolaus Geb
#endif // _DEBUG
#endif
#ifdef _IRR_XBOX_PLATFORM_
#include <xtl.h>
#endif
#include "irrlicht.h"
......
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht_xbox", "Irrlicht_xbox.vcproj", "{2440E601-7438-4C6B-B4AF-BBFE9735875E}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Profile = Profile
Profile_FastCap = Profile_FastCap
Release = Release
Release_LTCG = Release_LTCG
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Debug.ActiveCfg = Debug|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Debug.Build.0 = Debug|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Profile.ActiveCfg = Profile|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Profile.Build.0 = Profile|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Profile_FastCap.ActiveCfg = Profile_FastCap|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Profile_FastCap.Build.0 = Profile_FastCap|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Release.ActiveCfg = Release|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Release.Build.0 = Release|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Release_LTCG.ActiveCfg = Release_LTCG|Xbox
{2440E601-7438-4C6B-B4AF-BBFE9735875E}.Release_LTCG.Build.0 = Release_LTCG|Xbox
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment