Muzzle Flash

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
Xenocide

Muzzle Flash

Post by Xenocide »

Ok, I'm trying to set it up so that when you press the left mouse button it will
display a muzzle flash.

I'm trying to use an image like the particle pictures to show a muzzle flash effect. How would I display the picture near the muzzle of the gun?
Also, how should I set it up in the Receiver?

Here is what I have now (for the receiver).

Code: Select all

if( event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN )
{
Shoot();
} 
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

Presuming your shoot function displays the muzzle flash, that should work. As for positioning the muzzle flash, get the position of the node for your gun, and apply an offset for the barrel length. You will also need to account for rotation, of course. Are you using particles for you muzzle flash? If so make the emmitter a child of the gun node and your rotation should be taken care of (if do that don't even have to get position of gun node)
Xenocide

Post by Xenocide »

Thanks! One more question though. How could I make the particle/image a child of the gun? I've never used child/parent relationships before.
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

ISceneNode::addChild(ISceneNode *) If you're image is not a scene node could be harder. If you use a billboard you could always make an empty scene node, attach it to the gun, and always create the billboard at the position of the empty node. A muzzle flashshouldn't need to move, so its only initial position thta matters

BTW all this is assuming your gun is a seperate node. If your using md2 with a gun built into the model things could be very difficult
l0calh05t
Posts: 68
Joined: Wed Apr 07, 2004 7:08 pm

Post by l0calh05t »

Hmm, in Half-Life the muzzle flash is attached to one of the bones of the gun AFAIK, does irrlicht provide access to the skeleton of a model just as ogre does for example?

In that case it should be fairly easy to implement (perhaps you could even add a particle scene node which moves with the gun and creates the muzzle flash)
Raw data for raw nerves

My main PC: Athlon XP 2800+, 512MB RAM, ATI Radeon 9700 Pro 128MB, Win2k SP4
My secondary PC: Pentium III 500 Mhz, 256MB RAM, TNT2 64, Gentoo Linux
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

Yes, that is what I was just suggesting, though perhaps I wasn't perfectly clear. If using .ms3d or .x you can get the matrix of a joint. With .ms3d you can even create a scene node that follows all transformations of an .ms3d joint
VeneX
Posts: 228
Joined: Sun Nov 30, 2003 3:32 pm
Location: The Netherlands
Contact:

Post by VeneX »

Particle works fine:
Image
Visit my website @ www.venex.be
Plethora project will be added to the site
AMD AthlonXP 2600+, 512MB DDR, Radeon M10 (mobile 9600) PRO 64MB, WinXP
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

Those are sweet shots :shock:
Post Reply