Changeset 980 for GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
- Timestamp:
- 05/24/06 10:47:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r895 r980 200 200 // Set the color to the submesh sumbmeshIndex 201 201 //--------------------------------------------------------------------------- 202 void GeoMeshView::set ColorSubmeshi(int submeshIndex)203 { 204 colorsubmeshi= submeshIndex;202 void GeoMeshView::setSubMeshSelected(int submeshIndex) 203 { 204 mSubMeshSelected = submeshIndex; 205 205 } 206 206 … … 208 208 // Sets the leaves submesh index. 209 209 //--------------------------------------------------------------------------- 210 void GeoMeshView::setLeavesSub mesh(int submeshIndex)211 { 212 leavesSub mesh = submeshIndex;210 void GeoMeshView::setLeavesSubMesh(int submeshIndex) 211 { 212 leavesSubMesh = submeshIndex; 213 213 } 214 214 … … 216 216 // Gets the leaves submesh index. 217 217 //--------------------------------------------------------------------------- 218 int GeoMeshView::getLeavesSub mesh()219 { 220 return leavesSub mesh;218 int GeoMeshView::getLeavesSubMesh() 219 { 220 return leavesSubMesh; 221 221 } 222 222 … … 277 277 } 278 278 279 /* 279 280 //--------------------------------------------------------------------------- 280 281 // Get the bounding box of the object. … … 386 387 return bounds; 387 388 } 389 */ 388 390 389 391 //--------------------------------------------------------------------------- … … 446 448 GLfloat color_blanco[] = {1.0f,1.0f,1.0f,1.0f}; 447 449 448 this->geoMesh = geomesh; 449 colorsubmeshi = -1; 450 leavesSubmesh = -1; 450 this->geoMesh = geomesh; 451 mSubMeshSelected = -1; 452 leavesSubMesh = -1; 453 mScaleFactor = geomesh->mMeshBounds.scaleFactor; 451 454 452 455 // Refresh vertices to the vertex array. … … 577 580 // Repaint the Mesh. 578 581 //--------------------------------------------------------------------------- 579 void GeoMeshView::drawGeoMesh( int selectedMesh)582 void GeoMeshView::drawGeoMesh(bool paintWire) 580 583 { 581 584 SubMesh *geosubmesh; … … 601 604 if (geosubmesh->mType == GEO_TRIANGLE_LIST) 602 605 { 603 if ( selectedMesh== submesh)606 if (mSubMeshSelected == submesh) 604 607 { 605 608 submesh_selected = true; … … 611 614 612 615 // Draw the actual submesh in triangle list. 613 drawTriangleList(submesh,submesh_selected );616 drawTriangleList(submesh,submesh_selected,paintWire); 614 617 } 615 618 else … … 618 621 drawTriangleStrip(submesh); 619 622 } 620 } 621 } 622 /* 623 // Choose the render operation. 624 else if (geoMesh->mType == GEO_TRIANGLE_LIST) 625 { 626 // Paint vertices. 627 drawTriangleList(selectedMesh); 628 } 629 else 630 { 631 // Paint vertices. 632 drawTriangleStrip(); 633 } 634 */ 623 } 624 } 635 625 } 636 626 }// End drawGeoMesh. … … 743 733 //--------------------------------------------------------------------------- 744 734 void GeoMeshView::drawTriangleList( int submesh, 745 bool selectedSubMesh) 735 bool selectedSubMesh, 736 bool paintWire) 746 737 { 747 738 SubMesh *geosubmesh; … … 761 752 geosubmesh = &geoMesh->mSubMesh[submesh]; 762 753 763 // If a mesh is selected. 764 if (selectedSubMesh) 765 { 766 glColor3d(1.0,0.0,0.0); 767 GLfloat red[] = {1.0f,0.0f,0.0f,1.0f}; 768 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,red); 769 } 770 // If is a tree. 771 else if (leavesSubmesh >= 0) 772 { 773 glColor3d(1.0, 0.5, 0.5); 774 GLfloat brown[] = {1.0f,0.5f,0.5f,1.0f}; 775 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,brown); 776 777 // For each index of the strip. 778 if (submesh == leavesSubmesh) 779 { 780 glColor3d(0.0,1.0,0.0); 781 GLfloat green[] = {0.0f,1.0f,0.0f,1.0f}; 782 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,green); 783 } 784 } 785 // If is NOT a tree. 786 else 787 { 788 // Set white color to the object. 789 glColor3d(1.0, 1.0, 1.0); 790 GLfloat white[] = {1.0f,1.0f,1.0f,1.0f}; 791 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,white); 792 } 793 794 754 // If wire is not selected. 755 if (!paintWire) 756 { 757 // If a mesh is selected. 758 if (selectedSubMesh) 759 { 760 glColor3d(1.0,0.0,0.0); 761 GLfloat red[] = {1.0f,0.0f,0.0f,1.0f}; 762 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,red); 763 } 764 // If is a tree. 765 else if (leavesSubMesh >= 0) 766 { 767 glColor3d(1.0, 0.5, 0.5); 768 GLfloat brown[] = {1.0f,0.5f,0.5f,1.0f}; 769 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,brown); 770 771 // For each index of the strip. 772 if (submesh == leavesSubMesh) 773 { 774 glColor3d(0.0,1.0,0.0); 775 GLfloat green[] = {0.0f,1.0f,0.0f,1.0f}; 776 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,green); 777 } 778 } 779 // If is NOT a tree. 780 else 781 { 782 // Set white color to the object. 783 glColor3d(1.0, 1.0, 1.0); 784 GLfloat white[] = {1.0f,1.0f,1.0f,1.0f}; 785 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,white); 786 } 787 } 788 795 789 // Enable arrays. 796 790 glEnableClientState(GL_VERTEX_ARRAY); … … 1056 1050 // Frustrum. 1057 1051 glViewport(0,0,w(),h()); 1058 gluPerspective(60, 1,0.1,1000);1052 gluPerspective(60,(float)w()/(float)h(),0.1,1000); 1059 1053 1060 1054 glMatrixMode(GL_MODELVIEW); … … 1082 1076 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1083 1077 1084 gluLookAt(0,0, mScaleFactor*2+size, 0,0,0, 0,1,0);1078 gluLookAt(0,0,2/*mScaleFactor*/ + size * 0.25, 0,0,0, 0,1,0); 1085 1079 1086 1080 glTranslatef(xshift,yshift,0); 1087 1081 glRotatef(hAng,0,1,0); 1088 1082 glRotatef(vAng,1,0,0); 1089 glTranslatef(-xMed,-yMed,-zMed);1083 //glTranslatef(-xMed,-yMed,-zMed); 1090 1084 1091 1085 // Set white color to the object. … … 1094 1088 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 1095 1089 1090 glClearColor(0,0,0,0); 1091 1096 1092 if (mCW) 1097 1093 { … … 1117 1113 glDisable(GL_LIGHTING); 1118 1114 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); 1119 drawGeoMesh( colorsubmeshi);1115 drawGeoMesh(false); 1120 1116 } 1121 1117 else … … 1130 1126 glColor3d(0.0, 0.0, 1.0); 1131 1127 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); 1132 drawGeoMesh( -1);1128 drawGeoMesh(true); 1133 1129 } 1134 1130 else … … 1139 1135 glEnable(GL_LIGHTING); 1140 1136 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 1141 drawGeoMesh( colorsubmeshi);1137 drawGeoMesh(false); 1142 1138 } 1143 1139 }
Note: See TracChangeset
for help on using the changeset viewer.