Laser Weapon
#1
Posted 31 January 2003 - 11:28 PM
#2
Posted 02 February 2003 - 12:33 PM
the other idea could be some sort of billboard around an axis, or so.. i've once seen a page explaining it.. but i don't remember the link, sorry..
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
#3
Posted 04 February 2003 - 04:42 AM
#4
Posted 04 February 2003 - 04:46 AM
#5
Posted 04 February 2003 - 10:04 AM
So if u consider a laser with 2 points, point A where is originates from (probably a gun), point B it's destination or current position. Then u draw a rectangle with a height equal to the diameter of the laser with one end at point A and the other end at point B. U can rotate the rectangle by the vector AB so that the viewer can see the maximum surface area of the rectangle.
Should the laser fire directly at the viewer then draw a circle using a billboard to create the effect.
If u use billboard u can create the 3D effects if u have really cool textures.
opps.... I said the hieght of rectangle should be the radius of the laser beam, in fact it should be the diameter.
#6
Posted 04 February 2003 - 01:00 PM
if you want, you can use 2 [or more, maybe just 2] rectangles, have 2 different textures and have some kind of 'animation' going on. this will do nicely with yau's implementation. of course, there are other ways but i would do what yau said.
...just a thought.
#7
Posted 05 February 2003 - 02:55 PM
__________________________________________________
|__________________________________________________| <- Side B and Side A
From the side a laser is JUST a rectangle. Using clever texture mapping, create a texture that is pretty bright @ the center and pitch dark @ the edges.
Now when you have the Side A and B, these should be modelled in "circular" forms. Thus create a texture (or resuse the textre) and using alpha blending, just chop off the corners.
I guess this is te best way of doing this.
Any better way I would love to know.
#8
Posted 05 February 2003 - 03:49 PM
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
#9
Posted 05 February 2003 - 03:49 PM
let's use a vector for the path of the laser. starting point is at the barrel of the weapon and the terminal point is the opponent ship. [i just want to cover all grounds, bare with me]. using the magnitude/length of the vector as the 'length' of the laser's path. make a rectangle based on the length and then texture. theoretically, no matter what viewpoint you're at, you'll see a relative laser shot. well, maybe all points of view except directly where it will be just a point.
any more ideas?
#10
Posted 05 February 2003 - 07:21 PM
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
#11
Posted 06 February 2003 - 01:03 AM
With just a rectangle u could create a texture where in the middle of the beam is bright and towards the edge of the beem the color becomes slightly dull and transparent. This is very difficult to accomplish with a prism.
#12
Posted 06 February 2003 - 01:03 AM
i like his idea but in my personal opinion, unless you make it dynamic [make it move or add some really cool things like baldurk said, lighting in itself may work against it, making it look kind of ... different :huh:
what i'm getting at is, it's like a big 'triangular piece of "metal" ' will go from the weapon to the target. cool funny effect, maybe not so 'realistic'. open to interpretation. :lol:
#13
Posted 06 February 2003 - 01:50 AM
Yau said:
So if u consider a laser with 2 points, point A where is originates from (probably a gun), point B it's destination or current position. Then u draw a rectangle with a height equal to the diameter of the laser with one end at point A and the other end at point B. U can rotate the rectangle by the vector AB so that the viewer can see the maximum surface area of the rectangle.
Should the laser fire directly at the viewer then draw a circle using a billboard to create the effect.
If u use billboard u can create the 3D effects if u have really cool textures.
opps.... I said the hieght of rectangle should be the radius of the laser beam, in fact it should be the diameter.
Or if you have a website, that would also help.
Thanks
#14
Posted 06 February 2003 - 06:52 AM
void drawLaser(float origin[3], // position where the laser originates
float dest[3], // position where the laser ends
float camera_pos[3], // position of the camera
float radius // radius of laser
)
{
float vector1[3];
float vector2[3];
// vector1 is the vector from origin to the camera
vector1[0] = camera_pos[0] - origin[0];
vector1[1] = camera_pos[1] - origin[1];
vector1[2] = camera_pos[2] - origin[2];
// vector2 is the vector from the origin to the destination
vector2[0] = dest[0] - origin[0];
vector2[1] = dest[1] - origin[1];
vector2[2] = dest[2] - origin[2];
float normal[3];
// get the normal or cross product between vector1 and vector 2
// we will use this vector to create a rectangle which runs along vector 2
// and as facing a direction that give maximum surface area to the camera.
normal[0] = vector1[1] * vector2[2] - vector1[2] * vector2[1];
normal[1] = vector1[2] * vector2[0] - vector1[0] * vector2[2];
normal[2] = vector1[0] * vector2[1] - vector1[1] * vector2[0];
float magnitude;
magnitude = sqrt(SQR(normal[0]) + SQR(normal[1]) + SQR(normal[2]));
// normalize the normal, so the magnitude of normal is 1
normal[0] = normal[0]/magnitude;
normal[1] = normal[1]/magnitude;
normal[2] = normal[2]/magnitude;
// now create the corners for the rectangle
float corners[4][3];
// first corner
corners[0][0] = origin[0] - (radius * normal[0]);
corners[0][1] = origin[1] - (radius * normal[1]);
corners[0][2] = origin[2] - (radius * normal[2]);
// second corner
corners[1][0] = origin[0] + (radius * normal[0]);
corners[1][1] = origin[1] + (radius * normal[1]);
corners[1][2] = origin[2] + (radius * normal[2]);
// third corner
corners[2][0] = dest[0] + (radius * normal[0]);
corners[2][1] = dest[1] + (radius * normal[1]);
corners[2][2] = dest[2] + (radius * normal[2]);
// forth corner
corners[3][0] = dest[0] - (radius * normal[0]);
corners[3][1] = dest[1] - (radius * normal[1]);
corners[3][2] = dest[2] - (radius * normal[2]);
// now draw the rectangle
// you can add material, colours or texture commands here to make ur laser look more funky
glBegin(GL_QUADS);
// remember add a texture coordinate infront of each glVertex3fv for funkier looking lasers
glVertex3fv(corners[0]);
glVertex3fv(corners[1]);
glVertex3fv(corners[2]);
glVertex3fv(corners[3]);
glEnd();
}
And finished.
B4 i mentioned that we should rotated the rectangle to allow maximum surface area to face the camera. You may notice that there r no OpenGL rotate commands here, but by using the normal between the vector from the start of the laser to the camera and the vector from the start of the laser to the end to generate the rectangle we esentially created a rectangle rotated to face the camera nicely.
I hope this code works because I kinda fudged it on the spot.
#15
Posted 06 February 2003 - 06:29 PM
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
#16
Posted 25 February 2003 - 06:42 AM
#17
Posted 25 February 2003 - 10:14 AM
#18
Posted 25 February 2003 - 10:58 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












