[LibGDX]Draw laser beams(LaserFX)

I found a tutorial which explains how to draw cool looking laser effects in LibGDX:
http://codepoke.net/2011/12/27/opengl-libgdx-laser-fx/

However, I find the tutorial incomplete. There are no concrete coding examples on how to implement it.

Could someone explain in a better way?

For example, what to do with ending mesh?

You pass the mesh (vertices) to the gpu

I appreciate that you are trying to help, but that wasn’t helpful at all.

Have you ever used opengl, if yes have you used spriteBatching yet?

I use SpriteBatch in my game.

No one knows? :confused:

What about all that code at the bottom. Isn’t that sufficient? I just read through the article and I don’t understand where you are getting lost. Could you explain your problem?

First of all, the parameters.

region The AtlasRegion to use, I dont get this one. Is this a collection of all the laser images?

Then, what do I do with the returned float array?

The AtlasRegion is just part of the TextureAtlas that specifies only a certain part of the whole image. You could instead use a simple TextureRegion to get the texture coordinates. The returned float array is all of your vertex data. I’m not sure about libgdx but I believe that you can use this method [icode]draw(Texture texture, float[] spriteVertices, int offset, int length)[/icode] to draw a texture with the custom data.

I am in process of writing my own laser drawing function. Does not looks as good as Laser FX, but performs better.

I have ran into a math problem and hope someone here can help me.

Have a look at the following image:

http://s10.postimg.org/jb7x24su1/img.png

The laser is set to fire at a certain point(the top-left corner of the red guy), which it actually does. The top-left, or the bottom-left(not sure which one) corner of the laser beam is exactly at the target coordinate.

What I want to do is to have the lasers middle point at the target point, not the corner.

Here is my code, I am using the following method to draw the laser:

SpriteBatch.draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation)
float angle = MathStuff.getAngle(srcX, srcY, destX, destY); //Calculate the angle between the source and destination point.

batch.draw(beamImage, srcX, srcY, 0, 0, MathStuff.distance(srcX, srcY, destX, destY), beamImage.getHeight(), 1, 1, angle);