/* Copyright © 2010, 2011, 2012 Vladimír Vondruš This file is part of Magnum. Magnum is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3 only, as published by the Free Software Foundation. Magnum is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 3 for more details. */ #include "DebugDrawResourceManager.h" #include "AbstractShaderProgram.h" #include "Buffer.h" #include "Mesh.h" #include "ResourceManager.h" #include "Shaders/FlatShader.h" #include "AbstractShape.h" #include "Box.h" #include "ObjectShape.h" #include "ShapeGroup.h" #include "Implementation/BoxRenderer.h" #include "Implementation/DebugRenderer.h" namespace Magnum { template class ResourceManager; namespace Physics { template SceneGraph::Drawable* DebugDrawResourceManager::createDebugRenderer(ObjectShape* shape, ResourceKey options) { Implementation::DebugRenderer* renderer = new Implementation::DebugRenderer(shape->object(), instance()->get(options)); createDebugMesh(renderer, shape->shape()); return renderer; } template SceneGraph::Drawable<2>* DebugDrawResourceManager::createDebugRenderer(ObjectShape<2>* shape, ResourceKey options); template SceneGraph::Drawable<3>* DebugDrawResourceManager::createDebugRenderer(ObjectShape<3>* shape, ResourceKey options); void DebugDrawResourceManager::createDebugMesh(Implementation::DebugRenderer<2>* renderer, AbstractShape2D* shape) { switch(shape->type()) { case AbstractShape2D::Type::Box: renderer->addRenderer(new Implementation::BoxRenderer<2>(*static_cast(shape))); break; case AbstractShape2D::Type::ShapeGroup: { ShapeGroup2D* group = static_cast(shape); if(group->first()) createDebugMesh(renderer, group->first()); if(group->second()) createDebugMesh(renderer, group->second()); break; } default: Warning() << "Physics::DebugDrawResourceManager::createDebugRenderer(): type" << shape->type() << "not implemented"; } } void DebugDrawResourceManager::createDebugMesh(Implementation::DebugRenderer<3>*, AbstractShape3D*) {} DebugDrawResourceManager::DebugDrawResourceManager() { setFallback(new Options); set("shader2d", new Shaders::FlatShader<2>, ResourceDataState::Final, ResourcePolicy::Resident); } DebugDrawResourceManager::~DebugDrawResourceManager() {} }}