You need pills to be stupid? I can do it naturally!
Mind you, I have thought it would be nice to have a method like addQuad(x,y,z,x1,y1,z1,u,v,u1,v1) purely for convenience...
I just finished the lightning bolt implementation.
It is basically two rectangular planes casted from source to target, one vertical and one horizontal (a very long "plus"). I then apply a zig zag texture on both and set transparency. At each paint I toggle a few textures back and forth and play with lighting. I did this years ago in the Unreal 1 Editor and it looks pretty much the same (a good thing).
One thing though - I'm not quite happy with my math (or lack there of). Its the stupid pills again.
Basically - it is easy to create the long ends of a rectangle for a source and a target (y is constant for me!). The problem is the width on the x/z plane.
You need a perpendicular to the line between the points to create a width.
I just could not get my small mind around it. Initially I was creating this new "Rectangle" primitive totally in place - ie. pre-rotated between the source and target. To cheese on calculating the perpendicular on my rectangle (ie. the short end widths) I created the Rectangle on the y axis (like a blade on its edge). I thought hey - it will be easy to then simply rotate it by PI/2 to create the horizontal Rectangle. Right? Rigghhht??? Nope! The problem is of course the RotationMatrix. I just couldnt get a decent one on the Rectangle and I tried for hours. Every rotation was really messed up and the stupid pills where in full effect.
Finally after pulling my hair out, I found another way. Far easier. I calculated the length of the line (that math I know!) and built it horizontally at the World origin this time. That lets me skip the nasty perpendicular calculation since the rectangle is square to the world. So I just add and subtract some X since there is no rotation. Then I moved it to the center point between source and target and rotated it to match the source's yRotation.
I guess that's not too bad. It looks really nice and now I can use this much lighter weight Rectangle concept elsewhere.
My next hurdle is to apply this same approach to creating a rectangle on the ground that follows the mouse while pivoting on a source at the other end. If you have ever played
Temple Of Elemental Evil you know what I mean. Its a line indicating the path you are going to walk if you click. I think I can do the same thing with one exception - I'll need 2 invisible dummy objects. One will chase the mouse. The other will track the object by rotating as it moves. I need to maintain that Y axis rotation so my math works.