1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "nel/3d/landscapevb_info.h"
20 #include "nel/3d/vertex_buffer.h"
21 #include "nel/3d/landscapevb_allocator.h"
31 // ***************************************************************************
32 // ***************************************************************************
34 // ***************************************************************************
35 // ***************************************************************************
38 // ***************************************************************************
39 void CFarVertexBufferInfo::setupNullPointers()
42 VertexCoordPointer
= NULL
;
43 TexCoordPointer0
= NULL
;
44 TexCoordPointer1
= NULL
;
46 GeomInfoPointer
= NULL
;
47 DeltaPosPointer
= NULL
;
48 AlphaInfoPointer
= NULL
;
52 // ***************************************************************************
53 void CFarVertexBufferInfo::setupPointersForVertexProgram()
55 // see CLandscapeVBAllocator for program definition.
56 uint8
*vcoord
= (uint8
*)VertexCoordPointer
;
58 TexCoordPointer0
= vcoord
+ TexCoordOff0
;
59 TexCoordPointer1
= vcoord
+ TexCoordOff1
;
60 GeomInfoPointer
= vcoord
+ GeomInfoOff
;
61 DeltaPosPointer
= vcoord
+ DeltaPosOff
;
62 AlphaInfoPointer
= vcoord
+ AlphaInfoOff
;
66 // ***************************************************************************
67 void CFarVertexBufferInfo::setupVertexBuffer(CVertexBuffer
&vb
, bool forVertexProgram
)
69 VertexFormat
= vb
.getVertexFormat();
70 VertexSize
= vb
.getVertexSize();
71 NumVertices
= vb
.getNumVertices();
80 VertexCoordPointer
= Accessor
.getVertexCoordPointer();
84 // With VertexCoordPointer setuped, init for VP.
85 TexCoordOff0
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX0
); // v[8]= Tex0.
86 TexCoordOff1
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX1
); // v[9]= Tex1.
87 GeomInfoOff
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_GEOMINFO
); // v[10]= GeomInfos.
88 DeltaPosOff
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_DELTAPOS
); // v[11]= EndPos-StartPos
89 // Init Alpha Infos only if enabled (enabled if Value 5 are).
91 if( vb
.getVertexFormat() & (1<<NL3D_LANDSCAPE_VPPOS_ALPHAINFO
) )
92 AlphaInfoOff
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_ALPHAINFO
); // v[12]= AlphaInfos
95 setupPointersForVertexProgram();
99 TexCoordOff0
= vb
.getTexCoordOff(0);
100 TexCoordOff1
= vb
.getTexCoordOff(1);
101 TexCoordPointer0
= Accessor
.getTexCoordPointer(0, 0);
102 TexCoordPointer1
= Accessor
.getTexCoordPointer(0, 1);
104 // In Far0, we don't have Color component.
105 if(VertexFormat
& CVertexBuffer::PrimaryColorFlag
)
107 ColorOff
= vb
.getColorOff();
108 // todo hulud d3d vertex color RGBA / BGRA
109 ColorPointer
= Accessor
.getColorPointer();
121 // ***************************************************************************
122 void CNearVertexBufferInfo::setupNullPointers()
125 VertexCoordPointer
= NULL
;
126 TexCoordPointer0
= NULL
;
127 TexCoordPointer1
= NULL
;
128 TexCoordPointer2
= NULL
;
129 GeomInfoPointer
= NULL
;
130 DeltaPosPointer
= NULL
;
134 // ***************************************************************************
135 void CNearVertexBufferInfo::setupPointersForVertexProgram()
137 // see CLandscapeVBAllocator for program definition.
138 uint8
*vcoord
= (uint8
*)VertexCoordPointer
;
140 TexCoordPointer0
= vcoord
+ TexCoordOff0
;
141 TexCoordPointer1
= vcoord
+ TexCoordOff1
;
142 TexCoordPointer2
= vcoord
+ TexCoordOff2
;
143 GeomInfoPointer
= vcoord
+ GeomInfoOff
;
144 DeltaPosPointer
= vcoord
+ DeltaPosOff
;
149 // ***************************************************************************
150 void CNearVertexBufferInfo::setupVertexBuffer(CVertexBuffer
&vb
, bool forVertexProgram
)
152 VertexFormat
= vb
.getVertexFormat();
153 VertexSize
= vb
.getVertexSize();
154 NumVertices
= vb
.getNumVertices();
163 VertexCoordPointer
= Accessor
.getVertexCoordPointer();
167 // With VertexCoordPointer setuped, init for VP.
168 TexCoordOff0
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX0
); // v[8]= Tex0.
169 TexCoordOff1
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX1
); // v[9]= Tex1.
170 TexCoordOff2
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX2
); // v[13]= Tex1.
171 GeomInfoOff
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_GEOMINFO
); // v[10]= GeomInfos.
172 DeltaPosOff
= vb
.getValueOffEx(NL3D_LANDSCAPE_VPPOS_DELTAPOS
); // v[11]= EndPos-StartPos
175 setupPointersForVertexProgram();
179 TexCoordPointer0
= Accessor
.getTexCoordPointer(0, 0);
180 TexCoordPointer1
= Accessor
.getTexCoordPointer(0, 1);
181 TexCoordPointer2
= Accessor
.getTexCoordPointer(0, 2);
183 TexCoordOff0
= vb
.getTexCoordOff(0);
184 TexCoordOff1
= vb
.getTexCoordOff(1);
185 TexCoordOff2
= vb
.getTexCoordOff(2);