1 /* 2 * Project: VizKit 3 * Version: 2.3 4 5 * Date: 20090823 6 * File: VisualGraphicTypes.h 7 * 8 */ 9 10 /*************************************************************************** 11 12 Copyright (c) 2004-2009 Heiko Wichmann (http://www.imagomat.de/vizkit) 13 14 15 This software is provided 'as-is', without any expressed or implied warranty. 16 In no event will the authors be held liable for any damages 17 arising from the use of this software. 18 19 Permission is granted to anyone to use this software for any purpose, 20 including commercial applications, and to alter it and redistribute it 21 freely, subject to the following restrictions: 22 23 1. The origin of this software must not be misrepresented; 24 you must not claim that you wrote the original software. 25 If you use this software in a product, an acknowledgment 26 in the product documentation would be appreciated 27 but is not required. 28 29 2. Altered source versions must be plainly marked as such, 30 and must not be misrepresented as being the original software. 31 32 3. This notice may not be removed or altered from any source distribution. 33 34 ***************************************************************************/ 35 36 #ifndef VisualGraphicTypes_h 37 #define VisualGraphicTypes_h 38 39 40 #include "VisualTypes.h" 41 #include <vector> 42 43 44 /* The common graphics related types used by VisualGraphics and VisualActorGraphics. */ 45 46 namespace VizKit { 47 48 class VisualVertex; // Forward declaration (to avoid include of header file). 49 50 /** 51 * A pixel color contains ARGB values (alpha, red, green, blue with 8 bits for each color channel). 52 */ 53 typedef uint32 PixelColor; 54 55 /** 56 * A Point2D is a position in 2-dimensional planar space. 57 */ 58 typedef struct { 59 double x; /**< Horizontal position. */ 60 double y; /**< Vertical position. */ 61 } Point2D; 62 63 /** 64 * A pixel is a two-dimensional point relative to physical coordinate system. 65 */ 66 typedef struct { 67 uint32 x; /**< Horizontal position. */ 68 uint32 y; /**< Vertical position. */ 69 } Pixel; 70 71 /** 72 * A colored pixel is a pixel with a color value. 73 */ 74 typedef struct { 75 PixelColor color; /**< Color value of the pixel. */ 76 uint32 x; /**< Horizontal position. */ 77 uint32 y; /**< Vertical position. */ 78 } ColoredPixel; 79 80 /** 81 * A Point3D is a position in 3-dimensional space. 82 */ 83 typedef struct { 84 double x; /**< Horizontal position. */ 85 double y; /**< Vertical position. */ 86 double z; /**< Depth position. */ 87 } Point3D; 88 89 /** 90 * A Coord is a three-dimensional point relative to logical coordinate system. 91 */ 92 typedef Point3D Coord; 93 94 /** 95 * A RelCoord is a relative three-dimensional point in coordinate system. 96 * x: 0.0 means: left, 1.0 means: right; y: 0.0 means: bottom, 1.0 means: top; z: 0.0 means: front, 1.0 means: back. 97 */ 98 typedef Point3D RelCoord; 99 100 /** 101 * Predefined zero coord (x = 0.0 and y = 0.0). 102 */ 103 extern const Coord zeroCoord; 104 105 /** 106 * A Vector points in a direction. 107 */ 108 typedef Point3D Vector; 109 110 /** 111 * A TexCoord is a coord position of a texture. 112 */ 113 typedef struct { 114 double s; /**< Horizontal position. */ 115 double t; /**< Vertical position. */ 116 } TexCoord; 117 118 /** 119 * A RelTexCoord is a coord position of a texture. 120 * s: 0.0 means: left, 1.0 means: right; t: 0.0 means: bottom, 1.0 means: top. 121 */ 122 typedef TexCoord RelTexCoord; 123 124 /** 125 * A two-dimensional size relative to logical coordinate system. 126 */ 127 typedef struct { 128 double width; /**< Horizontal size. */ 129 double height; /**< Vertical size. */ 130 } CoordSize2D; 131 132 /** 133 * A three-dimensional size relative to logical coordinate system. 134 */ 135 typedef struct { 136 double width; /**< Horizontal size. */ 137 double height; /**< Vertical size. */ 138 double depth; /**< Size in z-dimension. */ 139 } CoordSize3D; 140 141 /** 142 * A two-dimensional size relative to physical coordinate system. 143 */ 144 typedef struct { 145 uint32 width; /**< Horizontal size. */ 146 uint32 height; /**< Vertical size. */ 147 } PixelRect; 148 149 /** 150 * A rectangle. 151 */ 152 typedef struct { 153 PixelRect pixelRect; /**< The size of the rectangle in pixels. */ 154 CoordSize2D coordSize; /**< The size of the rectangle in coord dimensions. */ 155 } Rect; 156 157 /** 158 * A positioned rectangle, measured in pixels. Origin at top-left. 159 */ 160 typedef struct { 161 PixelRect pixelRect; /**< The size of the rectangle in pixels. */ 162 Pixel topLeftPixel; /**< The top-left pixel of the positioned rect. */ 163 } TopLeftPositionedPixelRect; 164 165 /** 166 * A positioned rectangle, measured in pixels. Origin at bottom-left. 167 */ 168 typedef struct { 169 PixelRect pixelRect; /**< The size of the rectangle in pixels. */ 170 Pixel bottomLeftPixel; /**< The bottom-left pixel of the positioned rect. */ 171 } BottomLeftPositionedPixelRect; 172 173 /** 174 * A positioned rectangle, measured in coords. Origin at bottom-left. 175 */ 176 typedef struct { 177 CoordSize2D coordSize; /**< The size of the rectangle in coords. */ 178 Coord bottomLeftCoord; /**< The top-left coord of the positioned rect. */ 179 } PositionedCoordRect; 180 181 /** 182 * Orientation. 183 */ 184 typedef enum { 185 kPortrait = 0, 186 kLandscape, 187 kSquare 188 } Orientation; 189 190 /** 191 * A relational rectangle is determined by aspect ratio of width and height and orientation. No absolute are given. 192 */ 193 typedef struct { 194 Orientation orientation; /**< The orientation of the rectangle. */ 195 double aspectRatio; /**< The aspect ratio (being > 1). */ 196 } RelationalRect; 197 198 /** 199 * A box. 200 */ 201 typedef struct { 202 CoordSize3D coordSize; /**< The size of the box in coord dimensions. */ 203 } Box; 204 205 /** 206 * A positioned box. Origin at bottom-left-front. 207 */ 208 typedef struct { 209 CoordSize3D coordSize; /**< The size of the rectangle in coord dimensions. */ 210 Coord bottomLeftFrontCoord; /**< The top-left-front coord of the positioned box. */ 211 } PositionedBox; 212 213 /** 214 * ScalingBehaviourEnumValues enumerate the possible bit flag values of a ScalingBehaviour. 215 */ 216 enum ScalingBehaviourEnumValues { 217 kNoScaling = 0x1, // 00000001 218 kScalingAllowed = 0x2, // 00000010 219 kPreserveAspectRatio = 0x6, // 00000110 220 kNonproportional = 0xA, // 00001010 221 kClippingAllowed = 0x10 // 00010000 222 }; 223 224 /** 225 * ScalingBehaviour is the data type for specifying the scaling behaviour of a texture in combination with margins 226 */ 227 typedef uint32 ScalingBehaviour; 228 229 /** 230 * Visibility specifies the visibility. Two states are possible: visible and invisible. 231 */ 232 typedef enum { 233 kVisible = 0, 234 kInvisible 235 } Visibility; 236 237 /** 238 * ProjectionMode specifies orthographic or perspective projection. 239 */ 240 typedef enum { 241 kOrthographic = 0, 242 kPerspective 243 } ProjectionMode; 244 245 /** 246 * Symbolic names for arbitrary positions in 3-dimensional space. 247 */ 248 typedef enum { 249 kTopLeft = 0, 250 kBottomLeft, 251 kBottomRight, 252 kTopRight 253 } SpacePosition; 254 255 /** 256 * Stores the values of a composite color of red, green, blue and alpha. 257 */ 258 typedef struct { 259 double red; /**< Red value. Backing store. Value does not change except if it is set explicitely exernally. 0.0f .. 1.0f. */ 260 double green; /**< Green value. Backing store. Value does not change except if it is set explicitely exernally. 0.0f .. 1.0f. */ 261 double blue; /**< Blue value. Backing store. Value does not change except if it is set explicitely exernally. 0.0f .. 1.0f. */ 262 double alpha; /**< Alpha value. Backing store. Value does not change except if it is set explicitely exernally. 0.0f .. 1.0f. */ 263 double r; /**< Red value. 0.0f .. 1.0f. */ 264 double g; /**< Green value. 0.0f .. 1.0f. */ 265 double b; /**< Blue value. 0.0f .. 1.0f. */ 266 double a; /**< Alpha value. 0.0f .. 1.0f. */ 267 } RGBAColor; 268 269 /** 270 * Stores the color values used by a vertex. 271 */ 272 typedef RGBAColor VertexColor; 273 274 /** 275 * Predefined black color. 276 */ 277 extern const VertexColor black; 278 279 /** 280 * Predefined white color. 281 */ 282 extern const VertexColor white; 283 284 /** 285 * Predefined red color. 286 */ 287 extern const VertexColor red; 288 289 /** 290 * Predefined green color. 291 */ 292 extern const VertexColor green; 293 294 /** 295 * Predefined blue color. 296 */ 297 extern const VertexColor blue; 298 299 /** 300 * Predefined transparent color. 301 */ 302 extern const VertexColor transparent; 303 304 /** 305 * Stores the coord position values used by a vertex. 306 */ 307 typedef struct { 308 Coord coord; /**< Coord position of vertex. */ 309 RelCoord relCoord; /**< Relative coord position of vertex. x: 0.0 means: left, 1.0 means: right; y: 0.0 means: bottom, 1.0 means: top; z: 0.0 means: front, 1.0 means: back. */ 310 } VertexPosition; 311 312 /** Chain of vertex positions. */ 313 typedef std::vector<VertexPosition*> VertexPositionChain; 314 /** Pointer to chain of vertex positions. */ 315 typedef VertexPositionChain* VertexPositionChainRef; 316 /** Constant chain of vertex positions. */ 317 typedef const VertexPositionChain ConstVertexPositionChain; 318 /** Pointer to constant chain of vertex positions. */ 319 typedef const VertexPositionChainRef ConstVertexPositionChainRef; 320 321 /** Iterator of chain of vertex positions. */ 322 typedef VertexPositionChain::iterator VertexPositionChainIterator; 323 /** Iterator of constant chain of vertex positions. */ 324 typedef ConstVertexPositionChain::iterator ConstVertexPositionChainIterator; 325 /** Constant iterator of chain of vertex positions. */ 326 typedef VertexPositionChain::const_iterator VertexPositionChainConstIterator; 327 /** Constant iterator of constant chain of vertex positions. */ 328 typedef ConstVertexPositionChain::const_iterator ConstVertexPositionChainConstIterator; 329 330 /** 331 * Stores the s and t coordinate values of texture positions. 332 * Texture coordinates are referred to as s-, t-, r-, and q-coordinates to distinguish 333 * them from object coordinates (x, y, z, and w) and from elevator coordinates (u and v). 334 */ 335 /* 336 typedef struct { 337 double sPos; 338 double tPos; 339 double sRelativePos; 340 double tRelativePos; 341 } TexCoordPosition; 342 */ 343 typedef struct { 344 TexCoord coord; /**< Position of texture coord. */ 345 RelTexCoord relCoord; /**< Relative position of texture coord. */ 346 } TexCoordPosition; 347 348 /** Chain of vertices. */ 349 typedef std::vector<VisualVertex*> VertexChain; 350 /** Pointer to chain of vertices. */ 351 typedef VertexChain* VertexChainRef; 352 /** Constant chain of vertices. */ 353 typedef const VertexChain ConstVertexChain; 354 /** Pointer to constant chain of vertices. */ 355 typedef const VertexChainRef ConstVertexChainRef; 356 357 /** Iterator of chain of vertices. */ 358 typedef VertexChain::iterator VertexChainIterator; 359 /** Iterator of constant chain of vertices. */ 360 typedef ConstVertexChain::iterator ConstVertexChainIterator; 361 /** Constant iterator of chain of vertices. */ 362 typedef VertexChain::const_iterator VertexChainConstIterator; 363 /** Constant iterator of constant chain of vertices. */ 364 typedef ConstVertexChain::const_iterator ConstVertexChainConstIterator; 365 366 extern const int kGL_POINTS; /**< Primitive GL type GL_POINTS (mode). */ 367 extern const int kGL_LINES; /**< Primitive GL type GL_LINES (mode). */ 368 extern const int kGL_LINE_STRIP; /**< Primitive GL type GL_LINE_STRIP (mode). */ 369 extern const int kGL_LINE_LOOP; /**< Primitive GL type GL_LINE_LOOP (mode). */ 370 extern const int kGL_TRIANGLES; /**< Primitive GL type GL_TRIANGLES (mode). */ 371 extern const int kGL_TRIANGLE_STRIP; /**< Primitive GL type GL_TRIANGLE_STRIP (mode). */ 372 extern const int kGL_TRIANGLE_FAN; /**< Primitive GL type GL_TRIANGLE_FAN (mode). */ 373 extern const int kGL_QUADS; /**< Primitive GL type GL_QUADS (mode). */ 374 extern const int kGL_QUAD_STRIP; /**< Primitive GL type GL_QUAD_STRIP (mode). */ 375 extern const int kGL_POLYGON; /**< Primitive GL type GL_POLYGON (mode). */ 376 377 extern const int kGL_RGBA; /**< Primitive GL type GL_RGBA (format). */ 378 extern const int kGL_BGRA; /**< Primitive GL type GL_BGRA (format). */ 379 extern const int kGL_RGB; /**< Primitive GL type GL_RGB (format). */ 380 extern const int kGL_LUMINANCE; /**< Primitive GL type GL_LUMINANCE (format). */ 381 extern const int kGL_LUMINANCE_WITH_ALPHA; /**< Primitive GL type GL_LUMINANCE_ALPHA (format). */ 382 extern const int kGL_INTENSITY; /**< Primitive GL type GL_INTENSITY (format). */ 383 384 extern const int kGL_UNSIGNED_BYTE; /**< Primitive GL type GL_UNSIGNED_BYTE (data type). */ 385 extern const int kGL_FLOAT; /**< Primitive GL type GL_FLOAT (data type). */ 386 extern const int kGL_UNSIGNED_INT_8_8_8_8_REV; /**< Primitive GL type GL_UNSIGNED_INT_8_8_8_8_REV (data type). */ 387 extern const int kGL_UNSIGNED_INT_8_8_8_8; /**< Primitive GL type GL_UNSIGNED_INT_8_8_8_8 (data type). */ 388 389 extern const int kGL_FRONT_COLOR_BUFFER; /**< GL enum GL_FRONT (color buffer specification for reading or drawing pixels). */ 390 extern const int kGL_BACK_COLOR_BUFFER; /**< GL enum GL_BACK (color buffer specification for reading or drawing pixels). */ 391 392 /** 393 * The measure of box values. 394 */ 395 typedef enum { 396 kPixel = 0, /**< Box attribute is measured in pixels. */ 397 kPercent /**< Box attribute is measured in percent (of enclosing/surrounding VisualStageBox). */ 398 } Unit; 399 400 /** 401 * Types of horizontal alignment. 402 */ 403 typedef enum { 404 kLeftAligned = 0, /**< Left alignment. */ 405 kCenterAligned, /**< Centered alignment. */ 406 kRightAligned /**< Right alignment. */ 407 } HorizontalAlignment; 408 409 /** 410 * Types of vertical alignment. 411 */ 412 typedef enum { 413 kTopAligned = 0, /**< Top alignment. */ 414 kMiddleAligned, /**< Middle alignment. */ 415 kBottomAligned /**< Bottom alignment. */ 416 } VerticalAlignment; 417 418 /** 419 * Types of alignment in z-dimension. 420 */ 421 typedef enum { 422 kFrontAligned = 0, /**< Front alignment. */ 423 kDepthCenterAligned, /**< Centered alignment. */ 424 kBackAligned /**< Back alignment. */ 425 } DepthAlignment; 426 427 /** 428 * Whether the Nurbs is displayed in outlined mode or filled. 429 */ 430 typedef enum { 431 kFill = 0, /**< Fill Nurbs. */ 432 kOutlinePolygon /**< Draw outline. */ 433 } NurbsDisplayMode; 434 435 /** 436 * How to blend texture data with the framebuffer data. 437 */ 438 typedef enum { 439 kBlend = 0, /**< Blend with framebuffer data (glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA). */ 440 kReplace /**< Replace framebuffer data. */ 441 } BlendMode; 442 443 } 444 445 #endif /* VisualGraphicTypes_h */ 446