Browse Source

DebugTools: implemented ShapeRenderer for 3D sphere.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
e72bf297ab
  1. 7
      src/DebugTools/Implementation/SphereRenderer.cpp
  2. 5
      src/DebugTools/Implementation/SphereRenderer.h
  3. 9
      src/DebugTools/ShapeRenderer.cpp

7
src/DebugTools/Implementation/SphereRenderer.cpp

@ -28,8 +28,10 @@
#include "DebugTools/ShapeRenderer.h"
#include "Shapes/Sphere.h"
#include "Primitives/Circle.h"
#include "Primitives/UVSphere.h"
#include "Shaders/Flat.h"
#include "Trade/MeshData2D.h"
#include "Trade/MeshData3D.h"
namespace Magnum { namespace DebugTools { namespace Implementation {
@ -37,6 +39,10 @@ AbstractSphereRenderer<2>::AbstractSphereRenderer(): AbstractShapeRenderer<2>("s
if(!wireframeMesh) createResources(Primitives::Circle::wireframe(40));
}
AbstractSphereRenderer<3>::AbstractSphereRenderer(): AbstractShapeRenderer<3>("sphere3d", "sphere3d-vertices", "sphere3d-indices") {
if(!wireframeMesh) createResources(Primitives::UVSphere::wireframe(40, 20));
}
template<UnsignedInt dimensions> SphereRenderer<dimensions>::SphereRenderer(const Shapes::Implementation::AbstractShape<dimensions>* sphere): sphere(static_cast<const Shapes::Implementation::Shape<Shapes::Sphere<dimensions>>*>(sphere)->shape) {}
template<UnsignedInt dimensions> void SphereRenderer<dimensions>::draw(Resource<ShapeRendererOptions>& options, const typename DimensionTraits<dimensions, Float>::MatrixType& projectionMatrix) {
@ -49,5 +55,6 @@ template<UnsignedInt dimensions> void SphereRenderer<dimensions>::draw(Resource<
}
template class SphereRenderer<2>;
template class SphereRenderer<3>;
}}}

5
src/DebugTools/Implementation/SphereRenderer.h

@ -39,6 +39,11 @@ template<> class AbstractSphereRenderer<2>: public AbstractShapeRenderer<2> {
AbstractSphereRenderer();
};
template<> class AbstractSphereRenderer<3>: public AbstractShapeRenderer<3> {
public:
AbstractSphereRenderer();
};
template<UnsignedInt dimensions> class SphereRenderer: public AbstractSphereRenderer<dimensions> {
public:
SphereRenderer(const Shapes::Implementation::AbstractShape<dimensions>* sphere);

9
src/DebugTools/ShapeRenderer.cpp

@ -53,15 +53,15 @@ template<> void createDebugMesh(ShapeRenderer<2>* renderer, const Shapes::Implem
case Shapes::AbstractShape2D::Type::Point:
renderer->renderers.push_back(new Implementation::PointRenderer<2>(shape));
break;
case Shapes::AbstractShape2D::Type::Sphere:
renderer->renderers.push_back(new Implementation::SphereRenderer<2>(shape));
break;
case Shapes::AbstractShape2D::Type::Composition: {
const Shapes::Composition2D& composition =
static_cast<const Shapes::Implementation::Shape<Shapes::Composition2D>*>(shape)->shape;
for(std::size_t i = 0; i != composition.size(); ++i)
createDebugMesh(renderer, Shapes::Implementation::getAbstractShape(composition, i));
} break;
case Shapes::AbstractShape2D::Type::Sphere:
renderer->renderers.push_back(new Implementation::SphereRenderer<2>(shape));
break;
default:
Warning() << "DebugTools::ShapeRenderer2D::createShapeRenderer(): type" << shape->type() << "not implemented";
}
@ -81,6 +81,9 @@ template<> void createDebugMesh(ShapeRenderer<3>* renderer, const Shapes::Implem
case Shapes::AbstractShape3D::Type::Point:
renderer->renderers.push_back(new Implementation::PointRenderer<3>(shape));
break;
case Shapes::AbstractShape3D::Type::Sphere:
renderer->renderers.push_back(new Implementation::SphereRenderer<3>(shape));
break;
case Shapes::AbstractShape3D::Type::Composition: {
const Shapes::Composition3D& composition =
static_cast<const Shapes::Implementation::Shape<Shapes::Composition3D>*>(shape)->shape;

Loading…
Cancel
Save