PDA

View Full Version : Rotation for point sprites



Escondida
06-30-2003, 08:34 AM
Hi everyone,

I'm having some small problems using GL_NV_POINT_SPRITE. The fact is that I don't know how to rotate the sprites efficiently.
I found in previous topics few month ago that it can be performed through the texture matrix, but I'm afraid of the big amounts of computation this requires.
Has anyone any idea about this topic ?
Thx in advance for all your suggestions,

Kind regards,
Escondida

JONSKI
06-30-2003, 02:09 PM
I could be wrong, but I'm pretty sure the purpose of GL_NV_POINT_SPRITE is fast and easy billboarding (i.e. textures rendered orthogonal to the viewer). If you want to rotate a "sprite", then you can simply render a transformed and textured quad.

Escondida
07-02-2003, 07:43 AM
Thx for your answer JONSKI,

I'm just wondering now what is the most efficient for a large number of points:
- handling rotations with quads or
- get a set of texture that represent the
different orientations of the sprite (let's say 16 orientations), and bind them dynamically, while still using point sprites...

If you have any idea,

thx a lot for your time

escondida

Tom Nuydens
07-02-2003, 08:30 AM
You can't rotate a point sprite, it's always aligned to the screen. Such is the definition of a sprite. What you can do, however, is rotate the texture that's applied to the sprite, and you can do this using the texture matrix. There is no significant computation required -- just switch to the texture matrix and call glRotatef().

-- Tom

Escondida
07-02-2003, 08:52 AM
Thx a lot Tom,

your solution works pretty fine, and there's
no FPS disaster as I thought there would be.

Escondida

paul_martz
07-02-2003, 10:20 AM
If you decide to go with a textured quad instead, but are not sure how to orient it so it always faces the eye, try the following matrix:
A B C 0
D E F 0
G H I 0
J K L 1

where:
[JKL] is the location of the sprite
[GHI] is a vector from the sprite to the eye, made unit length (call it the eye vector)
[DEF] is the up vector, usually [ 0 1 0 ]
and
[ABC] is the cross product of the up vector and the eye vector.

glMultMatrix this matrix against your current view, then render the quad. It will always face the eye.

Hope that helps.