Drawing a gun model with a FPS 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
Ivo Georgiev
Posts: 27
Joined: Wed Dec 12, 2007 7:05 pm

Drawing a gun model with a FPS camera

Post by Ivo Georgiev »

I want to add a gun model to one FPS camera...like in the normal fps games...the FPS camera is named "camera"
I am sorry for the "write my code" question...
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Please use the search feature on the forums as this question has been asked numerous times:

http://irrlicht.sourceforge.net/phpBB2/ ... d%20camera
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Post by christianclavet »

You could load your gun then parent it to the camera simply.

Use something like this (check in the SDK for the complete syntax)

gun->setParent(Camera)

Once that is done, you will still have to position it so that it look ok in your view. But it should follow your camera moves.
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

Simply put, the mesh is loaded in front of the camera, you want it to stay there, it could even be an arm attached to a gun floating in the air, yet the player would never know it. So the parent is the camera, holding the child.
Programming Blog: http://www.uberwolf.com
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: Drawing a gun model with a FPS camera

Post by rogerborg »

Ivo Georgiev wrote:I want to add a gun model to one FPS camera...like in the normal fps games...
That's great, you go ahead and do that.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Ivo Georgiev
Posts: 27
Joined: Wed Dec 12, 2007 7:05 pm

Post by Ivo Georgiev »

Thanks, it worked...I am sorry...I wasnt able to find the search form...You are forgeting something : "gunnode->setPosition(core::vector3df(something , something1 , something2));"
I cant make the gun visible...It is aways behind the camera :D I cant put the right values in "something", "something1", "something2"
LosNir
Posts: 43
Joined: Wed Dec 19, 2007 6:38 pm
Location: Israel
Contact:

Post by LosNir »

try:

gunnode->setPosition(gunnode->getPosition()+core::vector3df(5 , 5 , 5));

also, make sure the model is correctly loaded.
Ivo Georgiev
Posts: 27
Joined: Wed Dec 12, 2007 7:05 pm

Post by Ivo Georgiev »

When I dont set it as a child, it shows up in the middle of the map...so it works...now I will try your code
Post Reply