Changeset 1768 for GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
- Timestamp:
- 11/20/06 09:15:28 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp
r1763 r1768 797 797 int MeshInstance::GetRandomEdgePoint(Vector3 &point, Vector3 &normal) 798 798 { 799 // TODO 800 return mMesh->GetRandomSurfacePoint(point, normal); 799 // get random face 800 const int faceIdx = (int)RandomValue(0.0f, (float)mMesh->mFaces.size() - 0.5f); 801 Face *face = mMesh->mFaces[faceIdx]; 802 803 // get random edge of face (hack: this is not uniform in the edges! 804 const int edgeIdx = (int)RandomValue(0.0f, face->mVertexIndices.size() - 0.5f); 805 806 const int vertexIdxA = face->mVertexIndices[edgeIdx]; 807 const int vertexIdxB = face->mVertexIndices[(edgeIdx + 1) % (int)face->mVertexIndices.size()]; 808 809 const Vector3 a = mMesh->mVertices[vertexIdxA]; 810 const Vector3 b = mMesh->mVertices[vertexIdxB]; 811 812 const float w = RandomValue(0.0f, 1.0f); 813 814 // get random point on edge 815 point = a * w + b * (1.0f - w); 816 817 // hack: set normal of face as normal 818 normal = mMesh->GetFacePlane(faceIdx).mNormal; 819 820 return 1; 801 821 } 802 822
Note: See TracChangeset
for help on using the changeset viewer.