Hi Everybody
according to the thread of Irrlicht TechDemo
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=11267
there was a simple project that written by MikeR , i have decided to make a Splash window for this project , i have chenged it so that it uses Fmod library instead of audiere library.
here are a screenShots of Splas Window
download it from here
http://bcxdx.spoilerspace.com/BCXGL/IrrTechDemo.zip
hope that you like it and add your own contribution code to make a stuning Irrlicht techDemo .
here is the Splash code
Code: Select all
/************************************
Magic library
Splash Window For Irrlicht
TechDemo
By Emil Halim
*************************************/
#include <CFmod.cpp>
struct chrPostion
{
f32 initX,initY,initZ;
f32 finlX,finlY,finlZ;
f32 X,Y,Z;
void Create(f32 ix,f32 iy,f32 iz,f32 fx,f32 fy,f32 fz)
{
initX=X=ix;
initY=Y=iy;
initZ=Z=iz;
finlX=fx;
finlY=fy;
finlZ=fz;
}
void Update(f32 factor)
{
if(factor < 0.0f)
{
X=initX;
Y=initY;
Z=initZ;
return;
}
if(factor > 1.0f)
{
X=finlX;
Y=finlY;
Z=finlZ;
return;
}
X=factor*finlX+(1.0f-factor)*initX;
Y=factor*finlY+(1.0f-factor)*initY;
Z=factor*finlZ+(1.0f-factor)*initZ;
}
};
ISceneManager* SplashSmgr=0;
SMaterial FontA;
TMagicCharSceneNode *CharNode[8];
chrPostion ChrPos[8];
SMaterial Rain;
TTime *Timer1,*Timer2,*Timer3;
SMaterial logoimage;
SMaterial rastaImage;
TFadeInOut* Fade;
#define StarCount 1000
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define Speed 0.2f
#define NoOfLayers 3
SMaterial dot;
IFmod* Music;
struct STAR
{
f32 x,y;
};
STAR Star[StarCount];
BOOL RenderSplash()
{
device->run();
driver->beginScene(true, true, SColor(0,0,0,0));
if(Timer1->CheckStartTime())
{
static f32 intr=0.0f,rot=0.0f;
intr+=0.001f;
rot+=1;
if(rot>359) rot=0.0f;
for(s32 i=0; i<8; i++)
{
ChrPos[i].Update(intr);
CharNode[i]->setPosition(vector3df(ChrPos[i].X,ChrPos[i].Y,ChrPos[i].Z));
CharNode[i]->setRotation(core::vector3df(0,rot,0));
}
}
if(Timer2->CheckStartTime())
{
static f32 fade =0.0;
const f32 Fval = 0.05f*4;
fade+=0.001f;
for(s32 i=0; i<8; i++)
if(fade>Fval*i)
{
f32 a = 1.0f-fade+Fval*i;
CharNode[i]->setAlpha(a>0?a:0);
}
}
if(Timer3->CheckTime())
{
ViewOrtho();
SetBlend(ALPHABLEND);
SetColor(255,255,255);
static f32 fd=0.0;
fd += 0.01f;
if(fd>1.0)fd=1.0;
SetAlpha(fd);
driver->setMaterial(Rain);
SetScale(1.5,3.0);
DrawImage(Rain,320,265);
SetScale(1.0,1.0);
driver->setMaterial(dot);
for(int k=0; k<NoOfLayers; k++)
{
u32 c = k*70+100;
SetColor(c,c,c);
for(int i=0; i<StarCount/NoOfLayers; i+=NoOfLayers)
{
Star[i+k].x -= Speed * (k+1);
if(Star[i+k].x<0)Star[i+k].x=SCREEN_WIDTH;
DrawImage(dot,Star[i+k].x,Star[i+k].y);
}
}
SetBlend(LIGHTBLEND);
SetScale(1.0f,1.7f);
SetColor(100,0,255);
SetAlpha(fd);
driver->setMaterial(rastaImage);
f32 xstart=0,ycenter=70,scale=28;
static f32 angle=0,angleadd=5,freq=1;
angle+=angleadd;
for(f32 i=0;i<640;i++)
{
f32 temp = i+xstart;
if(temp>0 || temp<640)
DrawImage(rastaImage, temp, ycenter + sin((i+angle)*freq*3.14159265f/180)*scale);
DrawImage(rastaImage, temp, ycenter+300 + sin((i+angle)*freq*3.14159265f/180)*scale);
}
SetColor(255,0,0);
SetScale(0.5f,1.0f);
Fade->FadeInOut(500,500,500,true);
driver->setMaterial(FontA);
DrawText("CLICK LEFT MOUSE KEY FOR SKIP",100,448);
ViewPerspective();
}
else
{
ViewOrtho();
SetBlend(ALPHABLEND);
SetColor(255,255,255);
SetAlpha(1.0);
static f32 Sy=3.0;
Sy -= 0.01f;
if(Sy<0)Sy=0;
SetScale(1.5,Sy);
driver->setMaterial(Rain);
DrawImage(Rain,320,265);
SetColor(255,0,0);
SetScale(0.5f,1.0f);
Fade->FadeInOut(500,500,500,true);
driver->setMaterial(FontA);
DrawText("CLICK LEFT MOUSE KEY FOR SKIP",100,448);
ViewPerspective();
}
SplashSmgr->drawAll();
ViewOrtho();
SetScale(1.0f,1.0f);
SetColor(255,10,255);
glLineWidth(5);
glPointSize(5);
driver->setMaterial(dot);
DrawFrame(0,0,640,480);
ViewPerspective();
driver->endScene();
BOOL falg = true;
if(KeyDown(32) || MouseLeftKeyDown()) falg = false;
return falg;
}
void InitSplash()
{
ICameraSceneNode* SplashCam = SplashSmgr->addCameraSceneNode(0, vector3df(0,0,-200), vector3df(0,0,0));
FontA.Texture1 = driver->getTexture("../../media/FontAmiga.bmp");
driver->makeColorKeyTexture(FontA.Texture1,position2d<s32>(0,0));
GLuint fntA = CreateFont(FontA,32,28,32);
SetFont(fntA);
for(s32 i=0; i<8; i++)
{
CharNode[i] = new TMagicCharSceneNode(SplashSmgr->getRootSceneNode(),SplashSmgr, i);
CharNode[i]->setFont(fntA,&FontA);
CharNode[i]->setBlend(ALPHABLEND);
CharNode[i]->setColor(255,255,255);
CharNode[i]->setPosition(vector3df(0.0f,0.0f,-201.0f));
CharNode[i]->setScale(vector3df(1,1.5f,0));
ChrPos[i].Create(0,0,-200,-140.0f+i*40,0,0);
}
CharNode[0]->setChar('I');
CharNode[1]->setChar('R');
CharNode[2]->setChar('R');
CharNode[3]->setChar('L');
CharNode[4]->setChar('I');
CharNode[5]->setChar('C');
CharNode[6]->setChar('H');
CharNode[7]->setChar('T');
Rain.Texture1 = driver->addTexture(dimension2d<s32>(512,100),"");
TTextureManipulator* txtImage = new TTextureManipulator(Rain.Texture1);
txtImage->StartDrawing();
txtImage->Clear();
u32 clr=0x00;
for(int h=1;h<50;h++)
{
for(int w=0;w<512;w++)
txtImage->WritePixel(w, h, 0xFF000000|clr);
clr+=0x5;
}
for(int h=50;h<100;h++)
{
for(int w=0;w<512;w++)
txtImage->WritePixel(w, h, 0xFF000000|clr);
clr-=0x5;
}
txtImage->StopDrawing();
dot.Texture1 = driver->addTexture(dimension2d<s32>(2,2),"");
s32* map =(s32*)dot.Texture1->lock();
for(int i=0;i<3;i++)*map++ = 0xFFffffff;
dot.Texture1->unlock();
rastaImage.Texture1 = driver->addTexture(dimension2d<s32>(2,64),"");
txtImage->set(rastaImage.Texture1);
txtImage->StartDrawing();
txtImage->Clear();
clr=0x00;
for(int h=0;h<32;h+=2)
{
for(int w=0;w<1;w++)
{
txtImage->WritePixel(w, h , 0xFF000000|clr);
txtImage->WritePixel(w, h+1, 0xFF000000|clr);
}
clr+=0xf0f0f;
}
for(int h=32;h<64;h+=2)
{
for(int w=0;w<1;w++)
{
txtImage->WritePixel(w, h , 0xFF000000|clr);
txtImage->WritePixel(w, h+1, 0xFF000000|clr);
}
clr-=0xf0f0f;
}
txtImage->StopDrawing();
randomize(GetTickCount()/1000);
for(int i=0;i<StarCount;i++)
{
reRndX:
Star[i].x = rnd()*(SCREEN_WIDTH);
if(Star[i].x > SCREEN_WIDTH || Star[i].x < 0) goto reRndX;
reRndY:
Star[i].y = rnd()*100+180;
if(Star[i].y > 180+90 || Star[i].y < 180) goto reRndY;
}
Fade = new TFadeInOut();
FmodInit();
Music = new TMusic;
Music->Load("../../media/mod/Efy8100.mp3");
Music->Play();
Music->SetVolume(100);
TimeInit();
Timer1 = new TTime(2000,0);
Timer2 = new TTime(8000,0);
Timer3 = new TTime(0,48000);
}
here is the Main code
Code: Select all
/*
This is a Demo project made by the Irrlicht Community, showing off as many of the features
as possible within a tech-demo.
This first part was made by Mike Rowley http://www.3dcentral.net and is just a basic structure for
the community to add to.
For this example, Irrlicht and audiere are in the root (C:|) directory.
*/
#include <irrlicht.h>
#include <Magic2d.hpp>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
IrrlichtDevice *device = 0;
s32 cnt = 0;
bool closeDevice=false;
video::IVideoDriver* driver;
scene::ISceneManager* smgr=0;
#include "splash.cpp"
/*
The first thing we have is our event reciever. We need this so that our users can press "esc"
to exit. The event reciever can also be extended to do other operations within our program.
*/
class MyEventReceiver : public IEventReceiver
{
public :
virtual bool OnEvent(SEvent event)
{
if(event.EventType = EET_KEY_INPUT_EVENT)
{
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
device->closeDevice();
break;
}
return false;
}
}
};
//Let's get our program running
int main()
{
//we need a device to render our program
MyEventReceiver receiver;
device = createDevice(video:: EDT_OPENGL ,
core::dimension2d<s32>(640, 480), 32, false,true,true,&receiver);
if (device == 0)
return 1; // could not create selected driver.
//! initializing Magic Library
bool rslt = InitMagic(device);
if(rslt == false)
printf("Magic Library will only work with OpenGL driver");
driver = device->getVideoDriver();
smgr = device->getSceneManager();
SplashSmgr = smgr->createNewSceneManager();
//Our main world is loaded from a pk3 zip file.
device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
//************ MAIN WORLD MESH *************************************************
//This world is complete with Irrlicht Collisions
scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp"); //It's in the zip file. No need to give directions.
scene::ISceneNode* q3node = 0;
if (q3levelmesh)
q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0));
scene::ITriangleSelector* selector = 0;
if (q3node)
{
q3node->setPosition(core::vector3df(-1370,-130,-1400));
selector = smgr->createOctTreeTriangleSelector(q3levelmesh->getMesh(0), q3node, 128);
q3node->setTriangleSelector(selector);
selector->drop();
}
//******How about a fire made with the Particle Scene Node*********************
// create camp fire
scene::IParticleSystemSceneNode* campFire = 0;
campFire = smgr->addParticleSystemSceneNode(false);
campFire->setPosition(core::vector3df(50,50,600));
campFire->setScale(core::vector3df(2,2,2));
campFire->setParticleSize(core::dimension2d<f32>(20.0f, 10.0f));
scene::IParticleEmitter* em = campFire->createBoxEmitter(
core::aabbox3d<f32>(-7,0,-7,7,1,7),
core::vector3df(0.0f,0.06f,0.0f),
80,100, video::SColor(0,255,255,255),video::SColor(0,255,255,255), 800,2000);
campFire->setEmitter(em);
em->drop();
scene::IParticleAffector* paf = campFire->createFadeOutParticleAffector();
campFire->addAffector(paf);
paf->drop();
campFire->setMaterialFlag(video::EMF_LIGHTING, false);
campFire->setMaterialTexture(0, driver->getTexture("../../media/fireball.bmp"));
campFire->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
//FPS CAMERA ************No Camera, No Scene*************************************
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0, 100.0f, 300.0f);
camera->setPosition(core::vector3df(-100,50,-150));
//Let's add a collision animator to the camera so that we have collision and gravity
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(30,50,30),
core::vector3df(0,-3,0),
core::vector3df(0,50,0));
camera->addAnimator(anim);
anim->drop(); //Do not forget to drop the animator when we are finished with it.
// disable mouse cursor ******We don't want to see that ugly thing.*********
device->getCursorControl()->setVisible(false);
//***********************************************************
scene::ISceneNode* selectedSceneNode = 0;
scene::ISceneNode* lastSelectedSceneNode = 0;
//**********************************************************
//********************************************************
// splash window stuff & music
InitSplash();
TSplash *splah = new TSplash(driver);
splah->playSplash(RenderSplash,55000,640,200);
SplashSmgr->drop();
Music->SetVolume(0);
//********************************************************
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0);
smgr->drawAll(); //Draw the scene.
core::line3d<f32> line;
line.start = camera->getPosition();
line.end = line.start + (camera->getTarget() - line.start).normalize() * 1000.0f;
core::vector3df intersection;
core::triangle3df tri;
if (smgr->getSceneCollisionManager()->getCollisionPoint(
line, selector, intersection, tri))
{
driver->setTransform(video::ETS_WORLD, core::matrix4());
}
selectedSceneNode = smgr->getSceneCollisionManager()->getSceneNodeFromCameraBB(camera);
if (lastSelectedSceneNode)
lastSelectedSceneNode->setMaterialFlag(video::EMF_LIGHTING, false);
if (selectedSceneNode == q3node)
selectedSceneNode = 0;
if (selectedSceneNode)
selectedSceneNode->setMaterialFlag(video::EMF_LIGHTING, false);
lastSelectedSceneNode = selectedSceneNode;
/*
That's it, we just have to finish drawing.
*/
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"DemoWorld - Irrlicht Engine Example [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
return 0;
}
thanks