| 853 | } |
| 854 | |
| 855 | void GenerateCone(float length, float radius, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, unsigned int indexOffset) |
| 856 | { |
| 857 | constexpr float round = 2.f*static_cast<float>(M_PI); |
| 858 | float delta = round/subdivision; |
| 859 | |
| 860 | *vertexPointers.positionPtr++ = matrix.GetTranslation(); // matrix.Transform(Vector3f(0.f)); |
| 861 | |
| 862 | if (vertexPointers.normalPtr) |
| 863 | *vertexPointers.normalPtr++ = matrix.Transform(Vector3f::Up(), 0.f); |
| 864 | |
| 865 | for (unsigned int i = 0; i < subdivision; ++i) |
| 866 | { |
| 867 | float angle = delta*i; |
| 868 | *vertexPointers.positionPtr++ = matrix.Transform(Vector3f(radius*std::sin(angle), -length, radius*std::cos(angle))); |
| 869 | |
| 870 | *indices++ = indexOffset + 0; |
| 871 | *indices++ = indexOffset + i+1; |
| 872 | *indices++ = indexOffset + ((i != subdivision-1) ? i+2 : 1); |
| 873 | |
| 874 | if (i != 0 && i != subdivision-1) |
| 875 | { |
| 876 | *indices++ = indexOffset + ((i != subdivision-1) ? i+2 : 1); |
| 877 | *indices++ = indexOffset + i+1; |
| 878 | *indices++ = indexOffset + 1; |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | if (aabb) |
| 883 | { |
| 884 | aabb->MakeZero(); |
| 885 | |
| 886 | // On calcule le reste des points |
| 887 | Vector3f base(Vector3f::Down()*length); |
| 888 | |
| 889 | Vector3f lExtend = Vector3f::Left()*radius; |
| 890 | Vector3f fExtend = Vector3f::Forward()*radius; |
| 891 | |
| 892 | // Et on ajoute ensuite les quatres extrémités de la pyramide |
| 893 | aabb->ExtendTo(base + lExtend + fExtend); |
| 894 | aabb->ExtendTo(base + lExtend - fExtend); |
| 895 | aabb->ExtendTo(base - lExtend + fExtend); |
| 896 | aabb->ExtendTo(base - lExtend - fExtend); |
| 897 | aabb->Transform(matrix, false); |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | void GenerateCubicSphere(float size, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, unsigned int indexOffset) |
| 902 | { |