Weapon drawed in front of all

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.
Nemesis
Posts: 65
Joined: Sun Mar 20, 2005 12:45 pm

Weapon drawed in front of all

Post by Nemesis »

Hello! What I've try to write( :lol: ) is that when I put my weapon in front of the camera(especially when I scale the mesh)I have as result an hidden weapon by wall. My best result was I see the weapon until I reach the walls, and when this happen the weapon is hidden back the walls :( .
I can avoid this? I write some piece of code here for well explanation:

Code: Select all

//add camera and collision detection
       scene::ICameraSceneNode* camera = 			
       camera = smgr->addCameraSceneNodeFPS(0,100.0f,300.0f);
	camera->setPosition(core::vector3df(-100,50,-150));

	scene::ISceneNodeAnimator* anim =    smgr->createCollisionResponseAnimator(
		selector, camera, core::vector3df(30,50,30),
		core::vector3df(0,-3,0),
		core::vector3df(0,50,0));
	camera->addAnimator(anim);
	anim->drop();
	
	//add the arm & weapon model
    scene::IAnimatedMesh * weaponmesh= smgr->getMesh("Data/weapon.ms3d");
    scene::IAnimatedMeshSceneNode * weaponode=smgr->addAnimatedMeshSceneNode(weaponmesh,camera,-1);
    
     if (weaponode)
	{
		weaponode->setMaterialTexture( 0, driver->getTexture("Data/weapontext.bmp") );
        weaponode->setMaterialFlag(EMF_LIGHTING, false);
		weaponode->setFrameLoop(0, 1);
	    weaponode->setScale(core::vector3df(6,6,6)); 
		weaponode->setPosition(core::vector3df(0,-52,100)); 
		camera->setPosition(core::vector3df(-60,60,-40)); 
	}
Anticipate thanks :) !
S.T.A.R.S.! (Resident Evil 3)
cartoonit
Posts: 286
Joined: Mon Nov 15, 2004 6:36 pm

Post by cartoonit »

Surely you should just set the parent of the weapon to be the camera...
http://irrlicht.sourceforge.net/phpBB2/ ... apon#25364

Did you search???
Nemesis
Posts: 65
Joined: Sun Mar 20, 2005 12:45 pm

Post by Nemesis »

Yes I've searched and I've found a billion of useful topics(crosshair,shooting tutorial,etc),also that. In any case thanks for info, but I mean I want that the weapon don't disappear when I'm near the wall, in fact the wall have collision,but still the weapon can pass the wall(but not the camera).
Anticipate thanks :) .
S.T.A.R.S.! (Resident Evil 3)
Nemesis
Posts: 65
Joined: Sun Mar 20, 2005 12:45 pm

Post by Nemesis »

Can anyone post me a little tutorial for how I can upload and insert images on my posts?Thanks!
S.T.A.R.S.! (Resident Evil 3)
Guest

Post by Guest »

If you just want the weapon to be drawn above all, maybe you could try around with some render stages ("node->registerNodeForRendering") , maybe with irr::video::ESNRP_TRANSPARENT it works? But I did not tryied it out...
Nemesis
Posts: 65
Joined: Sun Mar 20, 2005 12:45 pm

Post by Nemesis »

Thanks for info, but I can't include your code well :( . Maybe I've done something wrong... Can you post some specific code? Anticipate thanks!
S.T.A.R.S.! (Resident Evil 3)
SARIN
Posts: 139
Joined: Fri Oct 29, 2004 3:53 am

Post by SARIN »

i think there may be some way to manually render the node. try useing scenenode->render() after smgr->drawAll(). it might look like this

smgr->beginScene(0,0,SColor(0,0,0,0));
smgr->drawAll();
weaponnode->render();
guienv>drawAll();
smgr->endScene();

try it and see.
o, and i would love a tut for how to take screenshots, although to post them i no how, u just gotta link it to a site with the image
Nemesis
Posts: 65
Joined: Sun Mar 20, 2005 12:45 pm

Post by Nemesis »

Thanks for reply :) . I've just tried that code it work but bad :( .In fact, when the level is loaded first of all my problem isn't resolved, and second the weapon&arm move free if I press a button for moving(also the mouse) also this render() have create a second instance of the weapon(but I think this can be avoided clearing the code of one instance). In any case thanks for interesting my topic SARIN, I already know you, thank for crosshair code :) , I have this code included in my FPS, but I don't like that he move every time I move the camera with the mouse(I mean it move with camera but isn't freezed, like medal of honor or most of the FPS), do you know a mode for freeze it?
In any case,topic still open :) ...
S.T.A.R.S.! (Resident Evil 3)
Nemesis
Posts: 65
Joined: Sun Mar 20, 2005 12:45 pm

Post by Nemesis »

Maybe inserting the ellipsoid of the camera a bit large... But doing this I don't pass on holes between walls :( . Please help me! I need that modification... Otherwise seem that the weapon is a ghost that can pass though walls :? ...
S.T.A.R.S.! (Resident Evil 3)
SARIN
Posts: 139
Joined: Fri Oct 29, 2004 3:53 am

Post by SARIN »

u could make a separate sphere for the gun...
but, i noticed a post a while back about not haveing 2 collision animators. follow the code to make two by searching, but set the cam as the parent. it might work...
eXodus
Posts: 320
Joined: Tue Jan 04, 2005 10:07 am
Location: Canada
Contact:

Post by eXodus »

Some games bypass this "ghost" effect by loading some kind of holster animation if the weapons collides with an object.

I'm sure its dead simple to code with Irrlicht.
Nemesis
Posts: 65
Joined: Sun Mar 20, 2005 12:45 pm

Post by Nemesis »

Thanks for reply guys :) ! But I've don't fully understand what do you mean :( . Maybe we talk different languages(I'm italian :lol: ) , but with codes we talk the same language :lol: . Why don't you send me a possible code about this problem? Thanks :) !
S.T.A.R.S.! (Resident Evil 3)
Nemesis
Posts: 65
Joined: Sun Mar 20, 2005 12:45 pm

Post by Nemesis »

Maybe it's a bug of the engine itself?
S.T.A.R.S.! (Resident Evil 3)
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

I lost whole night about this and found the reason:

Irrlicht collision won't works with Child Nodes!!!

If you take a look on CSceneNodeAnimatorCollisionResponse code can see that are used relative positions of node to detect collision point.
In this case collision can work only for parent node.
I'll post about it in Bug Report forum
ImageImage
Site development -Rock and metal online
--- etcaptor.com ------freenetlife.com
Xico
Posts: 30
Joined: Sun Jun 05, 2005 5:08 pm
Location: Buenos Aires, Argentina
Contact:

Post by Xico »

etcaptor wrote:I lost whole night about this and found the reason:

Irrlicht collision won't works with Child Nodes!!!

If you take a look on CSceneNodeAnimatorCollisionResponse code can see that are used relative positions of node to detect collision point.
In this case collision can work only for parent node.
I'll post about it in Bug Report forum
Not sure this is a bug. Actually I'm using it as a feature. By Example: have a spaceship flyng with some child nodes as thrusters, energy shield or any other visual effects; and i don't want to have col. detection for that nodes, just for the ship mesh.

A solution for the weapon problem can be change the ellipsoid radio, scale and position, trying to have the weapon inside the ellipsoid.

Regards
Post Reply