Game slowdown

I WISH SOMEONE HAD TOLD ME I WAS LOOKING FOR CYLINDRICAL BILLBOARDING!
 
Work on the game has slowed.  I’m hung on creating a laserbolt.  I am rendering an ellipsoid through my shader.  I fade the intensity of a color from white to the color, and add alpha as I go.  That creates a nice looking laserbolt, hot white down the middle and faded color on the edges. 
 

laserbolt ellilpsoid

 
 
The problem is defining the middle and keeping it oriented toward the viewer.  Imagine the cylinder in the picture is my laserbolt.  The stripe would be the white hotspot.

Perspective problem

I have to figure out a way to keep the stripe (the right/left vectors of its world matrix) oriented so that they point toward the camera.
 
Now, the camera sets at the origin (0,0,0), so the task is to imagine a plane running through the cylinder with the plane defined by the forward and right vectors with Up as the normal.  
 
What has to happen is that once the cylinder/laser bolt is pointed so that "forward" is pointing at the target, I need to rotate it about its own z axis (changing right and up while keeping them perpendicular to each other and Forward) until the plane passes through the camera at 000.  I’ve not figured it out yet.  The XNA forum hasn’t been able to help, so the problem is either A: Not stated well, B: So easy I should be able to see the answer, or C: Relatively difficult.  Its a function of both the position of the cylinder and the rotation about its own Y axis. 
 
So, research with the the game as a method is going to have to wait a while longer. 
 
In the meantime, I am diverging a bit into particle systems and preparing an overdue literature review and paper on "Renewal" in human subjects and about to collect some more data with my older "Spacebird" game.
 
[edit] as usual, once you write about it a few times, the answer comes to you.  To make it work, set forward to the target, cross the direction from the camera to the laser to get UP, then cross up with forward to get right.  That puts the vector from the camera to the middle of the laser on the plane that goes through forward / left/right so the hotspot is always centered along the width of the laserbolt.
 

Advertisements
This entry was posted in The Learning Game. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s