void CColoredButton::OnClicked() { if( m_iColorIndex != -1) return; // colored button can call eather custom palette window for choosing colors (where variable // to recieve result color is pointed with _pcolColorToSet) eather trough MFC-provided // color picker if( m_ptPickerType == PT_CUSTOM) { // instantiate new choose color palette window CColorPaletteWnd *pColorPalette = new CColorPaletteWnd; // calculate palette window's rectangle CRect rectWindow; CPoint ptMousePoint( 0,0); ClientToScreen( &ptMousePoint); // set screen coordinates of LU point of clicked tool button rectWindow.left = ptMousePoint.x; rectWindow.top = ptMousePoint.y - 200; rectWindow.right = rectWindow.left + 100; rectWindow.bottom = ptMousePoint.y; // create window BOOL bResult = pColorPalette->CreateEx( WS_EX_TOOLWINDOW, NULL, "Palette", WS_CHILD|WS_POPUP|WS_VISIBLE, rectWindow.left, rectWindow.top, rectWindow.Width(), rectWindow.Height(), m_hWnd, NULL, NULL); if( !bResult) { AfxMessageBox( "Error: Failed to create color palette"); return; } // initialize canvas for active texture button _pGfx->CreateWindowCanvas( pColorPalette->m_hWnd, &pColorPalette->m_pViewPort, &pColorPalette->m_pDrawPort); // get new color _pcolColorToSet = &m_colColor; } // request was made for MFC-type color picker else { COLORREF TmpColor = CLRF_CLR( m_colColor); if( MyChooseColor( TmpColor, *GetParent())) { m_bMixedColor = FALSE; // restore alpha value m_colColor = CLR_CLRF( TmpColor) | m_colColor&0x000000FF; Invalidate( FALSE); } } // invalidate parent dialog if( m_pwndParentDialog != NULL) m_pwndParentDialog->UpdateData( TRUE); }
void CColoredButton::OnClicked() { if( m_iColorIndex != -1) return; // colored button can call eather custom palette window for choosing colors (where variable // to receive result color is pointed with _pcolColorToSet) eather trough MFC-provided // color picker ASSERT( m_ptPickerType != PT_CUSTOM); COLORREF TmpColor = CLRF_CLR( m_colColor); if( MyChooseColor( TmpColor, *GetParent())) { m_bMixedColor = FALSE; // restore alpha value m_colColor = CLR_CLRF( TmpColor) | m_colColor&0x000000FF; OnColorChange(); Invalidate( FALSE); } // invalidate parent dialog if( m_pwndParentDialog != NULL) m_pwndParentDialog->UpdateData( TRUE); }
void CWndAnimationFrames::OnLButtonDown(UINT nFlags, CPoint point) { // get clicked frame INDEX iFrame = point.x/FRAME_BOX_WIDTH+m_iStartingFrame; // return if frame is not visible (clicked beyond last frame) if( !IsFrameVisible(iFrame)) return; Invalidate(FALSE); // if clicked frame was not selected previously if( iFrame != m_iSelectedFrame) { // select clicked frame m_iSelectedFrame = iFrame; m_pParentDlg->UpdateData( FALSE); // return return; } // select clicked frame m_iSelectedFrame = iFrame; m_pParentDlg->UpdateData( FALSE); // get curently selected light animation combo member INDEX iLightAnimation = m_pParentDlg->GetSelectedLightAnimation(); // get animation data CAnimData *pAD = m_pParentDlg->m_padAnimData; COLORREF newFrameColor = CLRF_CLR( pAD->GetFrame(iLightAnimation, iFrame)); if( MyChooseColor( newFrameColor, *m_pParentDlg) ) { // set new key frame value pAD->SetFrame(iLightAnimation, iFrame, CLR_CLRF(newFrameColor)|0x000000FF); // spread frames m_pParentDlg->SpreadFrames(); // redraw window Invalidate( FALSE); m_pParentDlg->UpdateData( FALSE); m_pParentDlg->m_bChanged = TRUE; } CWnd::OnLButtonDown(nFlags, point); }
/* * Converts data from Exploration3D format into arrays used for conversion to O3D */ void FillConversionArrays_t(const FLOATmatrix3D &mTransform) { #if USE_E3D // all polygons must be triangles if(_pe3Object->_facecount != 0) { throw("Error: Not all polygons are triangles!"); } // check if we need flipping (if matrix is flipping, polygons need to be flipped) const FLOATmatrix3D &m = mTransform; FLOAT fDet = m(1,1)*(m(2,2)*m(3,3)-m(2,3)*m(3,2))+ m(1,2)*(m(2,3)*m(3,1)-m(2,1)*m(3,3))+ m(1,3)*(m(2,1)*m(3,2)-m(2,2)*m(3,1)); FLOAT bFlipped = fDet<0; // ------------ Convert object vertices (coordinates) INDEX ctVertices = _pe3Object->pointcount; avVertices.New(ctVertices); // copy vertices for( INDEX iVtx=0; iVtx<ctVertices; iVtx++) { avVertices[iVtx] = ((FLOAT3D &)_pe3Object->points[iVtx])*mTransform; avVertices[iVtx](1) = -avVertices[iVtx](1); avVertices[iVtx](3) = -avVertices[iVtx](3); } // ------------ Convert object's mapping vertices (texture vertices) INDEX ctTextureVertices = _pe3Object->txtcount; avTextureVertices.New(ctTextureVertices); // copy texture vertices for( INDEX iTVtx=0; iTVtx<ctTextureVertices; iTVtx++) { avTextureVertices[iTVtx] = (FLOAT2D &)_pe3Object->txtpoints[iTVtx]; } // ------------ Organize triangles as list of surfaces // allocate triangles INDEX ctTriangles = _pe3Object->facecount; actTriangles.New(ctTriangles); acmMaterials.Lock(); // sort triangles per surfaces for( INDEX iTriangle=0; iTriangle<ctTriangles; iTriangle++) { ConversionTriangle &ctTriangle = actTriangles[iTriangle]; e3_TFACE *pe3Triangle = _pe3Object->GetFace( iTriangle); // copy vertex indices if (bFlipped) { ctTriangle.ct_iVtx[0] = pe3Triangle->v[2]; ctTriangle.ct_iVtx[1] = pe3Triangle->v[1]; ctTriangle.ct_iVtx[2] = pe3Triangle->v[0]; } else { ctTriangle.ct_iVtx[0] = pe3Triangle->v[0]; ctTriangle.ct_iVtx[1] = pe3Triangle->v[1]; ctTriangle.ct_iVtx[2] = pe3Triangle->v[2]; } // copy texture vertex indices if (bFlipped) { ctTriangle.ct_iTVtx[0] = pe3Triangle->t[2]; ctTriangle.ct_iTVtx[1] = pe3Triangle->t[1]; ctTriangle.ct_iTVtx[2] = pe3Triangle->t[0]; } else { ctTriangle.ct_iTVtx[0] = pe3Triangle->t[0]; ctTriangle.ct_iTVtx[1] = pe3Triangle->t[1]; ctTriangle.ct_iTVtx[2] = pe3Triangle->t[2]; } // obtain material e3_MATERIAL *pe3Mat = pe3Triangle->material; BOOL bNewMaterial = TRUE; // attach triangle into one material for( INDEX iMat=0; iMat<acmMaterials.Count(); iMat++) { // if this material already exist in array of materu if( acmMaterials[ iMat].cm_ulTag == (ULONG) pe3Mat) { // set index of surface ctTriangle.ct_iMaterial = iMat; // add triangle into surface list of triangles INDEX *piNewTriangle = new INDEX(1); *piNewTriangle = iTriangle; acmMaterials[ iMat].ms_Polygons.Add( piNewTriangle); bNewMaterial = FALSE; continue; } } // if material hasn't been added yet if( bNewMaterial) { // add new material ConversionMaterial *pcmNew = new ConversionMaterial; acmMaterials.Unlock(); acmMaterials.Add( pcmNew); acmMaterials.Lock(); // set polygon's material index INDEX iNewMaterial = acmMaterials.Count()-1; ctTriangle.ct_iMaterial = iNewMaterial; // add triangle into new surface's list of triangles INDEX *piNewTriangle = new INDEX(1); *piNewTriangle = iTriangle; acmMaterials[ iNewMaterial].ms_Polygons.Add( piNewTriangle); // remember recognition tag (ptr) pcmNew->cm_ulTag = (ULONG) pe3Mat; // ---------- Set material's name // if not default material if( pe3Mat != NULL && pe3Mat->name != NULL) { acmMaterials[iNewMaterial].cm_strName = CTString(pe3Mat->name); // get color COLOR colColor = CLR_CLRF( pe3Mat->GetDiffuse().rgb()); acmMaterials[iNewMaterial].cm_colColor = colColor; } else { acmMaterials[iNewMaterial].cm_strName = "Default"; acmMaterials[iNewMaterial].cm_colColor = C_GRAY; } } } acmMaterials.Unlock(); #endif }