Page 1 of 1

problem with moveing (when it should not ) draw3DBox

Posted: Thu Feb 26, 2009 10:41 am
by MarcinS
the idea of this little code is to make object moveing by clicikng on "floorcuebes".

"node" is a character that will be moved.

receiver is my own receiver

I also want to draw 3Dbox that will show on wich cube i just pointed. Well my problem is that it draws the box aroud the "node" and move it with "him"

Code: Select all

scene::ISceneNodeAnimator* anim = NULL;
		while(device->run())
			{
				 driver->beginScene(true, true, video::SColor(0,255,200,0));
				
				 smgr->drawAll();
				 if(receiver.MouseL() == 1)
					{
						target = smgr->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(core::position2di(receiver.MouseX(),receiver.MouseY()));
						anim = smgr->createFlyStraightAnimator(node->getPosition(),target->getPosition(),3500);
						target = NULL;
						receiver.MReset();
					}
				 if((receiver.MouseL() == 0)&&(receiver.MouseR() == 0))
					{
						target = smgr->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(core::position2di(receiver.MouseX(),receiver.MouseY()));
						if(target)
						{
							if (target->getID()==1)
							{
    sel_ = target->getBoundingBox();
								driver->draw3DBox(sel_);
							}
						}
						target = NULL;
						receiver.MReset();
					}
				 if (anim!=NULL)
					{
                        node->addAnimator(anim);
                        anim->drop();
						anim = NULL;
					}
				 driver->endScene();
			}

Image


Where is my mistake?[/img]

(i know i should edit the moving method becouse it will change speed etc. but this is not the goal now)

Posted: Thu Feb 26, 2009 10:54 am
by JP
Read the documentation for the draw3DBox function, it'll probably tell you that you need to set the driver's transformation matrix and material before calling the function, currently it's using the matrix and material from the previously rendered node.