BOOL CDlgPgInfoAttachingPlacement::BrowseAttachement( CAttachedModel *pam) { CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return FALSE; CModelerDoc* pDoc = pModelerView->GetDocument(); CTFileName fnOldModel = pam->am_moAttachedModel.GetName(); CTFileName fnModel = _EngineGUI.FileRequester( "Select model to attach", FILTER_MDL FILTER_END, "Attaching models directory", _fnmApplicationPath + fnOldModel.FileDir(), fnOldModel.FileName()+fnOldModel.FileExt()); if( fnModel == "") return FALSE; try { pam->SetModel_t( fnModel); } catch( char *strError) { (void) strError; return FALSE; } pam->am_bVisible = TRUE; pDoc->ClearAttachments(); pDoc->SetupAttachments(); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); UpdateData(FALSE); return TRUE; }
void CDlgPgCollision::OnPreviousCollisionBox() { CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); pDoc->m_emEditModel.ActivatePreviousCollisionBox(); UpdateData(FALSE); // update all views pDoc->UpdateAllViews( NULL); }
void CDlgPgInfoAttachingPlacement::OnPreviousAttachingPlacement() { if( m_iActivePlacement <= 0) return; m_iActivePlacement -= 1; UpdateData(FALSE); CModelerDoc* pDoc = theApp.GetDocument(); ASSERT( pDoc != NULL); if( pDoc == NULL) return; pDoc->UpdateAllViews( NULL); }
void CDlgPgCollision::OnCollideAsBox() { CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); pDoc->m_emEditModel.edm_md.md_bCollideAsCube = !pDoc->m_emEditModel.edm_md.md_bCollideAsCube; UpdateData(TRUE); UpdateData(FALSE); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); }
void CDlgPgCollision::OnAllignToSize() { CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); FLOATaabbox3D MaxBB; pDoc->m_emEditModel.edm_md.GetAllFramesBBox( MaxBB); pDoc->m_emEditModel.SetCollisionBox( MaxBB.Min(), MaxBB.Max()); UpdateData(FALSE); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); }
void CDlgPgCollision::OnRemoveCollisionBox() { CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); pDoc->m_emEditModel.DeleteCurrentCollisionBox(); UpdateData(FALSE); // document has been changed pDoc->SetModifiedFlag(); // update all views pDoc->UpdateAllViews( NULL); }
void CDlgPgInfoAttachingPlacement::OnNextAttachingPlacement() { CModelerDoc* pDoc = theApp.GetDocument(); ASSERT( pDoc != NULL); if( pDoc == NULL) return; CModelData *pMD = &pDoc->m_emEditModel.edm_md; if( m_iActivePlacement < pDoc->m_emEditModel.edm_aamAttachedModels.Count()-1) { m_iActivePlacement += 1; UpdateData(FALSE); pDoc->UpdateAllViews( NULL); } }
void CDlgPgInfoAttachingPlacement::OnIsVisible() { if( m_iActivePlacement == -1) return; CModelerDoc* pDoc = theApp.GetDocument(); ASSERT( pDoc != NULL); if( pDoc == NULL) return; pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); CAttachedModel *pamAttachedModel = &pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement]; pamAttachedModel->am_bVisible = !pamAttachedModel->am_bVisible; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); pDoc->ClearAttachments(); pDoc->SetupAttachments(); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); UpdateData(FALSE); }
void CDlgPgInfoAttachingPlacement::OnSelchangeAttachmentModelAnimationCombo() { if( m_iActivePlacement == -1) return; CModelerDoc* pDoc = theApp.GetDocument(); ASSERT( pDoc != NULL); if( pDoc == NULL) return; INDEX iCombo = m_comboAttachmentModelAnimation.GetCurSel(); if( iCombo != CB_ERR) { pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); CAttachedModel *pamAttachedModel = &pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement]; pamAttachedModel->am_iAnimation = iCombo; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); } pDoc->ClearAttachments(); pDoc->SetupAttachments(); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); }
void CDlgPgInfoAttachingPlacement::OnRemoveAttachingPlacement() { ASSERT( m_iActivePlacement != -1); CModelerDoc* pDoc = theApp.GetDocument(); ASSERT( pDoc != NULL); if( pDoc == NULL) return; CModelData *pMD = &pDoc->m_emEditModel.edm_md; pMD->md_aampAttachedPosition.Lock(); pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); // get currently active placement from edit model CAttachedModel *pamAttachedModel = &pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement]; // and from model data CAttachedModelPosition *pampModelPosition = &pMD->md_aampAttachedPosition[ m_iActivePlacement]; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); pMD->md_aampAttachedPosition.Unlock(); pDoc->ClearAttachments(); pDoc->m_emEditModel.edm_aamAttachedModels.Delete( pamAttachedModel); pMD->md_aampAttachedPosition.Delete( pampModelPosition); pDoc->SetupAttachments(); if( pDoc->m_emEditModel.edm_aamAttachedModels.Count() == 0) { m_iActivePlacement = -1; } if( m_iActivePlacement == pDoc->m_emEditModel.edm_aamAttachedModels.Count()) { m_iActivePlacement = pDoc->m_emEditModel.edm_aamAttachedModels.Count()-1; } UpdateData(FALSE); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); }
void CDlgInfoPgMip::ToggleMipFlag( ULONG ulFlag) { CModelerView *pModelerView = CModelerView::GetActiveMappingNormalView(); ASSERT(pModelerView != NULL); CModelerDoc *pDoc = pModelerView->GetDocument(); ASSERT(pDoc != NULL); ModelMipInfo *pMMIFirst = &pDoc->m_emEditModel.edm_md.md_MipInfos[ pDoc->m_iCurrentMip]; BOOL bSetting = (pMMIFirst->mmpi_ulFlags & ulFlag) == 0; // if setting, set just for this mip model if( bSetting) { pMMIFirst->mmpi_ulFlags |= ulFlag; } // if clearing, clear for all further mip models else { for( INDEX iMip=pDoc->m_iCurrentMip; iMip<pDoc->m_emEditModel.edm_md.md_MipCt; iMip++) { // get requested mip model ModelMipInfo *pMMI = &pDoc->m_emEditModel.edm_md.md_MipInfos[ iMip]; // if setting, set just for this mip model pMMI->mmpi_ulFlags &= ~ulFlag; } } // for patcehs if( ulFlag == MM_PATCHES_VISIBLE) { // reaclculate patch-polygon connections pDoc->m_emEditModel.CalculatePatchesPerPolygon(); } pDoc->UpdateAllViews(NULL); UpdateData( FALSE); }
void CDlgInfoPgRendering::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); CModelerDoc* pDoc = theApp.GetDocument(); if( pDoc == NULL) return; // if dialog is recieving data if( (!pDX->m_bSaveAndValidate) && IsWindow(m_colorDiffuse.m_hWnd) ) { enum SurfaceShadingType sstFirstShading = SST_INVALID; enum SurfaceTranslucencyType sttFirstTranslucency = STT_INVALID; BOOL bSameShading = TRUE; BOOL bSameTranslucency = TRUE; BOOL bSameDiffuse = TRUE; BOOL bSameReflections = TRUE; BOOL bSameSpecular = TRUE; BOOL bSameBump = TRUE; COLOR colFirstDiffuse; COLOR colFirstReflections; COLOR colFirstSpecular; COLOR colFirstBump; CTString strFirstName = "Invalid name"; ULONG ulFlagsOn = MAX_ULONG; ULONG ulFlagsOff = MAX_ULONG; INDEX ctSelectedSurfaces = pDoc->GetCountOfSelectedSurfaces(); BOOL bSelectionExists = ctSelectedSurfaces != 0; BOOL bFirstSelected = TRUE; ModelMipInfo &mmi = pDoc->m_emEditModel.edm_md.md_MipInfos[ pDoc->m_iCurrentMip]; for( INDEX iSurface=0; iSurface<mmi.mmpi_MappingSurfaces.Count(); iSurface++) { MappingSurface &ms = mmi.mmpi_MappingSurfaces[ iSurface]; // skip non selected surfaces if( !(ms.ms_ulRenderingFlags&SRF_SELECTED)) continue; strFirstName = ms.ms_Name; ULONG ulRenderFlags = ms.ms_ulRenderingFlags; ulFlagsOn &= ulRenderFlags; ulFlagsOff &= ~ulRenderFlags; if( sstFirstShading == SST_INVALID) sstFirstShading = ms.ms_sstShadingType; if( sttFirstTranslucency == STT_INVALID) sttFirstTranslucency = ms.ms_sttTranslucencyType; if( bFirstSelected) { bFirstSelected = FALSE; colFirstDiffuse = ms.ms_colDiffuse; colFirstReflections = ms.ms_colReflections; colFirstSpecular = ms.ms_colSpecular; colFirstBump = ms.ms_colBump; } else { if( ms.ms_colDiffuse != colFirstDiffuse) bSameDiffuse = FALSE; if( ms.ms_colReflections != colFirstReflections) bSameReflections = FALSE; if( ms.ms_colSpecular != colFirstSpecular) bSameSpecular = FALSE; if( ms.ms_colBump != colFirstBump) bSameBump = FALSE; } if( sstFirstShading != ms.ms_sstShadingType) bSameShading = FALSE; if( sttFirstTranslucency != ms.ms_sttTranslucencyType) bSameTranslucency = FALSE; } if( bSameDiffuse) m_colorDiffuse.SetColor( colFirstDiffuse); else m_colorDiffuse.SetMixedColor(); if( bSameReflections) m_colorReflections.SetColor( colFirstReflections); else m_colorReflections.SetMixedColor(); if( bSameSpecular) m_colorSpecular.SetColor( colFirstSpecular); else m_colorSpecular.SetMixedColor(); if( bSameBump) m_colorBump.SetColor( colFirstBump); else m_colorBump.SetMixedColor(); CTString strText; if( ctSelectedSurfaces == 0) strText = "No surfaces selected"; else if( ctSelectedSurfaces > 1) strText.PrintF( "%d surfaces selected", ctSelectedSurfaces); else strText.PrintF( "Surface: %s", strFirstName); m_strSurfaceName = strText; strText.PrintF( "Mip: %d", pDoc->m_iCurrentMip); m_strMipModel = strText; // apply flags to controls #define SET_TRI_STATE_TO_CTRL( ctrl, flag)\ if((ulFlagsOn & flag) && !(ulFlagsOff & flag)) ctrl.SetCheck( 1);\ else if(!(ulFlagsOn & flag) && (ulFlagsOff & flag)) ctrl.SetCheck( 0);\ else ctrl.SetCheck( 2); SET_TRI_STATE_TO_CTRL( m_IsBump, SRF_BUMP); SET_TRI_STATE_TO_CTRL( m_IsDetail, SRF_DETAIL); SET_TRI_STATE_TO_CTRL( m_IsDiffuse, SRF_DIFFUSE); SET_TRI_STATE_TO_CTRL( m_IsReflections, SRF_REFLECTIONS); SET_TRI_STATE_TO_CTRL( m_IsSpecular, SRF_SPECULAR); SET_TRI_STATE_TO_CTRL( m_IsInvisible, SRF_INVISIBLE); SET_TRI_STATE_TO_CTRL( m_IsDoubleSided, SRF_DOUBLESIDED); if( !bSameShading) m_comboShading.SetCurSel( -1); else { INDEX iShadingCombo = -1; switch( sstFirstShading) { case SST_FULLBRIGHT: iShadingCombo=0; break; case SST_MATTE: iShadingCombo=1; break; case SST_FLAT: iShadingCombo=2; break; } m_comboShading.SetCurSel( iShadingCombo); } if( !bSameTranslucency) m_comboTranslucency.SetCurSel( -1); else { INDEX iTranslucency = -1; switch( sttFirstTranslucency) { case STT_OPAQUE: iTranslucency=0; break; case STT_TRANSPARENT: iTranslucency=1; break; case STT_TRANSLUCENT: iTranslucency=2; break; case STT_ADD: iTranslucency=3; break; case STT_INVMULTIPLY: iTranslucency=4; break; } m_comboTranslucency.SetCurSel( iTranslucency); } m_comboTranslucency.EnableWindow( bSelectionExists); m_comboShading.EnableWindow( bSelectionExists); m_IsDoubleSided.EnableWindow( bSelectionExists); m_IsInvisible.EnableWindow( bSelectionExists); m_IsDiffuse.EnableWindow( bSelectionExists); m_IsReflections.EnableWindow( bSelectionExists); m_IsSpecular.EnableWindow( bSelectionExists); m_IsBump.EnableWindow( bSelectionExists); m_IsDetail.EnableWindow( bSelectionExists); m_colorSpecular.EnableWindow( bSelectionExists); m_colorReflections.EnableWindow( bSelectionExists); m_colorDiffuse.EnableWindow( bSelectionExists); m_colorBump.EnableWindow( bSelectionExists); GetDlgItem( IDC_TRANSLUCENCY)->EnableWindow( bSelectionExists); GetDlgItem( IDC_TRANSLUCENCY_T)->EnableWindow( bSelectionExists); GetDlgItem( IDC_MIP_MODEL)->EnableWindow( bSelectionExists); GetDlgItem( IDC_SURFACE_NAME)->EnableWindow( bSelectionExists); GetDlgItem( IDC_SHADING_T)->EnableWindow( bSelectionExists); GetDlgItem( IDC_DIFFUSE_COLOR_T)->EnableWindow( bSelectionExists); GetDlgItem( IDC_REFLECTION_COLOR_T2)->EnableWindow( bSelectionExists); GetDlgItem( IDC_SPECULAR_COLOR_T2)->EnableWindow( bSelectionExists); GetDlgItem( IDC_BUMP_COLOR_T)->EnableWindow( bSelectionExists); Invalidate( FALSE); m_udAllValues.MarkUpdated(); } //{{AFX_DATA_MAP(CDlgInfoPgRendering) DDX_Control(pDX, IDC_TRANSLUCENCY, m_comboTranslucency); DDX_Control(pDX, IDC_SHADING, m_comboShading); DDX_Control(pDX, IDC_SPECULAR_COLOR, m_colorSpecular); DDX_Control(pDX, IDC_REFLECTION_COLOR, m_colorReflections); DDX_Control(pDX, IDC_DIFUSE_COLOR, m_colorDiffuse); DDX_Control(pDX, IDC_BUMP_COLOR, m_colorBump); DDX_Text(pDX, IDC_MIP_MODEL, m_strMipModel); DDX_Text(pDX, IDC_SURFACE_NAME, m_strSurfaceName); DDX_Control(pDX, IDC_DOUBLE_SIDED, m_IsDoubleSided); DDX_Control(pDX, IDC_INVISIBLE, m_IsInvisible); DDX_Control(pDX, IDC_USE_DIFUSE, m_IsDiffuse); DDX_Control(pDX, IDC_USE_REFLECTIVITY, m_IsReflections); DDX_Control(pDX, IDC_USE_SPECULAR, m_IsSpecular); DDX_Control(pDX, IDC_USE_BUMP, m_IsBump); DDX_Control(pDX, IDC_DETAIL, m_IsDetail); //}}AFX_DATA_MAP // set flags back to surface #define TRI_STATE_CTRL_TO_FLAGS( ctrl, flag)\ if( (ctrl.GetCheck() == 1) && !(ms.ms_ulRenderingFlags & flag) ) {\ ms.ms_ulRenderingFlags |= flag;\ } else if( (ctrl.GetCheck() == 0) && (ms.ms_ulRenderingFlags & flag) ) {\ ms.ms_ulRenderingFlags &= ~flag;\ } // if dialog gives data if( pDX->m_bSaveAndValidate) { INDEX iComboShadow = m_comboShading.GetCurSel(); INDEX iComboTranslucency = m_comboTranslucency.GetCurSel(); ModelMipInfo &mmi = pDoc->m_emEditModel.edm_md.md_MipInfos[ pDoc->m_iCurrentMip]; for( INDEX iSurface=0; iSurface<mmi.mmpi_MappingSurfaces.Count(); iSurface++) { MappingSurface &ms = mmi.mmpi_MappingSurfaces[ iSurface]; ULONG ulFlagsBefore = ms.ms_ulRenderingFlags; // skip non selected surfaces if( !(ms.ms_ulRenderingFlags&SRF_SELECTED)) continue; TRI_STATE_CTRL_TO_FLAGS( m_IsBump, SRF_BUMP); TRI_STATE_CTRL_TO_FLAGS( m_IsDetail, SRF_DETAIL); TRI_STATE_CTRL_TO_FLAGS( m_IsDiffuse, SRF_DIFFUSE); TRI_STATE_CTRL_TO_FLAGS( m_IsReflections, SRF_REFLECTIONS); TRI_STATE_CTRL_TO_FLAGS( m_IsSpecular, SRF_SPECULAR); TRI_STATE_CTRL_TO_FLAGS( m_IsInvisible, SRF_INVISIBLE); TRI_STATE_CTRL_TO_FLAGS( m_IsDoubleSided, SRF_DOUBLESIDED); ULONG ulFlagsAfter = ms.ms_ulRenderingFlags; BOOL bBumpSet = ((ulFlagsBefore&SRF_BUMP)!=(ulFlagsAfter&SRF_BUMP))&&(ulFlagsAfter&SRF_BUMP); BOOL bDetailSet = ((ulFlagsBefore&SRF_DETAIL)!=(ulFlagsAfter&SRF_DETAIL))&&(ulFlagsAfter&SRF_DETAIL); // if bump set if( bBumpSet) { // turn off detail ms.ms_ulRenderingFlags &= ~SRF_DETAIL; theApp.m_chGlobal.MarkChanged(); } // if detail set if( bDetailSet) { // turn off bump ms.ms_ulRenderingFlags &= ~SRF_BUMP; theApp.m_chGlobal.MarkChanged(); } switch( iComboShadow) { case 0: ms.ms_sstShadingType=SST_FULLBRIGHT; break; case 1: ms.ms_sstShadingType=SST_MATTE; break; case 2: ms.ms_sstShadingType=SST_FLAT; break; } switch( iComboTranslucency) { case 0: ms.ms_sttTranslucencyType=STT_OPAQUE; break; case 1: ms.ms_sttTranslucencyType=STT_TRANSPARENT; break; case 2: ms.ms_sttTranslucencyType=STT_TRANSLUCENT; break; case 3: ms.ms_sttTranslucencyType=STT_ADD; break; case 4: ms.ms_sttTranslucencyType=STT_INVMULTIPLY; break; } ms.ms_colDiffuse = m_colorDiffuse.GetColor(); ms.ms_colReflections = m_colorReflections.GetColor(); ms.ms_colSpecular = m_colorSpecular.GetColor(); ms.ms_colBump = m_colorBump.GetColor(); } // update view pDoc->m_emEditModel.edm_md.md_bPreparedForRendering = FALSE; pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); } }
void CDlgPgCollision::DoDataExchange(CDataExchange* pDX) { CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); // if transfering data from document to dialog if( !pDX->m_bSaveAndValidate) { // get collision min vector FLOAT3D vMinCollisionBox = pDoc->m_emEditModel.GetCollisionBoxMin(); // get collision max vector FLOAT3D vMaxCollisionBox = pDoc->m_emEditModel.GetCollisionBoxMax(); FLOATaabbox3D bboxCollision = FLOATaabbox3D( vMinCollisionBox, vMaxCollisionBox); m_fWidth = bboxCollision.Size()(1); m_fHeight = bboxCollision.Size()(2); m_fLenght = bboxCollision.Size()(3); m_fXCenter = bboxCollision.Center()(1); m_fYDown = vMinCollisionBox(2); m_fZCenter = bboxCollision.Center()(3); // set equality radio initial value INDEX iEqualityType = pDoc->m_emEditModel.GetCollisionBoxDimensionEquality(); // get index of curently selected collision box char achrString[ 256]; sprintf( achrString, "%d.", pDoc->m_emEditModel.GetActiveCollisionBoxIndex()); m_strCollisionBoxIndex = achrString; // get name of curently selected collision box sprintf( achrString, "%s", pDoc->m_emEditModel.GetCollisionBoxName()); m_strCollisionBoxName = achrString; // enable all controls GetDlgItem( IDC_STATIC_WIDTH)->EnableWindow( TRUE); GetDlgItem( IDC_EDIT_WIDTH)->EnableWindow( TRUE); GetDlgItem( IDC_STATIC_HEIGHT)->EnableWindow( TRUE); GetDlgItem( IDC_EDIT_HEIGHT)->EnableWindow( TRUE); GetDlgItem( IDC_STATIC_LENGHT)->EnableWindow( TRUE); GetDlgItem( IDC_EDIT_LENGHT)->EnableWindow( TRUE); m_bCollideAsBox = pDoc->m_emEditModel.edm_md.md_bCollideAsCube; // if we are colliding using sphere approximation switch( iEqualityType) { case HEIGHT_EQ_WIDTH: { m_EqualityRadio = 0; if( !m_bCollideAsBox) { GetDlgItem( IDC_STATIC_HEIGHT)->EnableWindow( FALSE); GetDlgItem( IDC_EDIT_HEIGHT)->EnableWindow( FALSE); m_fHeight = m_fWidth; } break; } case LENGTH_EQ_WIDTH: { m_EqualityRadio = 1; if( !m_bCollideAsBox) { GetDlgItem( IDC_STATIC_LENGHT)->EnableWindow( FALSE); GetDlgItem( IDC_EDIT_LENGHT)->EnableWindow( FALSE); m_fLenght = m_fWidth; } break; } case LENGTH_EQ_HEIGHT: { m_EqualityRadio = 2; if( !m_bCollideAsBox) { GetDlgItem( IDC_STATIC_LENGHT)->EnableWindow( FALSE); GetDlgItem( IDC_EDIT_LENGHT)->EnableWindow( FALSE); m_fLenght = m_fHeight; } break; } default: { ASSERTALWAYS( "None of collision dimensions are the same and that can't be."); } } // mark that the values have been updated to reflect the state of the view m_udAllValues.MarkUpdated(); } CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDlgPgCollision) DDX_SkyFloat(pDX, IDC_EDIT_WIDTH, m_fWidth); DDX_SkyFloat(pDX, IDC_EDIT_HEIGHT, m_fHeight); DDX_SkyFloat(pDX, IDC_EDIT_LENGHT, m_fLenght); DDX_SkyFloat(pDX, IDC_EDIT_XCENTER, m_fXCenter); DDX_SkyFloat(pDX, IDC_EDIT_YDOWN, m_fYDown); DDX_SkyFloat(pDX, IDC_EDIT_ZCENTER, m_fZCenter); DDX_Radio(pDX, IDC_H_EQ_W, m_EqualityRadio); DDX_Text(pDX, IDC_COLLISION_BOX_NAME, m_strCollisionBoxName); DDX_Text(pDX, IDC_COLLISION_BOX_INDEX, m_strCollisionBoxIndex); DDX_Check(pDX, IDC_COLLIDE_AS_BOX, m_bCollideAsBox); //}}AFX_DATA_MAP // if transfering data from dialog to document if( pDX->m_bSaveAndValidate) { // if we are colliding using sphere approximation if( !pDoc->m_emEditModel.edm_md.md_bCollideAsCube) { INDEX iEqualityType; switch( m_EqualityRadio) { case 0: { iEqualityType = HEIGHT_EQ_WIDTH; CString strWidth; GetDlgItem( IDC_EDIT_WIDTH)->GetWindowText(strWidth); GetDlgItem( IDC_EDIT_HEIGHT)->SetWindowText(strWidth); break; } case 1: { iEqualityType = LENGTH_EQ_WIDTH; CString strWidth; GetDlgItem( IDC_EDIT_WIDTH)->GetWindowText(strWidth); GetDlgItem( IDC_EDIT_LENGHT)->SetWindowText( strWidth ); break; } case 2: { iEqualityType = LENGTH_EQ_HEIGHT; CString strHeight; GetDlgItem( IDC_EDIT_HEIGHT)->GetWindowText(strHeight); GetDlgItem( IDC_EDIT_LENGHT)->SetWindowText( strHeight); break; } default: { ASSERTALWAYS( "Illegal value found in collision dimensions equality radio."); } } // set collision equality value if( pDoc->m_emEditModel.GetCollisionBoxDimensionEquality() != iEqualityType) { pDoc->m_emEditModel.SetCollisionBoxDimensionEquality( iEqualityType); } } // set name of curently selected collision box pDoc->m_emEditModel.SetCollisionBoxName( CTString( m_strCollisionBoxName) ); // get collision min and max vectors FLOAT3D vMinCollisionBox; FLOAT3D vMaxCollisionBox; // get sizing values vMinCollisionBox(1) = m_fXCenter-m_fWidth/2.0f; vMinCollisionBox(2) = m_fYDown; vMinCollisionBox(3) = m_fZCenter-m_fLenght/2.0f; // get origin coordinates vMaxCollisionBox(1) = m_fXCenter+m_fWidth/2.0f; vMaxCollisionBox(2) = m_fYDown+m_fHeight; vMaxCollisionBox(3) = m_fZCenter+m_fLenght/2.0f; // transfer data from dialog to document pDoc->m_emEditModel.SetCollisionBox( vMinCollisionBox, vMaxCollisionBox); pDoc->SetModifiedFlag(); // update all views pDoc->UpdateAllViews( NULL); } }
void CDlgPgInfoAttachingPlacement::SetPlacementReferenceVertex(INDEX iCenter, INDEX iFront, INDEX iUp) { // patch for calling before page is refreshed if(this == NULL) return; CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); CModelData *pMD = &pDoc->m_emEditModel.edm_md; pMD->md_aampAttachedPosition.Lock(); CAttachedModelPosition & = pMD->md_aampAttachedPosition[ m_iActivePlacement]; // --------- Set axis-defining vertices, but swap if owerlaping // Center vertex if( iCenter != -1) { if(amp.amp_iFrontVertex == iCenter) { amp.amp_iFrontVertex = amp.amp_iCenterVertex; } else if(amp.amp_iUpVertex == iCenter) { amp.amp_iUpVertex = amp.amp_iCenterVertex; } amp.amp_iCenterVertex = iCenter; } // Front vertex if( iFront != -1) { if(amp.amp_iCenterVertex == iFront) { amp.amp_iCenterVertex = amp.amp_iFrontVertex; } else if(amp.amp_iUpVertex == iFront) { amp.amp_iUpVertex = amp.amp_iFrontVertex; } amp.amp_iFrontVertex = iFront; } // Up vertex if( iUp != -1) { if(amp.amp_iCenterVertex == iUp) { amp.amp_iCenterVertex = amp.amp_iUpVertex; } else if(amp.amp_iFrontVertex == iUp) { amp.amp_iFrontVertex = amp.amp_iUpVertex; } amp.amp_iUpVertex = iUp; } pMD->md_aampAttachedPosition.Unlock(); theApp.m_chGlobal.MarkChanged(); pDoc->ClearAttachments(); pDoc->SetupAttachments(); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); }
void CDlgPgInfoAttachingPlacement::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); CModelerView *pModelerView = CModelerView::GetActiveView(); if(pModelerView == NULL) return; CModelerDoc* pDoc = pModelerView->GetDocument(); CModelData *pMD = &pDoc->m_emEditModel.edm_md; INDEX ctPositions = pDoc->m_emEditModel.edm_aamAttachedModels.Count(); if( (m_iActivePlacement == -1) && ( ctPositions != 0) ) m_iActivePlacement = 0; if( m_iActivePlacement >= ctPositions) { if( ctPositions != 0) m_iActivePlacement = 0; else m_iActivePlacement = -1; } // if transfering data from document to dialog if( !pDX->m_bSaveAndValidate) { BOOL bAttachmentExists = ( m_iActivePlacement != -1); GetDlgItem( IDC_ATTACHING_PLACEMENT_INDEX_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_PREVIOUS_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_NAME )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_NEXT_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_REMOVE_ATTACHING_PLACEMENT )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_X_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_X_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Y_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Y_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Z_OFFSET_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_Z_OFFSET )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_HEADING_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_HEADING )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_PITCH_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_PITCH )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_BANKING_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_PLACEMENT_BANKING )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_IS_VISIBLE )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_BROWSE_MODEL )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_MODEL_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_MODEL_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_MODEL_ANIMATION_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHMENT_MODEL_ANIMATION_COMBO)->EnableWindow( bAttachmentExists); GetDlgItem( IDC_VERTICES_T )->EnableWindow( bAttachmentExists); GetDlgItem( IDC_ATTACHING_VERTICES )->EnableWindow( bAttachmentExists); if( bAttachmentExists) { pMD->md_aampAttachedPosition.Lock(); pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); CPlacement3D plCurrent = pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_plRelativePlacement; m_fHeading = DegAngle( plCurrent.pl_OrientationAngle(1)); m_fPitch = DegAngle( plCurrent.pl_OrientationAngle(2)); m_fBanking = DegAngle( plCurrent.pl_OrientationAngle(3)); m_fXOffset = plCurrent.pl_PositionVector(1); m_fYOffset = plCurrent.pl_PositionVector(2); m_fZOffset = plCurrent.pl_PositionVector(3); CAttachedModel *pam = &pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement]; m_strName = pam->am_strName; m_strAttachingModel = pam->am_moAttachedModel.GetName(); char achrLine[ 256]; sprintf( achrLine, "center:%d, front:%d, up:%d", pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iCenterVertex, pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iFrontVertex, pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_iUpVertex); m_strAttachingVertices = achrLine; sprintf( achrLine, "%d.", m_iActivePlacement); m_strPlacementIndex = achrLine; m_bIsVisible = pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_bVisible != 0; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); pMD->md_aampAttachedPosition.Unlock(); if( IsWindow( m_comboAttachmentModelAnimation.m_hWnd)) { m_comboAttachmentModelAnimation.EnableWindow( m_bIsVisible); FillAttachmentModelAnimationCombo(); } // mark that the values have been updated to reflect the state of the view m_udAllValues.MarkUpdated(); } } //{{AFX_DATA_MAP(CDlgPgInfoAttachingPlacement) DDX_Control(pDX, IDC_ATTACHMENT_MODEL_ANIMATION_COMBO, m_comboAttachmentModelAnimation); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_BANKING, m_fBanking); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_HEADING, m_fHeading); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_PITCH, m_fPitch); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_X_OFFSET, m_fXOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_Y_OFFSET, m_fYOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_Z_OFFSET, m_fZOffset); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_NAME, m_strName); DDX_Text(pDX, IDC_ATTACHING_MODEL_T, m_strAttachingModel); DDX_Text(pDX, IDC_ATTACHING_VERTICES, m_strAttachingVertices); DDX_Text(pDX, IDC_ATTACHING_PLACEMENT_INDEX_T, m_strPlacementIndex); DDX_Check(pDX, IDC_IS_VISIBLE, m_bIsVisible); //}}AFX_DATA_MAP // if transfering data from dialog to document if( pDX->m_bSaveAndValidate) { if( m_iActivePlacement == -1) return; pMD->md_aampAttachedPosition.Lock(); pDoc->m_emEditModel.edm_aamAttachedModels.Lock(); CPlacement3D plCurrent; plCurrent.pl_OrientationAngle(1) = AngleDeg( m_fHeading); plCurrent.pl_OrientationAngle(2) = AngleDeg( m_fPitch); plCurrent.pl_OrientationAngle(3) = AngleDeg( m_fBanking); plCurrent.pl_PositionVector(1) = m_fXOffset; plCurrent.pl_PositionVector(2) = m_fYOffset; plCurrent.pl_PositionVector(3) = m_fZOffset; pMD->md_aampAttachedPosition[ m_iActivePlacement].amp_plRelativePlacement = plCurrent; pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_strName = CStringA(m_strName); pDoc->m_emEditModel.edm_aamAttachedModels[ m_iActivePlacement].am_bVisible = m_bIsVisible; pDoc->m_emEditModel.edm_aamAttachedModels.Unlock(); pMD->md_aampAttachedPosition.Unlock(); pDoc->ClearAttachments(); pDoc->SetupAttachments(); pDoc->SetModifiedFlag(); pDoc->UpdateAllViews( NULL); } }