From: Mikko Rasa Date: Mon, 3 Sep 2012 15:58:31 +0000 (+0300) Subject: Add a method of getting the model matrix of a Renderable X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f2592f0e67d92043952eb7a2e39df182720cd990;p=libs%2Fgl.git Add a method of getting the model matrix of a Renderable This can be used for various position-dependent rendering techniques, such as certain effects and frustum culling. --- diff --git a/source/animatedobject.h b/source/animatedobject.h index df0b15eb..6bcd37ce 100644 --- a/source/animatedobject.h +++ b/source/animatedobject.h @@ -26,6 +26,8 @@ public: void set_matrix(const Matrix &); void set_pose_matrix(unsigned, const Matrix &); + virtual const Matrix *get_matrix() const { return &matrix; } + virtual void setup_render(Renderer &, const Tag &) const; }; diff --git a/source/effect.h b/source/effect.h index 7eeae682..7c943ae6 100644 --- a/source/effect.h +++ b/source/effect.h @@ -24,6 +24,8 @@ public: void enable_for_pass(const Tag &); void disable_for_pass(const Tag &); + + virtual const Matrix *get_matrix() const { return renderable.get_matrix(); } }; } // namespace GL diff --git a/source/renderable.h b/source/renderable.h index 2342ae28..3432a87e 100644 --- a/source/renderable.h +++ b/source/renderable.h @@ -7,6 +7,7 @@ namespace Msp { namespace GL { +class Matrix; class Renderer; /** @@ -27,6 +28,10 @@ public: returned value is treated as opaque. */ virtual long get_instance_key() const { return 0; } + /** Returns the model matrix of the Renderable. Null is returned if no such + matrix exists. */ + virtual const Matrix *get_matrix() const { return 0; } + /** Renders the renderable without a renderer. This can be convenient in some simple cases, but most renderables don't need to implement this method. */