home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / idlib / geometry / rvVertex.h < prev    next >
C/C++ Source or Header  |  2005-11-14  |  2KB  |  82 lines

  1. //
  2. // rvVertex.h - Describes some commonly used vertices (alternatives to the idDrawVert)
  3. // Date: 1/10/05
  4. // Created by: Dwight Luetscher - Raven Software
  5. //
  6.  
  7. #ifndef __RV_VERTEX_H__
  8. #define __RV_VERTEX_H__
  9.  
  10. //
  11. // rvBlend4DrawVert
  12. //
  13. // a vertex that is used to communicate data to drawing vertices stored in vertex buffers
  14. //
  15. class rvBlend4DrawVert {
  16. public:
  17.     idVec3            xyz;
  18.     int                blendIndex[4];            
  19.     float            blendWeight[4];        // NOTE: the vertex stored in the actual buffer that is actually used for drawing may leave out the last weight (implied 1 - sum of other weights)
  20.     idVec3            normal;
  21.     idVec3            tangent;
  22.     idVec3            binormal;
  23.     byte            color[4];            // diffuse color, [0] red, [1] green, [2] blue, [3] alpha
  24.     idVec2            st;
  25. };
  26.  
  27. //
  28. // rvSilTraceVertT
  29. //
  30. // a transformed vert that typically resides in system-memory and is used for operations
  31. // like silhouette determination and trace testing
  32. //
  33. class rvSilTraceVertT {
  34. public:
  35.     idVec4            xyzw;
  36.  
  37.     float            operator[]( const int index ) const;
  38.     float &            operator[]( const int index );
  39.  
  40.     void            Clear( void );
  41.  
  42.     void            Lerp( const rvSilTraceVertT &a, const rvSilTraceVertT &b, const float f );
  43.     void            LerpAll( const rvSilTraceVertT &a, const rvSilTraceVertT &b, const float f );
  44. };
  45.  
  46. #define SILTRACEVERT_SIZE_SHIFT            4
  47. #define SILTRACEVERT_SIZE                (1 << SILTRACEVERT_SIZE_SHIFT)
  48. #define SILTRACEVERT_XYZW_OFFSET        0
  49.  
  50. assert_sizeof( rvSilTraceVertT,            SILTRACEVERT_SIZE );
  51. assert_sizeof( rvSilTraceVertT,            (1<<SILTRACEVERT_SIZE_SHIFT) );
  52. assert_offsetof( rvSilTraceVertT, xyzw,    SILTRACEVERT_XYZW_OFFSET );
  53.  
  54. ID_INLINE float rvSilTraceVertT::operator[]( const int index ) const 
  55. {
  56.     assert( index >= 0 && index < 4 );
  57.     return ((float *)(&xyzw))[index];
  58. }
  59.  
  60. ID_INLINE float    &rvSilTraceVertT::operator[]( const int index ) 
  61. {
  62.     assert( index >= 0 && index < 4 );
  63.     return ((float *)(&xyzw))[index];
  64. }
  65.  
  66. ID_INLINE void rvSilTraceVertT::Clear( void ) 
  67. {
  68.     xyzw.Zero();
  69. }
  70.  
  71. ID_INLINE void rvSilTraceVertT::Lerp( const rvSilTraceVertT &a, const rvSilTraceVertT &b, const float f ) 
  72. {
  73.     xyzw = a.xyzw + f * ( b.xyzw - a.xyzw );
  74. }
  75.  
  76. ID_INLINE void rvSilTraceVertT::LerpAll( const rvSilTraceVertT &a, const rvSilTraceVertT &b, const float f ) 
  77. {
  78.     xyzw = a.xyzw + f * ( b.xyzw - a.xyzw );
  79. }
  80.  
  81. #endif    // #ifndef __RV_VERTEX_H__
  82.