doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DrawVert.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __DRAWVERT_H__
30 #define __DRAWVERT_H__
31 
32 /*
33 ===============================================================================
34 
35  Draw Vertex.
36 
37 ===============================================================================
38 */
39 
40 class idDrawVert {
41 public:
46  byte color[4];
47 #if 0 // was MACOS_X see comments concerning DRAWVERT_PADDED in Simd_Altivec.h
48  float padding;
49 #endif
50  float operator[]( const int index ) const;
51  float & operator[]( const int index );
52 
53  void Clear( void );
54 
55  void Lerp( const idDrawVert &a, const idDrawVert &b, const float f );
56  void LerpAll( const idDrawVert &a, const idDrawVert &b, const float f );
57 
58  void Normalize( void );
59 
60  void SetColor( dword color );
61  dword GetColor( void ) const;
62 };
63 
64 ID_INLINE float idDrawVert::operator[]( const int index ) const {
65  assert( index >= 0 && index < 5 );
66  return ((float *)(&xyz))[index];
67 }
68 ID_INLINE float &idDrawVert::operator[]( const int index ) {
69  assert( index >= 0 && index < 5 );
70  return ((float *)(&xyz))[index];
71 }
72 
73 ID_INLINE void idDrawVert::Clear( void ) {
74  xyz.Zero();
75  st.Zero();
76  normal.Zero();
77  tangents[0].Zero();
78  tangents[1].Zero();
79  color[0] = color[1] = color[2] = color[3] = 0;
80 }
81 
82 ID_INLINE void idDrawVert::Lerp( const idDrawVert &a, const idDrawVert &b, const float f ) {
83  xyz = a.xyz + f * ( b.xyz - a.xyz );
84  st = a.st + f * ( b.st - a.st );
85 }
86 
87 ID_INLINE void idDrawVert::LerpAll( const idDrawVert &a, const idDrawVert &b, const float f ) {
88  xyz = a.xyz + f * ( b.xyz - a.xyz );
89  st = a.st + f * ( b.st - a.st );
90  normal = a.normal + f * ( b.normal - a.normal );
91  tangents[0] = a.tangents[0] + f * ( b.tangents[0] - a.tangents[0] );
92  tangents[1] = a.tangents[1] + f * ( b.tangents[1] - a.tangents[1] );
93  color[0] = (byte)( a.color[0] + f * ( b.color[0] - a.color[0] ) );
94  color[1] = (byte)( a.color[1] + f * ( b.color[1] - a.color[1] ) );
95  color[2] = (byte)( a.color[2] + f * ( b.color[2] - a.color[2] ) );
96  color[3] = (byte)( a.color[3] + f * ( b.color[3] - a.color[3] ) );
97 }
98 
99 ID_INLINE void idDrawVert::SetColor( dword color ) {
100  *reinterpret_cast<dword *>(this->color) = color;
101 }
102 
103 ID_INLINE dword idDrawVert::GetColor( void ) const {
104  return *reinterpret_cast<const dword *>(this->color);
105 }
106 
107 #endif /* !__DRAWVERT_H__ */
byte color[4]
Definition: MegaTexture.cpp:54
unsigned int dword
Definition: Lib.h:77
assert(prefInfo.fullscreenBtn)
void Clear(void)
Definition: DrawVert.h:73
void SetColor(dword color)
Definition: DrawVert.h:99
idVec3 xyz
Definition: DrawVert.h:42
idVec3 tangents[2]
Definition: DrawVert.h:45
float operator[](const int index) const
Definition: DrawVert.h:64
Definition: Vector.h:316
void Lerp(const idDrawVert &a, const idDrawVert &b, const float f)
Definition: DrawVert.h:82
void Zero(void)
Definition: Vector.h:119
idVec2 st
Definition: DrawVert.h:43
Definition: Vector.h:52
dword GetColor(void) const
Definition: DrawVert.h:103
GLuint index
Definition: glext.h:3476
void LerpAll(const idDrawVert &a, const idDrawVert &b, const float f)
Definition: DrawVert.h:87
idVec3 normal
Definition: DrawVert.h:44
GLubyte GLubyte GLubyte a
Definition: glext.h:4662
void Normalize(void)
Definition: DrawVert.cpp:38
GLubyte GLubyte b
Definition: glext.h:4662
tuple f
Definition: idal.py:89
unsigned char byte
Definition: Lib.h:75
byte color[4]
Definition: DrawVert.h:46
void Zero(void)
Definition: Vector.h:415