Exemple #1
0
//TODO: Depth of field disabled... fix it.
ray camera::makeRay(vec3d imLoc){
    //this jitter needs to be moved into the Up, Right basis:
    ray r;
    r.ori=eyePos;
    r.dir= (imLoc-eyePos).normal();
    
    //To point to the actual point, solve for collision with the focal plane...
    //this collision is solved by l . n !=0 which is known, due to the way we calcualte focalPoint
    //then d = (p0-l0).n / (l.n)
    //focal point is [0--it defines the plan
    // back is normal to the plane then
    
    double d = (focalPoint-r.ori).dot(Back)/(r.dir.dot(Back));
    vec3d target(d*r.dir+r.ori);
    
    //find the amount to move the lens by... //Jitter happened here.
    vec3d lensJitter = rectAdjust(Back,confRad*2,confRad*2);
    //target is the point on the focal plane the rays need to converge through
    // the new source is given by the lensJitter + imLoc;
    r.ori=imLoc+lensJitter;
    r.dir = (target-r.ori).normal();
    
    r.depth=0;
    r.ior=1;
    return r;
}
//*****************************************************************************
//
// Function Name:  RColorDialog::ShowPage
//
// Description:    Helper function for creating/displaying the correct
//						 property sheet in the tab control.
//
// Returns:        VOID
//
// Exceptions:	    None
//
//*****************************************************************************
void RColorDialog::ShowPage( int nPage )
{
	CDialog* pPrevPage  = m_pCurrentPage;
	CDialog* pPages[]   = { &m_dlgColorPalette, &m_dlgColorTexture, &m_dlgColorPhoto };
	int		pPageIDs[] = { DIALOG_COLOR_DIALOG_GRADIENTS, m_dlgColorTexture.IDD, m_dlgColorPhoto.IDD };

	TpsAssert( nPage < NumElements( pPages ), "Invalid page number!" );

	if (m_pCurrentPage != pPages[nPage])
	{
		m_pCurrentPage = pPages[nPage] ;

		if (!IsWindow( m_pCurrentPage->m_hWnd ))
		{
			CRect   rectAdjust(0,0,0,0);
			CRect   rectWindow(0,0,0,0);

			m_ctlTabCtrl.AdjustRect( TRUE, &rectAdjust );
			m_ctlTabCtrl.GetWindowRect( &rectWindow );

			rectWindow.left -= rectAdjust.left;
			rectWindow.top  -= rectAdjust.top;
			ScreenToClient( &rectWindow );

			if (!m_pCurrentPage->Create( pPageIDs[nPage], this ))
			{
				if (!pPrevPage) return ;

				// Restore the current page pointer to the previous one.
				m_pCurrentPage = pPrevPage ;
				pPrevPage = NULL;

				// Find the index of the previous page. (For setting the tab)
				for (int i = 0; i < NumElements( pPages ); i++)
				{
					if (m_pCurrentPage == pPages[i])
					{
						m_ctlTabCtrl.SetCurSel( i ) ;
						break ;
					}
				}
			}

			m_pCurrentPage->SetWindowPos( &wndTop, rectWindow.left,
				rectWindow.top, 0, 0, SWP_NOSIZE ) ;

		} // if (IsWindow())
			
	} // if (new page)

	if (pPrevPage && IsWindow( pPrevPage->m_hWnd ))
		pPrevPage->ShowWindow( SW_HIDE ) ;

	m_pCurrentPage->ShowWindow( SW_SHOW ) ;

	GetDlgItem( IDC_COLOR_MORE )->EnableWindow( m_pCurrentPage == &m_dlgColorPalette );
}