00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "std3d.h"
00027
00028 #include "3d/landscapevb_info.h"
00029 #include "3d/vertex_buffer.h"
00030 #include "3d/vertex_buffer_hard.h"
00031 #include "3d/landscapevb_allocator.h"
00032
00033
00034 namespace NL3D
00035 {
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 void CFarVertexBufferInfo::setupNullPointers()
00047 {
00048 VertexCoordPointer= NULL;
00049 TexCoordPointer0= NULL;
00050 TexCoordPointer1= NULL;
00051 ColorPointer= NULL;
00052 GeomInfoPointer= NULL;
00053 DeltaPosPointer= NULL;
00054 AlphaInfoPointer= NULL;
00055 }
00056
00057
00058
00059 void CFarVertexBufferInfo::setupPointersForVertexProgram()
00060 {
00061
00062 uint8 *vcoord= (uint8*)VertexCoordPointer;
00063
00064 TexCoordPointer0= vcoord + TexCoordOff0;
00065 TexCoordPointer1= vcoord + TexCoordOff1;
00066 GeomInfoPointer= vcoord + GeomInfoOff;
00067 DeltaPosPointer= vcoord + DeltaPosOff;
00068 AlphaInfoPointer= vcoord + AlphaInfoOff;
00069 }
00070
00071
00072
00073 void CFarVertexBufferInfo::setupVertexBuffer(CVertexBuffer &vb, bool forVertexProgram)
00074 {
00075 VertexFormat= vb.getVertexFormat();
00076 VertexSize= vb.getVertexSize();
00077 NumVertices= vb.getNumVertices();
00078
00079 if(NumVertices==0)
00080 {
00081 setupNullPointers();
00082 return;
00083 }
00084
00085 VertexCoordPointer= vb.getVertexCoordPointer();
00086
00087 if(forVertexProgram)
00088 {
00089
00090 TexCoordOff0= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX0);
00091 TexCoordOff1= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX1);
00092 GeomInfoOff= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_GEOMINFO);
00093 DeltaPosOff= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_DELTAPOS);
00094
00095 AlphaInfoOff= 0;
00096 if( vb.getVertexFormat() & (1<<NL3D_LANDSCAPE_VPPOS_ALPHAINFO) )
00097 AlphaInfoOff= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_ALPHAINFO);
00098
00099
00100 setupPointersForVertexProgram();
00101 }
00102 else
00103 {
00104 TexCoordOff0= vb.getTexCoordOff(0);
00105 TexCoordOff1= vb.getTexCoordOff(1);
00106 TexCoordPointer0= vb.getTexCoordPointer(0, 0);
00107 TexCoordPointer1= vb.getTexCoordPointer(0, 1);
00108
00109
00110 if(VertexFormat & CVertexBuffer::PrimaryColorFlag)
00111 {
00112 ColorOff= vb.getColorOff();
00113 ColorPointer= vb.getColorPointer();
00114 }
00115 else
00116 {
00117 ColorOff= 0;
00118 ColorPointer= NULL;
00119 }
00120 }
00121
00122 }
00123
00124 void CFarVertexBufferInfo::setupVertexBufferHard(IVertexBufferHard &vb, void *vcoord, bool forVertexProgram)
00125 {
00126 VertexFormat= vb.getVertexFormat();
00127 VertexSize= vb.getVertexSize();
00128 NumVertices= vb.getNumVertices();
00129
00130 if(NumVertices==0)
00131 {
00132 setupNullPointers();
00133 return;
00134 }
00135
00136 VertexCoordPointer= vcoord;
00137
00138 if(forVertexProgram)
00139 {
00140
00141 TexCoordOff0= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_TEX0);
00142 TexCoordOff1= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_TEX1);
00143 GeomInfoOff= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_GEOMINFO);
00144 DeltaPosOff= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_DELTAPOS);
00145
00146 AlphaInfoOff= 0;
00147 if( vb.getVertexFormat() & (1<<NL3D_LANDSCAPE_VPPOS_ALPHAINFO) )
00148 AlphaInfoOff= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_ALPHAINFO);
00149
00150
00151 setupPointersForVertexProgram();
00152 }
00153 else
00154 {
00155 TexCoordOff0= vb.getValueOff (CVertexBuffer::TexCoord0);
00156 TexCoordOff1= vb.getValueOff (CVertexBuffer::TexCoord1);
00157 TexCoordPointer0= (uint8*)vcoord + TexCoordOff0;
00158 TexCoordPointer1= (uint8*)vcoord + TexCoordOff1;
00159
00160
00161 if(VertexFormat & CVertexBuffer::PrimaryColorFlag)
00162 {
00163 ColorOff= vb.getValueOff (CVertexBuffer::PrimaryColor);
00164 ColorPointer= (uint8*)vcoord + ColorOff;
00165 }
00166 else
00167 {
00168 ColorOff= 0;
00169 ColorPointer= NULL;
00170 }
00171 }
00172 }
00173
00174
00175
00176 void CNearVertexBufferInfo::setupNullPointers()
00177 {
00178 VertexCoordPointer= NULL;
00179 TexCoordPointer0= NULL;
00180 TexCoordPointer1= NULL;
00181 TexCoordPointer2= NULL;
00182 GeomInfoPointer= NULL;
00183 DeltaPosPointer= NULL;
00184 }
00185
00186
00187
00188 void CNearVertexBufferInfo::setupPointersForVertexProgram()
00189 {
00190
00191 uint8 *vcoord= (uint8*)VertexCoordPointer;
00192
00193 TexCoordPointer0= vcoord + TexCoordOff0;
00194 TexCoordPointer1= vcoord + TexCoordOff1;
00195 TexCoordPointer2= vcoord + TexCoordOff2;
00196 GeomInfoPointer= vcoord + GeomInfoOff;
00197 DeltaPosPointer= vcoord + DeltaPosOff;
00198
00199 }
00200
00201
00202
00203 void CNearVertexBufferInfo::setupVertexBuffer(CVertexBuffer &vb, bool forVertexProgram)
00204 {
00205 VertexFormat= vb.getVertexFormat();
00206 VertexSize= vb.getVertexSize();
00207 NumVertices= vb.getNumVertices();
00208
00209 if(NumVertices==0)
00210 {
00211 setupNullPointers();
00212 return;
00213 }
00214
00215 VertexCoordPointer= vb.getVertexCoordPointer();
00216
00217 if(forVertexProgram)
00218 {
00219
00220 TexCoordOff0= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX0);
00221 TexCoordOff1= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX1);
00222 TexCoordOff2= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_TEX2);
00223 GeomInfoOff= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_GEOMINFO);
00224 DeltaPosOff= vb.getValueOffEx(NL3D_LANDSCAPE_VPPOS_DELTAPOS);
00225
00226
00227 setupPointersForVertexProgram();
00228 }
00229 else
00230 {
00231 TexCoordPointer0= vb.getTexCoordPointer(0, 0);
00232 TexCoordPointer1= vb.getTexCoordPointer(0, 1);
00233 TexCoordPointer2= vb.getTexCoordPointer(0, 2);
00234
00235 TexCoordOff0= vb.getTexCoordOff(0);
00236 TexCoordOff1= vb.getTexCoordOff(1);
00237 TexCoordOff2= vb.getTexCoordOff(2);
00238 }
00239 }
00240
00241 void CNearVertexBufferInfo::setupVertexBufferHard(IVertexBufferHard &vb, void *vcoord, bool forVertexProgram)
00242 {
00243 VertexFormat= vb.getVertexFormat();
00244 VertexSize= vb.getVertexSize();
00245 NumVertices= vb.getNumVertices();
00246
00247 if(NumVertices==0)
00248 {
00249 setupNullPointers();
00250 return;
00251 }
00252
00253 VertexCoordPointer= vcoord;
00254
00255 if(forVertexProgram)
00256 {
00257
00258 TexCoordOff0= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_TEX0);
00259 TexCoordOff1= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_TEX1);
00260 TexCoordOff2= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_TEX2);
00261 GeomInfoOff= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_GEOMINFO);
00262 DeltaPosOff= vb.getValueOff(NL3D_LANDSCAPE_VPPOS_DELTAPOS);
00263
00264
00265 setupPointersForVertexProgram();
00266 }
00267 else
00268 {
00269 TexCoordPointer0= (uint8*)vcoord + vb.getValueOff (CVertexBuffer::TexCoord0);
00270 TexCoordPointer1= (uint8*)vcoord + vb.getValueOff (CVertexBuffer::TexCoord1);
00271 TexCoordPointer2= (uint8*)vcoord + vb.getValueOff (CVertexBuffer::TexCoord2);
00272
00273 TexCoordOff0= vb.getValueOff (CVertexBuffer::TexCoord0);
00274 TexCoordOff1= vb.getValueOff (CVertexBuffer::TexCoord1);
00275 TexCoordOff2= vb.getValueOff (CVertexBuffer::TexCoord2);
00276 }
00277 }
00278
00279
00280 }