Archived

This topic is now archived and is closed to further replies.

messiah2k

laser

Recommended Posts

I wonder if anyone has a good ide on how to do a nice laser shot from a gun. I tried a very simple ide where Iv''e simply done a glList of a small cylinder but when I fire it sort of flickers and dosn''t look very good. I just change the cylinders z value to move it into the screen. I feel like I''m on the wrong track here ??? //Messiah

Share this post


Link to post
Share on other sites
yeah it looks shit just to use a line, what I''m working on is figuring out how to make a quad which will have its own Zvector, giving it a direction in 3d space, then tell it to rotate around this z vector so that it faces the camera as much as possible. Basically the normal of the quad must intersect the camera Zvector at some point. Then I can texture my quad with a laser texture (animated texture?) and it will look good from any angle (except directly in front or behind where it won''t look like anything at all). But I haven''t figured out how yet so I guess this isn''t much help. Oh well.

-

Geocyte Has Committed Suicide.

Share this post


Link to post
Share on other sites
hmmm.... thanks anyway, your reply got me to think in new directions. I guess what you mean is to draw a giant quad where the texture move on.

//Messiah

Share this post


Link to post
Share on other sites
Not sure where you can get it, but pick up a copy of Uncle Martin''s Laser Factory (I think; it was on the OGLGP CD). It had a pretty nice laser effect, and it''ll help you visualize what you want.

If you''re working in 3D, I''d suggest using a beam composed of 3 or more quads stretching between the source and the target, making a shaft-like entity.

Later,
ZE.



//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[if you have a link proposal, email me.]

Share this post


Link to post
Share on other sites
http://www.google.com/search?q=billboard+opengl&sourceid=opera&num=0&ie=utf-8&oe=utf-8

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
I implemented that technique I was talking about before and it looks OK. The technique is related to billboarding but isn''t the same thing. Billboarding is when you tell a quad to always face the camera so, for example, instead of drawing a sphere with polygons you can draw a quad with a texture image of a sphere which will always face the camera no matter which angle you view it from. OK the polygon sphere will look better but the billboarded quad will be much faster. For our laser, however we cannot simply tell it to face the camera as it requires its own unique z direction component - it has, after all, been fired in a particular direction, and must continue to be drawn pointing in this direction so we need to leave the Z vector alone but we can adjust the X and Y vectors so that as far as those are concerned the laser faces the camera. We can do this by performing the following steps:

find the matrix that describes the position of the camera relative to the laser.
find the 2D angle between the laser and the camera on the lasers XY plane
After transforming the laser with all its regular transformations rotate it around its z axis by the angle you just worked out and behold - it will always try to face the camera without comprimising its z orientation.

it doesn''t look fantastic or anything but it works and it doesn''t look too bad either.

_






Geocyte Has Committed Suicide.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In addition to the billboarding, you might want to include a sprite (is that the right word?) if the z-axis is so parallel with the camera z that the laser just looks like a billboard viewed on its end. (Calculate if you should use a billboard or a sprite and just render that)

Share this post


Link to post
Share on other sites