Hi,
Thanks, it's working fine.
my SphereVolume is computed with the applicative data (in world units)
, not from the OSG node.
If I take the node->getVolume() and apply the toWorld transformation as
you suggested (even if it's the identity matrix in my cases) , I got a
correct result.
I will check why my SphereVolume is different than the
node->getVolume()
Thanks again,
Stephane
PS : in the pseudo code, it should be :
float curYC = h-h*(projectedCenter [1]+1)/2.0f;
as the screen y axis is reveresed.
>>> [EMAIL PROTECTED] 18/07/2008 12:58 >>>
Hello Stephane,
Stephane Routelous wrote:
> Hi,
>
> I'm trying to implement a "window select" (meaning that the 3d
objects
> are selected when the user drag a rectangle in the window).
> for that, I'm projecting my object to the screen with
multFullMatrixPnt
> and check if the projected object (in screencoord) intersect the
> selection rectangle.
quick question:
> <pseudo-code>
> void WindowSelect(int x1,int y1,int x2.int y2)
> {
> //x1,y1 and x2,y2 are the 2d mouse position on the select
> rectangle in screen coordinates
> ViewportPtr vp = getWindow()->getPort(0);
> OSG::Matrix wtos;
> getCamera()->getWorldToScreen(wtos,*vp);
> int w = vp->getWidth();
> int h = vp->getHeight();
> foreach ( obj3d o in objList )
> {
> SphereVolume sph = o->GetSphereVolume();
^^^^^^^^^^^^^^^^^^^^^^
is this volume in world coordinates ? If not you are missing the local
to world coordinate transformation. You can get the matrix for that
from
a Node with getToWorld.
> Pnt3f center = sph.GetCenter(); //the center of the
> sphere is on the center of the screen
> Pnt3f projectedCenter ;
> wtos.multFullMatrixPnt( center, projectedCenter );
> //map the center to screen coordinates
> //as the sphere center in in the middle of the screen,
I
> expect projectedCenter[0] = 0 and projectedCenter[1] = 0
> //but I got [0,1.66,0.93]
> //as explained in
>
http://www.mail-archive.com/[email protected]/msg02156.html
>
>
> float curXC = w*(projectedCenter [0]+1)/2.0f;
> float curYC = h*(projectedCenter [1]+1)/2.0f;
> if ( IsIn(curXC,curYC,x1,y1,x2,y2) )
> {
> obj3d->Select();
> }
> }
> }
>
> </pseudocode>
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
______________________________________________________________
Reputation Resources Results
http://www.rwdi.com
______________________________________________________________
This communication is intended for the sole use of the party to whom it
is addressed and may contain information that is privileged and/or
confidential. Any other distribution, copying or disclosure is strictly
prohibited. If you have received this e-mail in error, please notify us
immediately by telephone (1-519-823-1311) and delete the message without
retaining any hard or electronic copies of same.
RWDI scans outgoing emails for viruses, but makes no warranty as to their
absence in this email or attachments.
-------------------------------------------------------------------------
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