laser beams

Blitz3D Forums/Blitz3D Programming/laser beams

Uncle(Posted 2003) [#1]
Hi Guys,

After a couple of days of tying different methods I've got to admit Im stumped. What I am trying to do is write a small routine to fire a four of laser. These laser eminate from the top & bottom left and top & bottom right of the screen and end up at where the cursor was positioned when the mouse was clicked.

So far I have a working version using the pointentity command which points a laser beam mesh at pivot at the mouse position. It works ok but doesn't look good and I didn't want to use meshes for the beams if possible. Is this possible with sprites? Or is there a much easier way and am I just over complicating things?

Hope you can help,


Unc


jhocking(Posted 2003) [#2]
I think you are over-complicating things but I've not tried this so I can't give specific suggestions (sorry.) I mostly want to point out that people almost always underestimate how difficult it is to have shots emanating from the sides of the screen hit a target at the mouse cursor. It's a problem of perspective mostly; the specific angle to fire at varies depending on the distance to the target. And hence the complication, since the position of the mouse tells you nothing about the distance to the target. In other words the target is located in 3D space but the mouse cursor only exists in 2D. To give a specific example, up close an object on the left side of the screen is at a pretty steep angle whereas far away it is still pretty much straight forward.

Depending on your game (in particular automation of aiming vs. player control) maybe you should use a CameraPick to determine the target object and then place the pivot for aiming at at the location of the object when picked. Another simpler possibility is to simply always fire at the same place, assuming a hardwired depth for the target. Actually it sounds like you are already doing this and thus simply have to tweak that depth (ie. how far away the pivot for aiming at is located.) Because of perspective, unless the target object is extremely close the lasers will appear to converge at the targetted spot onscreen.

As for how to display the lasers, it depends on the exact look you want. Note that sprites ARE meshes, just with only two polygons. Assuming you are only troubled by the polycount of using meshes for your lasers then simply reduce the meshes to stretched quads.


big10p(Posted 2003) [#3]
There was a similar post to this over at BC.COM recently: i.e. Whats the best way to get good looking lasers a la Star Wars.

I think the conclusion was to use 2 stretched quads with one rotated 90 degrees to the other around the longest axis, if you see what I mean - you know, how some games do simple trees with crossed quads.

I did try an experiment recently using a single quad and then rotating it around the longest axis so that it always showed as much of the textured surface to the camera as possible. Had mixed results. Prolly more trouble than it's worth, especially if you have loads of lasers onscreen at once.


_PJ_(Posted 2003) [#4]
Try changing the Laser code in the archives. You will need to make 4 of them, and let the point A in the code be parented pivots to the corners of the camera. The Point B must be 'Picked' to establish the 3D Position of the 2D cursor location. I've not used this, but there are many discssions about it within these forums.

jhockings sprites may be easier to work with, if yo need any more help with this, I can try and knock something together for you.