I have Problem with Lightning, i loaded a small map, and 2 Bushes.
The Bushes don't need Backface culling.
here is the first Problem:
and here my second:
Thats the Code:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
bool ERROR = false;
int main()
{
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(800, 600), 32, false, true, false, 0);
if (!device)
return 1;
device->setWindowCaption(L"RaverShoot");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* gui = device->getGUIEnvironment();
IAnimatedMesh* Mesh = smgr->getMesh("Map1.x");
if(Mesh)
{
ISceneNode* Map = smgr->addAnimatedMeshSceneNode(Mesh);
}
else ERROR = true;
IAnimatedMesh* Mesh1 = smgr->getMesh("Plant.obj");
if(Mesh1)
{
ISceneNode* Plant = smgr->addAnimatedMeshSceneNode(Mesh1);
Plant->setScale(vector3df(20, 20, 20));
Plant->setPosition(vector3df(-130, 0, 0));
Plant->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
Plant->setMaterialFlag(EMF_LIGHTING, false);
IAnimatedMeshSceneNode* Plant2 = smgr->addAnimatedMeshSceneNode(Mesh1);
Plant2->setScale(vector3df(20, 20, 20));
Plant2->setPosition(vector3df(0, 0, 130));
Plant->setMaterialFlag(EMF_BACK_FACE_CULLING, false); // dont work ???? -.-
Plant2->addShadowVolumeSceneNode();
}
else ERROR = true;
ILightSceneNode* Light1 = smgr->addLightSceneNode(0, vector3df(100, 200, 100), SColor(255, 170, 0, 200), 500);
Light1->setLightType(ELT_POINT);
IAnimatedMesh* LightSphere = smgr->addSphereMesh("LightSphere");
ISceneNode* LightSphereNode = smgr->addAnimatedMeshSceneNode(LightSphere);
LightSphereNode->setPosition(vector3df(100, 200, 100));
//ICameraSceneNode* Camera = smgr->addCameraSceneNode(0, vector3df(300, 300, 300), vector3df(0, 0, 0));
ICameraSceneNode* Camera = smgr->addCameraSceneNodeFPS(0, 50, 0.1);
Camera->setPosition(vector3df(100, 200, 100));
Camera->setTarget(vector3df(0, 0, 0));
if(ERROR)
{
smgr->clear();
IGUIWindow* WND = gui->addWindow(rect<s32>(100, 100, 500, 400), false, L"Error");
gui->addStaticText(L"Can't load Objects",rect<s32>(10, 25, 390, 290), true, false, WND, -1, true);
}
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
gui->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Thanks RaverGames