Skip to main content
GameDev.net gamedev.net
🔒 Locked

Drawing laser beams

Started by Cybertron Dec 16, 2002 at 4:16 PM 6 replies 1.9k views
Original Post
Cybertron
Cybertron
Currently I am using two long rectangles at right angles, but it look ugly when rotated What is the best way to render beams without noticing any of the texture borders?
samosa
samosa
im no pro on this topic but wouldnt it be best to use a cylinder and stretch it as the beam stretches? just a thought, not sure of how implementable it is

,Matt

-= kill one your a murderer, kill thousands your a conquerer =-
-= kill one you're a murderer, kill thousands you're a conquerer =-
Waverider
Waverider
You could make it a triangular shaped cylinder. That way you are rendering only one more quad and the shape is less visible.
It's not what you're taught, it's what you learn.
Cybertron
Cybertron
That would make it worse, you would see the texture twice!

I wish I Knew how to make one rectangle that always faces the screen yet points in a specified direction...
mdias
mdias
To make a polygon look at the camera take a look at the billboarding
sample that comes with DX8 SDK.

KaMiKaZe
Carrot
Carrot
To get that ''glowing'' look that you see with lasers, use additive blending instead of normal (alpha) blending.

You''ll find it''ll still look okay when rotated too.
Bobboau
Bobboau
so, you're trying to render a beam weapon,
as in from a turret or something to a hit point on the target, the way it was done in freespace (space sim, but should be aplicable to any situation) was the use of one or more single pollys rotated around the center of the beam to face the viewer, so for a similar effect, what you need to know to calculate the points are

the starting point of the beam
the ending point of the beam
and
the veiwers eyeposition in the same frame or reference to the start and end points (it might be easier to have all of these in world coords)

armed with this,
subtract the starting point from the ending point and normalize the result to find the forward vector of the beam,
then for each end point of the beam you,
subtract the eyeposision from the end point your currently checking,
normalize the result and this gives you the right vector of the beam (or that end of it, though it could be the same for both I think),
*now you have the forward vector (fvec) and the right vector (rvec) all you need now is the up vector and you can start ploting verts*
take the crossproduct of the fvec and the rvec and this will give you the upvector, the up vector will be perpenditular to the eyeposition, so all you have to do is scale-add along the uvec and it's negitive by the width of you're beam, assign some apropriate UV coordanants and render with the texture of choice

if you want to look at some code, the freespace source code project forum is right here
http://dynamic4.gamespy.com/~freespace/forums/forumdisplay.php?s=&forumid=50

Bobboau, bringing you products that work... in theory

[edited by - Bobboau on December 17, 2002 5:17:34 AM]
Bobboau, bringing you products that work... in theory

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.