plCoordinateInterface* plStereizer::IGetParent() const { plCoordinateInterface* coord = IGetTargetCoordinateInterface(0); if( coord ) { return coord->GetParent(); } return nil; }
void plCameraModifier1::SetTransform(hsPoint3 at) { if (!GetTarget()) return; hsMatrix44 l2w; hsMatrix44 w2l; hsVector3 up(0,0,1); l2w.Make(&fFrom, &at, &up); l2w.GetInverse(&w2l); IGetTargetCoordinateInterface(0)->SetTransform( l2w, w2l ); }
void plBlower::ISetTargetTransform() { plCoordinateInterface* ci = IGetTargetCoordinateInterface(0); if( ci ) { hsMatrix44 l2p = ci->GetLocalToParent(); hsMatrix44 p2l = ci->GetParentToLocal(); hsPoint3 pos = l2p.GetTranslate(); pos += fCurrDel; hsPoint3 neg = -pos; l2p.SetTranslate(&pos); p2l.SetTranslate(&neg); ci->SetLocalToParent(l2p, p2l); } }
void plStereizer::ISetNewPos(const hsPoint3& newPos) { hsMatrix44 l2w = GetTarget()->GetLocalToWorld(); hsMatrix44 w2l = GetTarget()->GetWorldToLocal(); l2w.NotIdentity(); l2w.fMap[0][3] = newPos[0]; l2w.fMap[1][3] = newPos[1]; l2w.fMap[2][3] = newPos[2]; hsPoint3 invPos = -newPos; w2l.fMap[0][3] = ((hsVector3*)&w2l.fMap[0][0])->InnerProduct(invPos); w2l.fMap[1][3] = ((hsVector3*)&w2l.fMap[1][0])->InnerProduct(invPos); w2l.fMap[2][3] = ((hsVector3*)&w2l.fMap[2][0])->InnerProduct(invPos); IGetTargetCoordinateInterface(0)->SetTransform(l2w, w2l); }
void pfGUIControlMod::SetObjectCenter( float x, float y ) { hsMatrix44 xformMatrix, l2p, p2l; hsPoint3 center, corners[ 8 ]; if( x > 1.f ) x = 1.f; else if( x < 0.f ) x = 0.f; if( y > 1.f ) y = 1.f; else if( y < 0.f ) y = 0.f; if( fDialog && GetTarget() ) { plCoordinateInterface *CI = IGetTargetCoordinateInterface( 0 ); if( CI == nil ) return; // if( !fInvXformValid ) // UpdateBounds(); l2p = GetTarget()->GetLocalToWorld(); hsPoint3 oldPt = l2p.GetTranslate(); hsPoint3 oldScrnPt = fDialog->WorldToScreenPoint( oldPt ); hsPoint3 oldPtRedux; fDialog->ScreenToWorldPoint( oldScrnPt.fX, oldScrnPt.fY, oldScrnPt.fZ, oldPtRedux ); fDialog->ScreenToWorldPoint( x, y, fScreenCenter.fZ, center ); l2p.SetTranslate( ¢er ); l2p.GetInverse( &p2l ); GetTarget()->SetTransform( l2p, p2l ); fScreenCenter.fX = x; fScreenCenter.fY = y; } }
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; }
hsBool plViewFaceModifier::IFacePoint(plPipeline* pipe, const hsPoint3& at) { #if 1 // BOUNDSTEST extern int mfCurrentTest; if( mfCurrentTest != 101 ) if( HasFlag(kMaxBounds) ) { if( !pipe->TestVisibleWorld(fMaxBounds) ) return false; } #endif // BOUNDSTEST if( !(GetTarget() && GetTarget()->GetCoordinateInterface()) ) return false; hsMatrix44 worldToLocal = fOrigParentToLocal; // parentToLocal if( GetTarget()->GetCoordinateInterface()->GetParent() && GetTarget()->GetCoordinateInterface()->GetParent() ) { hsMatrix44 m; worldToLocal = worldToLocal * GetTarget()->GetCoordinateInterface()->GetParent()->GetWorldToLocal(); } hsPoint3 localAt = worldToLocal * at; float len = localAt.MagnitudeSquared(); if( len <= 0 ) return false; len = -hsFastMath::InvSqrtAppr(len); hsVector3 dirX, dirY, dirZ; dirZ.Set(localAt.fX * len, localAt.fY * len, localAt.fZ * len); if( HasFlag(kPivotFace) ) { dirY.Set(0.f, 0.f, 1.f); dirX = dirY % dirZ; dirX = hsFastMath::NormalizeAppr(dirX); dirY = dirZ % dirX; } else if( HasFlag(kPivotFavorY) ) { dirY.Set(0.f, 1.f, 0.f); dirX = dirY % dirZ; dirX = hsFastMath::NormalizeAppr(dirX); dirY = dirZ % dirX; } else if( HasFlag(kPivotY) ) { dirY.Set(0.f, 1.f, 0.f); dirX = dirY % dirZ; dirX = hsFastMath::NormalizeAppr(dirX); dirZ = dirX % dirY; } else if( HasFlag(kPivotTumble) ) { dirY = fLastDirY; dirX = dirY % dirZ; dirX = hsFastMath::NormalizeAppr(dirX); dirY = dirZ % dirX; fLastDirY = dirY; } else { hsAssert(false, "I've no idea what you're getting at here in ViewFace land"); } hsMatrix44 x; hsMatrix44 xInv; xInv.fMap[0][0] = x.fMap[0][0] = dirX[0]; xInv.fMap[1][0] = x.fMap[0][1] = dirY[0]; xInv.fMap[2][0] = x.fMap[0][2] = dirZ[0]; xInv.fMap[3][0] = x.fMap[0][3] = 0; xInv.fMap[0][1] = x.fMap[1][0] = dirX[1]; xInv.fMap[1][1] = x.fMap[1][1] = dirY[1]; xInv.fMap[2][1] = x.fMap[1][2] = dirZ[1]; xInv.fMap[3][1] = x.fMap[1][3] = 0; xInv.fMap[0][2] = x.fMap[2][0] = dirX[2]; xInv.fMap[1][2] = x.fMap[2][1] = dirY[2]; xInv.fMap[2][2] = x.fMap[2][2] = dirZ[2]; xInv.fMap[3][2] = x.fMap[2][3] = 0; x.fMap[3][0] = x.fMap[3][1] = x.fMap[3][2] = 0; xInv.fMap[0][3] = xInv.fMap[1][3] = xInv.fMap[2][3] = 0; xInv.fMap[3][3] = x.fMap[3][3] = 1.f; x.NotIdentity(); xInv.NotIdentity(); if( HasFlag(kScale) ) { x.fMap[0][0] *= fScale.fX; x.fMap[0][1] *= fScale.fX; x.fMap[0][2] *= fScale.fX; x.fMap[1][0] *= fScale.fY; x.fMap[1][1] *= fScale.fY; x.fMap[1][2] *= fScale.fY; x.fMap[2][0] *= fScale.fZ; x.fMap[2][1] *= fScale.fZ; x.fMap[2][2] *= fScale.fZ; float inv = 1.f / fScale.fX; xInv.fMap[0][0] *= inv; xInv.fMap[1][0] *= inv; xInv.fMap[2][0] *= inv; inv = 1.f / fScale.fY; xInv.fMap[0][1] *= inv; xInv.fMap[1][1] *= inv; xInv.fMap[2][1] *= inv; inv = 1.f / fScale.fZ; xInv.fMap[0][2] *= inv; xInv.fMap[1][2] *= inv; xInv.fMap[2][2] *= inv; } hsMatrix44 l2p = fOrigLocalToParent * x; hsMatrix44 p2l = xInv * fOrigParentToLocal; if( l2p != IGetTargetCoordinateInterface(0)->GetLocalToParent() ) // TERRORDAN { IGetTargetCoordinateInterface(0)->SetLocalToParent(l2p, p2l); IGetTargetCoordinateInterface(0)->FlushTransform(false); } return true; }