Hello Erik,
Erik Podetti wrote:
> Hi all,
> I'm trying to implement a shader but to do this I need the
> ModelViewMatrix from the simplesceneManager camera (that is a
> PerspectiveCamera). What I'm trying to do is to collect a series of
> positions (coordinates) of source lights in a texture via a MRT and FBO.
> But while gl_SourceLight[n].position is automatically multiplied for the
> correct modelViewMatrix, when I use a PolyForeground to project my
> texture I loose that matrix.
> Simply I need to save a ModelViewMatrix from a point of view and reuse
> it in another shader...So I tought to take the modelviewmatrix from the
> mgr->getCamera()
do you want the model view matrix, i.e. the combination of an object's
model matrix and the camera's view matrix or do you just need one of these?
To get the camera's viewing matrix you can do this:
Matrix matV;
mgr->getCamera()->getViewing(matV);
To get an object's model matrix you can do:
Matrix matM;
someNode->getToWorld(matM);
You can pass these or a combination of them as uniforms to your shader.
If you need the model or viewing matrix while rendering the scenegraph
(not the foreground) you can also add the "magically" named uniforms
"OSGWorldMatrix" and "OSGViewMatrix" to your SHLChunk and get these
values passed to the shader.
> but I didn't succeded in trasforming it to a MatrixCamera.
MatrixCamera and PerspectiveCamera are siblings (both children of
Camera) in the inheritance hierarchy, so there is not way to cast
between them (other than brute force, but that won't give meaningful
results here ;) ).
Hope it helps,
Carsten
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users