1 2Name 3 4 SGIX_sprite 5 6 7Name Strings 8 9 GL_SGIX_sprite 10 11Version 12 13 $Date: 1996/04/09 22:54:47 $ $Revision: 1.11 $ 14 15Number 16 17 52 18 19Dependencies 20 21 None 22 23Overview 24 25 This extension provides support for viewpoint dependent alignment 26 of geometry, in particular geometry that rotates about a point or 27 a specified axis to face the eye point. The primary use is for 28 quickly rendering roughly cylindrically or spherically symmetric 29 objects, e.g. trees, smoke, clouds, etc. using geometry textured 30 with a partially transparent texture map. 31 32 Rendering sprite geometry requires applying a transformation to 33 primitives before the current model view. This matrix includes a 34 rotation which is computed based on the current model view matrix 35 and a translation which is specified explicitly 36 (SPRITE_TRANSLATION_SGIX). The current model view matrix itself 37 is not modified. 38 39 Primitives are first transformed by a rotation, depending on the 40 sprite mode: 41 42 SPRITE_AXIAL_SGIX: The front of the object is rotated about 43 an axis so that it faces the eye as much as the axis 44 constraint allows. This is used for roughly rendering cylindrical 45 objects such as trees in visual simulation. 46 47 SPRITE_OBJECT_ALIGNED_SGIX: The front of the object is 48 rotated about a point to face the eye with the remaining 49 rotational degree of freedom specified by aligning the top 50 of the object with a specified axis in object coordinates. 51 This is used for spherical objects and special effects such 52 as smoke which must maintain an alignment in object 53 coordinates for realism. 54 55 SPRITE_EYE_ALIGNED_SGIX: The front of the object is rotated 56 about a point to face the eye with the remaining rotational 57 degree of freedom specified by aligning the top of the object 58 with a specified axis in eye coordinates. This is used for 59 rendering sprites which must maintain an alignment on the 60 screen, such as 3D annotations. 61 62 The axis of rotation or alignment, SPRITE_AXIS_SGIX, can be 63 an arbitrary direction to support geocentric coordinate frames 64 in which "up" is not along X, Y or Z. 65 66 Sprite geometry is modeled in a canonical frame: +Z is the up 67 vector. -Y is the front vector which is rotated to point towards 68 the eye. In the discussion below, the eye vector is the vector to 69 the eye from the origin of the model view frame translated by the 70 sprite position. 71 72New Procedures and Functions 73 74 void SpriteParameteriSGIX(enum pname, int param); 75 void SpriteParameterfSGIX(enum pname, float param); 76 void SpriteParameterivSGIX(enum pname, int* params); 77 void SpriteParameterfvSGIX(enum pname, float* params); 78 79Issues 80 81 * Should the canonical modeling frame of the geometry be specifiable? 82 - requires API for "up" and "front" vectors; additional math 83 84 * Should sprites for annotation be clip or eye aligned? Clip 85 alignment is a nearly trivial extension of object aligned. 86 However, once the projection matrix assumes rotation things 87 are unpredictable and we should avoid this complexity. 88 89New Tokens 90 91 Accepted by the <cap> parameter of Enable, Disable, and IsEnabled, 92 and by the <pname> parameter of GetBooleanv, GetIntegerv, 93 GetFloatv, and GetDoublev: 94 95 SPRITE_SGIX 96 97 Accepted by the <pname> parameter of SpriteParameteriSGIX, and 98 SpriteParameterfSGIX: 99 100 SPRITE_MODE_SGIX 101 102 Accepted by the <pname> parameter of SpriteParameterivSGIX, and 103 SpriteParameterfvSGIX, and by the <pname> parameter of GetBooleanv, 104 GetIntegerv, GetFloatv, and GetDoublev: 105 106 SPRITE_MODE_SGIX 107 SPRITE_AXIS_SGIX 108 SPRITE_TRANSLATION_SGIX 109 110 Accepted by the <param> parameter of SpriteParameteriSGIX and 111 and SpriteParameterfSGIX, and by the <params> parameter of 112 SpriteParameterivSGIX and SpriteParameterfvSGIX, when the 113 <pname> parameter is SPRITE_MODE_SGIX: 114 115 SPRITE_AXIAL_SGIX 116 SPRITE_OBJECT_ALIGNED_SGIX 117 SPRITE_EYE_ALIGNED_SGIX 118 119Additions to Chapter 2 of the 1.0 Specification (OpenGL Operation) 120 121 SPRITE_SGIX is enabled and disabled using Enable and Disable with 122 target equal to SPRITE_SGIX. When SPRITE_SGIX is enabled, the 123 current sprite mode, axis, translation and the ModelView matrix 124 are used to generate a sprite transformation which is applied to 125 subsequent primitives before applying the current model view matrix. 126 127 When the sprite mode is SPRITE_AXIAL_SGIX, the sprite transformation 128 is arranged such that, after sprite and ModelView transformation, 129 the front vector is pointing as nearly towards the origin of the 130 eye coordinate system as possible. 131 132 Each primitive is first rotated so that the sprite up vector aligns 133 with the sprite axis which is specified in the current model view 134 frame. Then the primitive is rotated about the axis so its 135 front vector is parallel with the projection of the eye vector 136 into the plane perpendicular to the rotation axis. Then the 137 primitive is translated by the specified translation. 138 139 There are four unique matrices involved in computing the transformation 140 required for sprite geometry: 141 142 M - model-view matrix 143 T - sprite translation matrix 144 A - sprite axis rotation matrix 145 R - sprite up vector/axis alignment rotation matrix 146 147 Note that in SPRITE_AXIAL_SGIX mode, the R matrix is a function of M, 148 T and A since the eye vector is derived from the inverse transpose matrix 149 of the compound (M * T * A). In both the SPRITE_OBJECT_ALIGNED_SGIX and 150 the SPRITE_EYE_ALIGNED_SGIX modes, the eye vector is extracted from the 151 inverse transpose of the compound (M * T). 152 153 Given the coordinates of SPRITE_TRANSLATION_SGIX the sprite translation 154 matrix (T) is constructed. Both A and R are rotation matrices generated 155 by computing an angle of rotation and the sprite axis (computing sine and 156 cosine of the rotation angle suffices for computing a rotation matrix). 157 The computation of the matrices (T, A, R) are given in Chapter 2.9 of 158 the 1.0 OpenGL Specification (Matrices). 159 160 The angle and axis of rotation parameters for generating rotation matrix 161 A are computed as follows: 162 163 cosTheta = (V0 (dot) V1); 164 rotAxis = (V0 (cross) V1); 165 sinTheta = |rotAxis|; 166 167 V0 is the canonical up vector. V1 is the sprite axis (SPRITE_AXIS_SGIX) 168 when in SPRITE_AXIAL_SGIX mode. In either the SPRITE_OBJECT_ALIGNED_SGIX 169 and the SPRITE_EYE_ALIGNED_SGIX modes V1 is the sprite axis aligned by 170 removing its component along the eye vector. The computation of V1 in 171 the latter cases is as follows: 172 173 scalar = Eye (dot) spriteAxis; 174 alignedSpriteAxis = spriteAxis - (scalar * Eye); 175 176 The rotation axis for computing the R matrix is the canonical up 177 vector. The angle of rotation is computed as follows: 178 179 cosTheta = (Eye (dot) canonicalFront); 180 sinTheta = (Eye (dot) canonicalRight); 181 182 Sprite primitive geometry is transformed from object coordinates 183 to eye coordinates by the following compound matrix (MM): 184 185 MM = M * T * A * R 186 187 Sprite geometry is not limited to vertex based primitives and evaluators 188 may apply as well. 189 190 Normals associated with sprite geometry are transformed by the inverse 191 transpose of the compound matrix (MM). In general, the user would not 192 want clip planes to be transformed by the compound matrix. In a similar 193 manner, raster position and texture coordinates (for certain texgen 194 modes). The user should be warrant that once glClipPlanes, glTexGen or 195 glRasterPos are called within a glEnable/Disable (SPRITE_SGIX) delimitors, 196 the associated geometry will be transformed by the compound matrix (MM). 197 198 When the sprite mode is SPRITE_OBJECT_ALIGN or SPRITE_EYE_ALIGN, 199 the sprite transformation rotates the front vector towards the eye 200 while keeping the up vector as aligned as possible with the 201 current sprite axis, i.e. the up vector is rotated to be parallel 202 to the projection of the current sprite axis into the plane 203 perpendicular to the front vector. Depending on the current 204 sprite mode, the sprite axis is taken to be expressed in object 205 (SPRITE_OBJECT_ALIGNED_SGIX) or transformed into eye 206 (SPRITE_EYE_ALIGNED_SGIX) coordinates. The transformation into 207 eye space uses the compound (M * T). 208 209 Regardless of the sprite transformation mode, the projection matrix 210 obviously assumes no rotation elements. This is again to warrant the 211 user against overriding the sprite transformation. 212 213Additions to Chapter 3 of the 1.0 Specification (Rasterization) 214 215 None 216 217Additions to Chapter 4 of the 1.0 Specification (Per-Fragment Operations 218and the Frame Buffer) 219 220 None 221 222Additions to Chapter 5 of the 1.0 Specification (Special Functions) 223 224 None 225 226Additions to Chapter 6 of the 1.0 Specification (State and State Requests) 227 228 None 229 230Additions to the GLX Specification 231 232 None 233 234Dependencies on SGI_extension_name 235 236 None 237 238Errors 239 240 INVALID_ENUM is generated if SpriteParameteriSGIX or SpriteParameterfSGIX 241 parameter <pname> is not SPRITE_MODE_SGIX. 242 243 INVALID_ENUM is generated if SpriteParameterivSGIX or SpriteParameterfvSGIX 244 parameter <pname> is not SPRITE_AXIS_SGIX or SPRITE_TRANSLATION_SGIX. 245 246 INVALID_ENUM is generated if SpriteParameteriSGIX or SpriteParameterfSGIX 247 parameter <pname> is SPRITE_MODE_SGIX, and parameter <param> is not 248 SPRITE_AXIAL_SGIX, SPRITE_OBJECT_ALIGNED_SGIX, or SPRITE_EYE_ALIGNED_SGIX. 249 250 INVALID_OPERATION is generated if glSpriteParameterSGIX is executed 251 between the execution of glBegin and the corresponding execution of 252 glEnd. 253 254New State 255 256 Initial 257 Get Value Get Command Type Value Attrib 258 --------- ----------- ---- ------- ------ 259 SPRITE_SGIX IsEnabled B FALSE transform/enable 260 SPRITE_MODE_SGIX GetIntegerv I SPRITE_AXIAL_SGIX transform 261 SPRITE_AXIS_SGIX GetFloatv V (0,0,1) transform 262 SPRITE_TRANSLATION_SGIX GetFloatv V (0,0,0) transform 263 264New Implementation Dependent State 265 266 None 267 268