| 655 | static SphereMesh gSphere; |
| 656 | |
| 657 | void GFXDrawUtil::drawSphere( const GFXStateBlockDesc &desc, F32 radius, const Point3F &pos, const ColorI &color, bool drawTop, bool drawBottom, const MatrixF *xfm ) |
| 658 | { |
| 659 | MatrixF mat; |
| 660 | if ( xfm ) |
| 661 | mat = *xfm; |
| 662 | else |
| 663 | mat = MatrixF::Identity; |
| 664 | |
| 665 | mat.scale(Point3F(radius,radius,radius)); |
| 666 | mat.setPosition(pos); |
| 667 | GFX->pushWorldMatrix(); |
| 668 | GFX->multWorld(mat); |
| 669 | |
| 670 | const SphereMesh::TriangleMesh * sphereMesh = gSphere.getMesh(2); |
| 671 | S32 numPoly = sphereMesh->numPoly; |
| 672 | S32 totalPoly = 0; |
| 673 | GFXVertexBufferHandle<GFXVertexPCT> verts(mDevice, numPoly*3, GFXBufferTypeVolatile); |
| 674 | verts.lock(); |
| 675 | S32 vertexIndex = 0; |
| 676 | for (S32 i=0; i<numPoly; i++) |
| 677 | { |
| 678 | if (!drawBottom) |
| 679 | { |
| 680 | if (sphereMesh->poly[i].pnt[0].z < -0.01f || sphereMesh->poly[i].pnt[1].z < -0.01f || sphereMesh->poly[i].pnt[2].z < -0.01f) |
| 681 | continue; |
| 682 | } |
| 683 | if (!drawTop) |
| 684 | { |
| 685 | if (sphereMesh->poly[i].pnt[0].z > 0.01f || sphereMesh->poly[i].pnt[1].z > 0.01f || sphereMesh->poly[i].pnt[2].z > 0.01f) |
| 686 | continue; |
| 687 | } |
| 688 | totalPoly++; |
| 689 | |
| 690 | verts[vertexIndex].point = sphereMesh->poly[i].pnt[0]; |
| 691 | verts[vertexIndex].color = color; |
| 692 | vertexIndex++; |
| 693 | |
| 694 | verts[vertexIndex].point = sphereMesh->poly[i].pnt[1]; |
| 695 | verts[vertexIndex].color = color; |
| 696 | vertexIndex++; |
| 697 | |
| 698 | verts[vertexIndex].point = sphereMesh->poly[i].pnt[2]; |
| 699 | verts[vertexIndex].color = color; |
| 700 | vertexIndex++; |
| 701 | } |
| 702 | verts.unlock(); |
| 703 | |
| 704 | mDevice->setStateBlockByDesc( desc ); |
| 705 | |
| 706 | mDevice->setVertexBuffer( verts ); |
| 707 | mDevice->setupGenericShaders(); |
| 708 | |
| 709 | mDevice->drawPrimitive( GFXTriangleList, 0, totalPoly ); |
| 710 | |
| 711 | GFX->popWorldMatrix(); |
| 712 | } |
| 713 | |
| 714 | //----------------------------------------------------------------------------- |
no test coverage detected