• Benvenuto in Making Videogames!
  • Dai sfogo alla tua fantasia!
  • Crea il tuo Videogioco!
Benvenuto ospite! Login Registrati




Valutazione discussione:
  • 1 voto(i) - 5 media
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial 21b - Quake3 Explorer
#1
render principale
Codice PHP:
void CQuake3EventHandler::Render()
{
    
IVideoDriver driver Game->Device->getVideoDriver();
    if ( 
== driver )
        return;

    
// TODO: This does not work, yet.
    
const bool anaglyph=false;
    if (
anaglyph)
    {
        
scene::ICameraSceneNodecameraOld Game->Device->getSceneManager()->getActiveCamera();
        
driver->beginScene(truetrueSColor(0,0,0,0));
        
driver->getOverrideMaterial().Material.ColorMask ECP_NONE;
        
driver->getOverrideMaterial().EnableFlags  EMF_COLOR_MASK;
        
driver->getOverrideMaterial().EnablePasses ESNRP_SKY_BOX +
                                                     
ESNRP_SOLID +
                                                     
ESNRP_TRANSPARENT +
                                                     
ESNRP_TRANSPARENT_EFFECT +
                                                     
ESNRP_SHADOW;
        
Game->Device->getSceneManager()->drawAll();
        
driver->clearZBuffer();

        const 
vector3df oldPosition cameraOld->getPosition();
        const 
vector3df oldTarget   cameraOld->getTarget();
        const 
matrix4 startMatrix   cameraOld->getAbsoluteTransformation();
        const 
vector3df focusPoint  = (oldTarget -
                
cameraOld->getAbsolutePosition()).setLength(10000) +
                
cameraOld->getAbsolutePosition() ;

        
scene::ICameraSceneNodecamera cameraOld;//Game->Device->getSceneManager()->addCameraSceneNode();

        //Left eye...
        
vector3df pos;
        
matrix4   move;

        
move.setTranslationvector3df(-1.5f,0.0f,0.0f) );
        
pos=(startMatrix*move).getTranslation();

        
driver->getOverrideMaterial().Material.ColorMask ECP_RED;
        
driver->getOverrideMaterial().EnableFlags  EMF_COLOR_MASK;
        
driver->getOverrideMaterial().EnablePasses =
                
ESNRP_SKY_BOX|ESNRP_SOLID|ESNRP_TRANSPARENT|
                
ESNRP_TRANSPARENT_EFFECT|ESNRP_SHADOW;

        
camera->setPosition(pos);
        
camera->setTarget(focusPoint);

        
Game->Device->getSceneManager()->drawAll();
        
driver->clearZBuffer();

        
//Right eye...
        
move.setTranslationvector3df(1.5f,0.0f,0.0f) );
        
pos=(startMatrix*move).getTranslation();

        
driver->getOverrideMaterial().Material.ColorMask ECP_GREEN ECP_BLUE;
        
driver->getOverrideMaterial().EnableFlags  EMF_COLOR_MASK;
        
driver->getOverrideMaterial().EnablePasses =
                
ESNRP_SKY_BOX|ESNRP_SOLID|ESNRP_TRANSPARENT|
                
ESNRP_TRANSPARENT_EFFECT|ESNRP_SHADOW;

        
camera->setPosition(pos);
        
camera->setTarget(focusPoint);

        
Game->Device->getSceneManager()->drawAll();

        
driver->getOverrideMaterial().Material.ColorMask=ECP_ALL;
        
driver->getOverrideMaterial().EnableFlags=0;
        
driver->getOverrideMaterial().EnablePasses=0;

        if (
camera != cameraOld)
        {
            
Game->Device->getSceneManager()->setActiveCamera(cameraOld);
            
camera->remove();
        }
        else
        {
            
camera->setPosition(oldPosition);
            
camera->setTarget(oldTarget);
        }
    }
    else
    {
        
driver->beginScene(truetrueSColor(0,0,0,0));
        
Game->Device->getSceneManager()->drawAll();
    }
    
Game->Device->getGUIEnvironment()->drawAll();
    
driver->endScene();

Aggiorna il nodo generico della scena
Codice PHP:
void CQuake3EventHandler::Animate()
{
    
u32 now Game->Device->getTimer()->getTime();

    
Q3Player player Player 0;

    
checkTimeFire player->Anim4now );

    
// Query Scene Manager attributes
    
if ( player->Anim[0].flags FIRED )
    {
        
ISceneManager *smgr Game->Device->getSceneManager ();
        
wchar_t msg[128];
        
IVideoDriver driver Game->Device->getVideoDriver();

        
IAttributes attr smgr->getParameters();
#ifdef _IRR_SCENEMANAGER_DEBUG                  
        
swprintf msg128,
            
L"Q3 %s [%ls], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)",
            
Game->CurrentMapName.c_str(),
            
driver->getName(),
            
driver->getFPS (),
            (
f32driver->getPrimitiveCountDrawn) * ( 1.f 1000000.f ),
            
attr->getAttributeAsInt "culled" ),
            
attr->getAttributeAsInt "calls" ),
            
attr->getAttributeAsInt "drawn_solid" ),
            
attr->getAttributeAsInt "drawn_transparent" ),
            
attr->getAttributeAsInt "drawn_transparent_effect" )
            );
#else
swprintf msg128,
            
L"Q3 %s [%ls], FPS:%03d Tri:%.03fm",
            
Game->CurrentMapName.c_str(),
            
driver->getName(),
            
driver->getFPS (),
            (
f32driver->getPrimitiveCountDrawn) * ( 1.f 1000000.f )
            );      
#endif      
        
Game->Device->setWindowCaptionmsg );

        
swprintf msg128,
                    
L"%03d fps, F1 GUI on/off, F2 respawn, F3-F6 toggle Nodes, F7 Collision on/off"
                    
L", F8 Gravity on/off, Right Mouse Toggle GUI",
                    
Game->Device->getVideoDriver()->getFPS ()
                );
        if ( 
gui.StatusLine )
            
gui.StatusLine->setText msg );
        
player->Anim[0].flags &= ~FIRED;
    }

    
// idle..
    
if ( player->Anim[1].flags FIRED )
    {
        if ( 
strcmp player->animation"idle" ) )
            
player->setAnim "idle" );

        
player->Anim[1].flags &= ~FIRED;
    }

    
createParticleImpacts now );


I principali stati del game
Codice PHP:
void runGame GameData *game )
{
    if ( 
game->retVal >= )
        return;

    
game->Device = (*game->createExDevice) ( game->deviceParam );
    if ( 
== game->Device)
    {
        
// could not create selected driver.
        
game->retVal 0;
        return;
    }

    
// create an event receiver based on current game data
    
CQuake3EventHandler *eventHandler = new CQuake3EventHandlergame );

    
// load stored config
    
game->load "explorer.cfg" );

    
// add our media directory and archive to the file system
    
for ( u32 i 0game->CurrentArchiveList.size(); ++)
    {
        
eventHandler->AddArchive game->CurrentArchiveList[i] );
    }

    
// Load a Map or startup to the GUI
    
if ( game->CurrentMapName.size () )
    {
        
eventHandler->LoadMap game->CurrentMapName);
        if ( 
== game->loadParam.loadSkyShader )
            
eventHandler->AddSky 1"skydome2" );
        
eventHandler->CreatePlayers ();
        
eventHandler->CreateGUI ();
        
eventHandler->SetGUIActive );

        
// set player to last position on restart
        
if ( game->retVal == )
        {
            
eventHandler->GetPlayer)->setpos game->PlayerPositiongame->PlayerRotation );
        }
    }
    else
    {
        
// start up empty
        
eventHandler->AddSky 1"skydome2" );
        
eventHandler->CreatePlayers ();
        
eventHandler->CreateGUI ();
        
eventHandler->SetGUIActive );
        
background_music "IrrlichtTheme.ogg" );
    }


    
game->retVal 3;
    while( 
game->Device->run() )
    {
        
eventHandler->Animate ();
        
eventHandler->Render ();
        
//if ( !game->Device->isWindowActive() )
            
game->Device->yield();
    }

    
game->Device->setGammaRamp 1.f1.f1.f0.f0.f );
    
delete eventHandler;
}

#if defined (_IRR_WINDOWS_) && 0
    #pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif 
La routine principale dove facciamo tutto il setup
Codice PHP:
int IRRCALLCONV main(int argccharargv[])
{
    
path prgname(argv[0]);
    
GameData game deletePathFromPath prgname) );

    
// dynamically load irrlicht
    
const c8 dllName argc argv[1] : "irrlicht.dll";
    
game.createExDevice load_createDeviceEx dllName );
    if ( 
== game.createExDevice )
    {
        
game.retVal 3;
        
printf "Could not load %s.\n"dllName );
        return 
game.retVal// could not load dll
    
}

    
// start without asking for driver
    
game.retVal 1;
    do
    {
        
// if driver could not created, ask for another driver
        
if ( game.retVal == )
        {
            
game.setDefault ();
            
// ask user for driver
            
game.deviceParam.DriverType=driverChoiceConsole();
            if (
game.deviceParam.DriverType==video::EDT_COUNT)
                
game.retVal 3;
        }
        
runGame ( &game );
    } while ( 
game.retVal );

    return 
game.retVal;


Versione pdf scaricabile da QUI
 
Rispondi
  


Discussioni simili
Discussione Autore Risposte Letto Ultimo messaggio
  Tutorial 21a - Quake3 Explorer Chip 0 640 23-08-2015, 11:25 AM
Ultimo messaggio: Chip
  Tutorial 16 - Quake3 Map Shader Support Chip 0 414 19-08-2015, 08:45 PM
Ultimo messaggio: Chip

Vai al forum:


Browsing: 1 Ospite(i)