#include <vegetable_shape.h>
Nevrax France
Definition at line 108 of file vegetable_shape.h.
Public Member Functions | |
void | build (CVegetableShapeBuild &vbuild) |
CVegetableShape () | |
Constructor. | |
void | loadShape (const std::string &shape) |
void | serial (NLMISC::IStream &f) |
serial | |
Data Fields | |
Shape def | |
bool | AlphaBlend |
CVegetableShapeBuild::TBendCenterMode | BendCenterMode |
bool | BestSidedPreComputeLighting |
bool | DoubleSided |
bool | Lighted |
Type of this shape. | |
bool | PreComputeLighting |
std::vector< uint32 > | TriangleIndices |
list of triangles index | |
CVertexBuffer | VB |
Temporary for easy Instanciation (correct size) | |
std::vector< uint32 > | InstanceVertices |
For each vertex of the shape, gives the index in the VegetableManager. |
|
Constructor.
Definition at line 42 of file vegetable_shape.cpp.
00043 { 00044 Lighted= false; 00045 DoubleSided= false; 00046 PreComputeLighting= false; 00047 AlphaBlend= false; 00048 BestSidedPreComputeLighting= false; 00049 } |
|
build a vegetable shape, with a standard shape. Definition at line 52 of file vegetable_shape.cpp. References NL3D::CVegetableShapeBuild::AlphaBlend, NL3D::CVegetableShapeBuild::BendCenterMode, NL3D::CVegetableShapeBuild::BestSidedPreComputeLighting, NL3D::CVegetableShapeBuild::DoubleSided, format, NL3D::CVertexBuffer::getColorPointer(), NL3D::CVertexBuffer::getNormalCoordPointer(), NL3D::CPrimitiveBlock::getNumTri(), NL3D::CVertexBuffer::getNumVertices(), NL3D::CVertexBuffer::getTexCoordPointer(), NL3D::CPrimitiveBlock::getTriPointer(), NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexFormat(), InstanceVertices, NL3D::CVegetableShapeBuild::Lighted, NL3D::CVegetableShapeBuild::MaxBendWeight, nlassert, NL3D::CVegetableShapeBuild::PB, NL3D::CVegetableShapeBuild::PreComputeLighting, NLMISC::CRGBA::R, NL3D::CVertexBuffer::setNumVertices(), NL3D::CVertexBuffer::setVertexFormat(), NLMISC::CUV::U, uint, uint32, NL3D::CVegetableShapeBuild::VB, w, and z.
00053 { 00054 // Must have TexCoord0. 00055 nlassert( vbuild.VB.getVertexFormat() & CVertexBuffer::TexCoord0Flag ); 00056 00057 // Header 00058 //--------- 00059 00060 // Lighted ? 00061 if(vbuild.Lighted && ( vbuild.VB.getVertexFormat() & CVertexBuffer::NormalFlag) ) 00062 Lighted= true; 00063 else 00064 Lighted= false; 00065 00066 // DoubleSided 00067 DoubleSided= vbuild.DoubleSided; 00068 00069 // PreComputeLighting. 00070 PreComputeLighting= Lighted && vbuild.PreComputeLighting; 00071 00072 // AlphaBlend: valid only for 2Sided and Unlit (or similar PreComputeLighting) mode 00073 AlphaBlend= vbuild.AlphaBlend && DoubleSided && (!Lighted || PreComputeLighting); 00074 00075 // BestSidedPreComputeLighting 00076 BestSidedPreComputeLighting= PreComputeLighting && vbuild.BestSidedPreComputeLighting; 00077 00078 // BendCenterMode 00079 BendCenterMode= vbuild.BendCenterMode; 00080 00081 // Format of the VB. 00082 uint32 format; 00083 format= CVertexBuffer::PositionFlag | CVertexBuffer::TexCoord0Flag | CVertexBuffer::TexCoord1Flag; 00084 // lighted? 00085 if(Lighted) 00086 format|= CVertexBuffer::NormalFlag; 00087 // set VB. 00088 VB.setVertexFormat(format); 00089 00090 00091 // Fill triangles. 00092 //--------- 00093 uint i; 00094 // resisz 00095 TriangleIndices.resize(vbuild.PB.getNumTri() * 3); 00096 uint32 *srcTri= vbuild.PB.getTriPointer(); 00097 // fill 00098 for(i=0; i<vbuild.PB.getNumTri(); i++) 00099 { 00100 TriangleIndices[i*3+0]= *(srcTri++); 00101 TriangleIndices[i*3+1]= *(srcTri++); 00102 TriangleIndices[i*3+2]= *(srcTri++); 00103 } 00104 00105 00106 // Fill vertices. 00107 //--------- 00108 // resize 00109 uint32 nbVerts= vbuild.VB.getNumVertices(); 00110 VB.setNumVertices(nbVerts); 00111 // if no vertex color, 00112 float maxZ= 0; 00113 bool bendFromColor= true; 00114 if(! (vbuild.VB.getVertexFormat() & CVertexBuffer::PrimaryColorFlag) ) 00115 { 00116 // must compute bendWeight from z. 00117 bendFromColor= false; 00118 // get the maximum Z. 00119 for(i=0;i<nbVerts;i++) 00120 { 00121 float z= ((CVector*)vbuild.VB.getVertexCoordPointer(i))->z; 00122 maxZ= max(z, maxZ); 00123 } 00124 // if no positive value, bend will always be 0. 00125 if(maxZ==0) 00126 maxZ= 1; 00127 } 00128 00129 // For all vertices, fill 00130 for(i=0;i<nbVerts;i++) 00131 { 00132 // Position. 00133 CVector *srcPos= (CVector*)vbuild.VB.getVertexCoordPointer(i); 00134 CVector *dstPos= (CVector*)VB.getVertexCoordPointer(i); 00135 *dstPos= *srcPos; 00136 00137 // Normal 00138 if(Lighted) 00139 { 00140 CVector *srcNormal= (CVector*)vbuild.VB.getNormalCoordPointer(i); 00141 CVector *dstNormal= (CVector*)VB.getNormalCoordPointer(i); 00142 *dstNormal= *srcNormal; 00143 } 00144 00145 // Texture. 00146 CUV *srcUV= (CUV*)vbuild.VB.getTexCoordPointer(i, 0); 00147 CUV *dstUV= (CUV*)VB.getTexCoordPointer(i, 0); 00148 *dstUV= *srcUV; 00149 00150 // Bend. 00151 // copy to texture stage 1. 00152 CUV *dstUVBend= (CUV*)VB.getTexCoordPointer(i, 1); 00153 if(bendFromColor) 00154 { 00155 CRGBA *srcColor= (CRGBA*)vbuild.VB.getColorPointer(i); 00156 // Copy and scale by MaxBendWeight 00157 dstUVBend->U= (srcColor->R / 255.f) * vbuild.MaxBendWeight; 00158 } 00159 else 00160 { 00161 float w= srcPos->z / maxZ; 00162 w= max(w, 0.f); 00163 // Copy and scale by MaxBendWeight 00164 dstUVBend->U= w * vbuild.MaxBendWeight; 00165 } 00166 } 00167 00168 00169 // Misc. 00170 //--------- 00171 // prepare for instanciation 00172 InstanceVertices.resize(VB.getNumVertices()); 00173 00174 } |
|
load a vegetable shape (.veget), lookup into CPath, and serial Definition at line 177 of file vegetable_shape.cpp. References serial(). Referenced by NL3D::CVegetableManager::getVegetableShape().
|
|
serial
Definition at line 186 of file vegetable_shape.cpp. References NL3D::CVertexBuffer::getNumVertices(), InstanceVertices, NLMISC::IStream::isReading(), NLMISC::IStream::serial(), NLMISC::IStream::serialCheck(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialEnum(), NLMISC::IStream::serialVersion(), sint, and uint32. Referenced by loadShape().
00187 { 00188 /* 00189 Version 1: 00190 - BestSidedPreComputeLighting 00191 */ 00192 sint ver= f.serialVersion(1); 00193 f.serialCheck((uint32)'_LEN'); 00194 f.serialCheck((uint32)'GEV_'); 00195 f.serialCheck((uint32)'BATE'); 00196 f.serialCheck((uint32)'__EL'); 00197 00198 f.serial(Lighted); 00199 f.serial(DoubleSided); 00200 f.serial(PreComputeLighting); 00201 f.serial(AlphaBlend); 00202 f.serialEnum(BendCenterMode); 00203 f.serial(VB); 00204 f.serialCont(TriangleIndices); 00205 00206 if(ver>=1) 00207 f.serial(BestSidedPreComputeLighting); 00208 else if(f.isReading()) 00209 BestSidedPreComputeLighting= false; 00210 00211 // if reading 00212 if(f.isReading()) 00213 { 00214 // prepare for instanciation 00215 InstanceVertices.resize(VB.getNumVertices()); 00216 } 00217 } |
|
Definition at line 132 of file vegetable_shape.h. Referenced by NL3D::CVegetableManager::getRdrPassInfoForShape(). |
|
Definition at line 134 of file vegetable_shape.h. Referenced by NL3D::CVegetableManager::addInstance(). |
|
Definition at line 133 of file vegetable_shape.h. Referenced by NL3D::CVegetableManager::addInstance(), and NL3D::CVegetableManager::updateInstanceLighting(). |
|
Definition at line 130 of file vegetable_shape.h. Referenced by NL3D::CVegetableManager::getRdrPassInfoForShape(), and NL3D::CVegetableManager::updateInstanceLighting(). |
|
For each vertex of the shape, gives the index in the VegetableManager.
Definition at line 147 of file vegetable_shape.h. Referenced by NL3D::CVegetableManager::addInstance(), build(), serial(), and NL3D::CVegetableManager::updateInstanceLighting(). |
|
Type of this shape.
Definition at line 129 of file vegetable_shape.h. Referenced by NL3D::CVegetable::generateInstance(), NL3D::CVegetableManager::getRdrPassInfoForShape(), and NL3D::CVegetableManager::updateInstanceLighting(). |
|
Definition at line 131 of file vegetable_shape.h. Referenced by NL3D::CVegetableManager::getRdrPassInfoForShape(), and NL3D::CVegetableManager::updateInstanceLighting(). |
|
list of triangles index
Definition at line 140 of file vegetable_shape.h. Referenced by NL3D::CVegetableManager::addInstance(), and NL3D::CVegetableManager::reserveIgAddInstances(). |
|
VertexBuffer of this Shape, ready to be transformed and copied into vegetable manager Format is Pos/Normal/Tex0/Tex1 (no Normal if !Lighted). where Tex1.U==BendWeigth Definition at line 138 of file vegetable_shape.h. Referenced by NL3D::CVegetableManager::addInstance(), NL3D::CVegetableManager::reserveIgAddInstances(), and NL3D::CVegetableManager::updateInstanceLighting(). |