starnge problems with eventreceiver ~help

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
Dragonair
Posts: 5
Joined: Fri Jan 02, 2009 11:20 am

starnge problems with eventreceiver ~help

Post by Dragonair »

hi,

i dont know whats happening .. i have created an event listener and coded to get a scene node's bBox displayed on clicking over it.. but when i click the the scene node it gets selected but thegui elemnts get disabled...

here is my source code :
pls chk it and tell me whats wrong :cry:

http://sites.google.com/site/piccolodbz ... ects=0&d=1

also the grid's color is changed.. automatically
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: starnge problems with eventreceiver ~help

Post by randomMesh »

Please post a minimal compilable snippet which reproduces the problem (using the

Code: Select all

 tags), rather than a link to a 3.1MB zip file.
"Whoops..."
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Re: starnge problems with eventreceiver ~help

Post by Acki »

Dragonair wrote:when i click the the scene node it gets selected but thegui elemnts get disabled...
can't reproduce this, I even don't see any gui elements... :shock:
or do you mean the toolbar, it works for me... ;)
Dragonair wrote:also the grid's color is changed.. automatically
this is just because you have lighting disabled for the grid, moreover you don't set the lighting and so it takes it from the last elementthat was rendered befor the grid...

simply add this lines before you draw the lines (also set the matrix to world view, you commented it with using projection matrix):

Code: Select all

SMaterial mat;
mat.Lighting = false;
mainDevice->getVideoDriver()->setTransform(ETS_WORLD,matrix4());
mainDevice->getVideoDriver()->setMaterial(mat);
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Dragonair
Posts: 5
Joined: Fri Jan 02, 2009 11:20 am

Post by Dragonair »

thanks for reply ..

sorry for the source code i posted ...i didnt knew bout it...

and yeah
@ above .. thanks for your reply .. it worked for grid :) .. but the problem of gui elements is still remaining ... by gui element i meant the menu at the top... when i click the scene then the current active camera is kindda bound to screen and i cant select anything else :( ..

what i did is :

in global i declared these :

Code: Select all

ISceneNode* nodeSelected=0;
ISceneNode* prevNodeSelected=0;
then in main loop :

Code: Select all

while(mainDevice->run()){
			if(mainDevice->isWindowActive()){
				//vidDriver->beginScene(true,true,SColor(255,255,255,255));
			vidDriver->beginScene((bool)v3s.backBuffer,(bool)v3s.zBuffer,SColor(v3s.bgAlpha,v3s.bgRed,v3s.bgGreen,v3s.bgBlue));
			
			//selection of nodes

			core::line3d<f32> ray;
			vector3df intersection; 
			triangle3df hitTriangle; 
			nodeSelected=0;
			ray = mainDevice->getSceneManager()->getSceneCollisionManager()->getRayFromScreenCoordinates(mainDevice->getCursorControl()->getPosition(),mainDevice->getSceneManager()->getActiveCamera());
			nodeSelected =  mainDevice->getSceneManager()->getSceneCollisionManager()->getSceneNodeAndCollisionPointFromRay(ray,intersection,hitTriangle,0,0);
			
		

			//
			
			
			
			  //	draw if window is active
			mainSceneManager->drawAll();
			//mainDevice->getCursorControl()->setVisible(false);
			sceneHandler1.draw3DGrid();
			
			
			
			iEnv->drawAll();
					
			
			//handler1.draw2DGrid(v3s.winWidth,v3s.winHeight,2,false,SColor(255,255,255,255),SColor(255,255,255,255));
			activeCam = mainDevice->getSceneManager()->getActiveCamera();//get active camera

			mainDevice->getGUIEnvironment()->drawAll();
			mainDevice->setWindowCaption(sfn.c_str());

			//driverInfoBox
			handler1.drawDriverInfoBox();

			
			vidDriver->endScene();
			
				}
			else{
			mainDevice->yield();
				}
			};


and in event receiver :

Code: Select all

if(events.EventType == EET_MOUSE_INPUT_EVENT){
			if(events.MouseInput.Event == EMIE_LMOUSE_LEFT_UP){
				
				if(nodeSelected)
					{
					nodeSelected->setDebugDataVisible(EDS_BBOX);
					prevNodeSelected=nodeSelected;
					}
				else
					{
					if(prevNodeSelected){
						prevNodeSelected->setDebugDataVisible(EDS_OFF);
						}
					}
					
			
				return true;
					
				}
			return false;
}
and also i have added cameras array cam[3] one of which is maya another fps and further one is simple camera scene node.. when i click the model , it gets selected but the menu at the top gets disabled or something similar .. :(
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Dragonair wrote:by gui element i meant the menu at the top... when i click the scene then the current active camera is kindda bound to screen and i cant select anything else :( ..
but that doesn't mean the tool bar is disabled (like you described) !!! :roll:
it's a problem with your camera array, you seem to change the camera somewhere when you act on the selection klick... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Dragonair
Posts: 5
Joined: Fri Jan 02, 2009 11:20 am

Post by Dragonair »

yess you were right .. :) it was the problem with my cams..

one more thing to ask.. please tell me how to create a 3d object mover like one in the center of this image :
Image

:)
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Post by randomMesh »

Dragonair wrote:how to create a 3d object mover like one in the center of this image :
You can use a custom scene node for this. Have a look at tutorial 03.CustomSceneNode.
"Whoops..."
Dragonair
Posts: 5
Joined: Fri Jan 02, 2009 11:20 am

Post by Dragonair »

k thankx :)
Post Reply