Changeset 1069 for GTP/trunk/Lib/Geom/shared/GeoTool
- Timestamp:
- 06/28/06 17:50:02 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.