| 371 | } |
| 372 | |
| 373 | void MeshRoadProfile::generateNormals() |
| 374 | { |
| 375 | VectorF t, b, n, t2, n2; |
| 376 | Point3F averagePt; |
| 377 | |
| 378 | mNodeNormals.clear(); |
| 379 | |
| 380 | // Loop through all profile line segments |
| 381 | for(U32 i=0; i < mNodes.size()-1; i++) |
| 382 | { |
| 383 | // Calculate normal for each node in line segment |
| 384 | for(U32 j=0; j<2; j++) |
| 385 | { |
| 386 | // Smoothed Node: Average the node with nodes before and after. |
| 387 | // Direction between the node and the average is the smoothed normal. |
| 388 | if( mNodes[i+j].isSmooth() ) |
| 389 | { |
| 390 | b = Point3F(0.0f, 0.0f, 1.0f); |
| 391 | t = mNodes[i+j-1].getPosition() - mNodes[i+j].getPosition(); |
| 392 | n = mCross(t, b); |
| 393 | n.normalizeSafe(); |
| 394 | |
| 395 | t2 = mNodes[i+j].getPosition() - mNodes[i+j+1].getPosition(); |
| 396 | n2 = mCross(t2, b); |
| 397 | n2.normalizeSafe(); |
| 398 | |
| 399 | n += n2; |
| 400 | } |
| 401 | // Non-smoothed Node: Normal is perpendicular to segment. |
| 402 | else |
| 403 | { |
| 404 | b = Point3F(0.0f, 0.0f, 1.0f); |
| 405 | t = mNodes[i].getPosition() - mNodes[i+1].getPosition(); |
| 406 | n = mCross(t, b); |
| 407 | } |
| 408 | |
| 409 | n.normalizeSafe(); |
| 410 | mNodeNormals.push_back(n); |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | void MeshRoadProfile::generateEndCap(F32 width) |
| 416 | { |
no test coverage detected