A few little problems

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
Andrey
Posts: 17
Joined: Sat Aug 05, 2006 6:53 pm
Location: Ukraine

A few little problems

Post by Andrey »

Hi all!
I'm new to Irrlicht and have some questions...
The first is: Why when I make so:

Code: Select all

EventReceiver* ev_rec = new EventReceiver;
IrrlichtDevice* device = createDevice(video::EDT_DIRECT3D9, 
		dimension2d<s32>(640, 480), false, false, false, ev_rec);
, i become the warning :

Code: Select all

warning C4800: 'EventReceiver *' : forcing value to bool 'true' or 'false' (performance warning)
and my eventreceiver doesn't work (I've cheked this via "brakes").
And when I do so :
device->setEventReceiver(ev_rec);
, then all is ok.

And my second problem is when I load a simple cube (e.q.) and make an event when I click on it. It's all ok, clicking works fine, but I've observed, that there are some points on the screen, when I click on one of them, my event reacts to it...but it shouldn't...
I use Blender 2.42 and DirectXExporter 1.41 to convert to the .X file. Does any-one had a problem like this, or I just make something wrong?
ahluka
Posts: 3
Joined: Wed Apr 12, 2006 3:38 pm
Location: South Wales, UK

Post by ahluka »

You're missing out the bits per pixel argument.

Code: Select all

device = createDevice( driverType, dimension2d<s32>(512, 384), 32, false, false, false, &recv );
Trial and error is worth a thousand explanations.
Andrey
Posts: 17
Joined: Sat Aug 05, 2006 6:53 pm
Location: Ukraine

Post by Andrey »

ahluka wrote:You're missing out the bits per pixel argument.

Code: Select all

device = createDevice( driverType, dimension2d<s32>(512, 384), 32, false, false, false, &recv );
He...really:)..thanx.
Andrey
Posts: 17
Joined: Sat Aug 05, 2006 6:53 pm
Location: Ukraine

Post by Andrey »

And as regards the second question, so I've tried to load *.ms3d file, created in MilkShape and got the same problem : I've found some points.. when I click on one of them, EventReceiver think, that these points belong to my 3dobject...
Here is my OnEvent(), but here is nothing extraordinary :

Code: Select all

bool EventReceiver::OnEvent(SEvent event)
{
	if(event.EventType == EET_MOUSE_INPUT_EVENT)
	{
		if(event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
		{
			if(in->CollisionManager->getSceneNodeFromScreenCoordinatesBB(position2d<s32>(event.MouseInput.X, event.MouseInput.Y), false))
				std::cout << "\nSELECTED!!!!!!!!!!!";

		}
	}
	return true;
}
Does any-one has any suppositions, what the reasons for this problem can be? Or is it a bug?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Since you're using the bounding box check it is likely that your event receiver reacts to positions which are near, though not inside the mesh. But it's much faster this way. But a simple cube should work. Try setting the debug data visibility to show the bounding boxes.
Andrey
Posts: 17
Joined: Sat Aug 05, 2006 6:53 pm
Location: Ukraine

Post by Andrey »

The problem is solved!!!!!!!! :D
So, first i had the code like this :

Code: Select all

ISceneNode* node1 = NULL; 
			node1 = in->CollisionManager->getSceneNodeFromScreenCoordinatesBB(position2d<s32>(event.MouseInput.X, event.MouseInput.Y), false);
			if(node1)
			{
                std::cout << "\nSELECTED!!!!!!!!!!!";
}
But it didn't work normal. The reason -- SetSceneNodeFromScreenCoordinatesBB (I don't know why) returns_NOT_ALWAYS "NULL" in case of clicking on the empty place! It can return a node, that have a BoundingBox{0,0,0,0,0,0}. So, it give back to us not_empty node (but not always)!

And when I changed my code like this :

Code: Select all

ISceneNode* node1 = NULL; 
			node1 = in->CollisionManager->getSceneNodeFromScreenCoordinatesBB(position2d<s32>(event.MouseInput.X, event.MouseInput.Y), false);
			if(node1 == in->sc_node)
			{
                std::cout << "\nSELECTED!!!!!!!!!!!";
}
Then all works fine!
But in Help we can see a few words about SetSceneNodeFromScreenCoordinatesBB:

Code: Select all

Returns:
Returns the visible scene node under screen coordinates with matching bits in its id. If there is no scene node under this position, 0 is returned. 
So, it's either variance, or a little bug :)
Post Reply