MyglView.cpp
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:57k
- /////////////////////////////////////////////////////////////////////////////
- // MyglView.cpp : implementation of the CMyglView class
- //
- // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1999
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "ModelMagic3D.h"
- #include <math.h>
- #include <wingdi.h>
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView local variables
- //
- static Matx4x4 g_SelctedObjMatrix; // User selected object transform matrix
- // (used for object point transfomation)
- static BOOL g_bStretchBlt = FALSE; // Printer device capability flags
- static BOOL g_bStretchDIBits = FALSE;
- static CTextureDibImage g_DibImage; // DIB image for screen print
- static BITMAPINFO* g_pBitmapInfo = NULL; // CMyglView global DIB pointers
- static GLubyte* g_pBitmapBits = NULL; // Bitmap pits
- static float g_fMarginTop = 0.75f; // CMyglView global margin settings
- static float g_fMarginBottom = 0.75f;
- static float g_fMarginLeft = 0.75f;
- static float g_fMarginRight = 0.75f;
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView
- IMPLEMENT_DYNCREATE(CMyglView, CView)
- BEGIN_MESSAGE_MAP(CMyglView, CView)
- //{{AFX_MSG_MAP(CMyglView)
- ON_WM_ERASEBKGND()
- ON_WM_SIZE()
- ON_WM_CREATE()
- ON_WM_PALETTECHANGED()
- ON_WM_QUERYNEWPALETTE()
- ON_WM_DESTROY()
- ON_WM_MOUSEMOVE()
- ON_COMMAND(ID_VIEW_PERSPECTIVE, OnViewPerspective)
- ON_COMMAND(ID_VIEW_ZOOMIN, OnViewZoomIn)
- ON_COMMAND(ID_VIEW_ZOOMOUT, OnViewZoomOut)
- ON_UPDATE_COMMAND_UI(ID_VIEW_PERSPECTIVE, OnUpdateViewPerspective)
- ON_COMMAND(ID_ANIMATE_SCEEN, OnAnimateSceen)
- ON_UPDATE_COMMAND_UI(ID_ANIMATE_SCEEN, OnUpdateAnimateSceen)
- ON_COMMAND(ID_VIEW_WIREFRAME, OnViewWireFrame)
- ON_UPDATE_COMMAND_UI(ID_VIEW_WIREFRAME, OnUpdateViewWireFrame)
- ON_COMMAND(ID_VIEW_FLATSHADE, OnViewFlatShade)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FLATSHADE, OnUpdateViewFlatShade)
- ON_COMMAND(ID_VIEW_DISPLAYAXIS, OnViewDisplayAxis)
- ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAYAXIS, OnUpdateViewDisplayAxis)
- ON_COMMAND(ID_VIEW_DISPLAYGRID, OnViewDisplayGrid)
- ON_UPDATE_COMMAND_UI(ID_VIEW_DISPLAYGRID, OnUpdateViewDisplayGrid)
- ON_COMMAND(ID_VIEW_ISO, OnViewIso)
- ON_UPDATE_COMMAND_UI(ID_VIEW_ISO, OnUpdateViewIso)
- ON_COMMAND(ID_VIEW_FRONT, OnViewFront)
- ON_UPDATE_COMMAND_UI(ID_VIEW_FRONT, OnUpdateViewFront)
- ON_COMMAND(ID_VIEW_SIDE, OnViewSide)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SIDE, OnUpdateViewSide)
- ON_COMMAND(ID_VIEW_TOP, OnViewTop)
- ON_UPDATE_COMMAND_UI(ID_VIEW_TOP, OnUpdateViewTop)
- ON_COMMAND(ID_VIEW_SMOOTHSHADE, OnViewSmoothShade)
- ON_UPDATE_COMMAND_UI(ID_VIEW_SMOOTHSHADE, OnUpdateViewSmoothShade)
- ON_WM_KEYDOWN()
- ON_COMMAND(ID_CAMERA_EDIT, OnCameraEdit)
- ON_WM_LBUTTONDOWN()
- ON_COMMAND(ID_VIEW_CULLFACES, OnViewCullfaces)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CULLFACES, OnUpdateViewCullfaces)
- ON_WM_LBUTTONDBLCLK()
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
- ON_COMMAND(ID_FILE_PAGE_SETUP, OnFilePageSetup)
- ON_COMMAND(ID_FILE_SAVE_IMAGE, OnFileSaveImage)
- ON_WM_RBUTTONDOWN()
- ON_WM_LBUTTONUP()
- ON_WM_SETCURSOR()
- ON_COMMAND(ID_VIEW_OUTLINE, OnViewOutline)
- ON_UPDATE_COMMAND_UI(ID_VIEW_OUTLINE, OnUpdateViewOutline)
- //}}AFX_MSG_MAP
- // Standard printing commands
- ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
- ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView construction/destruction
- CMyglView::CMyglView()
- {
- // Initialize our member variables
- m_pDC = NULL;
- m_hRC = NULL;
- m_nMouseZ = 0;
- m_CPointLeftButtonDown.x = 0;
- m_CPointLeftButtonDown.y = 0;
- m_fMouseZCoord = 0.0f;
- VecClear3f(m_fSelectedCoord);
- VecClear3f(m_fSelectedCoord2);
- VecClear3f(m_fLeftButtonDownCoord);
- }
- CMyglView::~CMyglView()
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView Camera view functions
- void CMyglView::ViewIso()
- {
- // Set the camera view type
- m_Camera.m_iViewType = VIEW_ISO;
- // Rotate about the X & Z-Axis
- m_Camera.SetRotation(-75.0f, 0.0f, -15.0f);
- }
- void CMyglView::ViewFront()
- {
- // Set the camera view type
- m_Camera.m_iViewType = VIEW_FRONT;
- // Rotate about the X-Axis
- m_Camera.SetRotation(-90.0f, 0.0f, 0.0f);
- }
- void CMyglView::ViewSide()
- {
- // Set the camera view type
- m_Camera.m_iViewType = VIEW_SIDE;
- // Rotate about the X & Z-Axis
- m_Camera.SetRotation(-90.0f, 0.0f, -90.0f);
- }
- void CMyglView::ViewTop()
- {
- // Set the camera view type
- m_Camera.m_iViewType = VIEW_TOP;
- // No Rotation
- m_Camera.SetRotation(0.0f, 0.0f, 0.0f);
- // No X or Y-Axis offsets
- m_Camera.m_fOrigin[X] = 0.0f;
- m_Camera.m_fOrigin[Y] = 0.0f;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView drawing
- void CMyglView::OnDraw(CDC* pDC)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(pDC->GetSafeHdc(), m_hRC, TRUE))
- return;
- // Display the world
- pWorld->DisplayWorld(pDC->GetSafeHdc(), &m_Camera, pDoc->m_dTime);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView printing
- BOOL CMyglView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CMyglView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
- {
- // TODO: Add your specialized code here and/or call the base class
-
- CView::OnPrepareDC(pDC, pInfo);
- }
- void CMyglView::OnFilePrintPreview()
- {
- // Since the default initialization of CView::OnFilePrintPreview() modifies
- // the window viewport and sends a WM_SIZE command, we capture the screen
- // DIB information BEFORE it is modified..
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(m_pDC->GetSafeHdc(), m_hRC, TRUE))
- return;
- // Read the window bits
- g_pBitmapBits = (GLubyte*)g_DibImage.ReadDIBitmap(&g_pBitmapInfo);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- // Now that we have the screen information, do the default initialization
- CView::OnFilePrintPreview();
- }
- void CMyglView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
- {
- // Gather some general information about the printer the
- // user selected..
- // Lock the handle to the structure to get a pointer
- LPDEVMODE pMode = (LPDEVMODE)::GlobalLock(pInfo->m_pPD->m_pd.hDevMode);
- // Get the printer name
- CString szPtrName;
- szPtrName.Format("%s", pMode->dmDeviceName);
- // Unlock the handles
- ::GlobalUnlock(pInfo->m_pPD->m_pd.hDevMode);
-
- int nBitsPerPixel = pDC->GetDeviceCaps(BITSPIXEL);
- int nColors = pDC->GetDeviceCaps(NUMCOLORS);
- int nBitPlanes = pDC->GetDeviceCaps(PLANES);
- int nColorRes = pDC->GetDeviceCaps(COLORRES);
- int nRasterCaps = pDC->GetDeviceCaps(RASTERCAPS);
- // Does the device support raster operations?
- if(nRasterCaps & RC_STRETCHBLT)
- g_bStretchBlt = TRUE;
- if(nRasterCaps & RC_STRETCHDIB)
- g_bStretchDIBits = TRUE;
- // Display in the debug window the information gathered
- TRACE("You selected printer '%s'n", szPtrName);
- TRACE("BitsPerPixel = %dn", nBitsPerPixel);
- TRACE("NumColors = %dn", nColors);
- TRACE("NumBitPlanes = %dn", nBitPlanes);
- TRACE("ColorResolution = %dn", nColorRes);
- TRACE("Supports StretchBlt = %dn", g_bStretchBlt);
- TRACE("Supports StretchDIBits = %dn", g_bStretchDIBits);
- if(!g_bStretchBlt && !g_bStretchDIBits)
- {
- char szError[100];
- sprintf(szError, "Printer '%s' does not support required functions!", szPtrName);
- AfxMessageBox( szError, MB_OK);
- }
- }
- void CMyglView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
- {
- HBRUSH brush; // Background brush for page
- POINT ImageSize; // Size of printed image
- POINT ImageOffset; // Offset from edges for image
- CRect rectPageMax; // Maximum usable Page rectangle
- CRect rectMargins; // Page margins, in device units
- CRect rectPageAdj; // Adjusted page area, in device units
- if(!pInfo->m_bPreview)
- {
- // Since we are not doing a print preview, go ahead and capture the screen
- // DIB information.
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(m_pDC->GetSafeHdc(), m_hRC, TRUE))
- return;
- // Read the window bits
- g_pBitmapBits = (GLubyte*)g_DibImage.ReadDIBitmap(&g_pBitmapInfo);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- }
- // Set our device context mapping mode.
- // Each logical unit is converted to 1 device pixel. Positive x is to
- // the right; positive y is down.
- pDC->SetMapMode (MM_TEXT);
- // Get our page margin size, in device units
- CalculateMargins(pDC, &rectMargins);
- // Get the maximum usable size of the page (in printer device points)
- rectPageMax.top = 0;
- rectPageMax.left = 0;
- rectPageMax.right = pDC->GetDeviceCaps(HORZRES);
- rectPageMax.bottom = pDC->GetDeviceCaps(VERTRES);
- // Create a white brush and clear the page
- brush = CreateSolidBrush(0x00ffffff);
- FillRect(pDC->GetSafeHdc(), &rectPageMax, brush);
- // Calculate the adjusted page area, in device units
- rectPageAdj.top = 0;
- rectPageAdj.left = 0;
- rectPageAdj.right = rectPageMax.right - (rectMargins.left + rectMargins.right);
- rectPageAdj.bottom = rectPageMax.bottom - (rectMargins.top + rectMargins.bottom);
- // Calculate the new image size and the image offset with image
- // centered on page
- ImageSize.x = rectPageAdj.right;
- ImageSize.y = (ImageSize.x * g_pBitmapInfo->bmiHeader.biHeight / g_pBitmapInfo->bmiHeader.biWidth);
- if (ImageSize.y > rectPageAdj.bottom)
- {
- ImageSize.y = rectPageAdj.bottom;
- ImageSize.x = ImageSize.y * g_pBitmapInfo->bmiHeader.biWidth / g_pBitmapInfo->bmiHeader.biHeight;
- }
- // Calculate the image offset
- ImageOffset.x = rectMargins.left + ((rectPageAdj.right - ImageSize.x)/2);
- ImageOffset.y = rectMargins.top + ((rectPageAdj.bottom - ImageSize.y)/2);
- // Set the bitmap stretching mode in the device context.
- // Note: The COLORONCOLOR mode is typically used to preserve
- // color in color bitmaps.
- SetStretchBltMode(pDC->GetSafeHdc(), COLORONCOLOR);
- // Does our device context support StretchDIBits?
- if(g_bStretchDIBits)
- {
- BOOL bRet = StretchDIBits(pDC->GetSafeHdc(),
- ImageOffset.x, ImageOffset.y,
- ImageSize.x, ImageSize.y,
- 0, 0,
- g_pBitmapInfo->bmiHeader.biWidth,
- g_pBitmapInfo->bmiHeader.biHeight,
- g_pBitmapBits,
- g_pBitmapInfo,
- DIB_RGB_COLORS,
- SRCCOPY);
- }
- else if(!g_bStretchBlt)
- {
- HDC hdc;
- HBITMAP bitmap;
- hdc = CreateCompatibleDC(pDC->GetSafeHdc());
- bitmap = CreateDIBitmap(hdc,
- &(g_pBitmapInfo->bmiHeader),
- CBM_INIT,
- g_pBitmapBits,
- g_pBitmapInfo,
- DIB_RGB_COLORS);
-
- HGDIOBJ temp = SelectObject(hdc, bitmap);
- BOOL bRet = StretchBlt(pDC->GetSafeHdc(),
- ImageOffset.x, ImageOffset.y,
- ImageSize.x, ImageSize.y,
- hdc,
- 0, 0,
- g_pBitmapInfo->bmiHeader.biWidth,
- g_pBitmapInfo->bmiHeader.biHeight,
- SRCCOPY);
- // Free our bitmap and bitmap device context
- DeleteObject(bitmap);
- DeleteDC(hdc);
- }
- // That's it. End the print job and free anything we allocated...
- // Delete our brush
- DeleteObject(brush);
- }
- void CMyglView::CalculateMargins(CDC* pDC, CRect* pRectMargins)
- {
- POINT pt;
- CRect rectUnPrintable;
- // Start by getting the dimensions of the unprintable part of the
- // page (in device units). GETPRINTINGOFFSET will tell us the left
- // and upper unprintable area.
- pDC->Escape(GETPRINTINGOFFSET, 0, NULL, &pt);
- rectUnPrintable.left = pt.x;
- rectUnPrintable.top = pt.y;
- // To get the right and lower unprintable area, we need to take
- // the entire width and height of the paper (GETPHYSPAGESIZE) and
- // subtract everything else.
- pDC->Escape(GETPHYSPAGESIZE, 0, NULL, &pt);
- rectUnPrintable.right = pt.x // total paper width
- - pDC->GetDeviceCaps(HORZRES)// printable width
- - rectUnPrintable.left; // left unprtable margin
-
- rectUnPrintable.bottom = pt.y // total paper height
- - pDC->GetDeviceCaps(VERTRES)// printable ht
- - rectUnPrintable.top; // rt unprtable margin
-
- // Convert the margin values from the Page Setup dialog
- // to device units and subtract the unprintable part we just
- // calculated.
- pt.x = pDC->GetDeviceCaps(LOGPIXELSX); // dpi in X directPageMaxion
- pt.y = pDC->GetDeviceCaps(LOGPIXELSY); // dpi in Y directPageMaxion
- pRectMargins->top = (long)(g_fMarginTop * pt.y) - rectUnPrintable.top;
- pRectMargins->bottom = (long)(g_fMarginBottom * pt.y) - rectUnPrintable.bottom;
- pRectMargins->right = (long)(g_fMarginRight * pt.x) - rectUnPrintable.right;
- pRectMargins->left = (long)(g_fMarginLeft * pt.x) - rectUnPrintable.left;
- // Ensure that our margins are in the printable range..
- if(pRectMargins->left < 0)
- pRectMargins->left = 0;
- if(pRectMargins->top < 0)
- pRectMargins->top = 0;
- if(pRectMargins->right < 0)
- pRectMargins->right = 0;
- if(pRectMargins->bottom < 0)
- pRectMargins->bottom = 0;
- // pRectMargins now contains the values used to shrink the
- // printable area of the page.
- // Convert to logical units and we're done!
- pDC->DPtoLP(pRectMargins);
- }
- void CMyglView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // Free the DIB bits
- if(g_pBitmapBits)
- free(g_pBitmapBits);
- // Free the DIB header info
- if(g_pBitmapInfo)
- free(g_pBitmapInfo);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView page setup
- void CMyglView::OnFilePageSetup()
- {
- float scale; // Our Page Setup margin scaling factor
- CPageSetupDialog psdlg; // Allocate the structure for our Page Setup dialog
- PRINTDLG printDlg; // Allocate the structure to store the returned printer info
- // Get the printer information
- AfxGetApp()->GetPrinterDeviceDefaults(&printDlg);
- // Lock the handles to the structures to get pointers
- LPDEVNAMES pDevNames = (LPDEVNAMES)::GlobalLock(printDlg.hDevNames);
- LPDEVMODE pDevMode = (LPDEVMODE)::GlobalLock(printDlg.hDevMode);
- // Allocate space for the Page Setup printer info structures
- psdlg.m_psd.hDevNames = ::GlobalAlloc(GPTR, ::GlobalSize(printDlg.hDevNames));
- psdlg.m_psd.hDevMode = ::GlobalAlloc(GPTR, ::GlobalSize(printDlg.hDevMode));
- // Lock the new handles
- LPDEVNAMES m_pDevNames = (LPDEVNAMES)::GlobalLock(psdlg.m_psd.hDevNames);
- LPDEVMODE m_pDevMode = (LPDEVMODE)::GlobalLock(psdlg.m_psd.hDevMode);
- // Copy the printer information into page setup dialog
- memcpy(m_pDevNames, pDevNames,
- (size_t)::GlobalSize(printDlg.hDevNames));
- memcpy(m_pDevMode, pDevMode,
- (size_t)::GlobalSize(printDlg.hDevMode));
- // Unlock the handles
- ::GlobalUnlock(printDlg.hDevNames);
- ::GlobalUnlock(printDlg.hDevMode);
- ::GlobalUnlock(psdlg.m_psd.hDevNames);
- ::GlobalUnlock(psdlg.m_psd.hDevMode);
- // Done initializing the CPageSetupDialog. This dialog will now
- // display the system default printer info
-
-
- // Determine the scaling factor of the Page Setup margins
- if(psdlg.m_psd.Flags & PSD_INTHOUSANDTHSOFINCHES)
- scale = 1000.0f;
- else if(psdlg.m_psd.Flags & PSD_INHUNDREDTHSOFMILLIMETERS)
- scale = 2540.0f; // 100*25.4mm/inch
- else
- scale = 1000.0f; // Default setting
- // Initialize our Page Setup dialog margin settings with
- // our CMyglView global margin settings
- psdlg.m_psd.rtMargin.top = (int)(g_fMarginTop*scale);
- psdlg.m_psd.rtMargin.bottom = (int)(g_fMarginBottom*scale);
- psdlg.m_psd.rtMargin.left = (int)(g_fMarginLeft*scale);
- psdlg.m_psd.rtMargin.right = (int)(g_fMarginRight*scale);
- // Display the Page Setup dialog..
- if(psdlg.DoModal() == IDOK)
- {
- // Select this printer as our default configuration
- AfxGetApp()->SelectPrinter(psdlg.m_psd.hDevNames, psdlg.m_psd.hDevMode);
- // Save the Page Setup dialog margin settings
- g_fMarginTop = (float)(psdlg.m_psd.rtMargin.top)/scale;
- g_fMarginBottom = (float)(psdlg.m_psd.rtMargin.bottom)/scale;
- g_fMarginLeft = (float)(psdlg.m_psd.rtMargin.left)/scale;
- g_fMarginRight = (float)(psdlg.m_psd.rtMargin.right)/scale;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView diagnostics
- #ifdef _DEBUG
- void CMyglView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CMyglView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CMyglDoc* CMyglView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyglDoc)));
- return (CMyglDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMyglView message handlers
- BOOL CMyglView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // OpenGL requires WS_CLIPCHILDREN and WS_CLIPSIBLINGS and must not
- // include CS_PARENTDC for the class style. Refer to SetPixelFormat
- // documentation in the "Comments" section for further information.
- cs.style |= (WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
- // Register a class with its own device context and the 'arrow' cursor
- cs.lpszClass = AfxRegisterWndClass(CS_OWNDC | CS_DBLCLKS |
- CS_HREDRAW | CS_VREDRAW,
- ::LoadCursor(NULL, IDC_ARROW));
- return CView::PreCreateWindow(cs);
- }
- int CMyglView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CView::OnCreate(lpCreateStruct) == -1)
- return -1;
- // Get the Device context to our window
- m_pDC = new CClientDC (this);
- if (m_pDC == NULL)
- return (-1);
- // Set our window pixel format for openGL rendering
- if(!the3dEngine.SetWindowPixelFormat(m_pDC->GetSafeHdc(),
- PFD_DRAW_TO_WINDOW | // Draw to Window (not bitmap)
- PFD_SUPPORT_OPENGL | // Support OpenGL calls in window
- PFD_DOUBLEBUFFER)) // Double buffered mode
- return -1;
- // Create the rendering context
- m_hRC = wglCreateContext(m_pDC->GetSafeHdc());
- if (!m_hRC)
- return -1;
- return 0;
- }
- BOOL CMyglView::OnEraseBkgnd(CDC* pDC)
- {
- // Override to keep the background from being erased everytime
- // the window is repainted
- return TRUE;
-
- // return CView::OnEraseBkgnd(pDC);
- }
- void CMyglView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
- if(!m_pDocument)
- return;
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(m_pDC->GetSafeHdc(), m_hRC, TRUE))
- return;
- // Reset our camera view
- m_Camera.ResetView(cx, cy);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- // Force a window repaint
- InvalidateRect(NULL, FALSE);
- }
- void CMyglView::OnPaletteChanged(CWnd* pFocusWnd)
- {
- if((the3dEngine.GetPalette() != NULL) && (pFocusWnd != this))
- {
- // Select the palette into the device context
- SelectPalette(m_pDC->GetSafeHdc(), the3dEngine.GetPalette(), FALSE);
- // Map entries to system palette
- RealizePalette(m_pDC->GetSafeHdc());
-
- // Remap the current colors to the newly realized palette
- UpdateColors(m_pDC->GetSafeHdc());
- return;
- }
- CView::OnPaletteChanged(pFocusWnd);
- }
- BOOL CMyglView::OnQueryNewPalette()
- {
- int iNumEntries; // Number of entries in the logical palette were
- // mapped to different entries in the system palette.
- // If the palette was created.
- if(the3dEngine.GetPalette())
- {
- // Selects the palette into the current device context
- SelectPalette(m_pDC->GetSafeHdc(), the3dEngine.GetPalette(), FALSE);
- // Map entries from the currently selected palette to
- // the system palette. The return value is the number
- // of palette entries modified.
- iNumEntries = RealizePalette(m_pDC->GetSafeHdc());
- // Repaint, forces remap of palette in current window
- InvalidateRect(NULL, FALSE);
- return iNumEntries;
- }
-
- return CView::OnQueryNewPalette();
- }
- void CMyglView::OnDestroy()
- {
- CView::OnDestroy();
- if(m_pDC)
- // Clean up rendering context stuff
- delete m_pDC;
- if(m_hRC)
- // Clean up rendering context stuff
- wglDeleteContext(m_hRC);
- }
- void CMyglView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
- {
- // Get a pointer to our Main Frame
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- ASSERT_VALID(pFrame);
- // Let the MainFrame know that we have changed views..
- pFrame->SendMessage(WM_REFRESH_DLG_BAR, RDB_NEW_USER_VIEW, 0L);
- CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
- }
- void CMyglView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // Get a pointer to our Main Frame
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- ASSERT_VALID(pFrame);
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Get a pointer to our worlds' selected object
- C3dObject* pObj = pWorld->m_pSelectedObj;
- // Get a pointer to our worlds' selected point
- C3dPoint* pPoint = pWorld->m_pSelectedPnt;
- // Calculate a new Mouse 'Z' value. Mouse 'Z' is mapped to
- // the mouse y position if the Right Mouse button is down
- // Save the mouse left button down screen position
- m_CPointLeftButtonDown = point;
- // Scale the mouse 'z' screen position to simulate a 'Z' world
- // coordinate.
- m_fMouseZCoord = (float)m_nMouseZ * g_fMouseZMult;
- // Convert the mouse left button down position to world
- m_Camera.GetWorldCoord(point.x, point.y, m_fMouseZCoord, m_fLeftButtonDownCoord);
- // Are we creating points?
- if(pDoc->m_bCreatePoints)
- {
- // Create a new C3dPoint and append to list
- C3dPoint* pPoint = new C3dPoint;
- ASSERT(pPoint);
-
- if(pDoc->m_bSnapToGrid)
- pWorld->m_pGrid->PointToGrid(&m_fLeftButtonDownCoord[X],
- &m_fLeftButtonDownCoord[Y],
- &m_fLeftButtonDownCoord[Z]);
- pPoint->SetOrigin(m_fLeftButtonDownCoord[X],
- m_fLeftButtonDownCoord[Y],
- m_fLeftButtonDownCoord[Z]);
- pWorld->m_PointList.Append(pPoint);
- // Save the pointer
- pWorld->m_pSelectedPnt = pPoint;
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- }
- // Selecting World Points?
- else if(pDoc->m_bSelectPoint)
- {
- GLfloat fMouseCoordinate[4];
- C3dPoint* pPoint;
- // Convert our point to 3D coordinates
- m_Camera.GetWorldCoord(point.x, point.y, m_fMouseZCoord, fMouseCoordinate);
- // Find the point from the point list.
- pPoint = pWorld->m_PointList.Find(m_fLeftButtonDownCoord[X],
- m_fLeftButtonDownCoord[Y],
- m_fLeftButtonDownCoord[Z],
- 0.1f);
- if(pPoint)
- // Save the point pointer
- pWorld->m_pSelectedPnt = pPoint;
- if(pWorld->m_pSelectedPnt)
- {
- // Set the selected coordinates
- m_fSelectedCoord[X] = pWorld->m_pSelectedPnt->m_fOrigin[X];
- m_fSelectedCoord[Y] = pWorld->m_pSelectedPnt->m_fOrigin[Y];
- m_fSelectedCoord[Z] = pWorld->m_pSelectedPnt->m_fOrigin[Z];
- }
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- }
- // Selecting Object Points?
- else if(pWorld->m_pSelectedObj && pDoc->m_bSelectObjPoints)
- {
- GLfloat fMouseCoordinate[4];
- C3dPoint* pPoint;
- // Convert our point to 3D coordinates
- m_Camera.GetWorldCoord(point.x, point.y, m_fMouseZCoord, fMouseCoordinate);
- // Find a point from the selected object
- pPoint = pWorld->m_pSelectedObj->FindPoint(&m_Camera,
- m_fLeftButtonDownCoord[X],
- m_fLeftButtonDownCoord[Y],
- m_fLeftButtonDownCoord[Z]);
- if(pPoint)
- {
- // Save the selected point and set the selected coordinates
- pWorld->m_pSelectedPnt = pPoint;
- pWorld->m_pSelectedObj->GetObjPointOrigin(pPoint,
- &m_fSelectedCoord[X],
- &m_fSelectedCoord[Y],
- &m_fSelectedCoord[Z]);
- // Save the inverse rotation transformation matrix of the
- // object. We will use this value in the OnMouseMove() function.
- // (We saved this matrix because an object, ie. light objects,
- // may modify their rotation values. Its also saves more
- // processing time, as we need this matrix to calcualte the
- // object coordinates.)
- pWorld->m_pSelectedObj->GetInvRotationMatrix(g_SelctedObjMatrix);
- }
- else if(pWorld->m_pSelectedPnt)
- {
- // Set the selected coordinates
- m_fSelectedCoord[X] = pWorld->m_pSelectedPnt->m_fOrigin[X];
- m_fSelectedCoord[Y] = pWorld->m_pSelectedPnt->m_fOrigin[Y];
- m_fSelectedCoord[Z] = pWorld->m_pSelectedPnt->m_fOrigin[Z];
- }
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- }
- // Selecting an Object?
- else if((pDoc->m_bSelectParentObj && pDoc->m_bSelect) ||
- (pDoc->m_bSelectChildObj && pDoc->m_bSelect))
- {
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(m_pDC->GetSafeHdc(), m_hRC, TRUE))
- return;
- // Did we select and object?
- C3dObject* pObject = pWorld->ProcessSelection(&m_Camera, point.x, point.y, pDoc->m_bSelectParentObj);
- if(pObject)
- {
- // Find the object in the tree view.
- HTREEITEM hItem = pFrame->m_wndTreeDlgBar.FindObject(pObject);
- if(hItem)
- pFrame->m_wndTreeDlgBar.SelectItem(hItem);
-
- // Save the pointer
- pWorld->m_pSelectedObj = pObject;
- pWorld->m_pSelectedPnt = NULL;
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- }
- else
- {
- pFrame->m_wndTreeDlgBar.SelectItem(NULL);
- pWorld->m_pSelectedObj = NULL;
- }
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- }
-
- // Save the appropriate selected Object's origin or translation value,
- // or the selected Points origin. This value will be used in the CMyglView::
- // OnMouseMove() function for later modification.
- if(pObj)
- {
- if(pDoc->m_bSelectParentObj || pDoc->m_bSelectChildObj)
- // Save the object's original origin
- pObj->GetOrigin(&m_fSelectedCoord[X],
- &m_fSelectedCoord[Y],
- &m_fSelectedCoord[Z]);
- if(pDoc->m_bSelectObjAxis)
- {
- // Save the object's original axis origin (Translation)
- pObj->GetTranslation(&m_fSelectedCoord[X],
- &m_fSelectedCoord[Y],
- &m_fSelectedCoord[Z]);
- // Save the object's original origin
- pObj->GetOrigin(&m_fSelectedCoord2[X],
- &m_fSelectedCoord2[Y],
- &m_fSelectedCoord2[Z]);
- }
- if(pDoc->m_bSelectObjTextureAxis)
- {
- if(pObj->m_pTexture)
- // Save the object's original texture axis origin
- pObj->m_pTexture->GetTextureOrigin3f(&m_fSelectedCoord[X],
- &m_fSelectedCoord[Y],
- &m_fSelectedCoord[Z]);
- }
- }
- // Save the camera origin coordinates. This value will be used in the CMyglView::
- // OnMouseMove() function for later modification.
- if(pDoc->m_bSelectCamera)
- // Save the object's original origin
- m_Camera.GetOrigin(&m_fSelectedCoord[X],
- &m_fSelectedCoord[Y],
- &m_fSelectedCoord[Z]);
- // Are we painting?
- if(pDoc->m_bPaint)
- {
- if(pDoc->m_bSelectParentObj || pDoc->m_bSelectChildObj)
- {
- // Paint the object
- if(pWorld->m_pSelectedObj)
- {
- pWorld->m_pSelectedObj->SetColor4fv(&pFrame->m_wndColorDlgBar.m_Color);
- pWorld->m_pSelectedObj->m_bBuildLists = TRUE;
- pWorld->m_pSelectedObj->m_bSolidColor = TRUE;
- }
- }
- if(pDoc->m_bSelectObjPoints)
- {
- if(pWorld->m_pSelectedPnt)
- {
- // Paint the point
- pWorld->m_pSelectedPnt->m_Color.SetColor4fv(&pFrame->m_wndColorDlgBar.m_Color);
- // If the point belongs to an object, force a rebuild of its
- // display list.
- if(pWorld->m_pSelectedObj)
- {
- pWorld->m_pSelectedObj->m_bBuildLists = TRUE;
- pWorld->m_pSelectedObj->m_bSolidColor = FALSE;
- }
- }
- }
- }
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- CView::OnLButtonDown(nFlags, point);
- }
- void CMyglView::OnLButtonUp(UINT nFlags, CPoint point)
- {
- // Reset the last Left button down mouse screen position an its
- // 3d coordinate.
- m_CPointLeftButtonDown.x = 0;
- m_CPointLeftButtonDown.y = 0;
- VecClear3f(&m_fLeftButtonDownCoord[0]);
-
- CView::OnLButtonUp(nFlags, point);
- }
- void CMyglView::OnLButtonDblClk(UINT nFlags, CPoint point)
- {
- // Get a pointer to our main window frame
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- ASSERT_VALID(pFrame);
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Make the rendering context current
- if(!the3dEngine.EnableRC(m_pDC->GetSafeHdc(), m_hRC, TRUE))
- return;
- // Did we select and object?
- C3dObject* pObject = pWorld->ProcessSelection(&m_Camera, point.x, point.y, pDoc->m_bSelectParentObj);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
-
- if(pObject)
- {
- // Save the object pointer
- pWorld->m_pSelectedObj = pObject;
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- // Update the TreeView Dialog Toolbar
- pFrame->m_wndTreeDlgBar.DisplaySelected(pObject);
- // Display the Object's attributes dialog box
- pWorld->m_pSelectedObj->EditAttributes(this, pWorld);
- // Force selection of parent objects
- pDoc->UserSelectedAnObject();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- else
- pWorld->m_pSelectedObj = NULL;
-
- CView::OnLButtonDblClk(nFlags, point);
- }
- void CMyglView::OnRButtonDown(UINT nFlags, CPoint point)
- {
- m_nInitMouseZ = point.y;
-
- CView::OnRButtonDown(nFlags, point);
- }
- void CMyglView::OnMouseMove(UINT nFlags, CPoint point)
- {
- VECTORF fMouseCoordinate;
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- ASSERT_VALID(pFrame);
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Get a pointer to our worlds' selected object and
- // selected light
- C3dObject* pObj = pWorld->m_pSelectedObj;
- // Calculate a new Mouse Z value. Mouse 'Z' is mapped to
- // the mouse y position if the Right Mouse button is down
- if(nFlags & MK_RBUTTON) {
- int deltaY = m_nInitMouseZ - point.y;
- m_nInitMouseZ = point.y;
- m_nMouseZ += deltaY;
- }
- // Convert the mouse point into world coordinates
- m_Camera.GetWorldCoord(point.x,
- point.y,
- m_fMouseZCoord,
- fMouseCoordinate);
- // Now that we have the mouse coordinate, subtract the Left button down
- // coordinate.
- if(nFlags & MK_LBUTTON)
- VecSubf(fMouseCoordinate, m_fLeftButtonDownCoord, fMouseCoordinate);
- // Lock the mouse coordinates?
- fMouseCoordinate[X] *= (float)pDoc->m_bUnLockXAxis;
- fMouseCoordinate[Y] *= (float)pDoc->m_bUnLockYAxis;
- fMouseCoordinate[Z] *= (float)pDoc->m_bUnLockZAxis;
- if(pDoc->m_bSnapToGrid)
- {
- // Round the 3d point to the nearest grid point
- pWorld->m_pGrid->PointToGrid(&fMouseCoordinate[X],
- &fMouseCoordinate[Y],
- &fMouseCoordinate[Z]);
- }
-
- // Object selected & left button down?
- if(pObj && (nFlags & MK_LBUTTON) )
- {
- // Modify Object?
- if(pDoc->m_bSelectParentObj || pDoc->m_bSelectChildObj)
- {
- // Move the selected object?
- if(pDoc->m_bMove)
- {
- GLfloat x, y, z;
- // Does this object have a parent?
- if(pObj->m_pParent)
- {
- Matx4x4 ObjRotationMatrix;
- // Get the inverse transformation matrix of the parent
- // object and multiply the mouse coordinate so that we
- // move the object in World coordinate space.
- pObj->m_pParent->GetInvRotationMatrix(ObjRotationMatrix);
- VecTransformf(fMouseCoordinate,
- fMouseCoordinate,
- ObjRotationMatrix);
- }
- // Note: We saved the Selected coordinate in the
- // WM_LBUTTONDOWN message handler.
- x = fMouseCoordinate[X]+m_fSelectedCoord[X];
- y = fMouseCoordinate[Y]+m_fSelectedCoord[Y];
- z = fMouseCoordinate[Z]+m_fSelectedCoord[Z];
- pObj->SetOrigin(x, y, z);
- }
- // Rotate the selected object?
- else if(pDoc->m_bRotate)
- {
- CSize rotate = m_CPointLeftButtonDown - point;
- m_CPointLeftButtonDown = point;
- if(m_Camera.m_iViewType == VIEW_ISO) {
- pObj->m_fRotation[Z] -= rotate.cx*g_fMouseRotateMult*pDoc->m_bUnLockZAxis;
- pObj->m_fRotation[X] -= rotate.cy*g_fMouseRotateMult*pDoc->m_bUnLockXAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_SIDE) {
- pObj->m_fRotation[Z] -= rotate.cx*g_fMouseRotateMult*pDoc->m_bUnLockZAxis;
- pObj->m_fRotation[Y] -= rotate.cy*g_fMouseRotateMult*pDoc->m_bUnLockYAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_TOP) {
- pObj->m_fRotation[Y] -= rotate.cx*g_fMouseRotateMult*pDoc->m_bUnLockYAxis;
- pObj->m_fRotation[X] -= rotate.cy*g_fMouseRotateMult*pDoc->m_bUnLockXAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_FRONT) {
- pObj->m_fRotation[Z] -= rotate.cx*g_fMouseRotateMult*pDoc->m_bUnLockZAxis;
- pObj->m_fRotation[X] -= rotate.cy*g_fMouseRotateMult*pDoc->m_bUnLockXAxis;
- }
- }
- // Scale the selected object?
- else if(pDoc->m_bScale)
- {
- CSize scale = m_CPointLeftButtonDown - point;
- m_CPointLeftButtonDown = point;
- if(m_Camera.m_iViewType == VIEW_ISO) {
- pObj->m_fScale[X] -= (float)scale.cx*g_fMouseScaleMult*pDoc->m_bUnLockXAxis;
- pObj->m_fScale[Y] -= (float)scale.cx*g_fMouseScaleMult*pDoc->m_bUnLockYAxis;
- pObj->m_fScale[Z] -= (float)scale.cy*g_fMouseScaleMult*pDoc->m_bUnLockZAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_SIDE) {
- pObj->m_fScale[Y] -= (float)scale.cx*g_fMouseScaleMult*pDoc->m_bUnLockYAxis;
- pObj->m_fScale[Z] -= (float)scale.cy*g_fMouseScaleMult*pDoc->m_bUnLockZAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_TOP) {
- pObj->m_fScale[X] -= (float)scale.cx*g_fMouseScaleMult*pDoc->m_bUnLockXAxis;
- pObj->m_fScale[Y] -= (float)scale.cy*g_fMouseScaleMult*pDoc->m_bUnLockYAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_FRONT) {
- pObj->m_fScale[X] -= (float)scale.cx*g_fMouseScaleMult*pDoc->m_bUnLockXAxis;
- pObj->m_fScale[Z] -= (float)scale.cy*g_fMouseScaleMult*pDoc->m_bUnLockZAxis;
- }
- }
- }
-
- // Modify Object point?
- if(pDoc->m_bSelectObjPoints)
- {
- // The object point was 'Selected' OnLButtonDown()
- C3dPoint* pPnt = pWorld->m_pSelectedPnt;
- // Do we have an object and point selected?
- if(pPnt && pObj)
- {
- // Move the Selected Point?
- if(pDoc->m_bMove)
- {
- // Matx4x4 ObjInvRotationMatrix;
- GLfloat x, y, z;
- // We saved the object inverse rotation matrix in the
- // OnLButtonDown() function. (We saved this matrix because
- // an object, ie. light objects, may modify their rotation
- // values. Its also saves more processing time..)
- // Use the inverse rotation transformation matrix of the
- // object and multiply it by the mouse coordinate so that
- // we move the point in the World coordinate space
- // pObj->GetInvRotationMatrix(ObjInvRotationMatrix);
- VecTransformf(fMouseCoordinate,
- fMouseCoordinate,
- g_SelctedObjMatrix);
- // ObjInvRotationMatrix);
- // Note: We saved the Selected coordinate in the
- // WM_LBUTTONDOWN message handler.
- x = fMouseCoordinate[X]+m_fSelectedCoord[X];
- y = fMouseCoordinate[Y]+m_fSelectedCoord[Y];
- z = fMouseCoordinate[Z]+m_fSelectedCoord[Z];
- pObj->SetObjPointOrigin(pPnt, x, y, z);
- // Rebuild the object
- pObj->m_bBuildLists = TRUE;
- }
- }
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- // Translate the selected objects' axis?
- if(pDoc->m_bSelectObjAxis)
- {
- // Move the selected object?
- if(pDoc->m_bMove)
- {
- GLfloat x, y, z;
- Matx4x4 ObjRotationMatrix;
- // Does this object have a parent?
- if(pObj->m_pParent)
- {
- VECTORF fMousePosn;
- // Get the inverse rotation matrix of the parent object
- // and multiply the mouse coordinate so that we move the
- // object's origin in World coordinate space.
- pObj->m_pParent->GetInvRotationMatrix(ObjRotationMatrix);
- VecTransformf(fMouseCoordinate,
- fMousePosn,
- ObjRotationMatrix);
- // Note: We saved the Selected coordinate in the
- // WM_LBUTTONDOWN message handler.
- pObj->m_fOrigin[X] = m_fSelectedCoord2[X]+fMousePosn[X];
- pObj->m_fOrigin[Y] = m_fSelectedCoord2[Y]+fMousePosn[Y];
- pObj->m_fOrigin[Z] = m_fSelectedCoord2[Z]+fMousePosn[Z];
- }
- else
- {
- // Object does not have a parent, mouse coordinates are already
- // in world coordinate space
- pObj->m_fOrigin[X] = m_fSelectedCoord2[X]+fMouseCoordinate[X];
- pObj->m_fOrigin[Y] = m_fSelectedCoord2[Y]+fMouseCoordinate[Y];
- pObj->m_fOrigin[Z] = m_fSelectedCoord2[Z]+fMouseCoordinate[Z];
- }
- // Get the inverse rotation matrix of this object, (with new origin)
- // and multiply the mouse coordinate so that we move the object
- // origin offset in World coordinate space.
- pObj->GetInvRotationMatrix(ObjRotationMatrix);
- VecTransformf(fMouseCoordinate,
- fMouseCoordinate,
- ObjRotationMatrix);
-
- // Note: We saved the Selected coordinate in the
- // WM_LBUTTONDOWN message handler.
- x = m_fSelectedCoord[X]-fMouseCoordinate[X];
- y = m_fSelectedCoord[Y]-fMouseCoordinate[Y];
- z = m_fSelectedCoord[Z]-fMouseCoordinate[Z];
- pObj->SetTranslation(x, y, z);
- }
- }
- // Translate the selected objects' texture axis?
- else if(pDoc->m_bSelectObjTextureAxis)
- {
- if(pObj->m_pTexture)
- {
- // Move the selected object?
- if(pDoc->m_bMove)
- {
- GLfloat x, y, z;
- Matx4x4 ObjRotationMatrix;
- /*
- // Does this object have a parent?
- if(pObj->m_pParent)
- {
- VECTORF fMousePosn;
- // Get the inverse rotation matrix of the parent object
- // and multiply the mouse coordinate so that we move the
- // object's origin in World coordinate space.
- pObj->m_pParent->GetInvRotationMatrix(ObjRotationMatrix);
- VecTransformf(fMouseCoordinate,
- fMousePosn,
- ObjRotationMatrix);
- // Note: We saved the Selected coordinate in the
- // WM_LBUTTONDOWN message handler.
- pObj->m_fOrigin[X] = m_fSelectedCoord2[X]+fMousePosn[X];
- pObj->m_fOrigin[Y] = m_fSelectedCoord2[Y]+fMousePosn[Y];
- pObj->m_fOrigin[Z] = m_fSelectedCoord2[Z]+fMousePosn[Z];
- }
- else
- {
- // Object does not have a parent, mouse coordinates are already
- // in world coordinate space
- pObj->m_fOrigin[X] = m_fSelectedCoord2[X]+fMouseCoordinate[X];
- pObj->m_fOrigin[Y] = m_fSelectedCoord2[Y]+fMouseCoordinate[Y];
- pObj->m_fOrigin[Z] = m_fSelectedCoord2[Z]+fMouseCoordinate[Z];
- }
- */
- // Get the inverse rotation matrix of this object, (with new origin)
- // and multiply the mouse coordinate so that we move the object
- // origin offset in World coordinate space.
- pObj->GetInvRotationMatrix(ObjRotationMatrix);
- VecTransformf(fMouseCoordinate,
- fMouseCoordinate,
- ObjRotationMatrix);
-
- // Note: We saved the Selected coordinate in the
- // WM_LBUTTONDOWN message handler.
- x = m_fSelectedCoord[X]-fMouseCoordinate[X];
- y = m_fSelectedCoord[Y]-fMouseCoordinate[Y];
- z = m_fSelectedCoord[Z]-fMouseCoordinate[Z];
- pObj->m_pTexture->SetTextureOrigin3f(x, y, z);
- pObj->m_bBuildLists = TRUE;
- }
- }
- }
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- // World point selected & left button down?
- C3dPoint* pPnt = pWorld->m_pSelectedPnt;
- if(pPnt && (nFlags & MK_LBUTTON) )
- {
- if(pDoc->m_bSelectPoint)
- {
- // Move the Selected Point?
- if(pDoc->m_bMove)
- {
- GLfloat x, y, z;
- // Note: We saved the Selected coordinate in the
- // WM_LBUTTONDOWN message handler.
- x = fMouseCoordinate[X]+m_fSelectedCoord[X];
- y = fMouseCoordinate[Y]+m_fSelectedCoord[Y];
- z = fMouseCoordinate[Z]+m_fSelectedCoord[Z];
- pPnt->SetOrigin(x, y, z);
- }
- }
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- if(pDoc->m_bSelectCamera && (nFlags & MK_LBUTTON))
- {
- // Move the camera?
- if(pDoc->m_bMove)
- {
- GLfloat x, y, z;
- VECTORF temp, mousePosn;
- Matx4x4 RotationMatrix;
- // Transform the mouse coordinates to camera coordinates
- Vec4f(fMouseCoordinate[X],
- fMouseCoordinate[Y],
- fMouseCoordinate[Z],
- 1.0f,
- temp);
- m_Camera.GetRotationMatrix(RotationMatrix);
- VecTransformf(temp, mousePosn, RotationMatrix);
-
- // Subtract the transformed mouse move coordinates from
- // the user selected OnLButtonDown coordinate and set
- // the camera origin accordinly.
- //
- // Note: We saved the initial camera coordinates
- // m_fSelectedCoord values in the
- // WM_LBUTTONDOWN message handler.
- VecSubf(m_fSelectedCoord, mousePosn, m_fSelectedCoord);
- UnVec3f(m_fSelectedCoord, &x, &y, &z);
- m_Camera.SetOrigin(x, y, z);
- }
- // Rotate the camera?
- if(pDoc->m_bRotate)
- {
- CSize rotate = m_CPointLeftButtonDown - point;
- m_CPointLeftButtonDown = point;
- if(m_Camera.m_iViewType == VIEW_ISO) {
- m_Camera.m_fRotation[Z] -= rotate.cx*g_fMouseRotateMult*pDoc->m_bUnLockZAxis;
- m_Camera.m_fRotation[X] -= rotate.cy*g_fMouseRotateMult*pDoc->m_bUnLockXAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_SIDE) {
- m_Camera.m_fRotation[Y] -= rotate.cx*g_fMouseRotateMult*pDoc->m_bUnLockZAxis;
- m_Camera.m_fRotation[X] -= rotate.cy*g_fMouseRotateMult*pDoc->m_bUnLockYAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_TOP) {
- m_Camera.m_fRotation[Z] -= rotate.cx*g_fMouseRotateMult*pDoc->m_bUnLockYAxis;
- m_Camera.m_fRotation[X] -= rotate.cy*g_fMouseRotateMult*pDoc->m_bUnLockXAxis;
- }
- else if(m_Camera.m_iViewType == VIEW_FRONT) {
- m_Camera.m_fRotation[Y] -= rotate.cx*g_fMouseRotateMult*pDoc->m_bUnLockZAxis;
- m_Camera.m_fRotation[X] -= rotate.cy*g_fMouseRotateMult*pDoc->m_bUnLockXAxis;
- }
- }
- // Update the Coordinate Dialog Toolbar
- pFrame->m_wndCoordDlgBar.UpdateDialogData();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- // Display the world coordinates on the status bar if we
- // are not animating the world..
- if(!pWorld->m_bAnimate)
- DisplayWorldCoord(fMouseCoordinate);
- CView::OnMouseMove(nFlags, point);
- }
- void CMyglView::OnViewPerspective()
- {
- if(m_Camera.m_bPerspective)
- m_Camera.m_bPerspective = FALSE;
- else
- m_Camera.m_bPerspective = TRUE;
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(GetDC()->m_hDC, m_hRC, TRUE))
- return;
- // Reset our camera view
- m_Camera.ResetView(NULL, NULL);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- void CMyglView::OnUpdateViewPerspective(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_Camera.m_bPerspective);
- }
- void CMyglView::OnViewZoomIn()
- {
- m_Camera.m_fOrigin[Z] = m_Camera.m_fOrigin[Z]/2;
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(GetDC()->m_hDC, m_hRC, TRUE))
- return;
- // Reset our camera view
- m_Camera.ResetView(NULL, NULL);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- void CMyglView::OnViewZoomOut()
- {
- m_Camera.m_fOrigin[Z] = m_Camera.m_fOrigin[Z]*2;
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(GetDC()->m_hDC, m_hRC, TRUE))
- return;
- // Reset our camera view
- m_Camera.ResetView(NULL, NULL);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- void CMyglView::OnAnimateSceen()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Toggle the animation flag
- pWorld->m_bAnimate = !pWorld->m_bAnimate;
- if(!pWorld->m_bAnimate)
- pDoc->m_dTime = 0.0; // Reset the time index
- }
- void CMyglView::OnUpdateAnimateSceen(CCmdUI* pCmdUI)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- pCmdUI->SetCheck(pWorld->m_bAnimate);
- }
- void CMyglView::OnViewWireFrame()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Set the rendering mode flag and force a
- // rebuild of all object display lists
- pWorld->m_iRenderMode = RENDER_WIREFRAME;
- pWorld->RebuildAllObjects();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- void CMyglView::OnUpdateViewWireFrame(CCmdUI* pCmdUI)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- pCmdUI->SetCheck(pWorld->m_iRenderMode == RENDER_WIREFRAME);
- }
- void CMyglView::OnViewFlatShade()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Set the rendering mode flag and force a
- // rebuild of all object display lists
- pWorld->m_iRenderMode = RENDER_FLAT;
- pWorld->RebuildAllObjects();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- void CMyglView::OnUpdateViewFlatShade(CCmdUI* pCmdUI)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- pCmdUI->SetCheck(pWorld->m_iRenderMode == RENDER_FLAT);
- }
- void CMyglView::OnViewSmoothShade()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Set the rendering mode flag and force a
- // rebuild of all object display lists
- pWorld->m_iRenderMode = RENDER_SMOOTH;
- pWorld->RebuildAllObjects();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- void CMyglView::OnUpdateViewSmoothShade(CCmdUI* pCmdUI)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- pCmdUI->SetCheck(pWorld->m_iRenderMode == RENDER_SMOOTH);
- }
- void CMyglView::OnViewOutline()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Set the rendering mode flag and force a
- // rebuild of all object display lists
- pWorld->m_iRenderMode = RENDER_OUTLINE;
- pWorld->RebuildAllObjects();
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- void CMyglView::OnUpdateViewOutline(CCmdUI* pCmdUI)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- pCmdUI->SetCheck(pWorld->m_iRenderMode == RENDER_OUTLINE);
- }
- void CMyglView::OnViewDisplayAxis()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- if(pWorld->m_bDisplayAxis)
- pWorld->m_bDisplayAxis = FALSE;
- else
- pWorld->m_bDisplayAxis = TRUE;
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- void CMyglView::OnUpdateViewDisplayAxis(CCmdUI* pCmdUI)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- pCmdUI->SetCheck(pWorld->m_bDisplayAxis);
- }
- void CMyglView::OnViewDisplayGrid()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- if(pWorld->m_bDisplayGrid)
- pWorld->m_bDisplayGrid = FALSE;
- else
- pWorld->m_bDisplayGrid = TRUE;
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- void CMyglView::OnUpdateViewDisplayGrid(CCmdUI* pCmdUI)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- pCmdUI->SetCheck(pWorld->m_bDisplayGrid);
- }
- void CMyglView::OnViewIso()
- {
- // Set the camera position
- ViewIso();
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- void CMyglView::OnUpdateViewIso(CCmdUI* pCmdUI)
- {
- if(m_Camera.m_iViewType == VIEW_ISO)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMyglView::OnViewFront()
- {
- // Set the camera position
- ViewFront();
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- void CMyglView::OnUpdateViewFront(CCmdUI* pCmdUI)
- {
- if(m_Camera.m_iViewType == VIEW_FRONT)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMyglView::OnViewSide()
- {
- // Set the camera position
- ViewSide();
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- void CMyglView::OnUpdateViewSide(CCmdUI* pCmdUI)
- {
- if(m_Camera.m_iViewType == VIEW_SIDE)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMyglView::OnViewTop()
- {
- // Set the camera position
- ViewTop();
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- void CMyglView::OnUpdateViewTop(CCmdUI* pCmdUI)
- {
- if(m_Camera.m_iViewType == VIEW_TOP)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMyglView::DisplayWorldCoord(VECTORF fMouseCoordinate)
- {
- // Display the world coordinates on the status bar
- char buf[80];
- float x = fMouseCoordinate[X];
- float y = fMouseCoordinate[Y];
- float z = fMouseCoordinate[Z];
-
- CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
- ASSERT(pFrame);
- CStatusBar* pStatus = &pFrame->m_wndStatusBar;
- ASSERT(pStatus);
- sprintf(buf, "'X'= %5.2f 'Y'= %5.2f 'Z'= %5.2fn", x, y, z);
- pStatus->SetPaneText(0, buf);
- }
- void CMyglView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- if(pWorld->m_bFly)
- {
- switch (nChar)
- {
- case VK_UP:
- m_Camera.m_fOrigin[Z] -=2.0f;
- break;
- case VK_DOWN:
- m_Camera.m_fOrigin[Z] +=2.0f;
- break;
- case VK_LEFT:
- m_Camera.m_fRotation[Z] -=2.0f;
- break;
- case VK_RIGHT:
- m_Camera.m_fRotation[Z] +=2.0f;
- break;
- default:
- break;
- }
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- if(!pWorld->m_bFly && nChar == VK_DELETE) // DELETE KEY PRESSED
- {
- if(pWorld->m_pSelectedObj)
- {
- // Get a pointer to the MainFrame
- CMyglApp* pApp = (CMyglApp *)AfxGetApp();
- ASSERT(pApp);
- if(pApp->m_bConfirmObjectDeletion)
- {
- char buf[80];
- sprintf(buf, "Do you want to delete object '%s'?n", pWorld->m_pSelectedObj->m_szName);
- if(AfxMessageBox(buf, MB_OKCANCEL) == IDOK)
- pWorld->DeleteObject(pWorld->m_pSelectedObj);
- else
- return;
- }
- else
- pWorld->DeleteObject(pWorld->m_pSelectedObj);
- pWorld->m_pSelectedObj = NULL;
- // Get a pointer to the MainFrame
- CMainFrame* pMainFrame = (CMainFrame*)pApp->m_pMainWnd;
- ASSERT(pMainFrame);
- // Force a refresh of the mainframe's dialog bars (TreeView, ..)
- pMainFrame->SendMessage(WM_REFRESH_DLG_BAR, RDB_FORCE_REFRESH, 0L);
- // Force a repaint of the documents views
- pDoc->UpdateAllViews(NULL);
- }
- }
- CView::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- void CMyglView::OnCameraEdit()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- // Edit the camera attributes
- if(m_Camera.EditAttributes(this, pWorld) == IDOK)
- {
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(m_pDC->GetSafeHdc(), m_hRC, TRUE))
- return;
- // Reset our camera view
- m_Camera.ResetView(NULL, NULL);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- // Force a repaint of the window
- InvalidateRect(NULL, FALSE);
- }
- return;
- }
- void CMyglView::OnViewCullfaces()
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- if(pWorld->m_bCullFaces)
- pWorld->m_bCullFaces = FALSE;
- else
- pWorld->m_bCullFaces = TRUE;
- // Force a repaint of the window
- pDoc->UpdateAllViews(NULL);
- }
- void CMyglView::OnUpdateViewCullfaces(CCmdUI* pCmdUI)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // Get a pointer to our document's 3dWorld
- C3dWorld* pWorld = pDoc->m_pWorld;
- ASSERT_VALID(pWorld);
- if(pWorld->m_bCullFaces)
- pCmdUI->SetCheck(TRUE);
- else
- pCmdUI->SetCheck(FALSE);
- }
- void CMyglView::OnFileSaveImage()
- {
- CFileDialog fileDlg(FALSE, NULL, NULL);
- fileDlg.m_ofn.lpstrFilter = "Bitmap Files (*.bmp) *.bmp ";
- fileDlg.m_ofn.lpstrTitle = "Save Image As";
- int retn = fileDlg.DoModal();
- if(retn == IDOK) {
- CString szFile = fileDlg.GetFileName();
- CString szPath = fileDlg.GetPathName();
- CString szFileExt = fileDlg.GetFileExt();
- if(szFileExt.Compare("") == 0)
- {
- // Assign the default 'bmp' extension
- szFileExt = _T("bmp");
- szFile += _T(".bmp");
- szPath += _T(".bmp");
- }
- if(szFileExt.Compare("bmp") == 0)
- {
- // Make this view the current OpenGL rendering context...
- if(!the3dEngine.EnableRC(m_pDC->GetSafeHdc(), m_hRC, TRUE))
- return;
- g_pBitmapBits = (GLubyte*)g_DibImage.ReadDIBitmap(&g_pBitmapInfo);
- g_DibImage.SaveDIBFile(szPath.GetBuffer(128), g_pBitmapInfo, g_pBitmapBits);
- // Releases the device context that is used by the rendering context
- // to allow other rendering contexts to co-exist.
- the3dEngine.EnableRC(NULL, NULL, FALSE);
- }
- else
- AfxMessageBox("Invalid File Extension! Select files with 'bmp' extension.", MB_OK, NULL);
- }
- }
- BOOL CMyglView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
- {
- // Get a pointer to our view's document
- CMyglDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if(pDoc->m_bPaint)
- {
- // Set our cursor and save the previous
- pDoc->m_hCursorPrev = ::SetCursor(pDoc->m_hPaintCursor);
- ::ShowCursor(TRUE);
- return TRUE;
- }
- return CView::OnSetCursor(pWnd, nHitTest, message);
- }