Posted: Sun Nov 15, 2009 9:10 am
So I noticed its not light that moves, but shadows. None knows what to do with this? Could it be a problem with my graphic card?(I have problems with my graphic card in games)
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Code: Select all
#include <irrlicht.h>
#include <iostream>
#include <XEffects.h>
#include <CShaderPre.cpp>
#include <EffectHandler.cpp>
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
const float pi = 22.0/7.0; //pretty useful, you know?
int daytime= 60*6; //this is 360 minutes after midnight
const int gameMinsPerMin= 60*24;
int main()
{
//E_DRIVER_TYPE driverType = EDT_OPENGL;//default is opengl - any problems?
IrrlichtDevice *device =
createDevice(EDT_OPENGL, dimension2d<u32>(1024, 768), 16, true, true, true, 0);//fullscreen, shadows, some kind of sync, unknown value
if (!device)
return 1;
device->setWindowCaption(L"3DGame");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT, true);
//-----COOL FONT--------------------------------------------------------
stringw text= L"Arrows to move\nAlt+F4 to exit\n\nGame mins per min: ";
text += gameMinsPerMin;
guienv->addStaticText(text.c_str(),
rect<s32>(10,10,120,50), true);
//-----CAMERA-------------------------------------------------------------
ICameraSceneNode* camera =smgr->addCameraSceneNodeFPS(0, //parent
60, //rotatespeed
0.04,//movespeed
-1, //id
0, //keymap array
0, //keyMapSize
true, //noVerticalMovement
3.0f, //jumpSpeed
false); //invertMouse
camera->setPosition(vector3df(0,160,0));
camera->setFarValue(100000);
device->getCursorControl()->setVisible(false);
//-----LEVEL LOADING------------------------------------------------------
if(smgr->loadScene("./data/levels/test2/Scene.irr")==false) device->drop();
EffectHandler* effect = new EffectHandler(device, driver->getScreenSize(), false, false);
effect->setAmbientColor(SColor(255, 32, 32, 32));
effect->setClearColour(SColor(255, 50, 50, 100));
IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();
array<ISceneNode *> nodes;
smgr->getSceneNodesFromType(ESNT_ANY, nodes); // Find all nodes
for (u32 i=0; i < nodes.size(); ++i)
{
ISceneNode * node = nodes[i];
node->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
//---DYNAMIC SHADOWS---------
node->getMaterial(0).Lighting = false;
E_FILTER_TYPE filterType = (E_FILTER_TYPE)clamp<u32>((u32)1 - '1', 0, 4);
effect->addShadowToNode(node, filterType, ESM_BOTH);
ITriangleSelector * selector = 0;
switch(node->getType())
{
case ESNT_CUBE:
case ESNT_ANIMATED_MESH:
selector = smgr->createTriangleSelector(((IAnimatedMeshSceneNode*)node)->getMesh(), node);
break;
case ESNT_MESH:
selector = smgr->createTriangleSelector(((IMeshSceneNode*)node)->getMesh(), node);
break;
case ESNT_SPHERE: // Derived from IMeshSceneNode
selector = smgr->createTriangleSelector(((IMeshSceneNode*)node)->getMesh(), node);
break;
case ESNT_TERRAIN:
selector = smgr->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node);
break;
case ESNT_OCT_TREE:
selector = smgr->createOctTreeTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
break;
default:
break;
}
if(selector)
{
meta->addTriangleSelector(selector);
selector->drop();
}
}
ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(meta, camera, vector3df(5,5,5), vector3df(0,-10,0), vector3df(0,5,0));
meta->drop();
camera->addAnimator(anim);
anim->drop();
//-----SUN---------------------------------...staring into the shining sun
/*ISceneNode* sun = 0;
sun = smgr->addLightSceneNode(0, vector3df(0,0,0),SColorf(.9f, .7f, .7f, .9f), 1000000.0f);//akoze slnko
ISceneNodeAnimator* sunAnim = 0;
sunAnim = smgr->createFlyCircleAnimator (vector3df(0,0,0), //center
500, //radius = 100.f,
(((((((2*pi)/24))/1000)/60)/60)*gameMinsPerMin), //speed = 0.001f,
vector3df(1.f, 0.f, 0.f), //direction = vector3df(0.f, 1.f, 0.f),
0, //startPosition = 0.f,
0); //radiusEllipsoid = 0.f
sun->addAnimator(sunAnim);
sunAnim->drop();
sun = smgr->addBillboardSceneNode(sun, dimension2d<f32>(25, 25));
sun->setMaterialFlag(EMF_LIGHTING, false);
sun->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
sun->setMaterialTexture(0, driver->getTexture("./data/textures/sun.bmp"));*/
effect->addShadowLight(SShadowLight(4096, vector3df(100, 100, 100), vector3df(0, 0, 0), //real sun
SColor(0, 200, 150, 150), 0.0f, 1000.0f, 89.9f * DEGTORAD));
//-----MAIN LOOP---------------------------------------------------------
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
guienv->drawAll();
effect->update();
driver->endScene();
}
device->drop();
return 0;
}
Code: Select all
if(node->getType() == ESNT_CAMERA)
continue;
Yes I think there is no way at the moment. I was going to add it in the previous release but I realised the design of XEffects didn't make it easy to retrieve and manipulate shadow lights. Instead you will have to wait until shadows are integrated in Irrlicht for easy manipulation of shadows using the famliar ILightSceneNode and SLightData interfaces.ent1ty wrote:How about destroying the shadowlight? is there no way?
Thanks but that's ok I can certainly make them optional..BlindSide wrote:@xDan and 3DModellerman: Most effects aren't supported on SM 2.0 cards. The most you'll get is standard shadow mapping without any filtering. If using this in an application I recommend that you have these effects optional and only enable them when the graphics card can run them. xDan if you pay for shipping I can send you my old AGP Geforce 6200 which can run all the effects but its a bit slow and old.
Hopefully in Irrlicht 1.7ent1ty wrote:Too bad I could save 5 fps in night and another 5 when flashlight turned off. Is there any chance of adding this soon?