bool
getWorld2ScreenCoord( vpChannel *channel,
vpTransform *xform,
float *scrX,
float *scrY ){
vuMatrixf world2screen;
vuVec4f point;
vuVec3d pos;
vuVec3d posTest1;
vuMatrix viewMat = channel->getViewMatrix();
vuVec3d at;
at.set( 0.0, 1.0, 0.0 );
viewMat.transformPoint( &at );
at -= viewMat[ 3 ];
xform->getAbsolutePosition( &pos );
posTest1 = pos;
posTest1 -= viewMat[ 3 ];
if ( at.dot( posTest1 ) > 0.0 ) {
int ox, oy, sx, sy;
channel->getVrChannel()->getViewport( &ox, &oy, &sx, &sy );
world2screen = channel->getVrChannel()->getWorldToScreenMatrix();
point.set( pos[0], pos[1], pos[2], 1.0f );
world2screen.transform( &point );
float fx = point.m_vec[ 0 ] / point.m_vec[ 3 ];
float fy = point.m_vec[ 1 ] / point.m_vec[ 3 ];
*scrX = ( fx + 1.0f ) / 2.0f;
&scrY = ( fy + 1.0f ) / 2.0f;
}
}
|