Heres the whole code that I was working on when I got this.
Code: Select all
#include <irrlicht.h>
#include <iostream>
#include <windows.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui;
#ifdef _MSC_VER
#pragma comment(lib, "Irrlicht.lib")
#endif
int main()
{
//Screen size 640, 480, 32 bit, fullscreen = false, stencilbuffer = false, vsync = true
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 32, false, true, false);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
/////////////////////////////////////////////////////////////////////////
// START ---- CAMERA
/////////////////////////////////////////////////////////////////////////
//parent = 0, rotateSpeed AKA mouse = 0, moveSpeed = 0.1f
scene::ICameraSceneNode * camera = smgr->addCameraSceneNodeFPS(0, 100.f, 0.1f);
camera->setPosition(core::vector3df(40.f, 20.f, 5.f));
device->getCursorControl()->setVisible(false);
/////////////////////////////////////////////////////////////////////////
// START ---- CAMERA
/////////////////////////////////////////////////////////////////////////
//Create a cube
ISceneNode* cubey = smgr->addCubeSceneNode();
//Add light
smgr->setAmbientLight(video::SColorf(0.3,0.3,0.3,1));
scene::ISceneNode* light01 = smgr->addLightSceneNode(0, core::vector3df(10,450,0), video::SColorf(0,50,150), 800.0f);
light01 = smgr->addBillboardSceneNode(light01, core::dimension2d<f32>(500, 500));
light01->setMaterialFlag(video::EMF_LIGHTING, false);
light01->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
light01->setMaterialTexture(0, driver->getTexture("./media/particlewhite.bmp"));
// First, this is the path to the texture you want to use for your sphere
smgr->addSkyDomeSceneNode(driver->getTexture("./media/sky.jpg"),
16, // 16 rows from top to bottom
16, // rectangles each row
1.0f, // percent of the texture used, example 0.9f will only use the top 90% of the image file (range 0.0f-1.0f)
2.0f); // percent of the sphere to cover 1.0f covers the top half of the sphere, while 2.0f covers the entire sphere
// create a particle system
scene::IParticleSystemSceneNode* ps = smgr->addParticleSystemSceneNode(false);
scene::IParticleEmitter* em = ps->createBoxEmitter(
core::aabbox3d<f32>(-7,0,-7,7,1,7), // emitter size
core::vector3df(0.0f,-0.06f,0.0f), // initial direction
10,100, // emit rate
video::SColor(0,0,0,255), // darkest color
video::SColor(0,255,255,255), // brightest color
80,20000,0, // min and max age, angle
core::dimension2df(5.f,5.f), // min size
core::dimension2df(20.f,20.f)); // max size
ps->setEmitter(em); // this grabs the emitter
em->drop(); // so we can drop it here without deleting it
scene::IParticleAffector* paf = ps->createFadeOutParticleAffector();
ps->addAffector(paf); // same goes for the affector
paf->drop();
ps->setPosition(core::vector3df(10,450,0));
ps->setScale(core::vector3df(100,100,100));
ps->setMaterialFlag(video::EMF_LIGHTING, false);
ps->setMaterialFlag(video::EMF_ZWRITE_ENABLE, false);
ps->setMaterialTexture(0, driver->getTexture("./media/rain.jpg"));
ps->setMaterialType(video::EMT_TRANSPARENT_VERTEX_ALPHA);
IAnimatedMesh* plane = smgr->addHillPlaneMesh("floor", // Name of mesh
core::dimension2d<f32>(20,20), // Size of a tile of the mesh. (10.0f, 10.0f) would be a good value to start, for example.
core::dimension2d<u32>(40,40), 0, 0, // Specifies how much tiles there will be. If you specifiy for example that a tile has the size (10.0f, 10.0f) and the tileCount is (10,10), than you get a field of 100 tiles which has the dimension 100.0fx100.0f.
core::dimension2d<f32>(0,0), //material
core::dimension2d<f32>(10,10)); //countHills
IAnimatedMesh* mesh = smgr->getMesh("./media/tree01.b3d");
IAnimatedMeshSceneNode* tree = smgr->addAnimatedMeshSceneNode(mesh);
tree->setMaterialFlag(EMF_LIGHTING, false);
tree->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
tree->setPosition(core::vector3df(0,8,0));
IAnimatedMesh* mesh1 = smgr->getMesh("./media/island.obj");
IAnimatedMeshSceneNode* island = smgr->addAnimatedMeshSceneNode(mesh1);
island->setMaterialTexture(0, driver->getTexture("./media/sand.jpg"));
island->setMaterialFlag(EMF_LIGHTING, false);
island->setScale(core::vector3df(10,10,10));
island->setPosition(core::vector3df(0,21.5,0));
camera->setTarget(island->getAbsolutePosition());
//IAnimatedMeshSceneNode* floor = smgr->addAnimatedMeshSceneNode(plane);
//mesh, waveheight, wave speed, wave length
ISceneNode* sea = smgr->addWaterSurfaceSceneNode(plane->getMesh(0), 0.5f, 350.0f, 80.0f);
sea->setMaterialTexture(0, driver->getTexture("./media/sand.jpg"));
sea->setMaterialTexture(1, driver->getTexture("./media/water.jpg"));
sea->setMaterialFlag(EMF_LIGHTING, true);
sea->setMaterialType(video::EMT_REFLECTION_2_LAYER);
scene::ITriangleSelector* selector = smgr->createTriangleSelectorFromBoundingBox(sea);
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(5,5,5),
core::vector3df(0,0,0)
);
camera->addAnimator(anim);
anim->drop();
/////////////////////////////////////////////////////////////////////////
// Main loop
/////////////////////////////////////////////////////////////////////////
int lastFPS = -1;
while(device->run() && !GetAsyncKeyState(VK_ESCAPE))
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Petes Weather System [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}else{
device->yield(); //Cause the device to temporarily pause execution and let other processes run.
}
device->drop();
return 0;
}
I don't think you need it.
But I hope this might help something.