- Timestamp:
- 06/28/06 17:50:02 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/GTGeometry.vcproj
r1058 r1069 112 112 </File> 113 113 <File 114 RelativePath=".\src\GeoLodManager.cpp"> 115 </File> 116 <File 114 117 RelativePath=".\src\GeoLodStripsConstructor.cpp"> 115 118 </File> … … 349 352 <File 350 353 RelativePath=".\include\GeoBase.h"> 354 </File> 355 <File 356 RelativePath=".\include\GeoLodManager.h"> 351 357 </File> 352 358 <File -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h
r1058 r1069 127 127 void LoadStripMesh(char *name, Mesh *geomesh); 128 128 129 Geometry::CREATE MULTIINDEXDATAFUNC create_multi_index_data_func;129 Geometry::CREATEINDEXDATAFUNC create_index_data_func; 130 130 131 131 // Strips vector. … … 136 136 public: 137 137 138 MultiIndexData *dataRetrievalInterface;138 IndexData *dataRetrievalInterface; 139 139 140 140 /** Constructor, receives as a parameter the name of the file 141 141 * including the multiresolution object. 142 142 */ 143 LodStripsLibrary(std::string, Mesh *geomesh, CREATE MULTIINDEXDATAFUNC midfun=NULL);143 LodStripsLibrary(std::string, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL); 144 144 145 145 /// Destructor. 146 146 ~LodStripsLibrary(void); 147 148 /// Returns the highest LOD.149 uint32 MaxLod();150 151 /// Returns the lowest LOD.152 uint32 MinLod();153 147 154 148 /// Returns de current LOD and changes to the specified LOD. -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h
r1058 r1069 51 51 // uint32 Get_Trunk_VertexCount(void) const; 52 52 // uint32 Get_Trunk_MaxIndexCount(uint32 istrip) const; 53 uint32 CurrentLOD_Trunk_StripCount(void) const;53 // uint32 CurrentLOD_Trunk_StripCount(void) const; 54 54 // uint32 CurrentLOD_Trunk_IndexCount(void) const; 55 uint32 CurrentLOD_Trunk_IndexCountByStrip(uint32 istrip) const;55 // uint32 CurrentLOD_Trunk_IndexCountByStrip(uint32 istrip) const; 56 56 /* const VertexData* Get_Trunk_VertexData(void) const;*/ 57 const MultiIndexData* CurrentLOD_Trunk_Indices(void) const;57 const IndexData* CurrentLOD_Trunk_Indices(void) const; 58 58 59 59 // uint32 Get_Foliage_VertexCount(void) const; -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/VertexData.h
r1019 r1069 45 45 }; 46 46 47 class MultiIndexData47 /* class MultiIndexData 48 48 { 49 49 private: … … 76 76 void SetNumValidIndices(unsigned int iprim, unsigned int valid){ num_valid_inds[iprim]=valid; } 77 77 unsigned int GetNumPrims(void) const { return num_prims; } 78 }; 78 };*/ 79 79 80 80 typedef VertexData* CreateVertexDataFunc(unsigned int numv); … … 82 82 typedef IndexData* CreateIndexDataFunc(unsigned int numi); 83 83 typedef CreateIndexDataFunc* CREATEINDEXDATAFUNC; 84 typedef MultiIndexData* CreateMultiIndexDataFunc(unsigned int numprims, unsigned int *numi);85 typedef CreateMultiIndexDataFunc* CREATEMULTIINDEXDATAFUNC; 84 /* typedef MultiIndexData* CreateMultiIndexDataFunc(unsigned int numprims, unsigned int *numi); 85 typedef CreateMultiIndexDataFunc* CREATEMULTIINDEXDATAFUNC;*/ 86 86 87 87 class DefaultVertexData : public VertexData … … 138 138 IndexData *DefaultIndexDataCreator(unsigned int numi); 139 139 140 class DefaultMultiIndexData : public MultiIndexData140 /* class DefaultMultiIndexData : public MultiIndexData 141 141 { 142 142 private: … … 158 158 }; 159 159 MultiIndexData *DefaultMultiIndexDataCreator(unsigned int numprims, unsigned int *numi); 160 160 */ 161 161 } 162 162 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp
r1058 r1069 17 17 // Constructors. 18 18 //----------------------------------------------------------------------------- 19 LodStripsLibrary::LodStripsLibrary( std::string name, Mesh *geomesh, CREATEMULTIINDEXDATAFUNC midfun)20 :create_ multi_index_data_func(midfun?midfun:DefaultMultiIndexDataCreator)19 LodStripsLibrary::LodStripsLibrary(std::string name, Mesh *geomesh, CREATEINDEXDATAFUNC idfun) 20 :create_index_data_func(idfun?idfun:DefaultIndexDataCreator) 21 21 { 22 22 const char *name_of_file; … … 241 241 242 242 //----------------------------------------------------------------------------- 243 // Gets the maximum level of detail.244 //-----------------------------------------------------------------------------245 uint32 LodStripsLibrary::MaxLod()246 {247 return mMaxLod;248 }249 250 //-----------------------------------------------------------------------------251 // Gets the minimum level of detail.252 //-----------------------------------------------------------------------------253 uint32 LodStripsLibrary::MinLod()254 {255 return mMinLod;256 }257 258 //-----------------------------------------------------------------------------259 243 // Returns the number of vertices of the highest LOD. 260 244 //----------------------------------------------------------------------------- … … 386 370 mTotalFaces = 0; 387 371 388 unsigned int * strip_sizes = new unsigned int[mFileStrips.size()]; 372 // unsigned int * strip_sizes = new unsigned int[mFileStrips.size()]; 373 unsigned int total_strip_size = 0; 389 374 for (i = 0; i < mFileStrips.size(); i++) 390 375 { 391 strip_sizes[i]= t = int(mFileStrips[i].size());376 total_strip_size += t = int(mFileStrips[i].size()); 392 377 if (t>max) 393 378 max = t; … … 406 391 407 392 // Copy strips. 408 dataRetrievalInterface=create_ multi_index_data_func(mFileStrips.size(),strip_sizes);409 dataRetrievalInterface->Begin(); 410 for (i = 0; i < mFileStrips.size(); i++)411 { 412 for (j = 0; j < mFileStrips[i].size(); j++ )393 dataRetrievalInterface=create_index_data_func(total_strip_size); 394 dataRetrievalInterface->Begin(); 395 for (int ii = 0, i = 0; i < mFileStrips.size(); i++) 396 { 397 for (j = 0; j < mFileStrips[i].size(); j++,ii++) 413 398 { 414 399 mStrips[i].push_back(mFileStrips[i][j]); 415 dataRetrievalInterface->SetIndex(i ,j,mFileStrips[i][j]);400 dataRetrievalInterface->SetIndex(ii,mFileStrips[i][j]); 416 401 } 417 402 … … 434 419 } 435 420 436 delete[] strip_sizes;421 // delete[] strip_sizes; 437 422 } 438 423 … … 593 578 { 594 579 dataRetrievalInterface->Begin(); 595 for (int i=0; i<mTotalStrips; i++) 596 { 597 unsigned int j=0; 598 for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, j++) 599 dataRetrievalInterface->SetIndex(i,j,*it); 600 dataRetrievalInterface->SetNumValidIndices(i,j); 580 for (int i=0, ii=0; i<mTotalStrips; i++) 581 { 582 for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii++) 583 dataRetrievalInterface->SetIndex(ii,*it); 584 dataRetrievalInterface->SetNumValidIndices(ii); 601 585 } 602 586 dataRetrievalInterface->End(); -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp
r1058 r1069 48 48 // if (current_foliage_indices) delete[] current_foliage_indices;*/ 49 49 } 50 50 /* 51 51 uint32 LodTreeLibrary::CurrentLOD_Trunk_StripCount(void) const 52 52 { 53 53 assert(trunk); 54 // return trunk->TOTALTIRAS;55 return trunk->dataRetrievalInterface->GetNumPrims();56 } 57 58 59 uint32 LodTreeLibrary::CurrentLOD_Trunk_IndexCountByStrip(uint32 istrip) const54 return trunk->TOTAL; 55 // return trunk->dataRetrievalInterface->GetNumPrims(); 56 }*/ 57 58 59 /*uint32 LodTreeLibrary::CurrentLOD_Trunk_IndexCountByStrip(uint32 istrip) const 60 60 { 61 61 assert(trunk); … … 64 64 return trunk->dataRetrievalInterface->GetNumValidIndices(istrip); 65 65 } 66 /* 66 67 67 uint32 LodTreeLibrary::CurrentLOD_Trunk_IndexCount(void) const 68 68 { … … 146 146 return trunk->vertices; 147 147 }*/ 148 const MultiIndexData* LodTreeLibrary::CurrentLOD_Trunk_Indices(void) const148 const IndexData* LodTreeLibrary::CurrentLOD_Trunk_Indices(void) const 149 149 { 150 150 return trunk->dataRetrievalInterface; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/VertexData.cpp
r831 r1069 35 35 36 36 37 Geometry::DefaultMultiIndexData::DefaultMultiIndexData(unsigned int numprims, unsigned int *numi):Geometry::MultiIndexData(numprims,numi)37 /*Geometry::DefaultMultiIndexData::DefaultMultiIndexData(unsigned int numprims, unsigned int *numi):Geometry::MultiIndexData(numprims,numi) 38 38 { 39 39 indices = new unsigned int*[numprims]; … … 52 52 return new DefaultMultiIndexData(numprims,numi); 53 53 } 54 */ -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r1058 r1069 592 592 size_t GeoMeshView::getLodStripsTriangleCount() 593 593 { 594 size_t triangle_count;595 596 // Initialize triangle count.597 triangle_count = 0;598 599 594 // For each strip. 600 // for (int strip = 0; strip < lodStripsLib->GetStripCount(); strip++) 601 MultiIndexData *dataInterface = lodStripsLib->dataRetrievalInterface; 602 for (int strip = 0; strip < dataInterface->GetNumPrims(); strip++) 595 // MultiIndexData *dataInterface = lodStripsLib->dataRetrievalInterface; 596 IndexData *dataInterface = lodStripsLib->dataRetrievalInterface; 597 size_t triangle_count = dataInterface->GetNumValidIndices() - 2; 598 /* for (int strip = 0; strip < dataInterface->GetNumPrims(); strip++) 603 599 { 604 600 // triangle_count += lodStripsLib->mStrips[strip].size() - 2; 605 601 triangle_count += dataInterface->GetNumValidIndices(strip) - 2; 606 } 602 }*/ 607 603 608 604 return triangle_count; … … 720 716 i = 0; 721 717 722 if (getColorStrips())718 /* if (getColorStrips()) 723 719 { 724 720 // Gets the color of the strip. … … 732 728 // Paint a new color. 733 729 glColor3f(r,g,b); 734 } 730 }*/ 735 731 736 732 … … 884 880 void GeoMeshView::drawLodStrip() 885 881 { 882 SubMesh *geosubmesh; 883 Index position; 884 Vector3 vector3; 885 Vector2 vector2; 886 float x,y,z; 887 float r,g,b; 888 int color_index; 889 int current_strip; 890 891 // Initialize current strip. 892 current_strip = 0; 893 894 // For each submesh. 895 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 896 { 897 // bind current texture to use 898 bool usetex = SetTextureRenderingState(submesh); 899 900 color_index = 0; 901 902 // Gets the actual submesh. 903 geosubmesh = &geoMesh->mSubMesh[submesh]; 904 905 // For each one of the strips. 906 /* for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 907 { 908 // Paint the current strip. 909 glBegin(GL_TRIANGLE_STRIP); 910 911 if (getColorStrips()) 912 { 913 // Gets the color of the strip. 914 r = mStripColors[submesh][color_index].r; 915 g = mStripColors[submesh][color_index].g; 916 b = mStripColors[submesh][color_index].b; 917 918 // Change to the next color. 919 color_index++; 920 921 // Paint a new color. 922 glColor3f(r,g,b); 923 } 924 925 // For each index of the strip. 926 for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(current_strip); index++) 927 { 928 position = lodStripsLib->dataRetrievalInterface->GetIndex(current_strip,index); 929 930 // Gets the vertex normal. 931 vector3 = geosubmesh->mVertexBuffer->mNormal[position]; 932 933 x = vector3[0]; 934 y = vector3[1]; 935 z = vector3[2]; 936 937 // Sets the vertex normal. 938 glNormal3f(x,y,z); 939 940 // set the texture coordinates if needed 941 if (usetex) 942 { 943 vector2 = geosubmesh->mVertexBuffer->mTexCoords[position]; 944 x = vector2[0]; 945 y = vector2[1]; 946 glTexCoord2f(x,y); 947 } 948 949 // Gets the vertex coordinates. 950 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 951 952 x = vector3[0]; 953 y = vector3[1]; 954 z = vector3[2]; 955 956 // Sets the vertex position. 957 glVertex3f(x,y,z); 958 } 959 960 // Increments current strip. 961 current_strip++; 962 963 // A strip is generated. 964 glEnd(); 965 966 }*/ 967 968 glBegin(GL_TRIANGLE_STRIP); 969 for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(); index ++) 970 { 971 position = lodStripsLib->dataRetrievalInterface->GetIndex(index); 972 973 // Gets the vertex normal. 974 vector3 = geosubmesh->mVertexBuffer->mNormal[position]; 975 976 x = vector3[0]; 977 y = vector3[1]; 978 z = vector3[2]; 979 980 // Sets the vertex normal. 981 glNormal3f(x,y,z); 982 983 // set the texture coordinates if needed 984 if (usetex) 985 { 986 vector2 = geosubmesh->mVertexBuffer->mTexCoords[position]; 987 x = vector2[0]; 988 y = vector2[1]; 989 glTexCoord2f(x,y); 990 } 991 992 // Gets the vertex coordinates. 993 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 994 995 x = vector3[0]; 996 y = vector3[1]; 997 z = vector3[2]; 998 999 // Sets the vertex position. 1000 glVertex3f(x,y,z); 1001 } 1002 glEnd(); 1003 1004 } 1005 1006 1007 }//End drawTriangleStrip. 1008 1009 1010 //--------------------------------------------------------------------------- 1011 // Paint lodtree object. 1012 //--------------------------------------------------------------------------- 1013 void GeoMeshView::drawLodTree() 1014 { 886 1015 SubMesh *geosubmesh; 887 1016 Index position; … … 896 1025 current_strip = 0; 897 1026 1027 // DRAW THE TRUNK AS A LODSTRIP OBJECT 1028 898 1029 // For each submesh. 899 1030 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 900 1031 { 1032 if (submesh==leavesSubMesh) 1033 continue; 1034 901 1035 // bind current texture to use 902 1036 bool usetex = SetTextureRenderingState(submesh); … … 908 1042 909 1043 // For each one of the strips. 910 for (int strip = 0; strip < geosubmesh->mStripCount; strip++)1044 /* for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 911 1045 { 912 1046 // Paint the current strip. … … 928 1062 929 1063 // For each index of the strip. 930 // for (int index = 0; index < lodStripsLib->mStrips[current_strip].size(); index++) 931 for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(current_strip); index++) 1064 for (int index = 0; index < lodTreeLib->CurrentLOD_Trunk_IndexCountByStrip(current_strip); index++) 932 1065 { 933 // position = lodStripsLib->mStrips[current_strip][index]; 934 position = lodStripsLib->dataRetrievalInterface->GetIndex(current_strip,index); 1066 position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(current_strip,index); 935 1067 936 1068 // Gets the vertex normal. … … 970 1102 glEnd(); 971 1103 972 } 973 } 974 975 }//End drawTriangleStrip. 976 977 978 //--------------------------------------------------------------------------- 979 // Paint lodtree object. 980 //--------------------------------------------------------------------------- 981 void GeoMeshView::drawLodTree() 982 { 983 SubMesh *geosubmesh; 984 Index position; 985 Vector3 vector3; 986 Vector2 vector2; 987 float x,y,z; 988 float r,g,b; 989 int color_index; 990 int current_strip; 991 992 // Initialize current strip. 993 current_strip = 0; 994 995 // DRAW THE TRUNK AS A LODSTRIP OBJECT 996 997 // For each submesh. 998 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 999 { 1000 if (submesh==leavesSubMesh) 1001 continue; 1002 1003 // bind current texture to use 1004 bool usetex = SetTextureRenderingState(submesh); 1005 1006 color_index = 0; 1007 1008 // Gets the actual submesh. 1009 geosubmesh = &geoMesh->mSubMesh[submesh]; 1010 1011 // For each one of the strips. 1012 for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 1013 { 1014 // Paint the current strip. 1015 glBegin(GL_TRIANGLE_STRIP); 1016 1017 if (getColorStrips()) 1104 }*/ 1105 glBegin(GL_TRIANGLE_STRIP); 1106 for (int index = 0; index < lodTreeLib->CurrentLOD_Trunk_Indices()->GetNumValidIndices(); index ++) 1107 { 1108 position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(index); 1109 1110 // Gets the vertex normal. 1111 vector3 = geosubmesh->mVertexBuffer->mNormal[position]; 1112 1113 x = vector3[0]; 1114 y = vector3[1]; 1115 z = vector3[2]; 1116 1117 // Sets the vertex normal. 1118 glNormal3f(x,y,z); 1119 1120 // set the texture coordinates if needed 1121 if (usetex) 1018 1122 { 1019 // Gets the color of the strip. 1020 r = mStripColors[submesh][color_index].r; 1021 g = mStripColors[submesh][color_index].g; 1022 b = mStripColors[submesh][color_index].b; 1023 1024 // Change to the next color. 1025 color_index++; 1026 1027 // Paint a new color. 1028 glColor3f(r,g,b); 1123 vector2 = geosubmesh->mVertexBuffer->mTexCoords[position]; 1124 x = vector2[0]; 1125 y = vector2[1]; 1126 glTexCoord2f(x,y); 1029 1127 } 1030 1128 1031 // For each index of the strip. 1032 // for (int index = 0; index < lodTreeLib->GetStrip(current_strip).size(); index++) 1033 for (int index = 0; index < lodTreeLib->CurrentLOD_Trunk_IndexCountByStrip(current_strip); index++) 1034 { 1035 // position = lodTreeLib->GetStrip(current_strip)[index]; 1036 position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(current_strip,index); 1037 1038 // Gets the vertex normal. 1039 vector3 = geosubmesh->mVertexBuffer->mNormal[position]; 1040 1041 x = vector3[0]; 1042 y = vector3[1]; 1043 z = vector3[2]; 1044 1045 // Sets the vertex normal. 1046 glNormal3f(x,y,z); 1047 1048 // set the texture coordinates if needed 1049 if (usetex) 1050 { 1051 vector2 = geosubmesh->mVertexBuffer->mTexCoords[position]; 1052 x = vector2[0]; 1053 y = vector2[1]; 1054 glTexCoord2f(x,y); 1055 } 1056 1057 // Gets the vertex coordinates. 1058 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 1059 1060 x = vector3[0]; 1061 y = vector3[1]; 1062 z = vector3[2]; 1063 1064 // Sets the vertex position. 1065 glVertex3f(x,y,z); 1066 } 1067 1068 // Increments current strip. 1069 current_strip++; 1070 1071 // A strip is generated. 1072 glEnd(); 1073 1074 } 1129 // Gets the vertex coordinates. 1130 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 1131 1132 x = vector3[0]; 1133 y = vector3[1]; 1134 z = vector3[2]; 1135 1136 // Sets the vertex position. 1137 glVertex3f(x,y,z); 1138 } 1139 glEnd(); 1140 1075 1141 } 1076 1142
Note: See TracChangeset
for help on using the changeset viewer.