git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1045 dfc29bdd-3216-0410-991c-e03cc46cb475

master
engineer_apple 2007-11-13 14:34:22 +00:00
parent b5436c6fe8
commit 95e75a6321
1 changed files with 81 additions and 18 deletions

View File

@ -10,6 +10,31 @@ to ask the user for a driver type using the console.
#include <irrlicht.h>
#include <iostream>
/*
define which Quake3 Level should be loaded
*/
#define IRRLICHT_QUAKE3_ARENA
//#define ORIGINAL_QUAKE3_ARENA
//#define CUSTOM_QUAKE3_ARENA
//#define SHOW_SHADER_NAME
#ifdef ORIGINAL_QUAKE3_ARENA
#define QUAKE3_STORAGE_FORMAT addFolderFileArchive
#define QUAKE3_STORAGE_1 "/baseq3/"
#ifdef CUSTOM_QUAKE3_ARENA
#define QUAKE3_STORAGE_2 "/cf/"
#define QUAKE3_MAP_NAME "maps/cf.bsp"
#else
#define QUAKE3_MAP_NAME "maps/q3dm8.bsp"
#endif
#endif
#ifdef IRRLICHT_QUAKE3_ARENA
#define QUAKE3_STORAGE_FORMAT addZipFileArchive
#define QUAKE3_STORAGE_1 "../../media/map-20kdm2.pk3"
#define QUAKE3_MAP_NAME "maps/20kdm2.bsp"
#endif
/*
As already written in the HelloWorld example, in the Irrlicht
@ -50,6 +75,8 @@ public:
Filename.reserve ( 256 );
FilenameTemplate = templateName;
FilenameTemplate.replace ( '/', '_' );
FilenameTemplate.replace ( '\\', '_' );
}
bool OnEvent(const SEvent& event)
@ -62,7 +89,7 @@ public:
video::IImage* image = Device->getVideoDriver()->createScreenShot();
if (image)
{
sprintf ( (c8*) Filename.c_str() ,
snprintf ( (c8*) Filename.c_str() , 255,
"%s_shot%04d.jpg",
FilenameTemplate.c_str (),
Number++
@ -135,6 +162,12 @@ int IRRCALLCONV main(int argc, char* argv[])
*/
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
gui::IGUIEnvironment* gui = device->getGUIEnvironment();
// create an event receiver for making screenshots
CScreenShotFactory screenshotFactory ( device, QUAKE3_MAP_NAME );
device->setEventReceiver ( &screenshotFactory );
//! add our private media directory to the file system
device->getFileSystem()->addFolderFileArchive("../../media/");
@ -146,8 +179,12 @@ int IRRCALLCONV main(int argc, char* argv[])
we are able to read from the files in that archive as they would
directly be stored on disk.
*/
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
//device->getFileSystem()->addFolderFileArchive("/baseq3/");
device->getFileSystem()->QUAKE3_STORAGE_FORMAT ( QUAKE3_STORAGE_1 );
#ifdef QUAKE3_STORAGE_2
device->getFileSystem()->QUAKE3_STORAGE_FORMAT ( QUAKE3_STORAGE_2 );
#endif
/*
Now we can load the mesh by calling getMesh(). We get a pointer returned
@ -165,12 +202,7 @@ int IRRCALLCONV main(int argc, char* argv[])
IVideoDriver class). Note that this optimization with the Octree is only
useful when drawing huge meshes consisting of lots of geometry.
*/
scene::IQ3LevelMesh* mesh = (scene::IQ3LevelMesh*) smgr->getMesh("maps/20kdm2.bsp");
//scene::IQ3LevelMesh* mesh = (scene::IQ3LevelMesh*) smgr->getMesh("maps/q3dm14.bsp");
// create an event receiver for making screenshots
CScreenShotFactory screenshotFactory ( device, "20kdm2" );
device->setEventReceiver ( &screenshotFactory );
scene::IQ3LevelMesh* mesh = (scene::IQ3LevelMesh*) smgr->getMesh( QUAKE3_MAP_NAME );
/*
@ -195,6 +227,9 @@ int IRRCALLCONV main(int argc, char* argv[])
// the additional mesh can be quite huge and is unoptimized
scene::IMesh * additional_mesh = mesh->getMesh ( quake3::E_Q3_MESH_ITEMS );
gui::IGUIFont *font = device->getGUIEnvironment()->getFont("../../media/fontlucida.png");
u32 count = 0;
for ( u32 i = 0; i!= additional_mesh->getMeshBufferCount (); ++i )
{
IMeshBuffer *meshBuffer = additional_mesh->getMeshBuffer ( i );
@ -214,10 +249,37 @@ int IRRCALLCONV main(int argc, char* argv[])
// in a pretty printers way.. commented out, because the console would be full...
// quake3::dumpShader ( Shader );
// Now add the MeshBuffer(s) with the current Shader to the Manager
#ifndef SHOW_SHADER_NAME
smgr->addQuake3SceneNode ( meshBuffer, shader );
#else
// Now add the MeshBuffer(s) with the current Shader to the Manager
#if 0
if ( shader->name != "textures/cf/window-decal"
)
continue;
#endif
if ( 0 == count )
{
core::stringc s;
//quake3::dumpShader ( s, shader );
printf ( s.c_str () );
}
count += 1;
node = smgr->addQuake3SceneNode ( meshBuffer, shader );
core::stringw name( node->getName() );
node = smgr->addBillboardTextSceneNode(
font,
name.c_str(),
node,
core::dimension2d<f32>(80.0f, 8.0f),
core::vector3df(0, 10, 0)
);
#endif
}
// original mesh is not needed anymore
mesh->releaseMesh ( quake3::E_Q3_MESH_ITEMS );
}
@ -270,11 +332,13 @@ int IRRCALLCONV main(int argc, char* argv[])
camera->setTarget ( pos + target );
index += 1;
/*
notEndList = ( index < (s32) entityList.size () &&
entityList[index].name == search.name &&
(device->getTimer()->getRealTime() >> 3 ) & 1
);
*/
notEndList = index == 2;
} while ( notEndList );
}
@ -287,8 +351,7 @@ int IRRCALLCONV main(int argc, char* argv[])
device->getCursorControl()->setVisible(false);
// load the engine logo
gui::IGUIEnvironment* env = device->getGUIEnvironment();
env->addImage(driver->getTexture("irrlichtlogo2.png"),core::position2d<s32>(10, 10));
gui->addImage(driver->getTexture("irrlichtlogo2.png"),core::position2d<s32>(10, 10));
// show the driver logo
core::position2di pos ( videoDim.Width - 128, videoDim.Height - 64 );
@ -296,14 +359,14 @@ int IRRCALLCONV main(int argc, char* argv[])
switch ( driverType )
{
case video::EDT_BURNINGSVIDEO:
env->addImage(driver->getTexture("burninglogo.png"),pos );
gui->addImage(driver->getTexture("burninglogo.png"),pos );
break;
case video::EDT_OPENGL:
env->addImage(driver->getTexture("opengllogo.png"),pos );
gui->addImage(driver->getTexture("opengllogo.png"),pos );
break;
case video::EDT_DIRECT3D8:
case video::EDT_DIRECT3D9:
env->addImage(driver->getTexture("directxlogo.png"),pos );
gui->addImage(driver->getTexture("directxlogo.png"),pos );
break;
}
@ -321,7 +384,7 @@ int IRRCALLCONV main(int argc, char* argv[])
{
driver->beginScene(true, true, video::SColor(255,20,20,40));
smgr->drawAll();
env->drawAll();
gui->drawAll();
driver->endScene();