look a weapon to the camera

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
804
Posts: 73
Joined: Thu Nov 10, 2011 7:07 pm

look a weapon to the camera

Post by 804 »

I have a modell of a weapon and I want to lock it to the camera, so if the player walks and turns around the weapon moves, too.
///////////////////////////////////////////
My Forum: http://game-home.1x.de/
My Homepage: http://mediadesign.about.lc/
///////////////////////////////////////////
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: look a weapon to the camera

Post by serengeor »

804 wrote:I have a modell of a weapon and I want to lock it to the camera, so if the player walks and turns around the weapon moves, too.
And what exactly does prevent you from doing that?
Working on game: Marrbles (Currently stopped).
804
Posts: 73
Joined: Thu Nov 10, 2011 7:07 pm

Re: look a weapon to the camera

Post by 804 »

A first person-camera with weapon !
but i don't know how to pos or rot it to get the right effect.

A view like this:
Image
///////////////////////////////////////////
My Forum: http://game-home.1x.de/
My Homepage: http://mediadesign.about.lc/
///////////////////////////////////////////
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: look a weapon to the camera

Post by serengeor »

and as I said, what does prevent you from coding it? what problems have occured when you tried? did you even try..?
Working on game: Marrbles (Currently stopped).
804
Posts: 73
Joined: Thu Nov 10, 2011 7:07 pm

Re: look a weapon to the camera

Post by 804 »

Yes i did a try!
the problem is that the weapon isn't at the same position as the camera, so i need some kind of circle animator
///////////////////////////////////////////
My Forum: http://game-home.1x.de/
My Homepage: http://mediadesign.about.lc/
///////////////////////////////////////////
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: look a weapon to the camera

Post by hybrid »

I think you should revisit the point where parent and child nodes are explained. Child nodes will make every transformation the parent does. So no need to animate here, just position the weapon properly as a child. But I guess that a search for weapon an camera would have brought up many threads which explain this.
804
Posts: 73
Joined: Thu Nov 10, 2011 7:07 pm

Re: look a weapon to the camera

Post by 804 »

Ok thanks, i will take a Look!
///////////////////////////////////////////
My Forum: http://game-home.1x.de/
My Homepage: http://mediadesign.about.lc/
///////////////////////////////////////////
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: look a weapon to the camera

Post by mongoose7 »

Why not just render the weapon on top of the scene? The view of the weapon is purely notional.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: look a weapon to the camera

Post by hendu »

It should go before the scene say AMD and Nvidia, since it covers a significant amount of area and can save drawing there :)
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: look a weapon to the camera

Post by Radikalizm »

hendu wrote:It should go before the scene say AMD and Nvidia, since it covers a significant amount of area and can save drawing there :)
Yeah, better to render it in the actual scene pass instead of as an overlay, irrlicht automatically does depth sorting based on a node's distance to the camera, so it would always be rendered first
804
Posts: 73
Joined: Thu Nov 10, 2011 7:07 pm

Re: look a weapon to the camera

Post by 804 »

Any examples, i don't understand how this Gould work.
///////////////////////////////////////////
My Forum: http://game-home.1x.de/
My Homepage: http://mediadesign.about.lc/
///////////////////////////////////////////
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: look a weapon to the camera

Post by Radikalizm »

804 wrote:Any examples, i don't understand how this Gould work.
Everything you need to do has been said, create your weapon node, add it as a child to the camera and position it so it looks correct on screen
There really is nothing more to it...
804
Posts: 73
Joined: Thu Nov 10, 2011 7:07 pm

Re: look a weapon to the camera

Post by 804 »

ISceneManager* smgr = device->getSceneManager();

ICameraSceneNode* Cam = smgr->addCameraSceneNode();

IAnimatedMeshSceneNode* weapon = smgr->addAnimatedMeshSceneNode(smgr->getMesh("media/gun.x"), Cam);
///////////////////////////////////////////
My Forum: http://game-home.1x.de/
My Homepage: http://mediadesign.about.lc/
///////////////////////////////////////////
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: look a weapon to the camera

Post by hendu »

Radikalizm wrote: Yeah, better to render it in the actual scene pass instead of as an overlay, irrlicht automatically does depth sorting based on a node's distance to the camera, so it would always be rendered first
Only the transparent and light passes are sorted by distance, solids are by texture (at least in 1.7).
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Re: look a weapon to the camera

Post by Radikalizm »

hendu wrote:
Radikalizm wrote: Yeah, better to render it in the actual scene pass instead of as an overlay, irrlicht automatically does depth sorting based on a node's distance to the camera, so it would always be rendered first
Only the transparent and light passes are sorted by distance, solids are by texture (at least in 1.7).
Ah, did not realize that, haven't taken a look at the irrlicht source for a while now so it's all a bit rusty :D
Post Reply