Thanks Carsten,

i've tried it with points now (OSG::Pnt3f)

but something is still strange.... values are still negatives and too big...
any other suggestion?

heres the code im using...

    OSG::Matrix m;
    getCamera()->getWorldToScreen( m, *(_viewport) ); // get the world to
screen matrix to matrix 'm'

    OSG::Pnt3f spoint;  // destination point
    m.multMatrixPnt( _start3d, spoint ); // transform world point (_start3d)
to screen point
    printf( "POINT = ( %f %f %f )\n", _start3d.x(), _start3d.y(),
_start3d.z() ); // print world point
    printf( "NEW MATRIXPNT (COLUMN) MAPPED POINT = ( %f %f %f )\n",
spoint.x(), spoint.y(), spoint.z() ); // print result
    m.multPntMatrix( _start3d, spoint ); // try with a row-format point
    printf( "NEW PNTMATRIX (ROW) MAPPED POINT = ( %f %f %f )\n", spoint.x(),
spoint.y(), spoint.z() );

 Thanks!!!!



On Tue, Jun 3, 2008 at 5:35 PM, Carsten Neumann <[EMAIL PROTECTED]>
wrote:

>        Hello Pablo,
>
> Pablo Carneiro Elias wrote:
> > Hi all.. I have some trouble trying to map points from world to
> > screen... I've found a function within the camera matrix that should
> > give me the world to screen matrix...
> >
> > virtual void getWorldToScreen (Matrix        &result, const Viewport&
> port);
> >
> > So I took my camera from SimpleSceneManager (which is a
> > PerspectiveCamera), and called the getWorldToScreen acquiring a matrix...
> >
> > then I tried to multiply a world point in order to get a screen point
> > like this:
> >
> > OSG::Matrix m;
> >
> > getCamera()->getWorldToScreen( m, *(_viewport.getCPtr()) ); // _viewport
> > is a ViewportPtr
> >
> > OSG::Vec3f result;
> > m.multMatrixVec( _start3d, result ); // _start3d is my 3d world point
>
> OpenSG makes a distinction between points (locations in space) and
> vectors (basically directions), therefore you need to use Pnt3f and
> multMatrixPnt.
> The (3 element) vectors are translation invariant as they are considered
> to have w = 0 in homogeneous coordinates, while 3 element points are
> treated as if w = 1.
> See also Source/Base/Base/Base.dox \section BaseVectors for more
> information on the distinction between points and vectors.
>
>        Hope it helps,
>                Carsten
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to