"funny" stuff, the problem only appears after a SSM.showAll();
if after the show all i zoom out (or manipulate the view with the
trackball navigator) , it seems the 2d coordinates are correctly
computed.
any idea ? do i need to manually call an update for something ?
Stephane
>>> [EMAIL PROTECTED] 18/07/2008 11:39 >>>
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.
<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();
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>
Do I do something wrong ?
thanks a lot,
Stephane
Stephane Routelous
[EMAIL PROTECTED]
Senior Software Specialist
Rowan Williams Davies & Irwin Inc. (RWDI)
Consulting Engineers & Scientists
650 Woodlawn Road West
Guelph, Ontario, Canada N1K 1B8
T (519) 823-1311 x2639
F (519) 823-1316
www.rwdi.com
______________________________________________________________
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
______________________________________________________________
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