--- /dev/null
+#include "dynamicmeshsource.h"
+
+using namespace std;
+
+namespace Msp::GameView {
+
+DynamicMeshSource::DynamicMeshSource(Game::Handle<Game::Entity> e, const GL::VertexFormat &fmt, const GL::Technique &tech):
+ Component(e),
+ mesh(fmt),
+ object(&mesh, &tech)
+{ }
+
+} // namespace Msp::GameView
--- /dev/null
+#ifndef MSP_GAMEVIEW_DYNAMICMESHSOURCE_H_
+#define MSP_GAMEVIEW_DYNAMICMESHSOURCE_H_
+
+#include <msp/game/component.h>
+#include <msp/gl/mesh.h>
+#include <msp/gl/object.h>
+
+namespace Msp::GameView {
+
+class DynamicMeshSource: public Game::Component
+{
+private:
+ GL::Mesh mesh;
+ GL::Object object;
+
+public:
+ DynamicMeshSource(Game::Handle<Game::Entity>, const GL::VertexFormat &, const GL::Technique &);
+
+ GL::Mesh &get_mesh() { return mesh; }
+ const GL::Object &get_object() const { return object; }
+};
+
+} // namespace Msp::GameView
+
+#endif
#include <msp/gl/colorcurve.h>
#include <msp/gl/directionallight.h>
#include <msp/gl/pointlight.h>
+#include "dynamicmeshsource.h"
#include "lightemitter.h"
#include "meshrenderer.h"
void Renderer::component_created(const Game::Events::ComponentCreated &event)
{
Game::Handle<Game::MeshSource> mesh_source = dynamic_handle_cast<Game::MeshSource>(event.component);
- if(mesh_source)
+ Game::Handle<DynamicMeshSource> dyn_mesh_src = dynamic_handle_cast<DynamicMeshSource>(event.component);
+ if(mesh_source || dyn_mesh_src)
{
RenderedEntity &re = get_rendered_entity(event.component->get_entity());
if(!re.mesh_renderer)
{
- const GL::Object &object = stage.get_resources().get<GL::Object>(mesh_source->get_object_name());
+ const GL::Object &object = dyn_mesh_src ? dyn_mesh_src->get_object() :
+ stage.get_resources().get<GL::Object>(mesh_source->get_object_name());
re.mesh_renderer = Game::Owned<MeshRenderer>(re.entity, object);
re.mesh_renderer->set_scene(&scene);
}