Changeset 1526 for GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves
- Timestamp:
- 09/28/06 17:49:37 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/Leaf.cpp
r1026 r1526 10 10 vertsLeaf[0] = vertsLeaf[1] = vertsLeaf[2] = vertsLeaf[3] =0; 11 11 center[0] = center[1] = center[2] = 0; 12 normal[0] = normal[1] = normal[2] = 0;12 // normal[0] = normal[1] = normal[2] = 0; 13 13 leafNear=-1; 14 14 parentLeafCount = 1; … … 40 40 for ( int i=0;i<3;i++){ 41 41 center[i] = aLeaf.center[i]; 42 normal[i] = aLeaf.normal[i];42 // normal[i] = aLeaf.normal[i]; 43 43 } 44 44 for (i = 0L; i < 4; i++) … … 53 53 54 54 55 RuntimeLeaf::RuntimeLeaf(void) 56 { 57 vertsLeaf[0] = vertsLeaf[1] = vertsLeaf[2] = vertsLeaf[3] = 0; 58 parent = root = childLeft = childRight = -1; 59 } 55 60 56 61 //-------------------------------------------------------------------------------------------------------------------------------- 57 // Destructor. We must deallocate the memory allocated for pointers to vertices and edges62 // Copy constructor 58 63 //-------------------------------------------------------------------------------------------------------------------------------- 59 Leaf::~Leaf (void)64 RuntimeLeaf::RuntimeLeaf (const RuntimeLeaf& aLeaf) 60 65 { 66 for (int i = 0L; i < 4; i++) 67 vertsLeaf[i] = aLeaf.vertsLeaf[i]; 68 parent = aLeaf.parent; 69 childLeft = aLeaf.childLeft; 70 childRight = aLeaf.childRight; 71 root = aLeaf.root; 61 72 } 62 73 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/VertexData.cpp
r1105 r1526 1 1 #include "VertexData.h" 2 2 3 Geometry::DefaultVertexData::DefaultVertexData(unsigned int numv):Geometry::VertexData(numv) 3 /* 4 void Geometry::DefaultIndexData::Init(unsigned int numi) 4 5 { 5 v = new float[numv*3]; 6 n = new float[numv*3]; 7 t = new float[numv*2]; 8 } 9 Geometry::DefaultVertexData::~DefaultVertexData(void) 10 { 11 /* delete[] v; 12 delete[] n; 13 delete[] t;*/ 14 } 15 16 Geometry::VertexData *Geometry::DefaultVertexDataCreator(unsigned int numv) 17 { 18 return new DefaultVertexData(numv); 19 } 20 21 22 Geometry::DefaultIndexData::DefaultIndexData(unsigned int numi):Geometry::IndexData(numi) 23 { 24 indices = new unsigned int[numi]; 6 indices = new unsigned int[numi]; 25 7 } 26 8 Geometry::DefaultIndexData::~DefaultIndexData(void) 27 9 { 28 /* delete[] indices;*/29 10 } 30 11 31 12 Geometry::IndexData *Geometry::DefaultIndexDataCreator(unsigned int numi) 32 13 { 33 return new DefaultIndexData(numi); 14 IndexData *ret = new DefaultIndexData(); 15 // ret->Init(numi); 16 return ret; 34 17 } 35 18 36 37 /*Geometry::DefaultMultiIndexData::DefaultMultiIndexData(unsigned int numprims, unsigned int *numi):Geometry::MultiIndexData(numprims,numi)38 {39 indices = new unsigned int*[numprims];40 for (unsigned int i=0; i<numprims; i++)41 indices[i]=new unsigned int[numi[i]];42 }43 Geometry::DefaultMultiIndexData::~DefaultMultiIndexData(void)44 {45 for (unsigned int i=0; i<GetNumPrims(); i++)46 delete[] indices[i];47 delete[] indices;48 }49 50 Geometry::MultiIndexData *Geometry::DefaultMultiIndexDataCreator(unsigned int numprims, unsigned int *numi)51 {52 return new DefaultMultiIndexData(numprims,numi);53 }54 19 */ -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp
r1083 r1526 10 10 // Parameters --> None 11 11 //-------------------------------------------------------------------------------------------------------------------------------- 12 Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const Geometry::TreeSimplificationSequence * simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 12 Foliage::Foliage(int leavessubmeshID, 13 const Geometry::SubMesh *leavesSubMesh, 14 const Geometry::TreeSimplificationSequence * simpSeq/*, 15 Geometry::CREATEVERTEXDATAFUNC vdfun*/): 13 16 Acth(NULL), 14 create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun),15 create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun),16 vertexdata(NULL),Leaves(NULL), MinDet(NULL)17 //create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun), 18 //create_index_data_func(idfun==NULL?Geometry::DefaultIndexDataCreator:idfun), 19 /*vertexdata(NULL),*/ Leaves(NULL), MinDet(NULL) 17 20 { 18 21 begin = final = -1; 19 20 ReadVertices(leavesSubMesh); 22 // indexdata=NULL; 23 24 // ReadVertices(leavesSubMesh); 25 int countv= int(leavesSubMesh->mVertexBuffer->mVertexCount); 26 Leaves = new RuntimeLeaf[countv*2]; 27 TotalVerts = countv; 28 21 29 ReadLeafs(leavesSubMesh); 22 30 if (!ReadSimpSeq(simpSeq)) exit(1); 23 31 FillRoot(); 24 CalculateTexCoordsAndNorms();25 26 indexdata->SetNumValidIndices(0);32 // CalculateTexCoordsAndNorms(); 33 34 // indexdata->SetNumValidIndices(0); 27 35 28 36 int h=0; … … 44 52 final = leafCount-1; 45 53 active_leaf_count = leafCount; 54 leavesSubMeshID=leavessubmeshID; 46 55 } 47 56 … … 51 60 Foliage::~Foliage (void) 52 61 { 53 if (vertexdata) delete vertexdata;54 if (indexdata) delete indexdata;62 // if (vertexdata) delete vertexdata; 63 // if (indexdata) delete indexdata; 55 64 delete[] Leaves; 56 65 delete MinDet; … … 222 231 223 232 } 224 233 /* 225 234 void Foliage::ReadVertices(const Geometry::SubMesh *submesh) 226 235 { … … 228 237 vertexdata = create_vertex_data_func(2*countv); 229 238 Leaves = new Leaf[countv*2]; 230 indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja239 //indexdata = create_index_data_func(countv*2*3); // 3 indices x 2 triangulos x hoja 231 240 232 241 vertexdata->Begin(); … … 249 258 float twox, twoy, twoz; 250 259 float threex, threey, threez; 251 252 /* Vertices[aHoja.vertsLeaf[0]].GetCoordinates (onex, oney, onez);253 Vertices[aHoja.vertsLeaf[1]].GetCoordinates(twox, twoy, twoz);254 Vertices[aHoja.vertsLeaf[2]].GetCoordinates (threex, threey, threez);*/255 260 256 261 vertexdata->GetVertexCoord(aleaf.vertsLeaf[0],onex,oney,onez); … … 286 291 res[2]=v[2]/module; 287 292 } 288 293 */ 289 294 void Foliage::ReadLeafs(const Geometry::SubMesh *submesh) 290 295 { … … 297 302 Leaves[h].vertsLeaf[2] = submesh->mIndex[h*6+2]; 298 303 Leaves[h].vertsLeaf[3] = submesh->mIndex[h*6+5]; 299 Leaves[h].visible = 0;300 301 GetNormalH ( Leaves[h]);304 // Leaves[h].visible = 0; 305 306 // GetNormalH ( Leaves[h]); 302 307 } 303 308 } … … 316 321 Leaves[tn].vertsLeaf[3] = it->mNewQuad[3]; 317 322 318 Leaves[tn].visible = 0;319 320 GetNormalH (Leaves[tn]);323 // Leaves[tn].visible = 0; 324 325 // GetNormalH (Leaves[tn]); 321 326 322 327 tv1 = it->mV0/2; … … 433 438 } 434 439 435 void Foliage::CalculateTexCoordsAndNorms(void)440 /*void Foliage::CalculateTexCoordsAndNorms(void) 436 441 { 437 442 vertexdata->Begin(); … … 453 458 vertexdata->End(); 454 459 } 455 460 */ 456 461 Foliage::Foliage(const Foliage *ar) 457 462 { … … 465 470 TotalVerts=ar->TotalVerts; 466 471 467 create_vertex_data_func=ar->create_vertex_data_func;468 create_index_data_func=ar->create_index_data_func;472 /* create_vertex_data_func=ar->create_vertex_data_func; 473 // create_index_data_func=ar->create_index_data_func; 469 474 vertexdata=create_vertex_data_func(ar->vertexdata->GetNumVertices()); 470 475 vertexdata->Begin(); … … 477 482 vertexdata->SetVertexNormal(i,va,vb,vc); 478 483 } 479 vertexdata->End(); 480 indexdata=create_index_data_func(ar->indexdata->GetNumMaxIndices());481 indexdata->Begin( );484 vertexdata->End();*/ 485 /* indexdata=create_index_data_func(ar->indexdata->GetNumMaxIndices()); 486 indexdata->Begin(ar->leavesSubMeshID,indexdata->GetNumMaxIndices()); 482 487 for (unsigned int i=0; i<indexdata->GetNumMaxIndices(); i++) 483 488 indexdata->SetIndex(i,ar->indexdata->GetIndex(i)); 484 indexdata->End(); 485 486 Leaves=new Leaf[vertexdata->GetNumVertices()];489 indexdata->End();*/ 490 491 Leaves=new RuntimeLeaf[TotalVerts]; 487 492 // for (unsigned int i=0; i<vertexdata->GetNumVertices(); i++) 488 493 // Leaves[i]=ar->Leaves[i]; 489 memcpy(Leaves,ar->Leaves,sizeof(Leaf)* vertexdata->GetNumVertices());494 memcpy(Leaves,ar->Leaves,sizeof(Leaf)*TotalVerts); 490 495 491 496 // esto no sé si devería haber akí 492 indexdata->SetNumValidIndices(0);497 // indexdata->SetNumValidIndices(0); 493 498 494 499 int h=0; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h
r1083 r1526 26 26 int begin, final; 27 27 int active_leaf_count; 28 int leavesSubMeshID; 28 29 29 Foliage (const Geometry::SubMesh *, const Geometry::TreeSimplificationSequence *, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); 30 Foliage ( int leavesSubMeshID, 31 const Geometry::SubMesh *, 32 const Geometry::TreeSimplificationSequence * ); 33 30 34 Foliage (const Foliage *); 31 35 virtual ~Foliage (void); // Destructor … … 33 37 void CalculateLOD(int nhojas); 34 38 35 Geometry::VertexData *vertexdata; 36 Geometry::IndexData *indexdata; 37 38 Leaf *Leaves; 39 RuntimeLeaf *Leaves; 39 40 ActiveLeafNode *MinDet; // first active leaf 40 41 int leafCount; … … 45 46 46 47 private: 47 Geometry::CREATEVERTEXDATAFUNC create_vertex_data_func;48 Geometry::CREATEINDEXDATAFUNC create_index_data_func;49 48 50 49 bool IsActive( int num) const; … … 59 58 bool ReadSimpSeq(const Geometry::TreeSimplificationSequence *); /// returns true when successful 60 59 void FillRoot(void); 61 62 void GetNormalH (Leaf&);63 64 void CrossProduct(const float *v1, const float *v2, float *res);65 void Normalize(const float *v, float *res);66 // void CalculaNormalesVertice(void);67 void CalculateTexCoordsAndNorms(void);68 69 60 }; 70 61
Note: See TracChangeset
for help on using the changeset viewer.