bool plCubicRenderTargetModifier::IEval( double secs, float del, uint32_t dirty ) { hsPoint3 center; hsMatrix44 mtx, invMtx; int i; plRenderRequestMsg *msg; if( fCubic == nil || fTarget == nil ) return true; /// Get center point for RT plCoordinateInterface *ci = IGetTargetCoordinateInterface( 0 ); if( ci == nil ) { plDrawInterface *di = IGetTargetDrawInterface( 0 ); center = di->GetWorldBounds().GetCenter(); } else center = ci->GetLocalToWorld().GetTranslate(); /// Set camera position of RT to this center fCubic->SetCameraMatrix(center); /// Submit render requests! for( i = 0; i < 6; i++ ) { if( fRequests[ i ] != nil ) { fRequests[ i ]->SetCameraTransform(fCubic->GetWorldToCamera(i), fCubic->GetCameraToWorld(i)); msg = new plRenderRequestMsg( nil, fRequests[ i ] ); plgDispatch::MsgSend( msg ); } } /// Done! return true; }
void pfGUIControlMod::UpdateBounds( hsMatrix44 *invXformMatrix, bool force ) { hsMatrix44 xformMatrix, projMatrix; hsPoint3 corners[ 8 ]; int i; if( ( !fBoundsValid || force ) && fDialog && GetTarget() ) { plDrawInterface *DI = IGetTargetDrawInterface( 0 ); if( DI == nil ) return; if( HasFlag( kBetterHitTesting ) ) { hsTArray<hsPoint3> scrnPoints; // Create a list of points to make a 2D convex hull from GetObjectPoints( GetTarget(), scrnPoints ); hsMatrix44 l2w = GetTarget()->GetLocalToWorld(); for( i = 0; i < scrnPoints.GetCount(); i++ ) { scrnPoints[ i ] = l2w * scrnPoints[ i ]; scrnPoints[ i ] = fDialog->WorldToScreenPoint( scrnPoints[ i ] ); } // Now create a convex hull from them, assuming the Zs are all the same int numPoints = scrnPoints.GetCount(); if( !CreateConvexHull( scrnPoints.AcquireArray(), numPoints ) ) return; // Copy & store. Also recalc our bounding box just for fun fBounds.MakeEmpty(); fBoundsPoints.SetCount( numPoints ); for( i = 0; i < numPoints; i++ ) { fBoundsPoints[ i ] = scrnPoints[ i ]; fBounds.Union( &fBoundsPoints[ i ] ); } } else { fBounds.MakeEmpty(); hsBounds3Ext worldBounds = DI->GetLocalBounds(); hsMatrix44 l2w = GetTarget()->GetLocalToWorld(); worldBounds.Transform( &l2w ); worldBounds.GetCorners( corners ); for( i = 0; i < 8; i++ ) { hsPoint3 scrnPt = fDialog->WorldToScreenPoint( corners[ i ] ); fBounds.Union( &scrnPt ); } } // Calc center Z // if( !fCenterValid ) { #if 0 corners[ 1 ] = GetTarget()->GetLocalToWorld().GetTranslate(); float w = corners[ 1 ].fX * fXformMatrix.fMap[3][0] + corners[ 1 ].fY * fXformMatrix.fMap[3][1] + corners[ 1 ].fZ * fXformMatrix.fMap[3][2] + 1.f * fXformMatrix.fMap[3][3]; corners[ 1 ] = fXformMatrix * corners[ 1 ]; corners[ 1 ].fX = ( ( corners[ 1 ].fX / corners[ 1 ].fZ ) + 1.f ) / 2.f; corners[ 1 ].fY = ( ( corners[ 1 ].fY / corners[ 1 ].fZ ) + 1.f ) / 2.f; fScreenCenter = corners[ 1 ]; // fScreenCenter.fZ = w; corners[ 1 ] = GetTarget()->GetLocalToWorld().GetTranslate(); fDialog->WorldToScreenPoint( corners[ 1 ].fX, corners[ 1 ].fY, corners[ 1 ].fZ, fScreenCenter ); fCenterValid = true; #else corners[ 1 ] = GetTarget()->GetLocalToWorld().GetTranslate(); fScreenCenter = fDialog->WorldToScreenPoint( corners[ 1 ] ); corners[ 1 ] = fScreenCenter; fCenterValid = true; #endif } fScreenMinZ = fBounds.GetMins().fZ; // Manually change the bounds so we know the z ranges from at least -1 to 1, suitable for us testing against for clicks corners[ 0 ] = fBounds.GetCenter(); corners[ 0 ].fZ = -1.f; fBounds.Union( &corners[ 0 ] ); corners[ 0 ].fZ = 1.f; fBounds.Union( &corners[ 0 ] ); fBoundsValid = true; } }