void WingGeom::UpdateDrawObj() { Geom::UpdateDrawObj(); Matrix4d attachMat; Matrix4d relTrans; attachMat = ComposeAttachMatrix(); relTrans = attachMat; relTrans.affineInverse(); relTrans.matMult( m_ModelMatrix.data() ); relTrans.postMult( attachMat.data() ); int nxsec = m_XSecSurf.NumXSec(); m_XSecDrawObj_vec.resize( nxsec, DrawObj() ); //==== Tesselate Surface ====// for ( int i = 0 ; i < nxsec ; i++ ) { m_XSecDrawObj_vec[i].m_PntVec = m_XSecSurf.FindXSec( i )->GetDrawLines( m_TessW(), relTrans ); m_XSecDrawObj_vec[i].m_GeomChanged = true; } m_HighlightXSecDrawObj.m_PntVec = m_XSecSurf.FindXSec( m_ActiveAirfoil )->GetDrawLines( m_TessW(), relTrans ); m_HighlightXSecDrawObj.m_GeomChanged = true; double w = m_XSecSurf.FindXSec( m_ActiveAirfoil )->GetXSecCurve()->GetWidth(); Matrix4d mat; m_XSecSurf.GetBasicTransformation( Z_DIR, X_DIR, XS_SHIFT_MID, false, 1.0, mat ); mat.scale( 1.0/w ); VspCurve crv = m_XSecSurf.FindXSec( m_ActiveAirfoil )->GetUntransformedCurve(); crv.Transform( mat ); vector< vec3d > pts; crv.Tesselate( m_TessW(), pts ); m_CurrentXSecDrawObj.m_PntVec = pts; m_CurrentXSecDrawObj.m_LineWidth = 1.0; m_CurrentXSecDrawObj.m_LineColor = vec3d( 0.0, 0.0, 0.0 ); m_CurrentXSecDrawObj.m_Type = DrawObj::VSP_LINES; m_CurrentXSecDrawObj.m_GeomChanged = true; VspCurve inbd = m_XSecSurf.FindXSec( m_ActiveXSec - 1 )->GetCurve(); inbd.Transform( relTrans ); VspCurve outbd = m_XSecSurf.FindXSec( m_ActiveXSec )->GetCurve(); outbd.Transform( relTrans ); BndBox iBBox, oBBox; inbd.GetBoundingBox( iBBox ); outbd.GetBoundingBox( oBBox ); oBBox.Update( iBBox ); m_HighlightWingSecDrawObj.m_PntVec = oBBox.GetBBoxDrawLines(); }
//==== Update ====// void WingSect::Update() { m_LateUpdateFlag = false; XSecSurf* xsecsurf = (XSecSurf*) GetParentContainerPtr(); // apply the needed transformation to get section into body orientation Matrix4d mat; xsecsurf->GetBasicTransformation( m_XSCurve->GetWidth(), mat ); VspCurve baseCurve = GetUntransformedCurve(); baseCurve.Transform( mat ); //==== Apply Transform ====// m_TransformedCurve = baseCurve; Matrix4d tran_mat; tran_mat.translatef( m_XDelta, m_YDelta, m_ZDelta ); Matrix4d rotate_mat; rotate_mat.rotateX( m_XRotate ); rotate_mat.rotateY( m_YRotate ); rotate_mat.rotateZ( m_ZRotate ); Matrix4d cent_mat; cent_mat.translatef( -m_XCenterRot, -m_YCenterRot, -m_ZCenterRot ); Matrix4d inv_cent_mat; inv_cent_mat.translatef( m_XCenterRot, m_YCenterRot, m_ZCenterRot ); m_Transform.loadIdentity(); m_Transform.postMult( tran_mat.data() ); m_Transform.postMult( cent_mat.data() ); m_Transform.postMult( rotate_mat.data() ); m_Transform.postMult( inv_cent_mat.data() ); m_Transform.postMult( xsecsurf->GetGlobalXForm().data() ); m_TransformedCurve.Transform( m_Transform ); //==== Inform Outboard Section of Change ====// int indx = xsecsurf->FindXSecIndex( m_ID ); if( indx < xsecsurf->NumXSec() - 1 ) { WingSect* nextxs = (WingSect*) xsecsurf->FindXSec( indx + 1); if( nextxs ) { nextxs->SetLateUpdateFlag( true ); } } }
//==== Update ====// void CustomXSec::Update() { m_Type = XSEC_CUSTOM; m_LateUpdateFlag = false; XSecSurf* xsecsurf = (XSecSurf*) GetParentContainerPtr(); // apply the needed transformation to get section into body orientation Matrix4d mat; xsecsurf->GetBasicTransformation( m_XSCurve->GetWidth(), mat ); VspCurve baseCurve = GetUntransformedCurve(); baseCurve.Transform( mat ); //==== Apply Transform ====// m_TransformedCurve = baseCurve; Matrix4d tran_mat; tran_mat.translatef( m_Loc.x(), m_Loc.y(), m_Loc.z() ); Matrix4d rotate_mat; rotate_mat.rotateX( m_Rot.x() ); rotate_mat.rotateY( m_Rot.y() ); rotate_mat.rotateZ( m_Rot.z() ); Matrix4d cent_mat; vec3d cent = m_CenterRot + m_Loc; cent_mat.translatef( -cent.x(), -cent.y(), -cent.z() ); Matrix4d inv_cent_mat; inv_cent_mat.translatef( cent.x(), cent.y(), cent.z() ); m_Transform.loadIdentity(); m_Transform.postMult( tran_mat.data() ); m_Transform.postMult( cent_mat.data() ); m_Transform.postMult( rotate_mat.data() ); m_Transform.postMult( inv_cent_mat.data() ); m_Transform.postMult( xsecsurf->GetGlobalXForm().data() ); m_TransformedCurve.Transform( m_Transform ); }
vector< vec3d > PropXSec::GetDrawLines( Matrix4d &transMat ) { vector< vec3d > lines; VspCurve curve = GetCurve(); curve.Scale( 1.0 / m_PropPos.m_Chord ); vec3d v = curve.CompPnt( 0 ); curve.OffsetZ( -v.z() ); m_PropPos.SetCurve( curve ); m_PropPos.Update(); curve = m_PropPos.GetCurve(); curve.Transform( transMat ); curve.TessAdapt( lines, 1e-2, 10 ); return lines; }