Problem with light

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
RaverGames
Posts: 17
Joined: Sat Sep 25, 2010 8:54 am

Problem with light

Post by RaverGames »

Hello

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:

Image

and here my second:

Image

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;
}
This is what the console says:

Image

Thanks RaverGames
RaverGames
Posts: 17
Joined: Sat Sep 25, 2010 8:54 am

Post by RaverGames »

Ok i found the answer myself.

I forgot tu use

Code: Select all

->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
because i scaled the Plants
Post Reply