📄 projection.c
字号:
(clipRect.dy)--;
}
I3D_SetClipRect(pMe->m_p3D, &clipRect);
break;
default:
return FALSE;
}
return TRUE;
case EVT_KEY:
switch(wParam)
{
case AVK_1:
pMe->clipRectOp = UPPER_LX;
break;
case AVK_2:
pMe->clipRectOp = UPPER_LY;
break;
case AVK_3:
pMe->clipRectOp = CLIP_WIDTH;
break;
case AVK_4:
pMe->clipRectOp = CLIP_HEIGHT;
break;
// Show/Hide Commands
case AVK_POUND:
if(pMe->showHelp == FALSE)
pMe->showHelp = TRUE;
else if(pMe->showHelp == TRUE)
pMe->showHelp = FALSE;
break;
case AVK_CLR:
/*
User request to return to previous state. Set the next state,
and a flag, and wait until the current frame finishes rendering
before switching states. For information on why we do this,
read the comment in the parent event handler for the AVK_CLR event.
*/
// User changed the clipping rect, so restore the old one.
I3D_SetClipRect(pMe->m_p3D, &pMe->screen3DRect);
pMe->nextState = STATE_PROJECTION;
pMe->changeState = TRUE;
break;
default:
return FALSE;
}
return TRUE;
case EVT_COMMAND:
return TRUE;
default:
return FALSE;
}
}
/*===========================================================================
FUNCTION
OnProjectionFocal
DESCRIPTION
This function is called when the focal length menu item is selected.
Anything to do when first entering this tutorial should be done here,
ie. tutorial specific initializations.
PROTOTYPE:
static boolean OnProjectionFocal(TutorI3D* pMe)
PARAMETERS:
pMe [In] : Pointer to TutorI3D sturcture
DEPENDENCIES
none
RETURN VALUE
TRUE: If succeded
FALSE: If there was an error
SIDE EFFECTS
none
===========================================================================*/
static boolean OnProjectionFocal(TutorI3D* pMe)
{
return TRUE;
}
/*===========================================================================
FUNCTION
OnProjectionViewDepth
DESCRIPTION
This function is called when the view depth menu item is selected.
Anything to do when first entering this tutorial should be done here,
ie. tutorial specific initializations.
PROTOTYPE:
static boolean OnProjectionViewDepth(TutorI3D* pMe)
PARAMETERS:
pMe [In] : Pointer to TutorI3D sturcture
DEPENDENCIES
none
RETURN VALUE
TRUE: If succeded
FALSE: If there was an error
SIDE EFFECTS
none
===========================================================================*/
static boolean OnProjectionViewDepth(TutorI3D* pMe)
{
return TRUE;
}
/*===========================================================================
FUNCTION
OnProjectionScreenMapping
DESCRIPTION
This function is called when the screem mapping menu item is selected.
Anything to do when first entering this tutorial should be done here,
ie. tutorial specific initializations.
PROTOTYPE:
static boolean OnProjectionScreenMapping(TutorI3D* pMe)
PARAMETERS:
pMe [In] : Pointer to TutorI3D sturcture
DEPENDENCIES
none
RETURN VALUE
TRUE: If succeded
FALSE: If there was an error
SIDE EFFECTS
none
===========================================================================*/
static boolean OnProjectionScreenMapping(TutorI3D* pMe)
{
return TRUE;
}
/*===========================================================================
FUNCTION
OnProjectionClipRect
DESCRIPTION
This function is called when the clipping rect menu item is selected.
Anything to do when first entering this tutorial should be done here,
ie. tutorial specific initializations.
PROTOTYPE:
static boolean OnProjectionClipRect(TutorI3D* pMe)
PARAMETERS:
pMe [In] : Pointer to TutorI3D sturcture
DEPENDENCIES
none
RETURN VALUE
TRUE: If succeded
FALSE: If there was an error
SIDE EFFECTS
none
===========================================================================*/
static boolean OnProjectionClipRect(TutorI3D* pMe)
{
AEERect initClipRect;
// setup the initial clipping rectangle, as something smaller than
// the entire screen.
SETAEERECT(&initClipRect, pMe->di.cxScreen/4,DRAWING_AREA_3D_HEIGHT/4,
60,60);
I3D_SetClipRect(pMe->m_p3D, &initClipRect);
return TRUE;
}
/*===========================================================================
FUNCTION: ProjectionFocalManipulateBuf
DESCRIPTION
This function adds text and 2D graphics to the frame buffer after
3D frame render is complete for the focal length tutorial.
PROTOTYPE:
void ProjectionFocalManipulateBuf(TutorI3D* pMe)
PARAMETERS:
pMe: [in]: Pointer to TutorI3D sturcture
DEPENDENCIES
none
RETURN VALUE
none
SIDE EFFECTS
none
===========================================================================*/
void ProjectionFocalManipulateBuf(TutorI3D* pMe)
{
AECHAR szBuf[50];
char chBuf[50];
RGBVAL rgb;
uint16 fl;
int textWidth;
int nLine=0; // # of lines used to output text
int maxWidth;
int xText;
int yText;
if(!pMe)
return;
TutorI3D_SetTopMenuTextValues(pMe, &xText, &yText, &maxWidth);
TutorI3D_SetupTutorialWindow(pMe);
rgb = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_API_TEXT);
SPRINTF(chBuf, "I3D_SetFocalLength(flength)" );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
outputColorText(pMe, szBuf, 19, 7, xText, yText,
maxWidth, CLR_API_VAR_TEXT);
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, MENU_TEXT_CLR );
// Now draw the tutorial information in the bottom menu.
// First set the initial output point for the text and maxWidth.
TutorI3D_SetBottomMenuTextValues(pMe,&xText,&yText,&maxWidth);
I3D_GetFocalLength(pMe->m_p3D, &fl);
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
SPRINTF(chBuf, "flength = %d", fl );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth,
&textWidth );
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_BLACK);
STR_TO_WSTR("Press '#' for Help", szBuf, sizeof(szBuf));
IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf,
-1, 0, 0, NULL, IDF_ALIGN_CENTER| IDF_ALIGN_BOTTOM |
IDF_TEXT_TRANSPARENT);
if(pMe->showHelp)
{
IDISPLAY_EraseRect(pMe->a.m_pIDisplay, &pMe->screenAPI3DRect);
nLine = 0;
xText = pMe->menuTopRect.x + 1;
yText = pMe->menuTopRect.y + pMe->menuTopRect.dy + 5;
STR_TO_WSTR("Up: + flength", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("Down: - flength", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("#: show/hide help", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
}
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb);
}
/*===========================================================================
FUNCTION: ProjectionViewDepthManipulateBuf
DESCRIPTION
This function adds text and 2D graphics to the frame buffer after
3D frame render is complete for the view depth tutorial.
PROTOTYPE:
void ProjectionViewDepthManipulateBuf(TutorI3D* pMe)
PARAMETERS:
pMe: [in]: Pointer to TutorI3D sturcture
DEPENDENCIES
none
RETURN VALUE
none
SIDE EFFECTS
none
===========================================================================*/
void ProjectionViewDepthManipulateBuf(TutorI3D* pMe)
{
AECHAR szBuf[50];
char chBuf[50];
uint16 nz,fz;
RGBVAL rgb=0;
RGBVAL rgb1=0;
int textWidth;
int nLine=0; // # of lines used to output text
int maxWidth;
int xText;
int yText;
if(!pMe)
return;
TutorI3D_SetTopMenuTextValues(pMe, &xText, &yText, &maxWidth);
TutorI3D_SetupTutorialWindow(pMe);
rgb = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_API_TEXT);
SPRINTF(chBuf, "I3D_SetViewDepth(nearPln,farPln)" );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
outputColorText(pMe, szBuf, 17, 14, xText, yText,
maxWidth, CLR_API_VAR_TEXT);
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, MENU_TEXT_CLR );
// Now draw the tutorial information in the bottom menu.
// First set the initial output point for the text and maxWidth.
TutorI3D_SetBottomMenuTextValues(pMe,&xText,&yText,&maxWidth);
I3D_GetViewDepth(pMe->m_p3D, &nz, &fz);
if(pMe->viewDepthPlane == NEAR_PLANE)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "nearPln = %d", nz );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth,
&textWidth );
if(pMe->viewDepthPlane == NEAR_PLANE)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
else if(pMe->viewDepthPlane == FAR_PLANE)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "farPln = %d", fz );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText + nLine*pMe->charHeight,
-1, maxWidth, &textWidth );
if(pMe->viewDepthPlane == FAR_PLANE)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_BLACK);
SPRINTF(chBuf, "Model Z = %d", pMe->translateVector.z >> 16 );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText + nLine*pMe->charHeight,
-1, maxWidth, &textWidth );
STR_TO_WSTR("Press '#' for Help", szBuf, sizeof(szBuf));
IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_NORMAL, szBuf,
-1, 0, 0, NULL, IDF_ALIGN_CENTER | IDF_ALIGN_BOTTOM |
IDF_TEXT_TRANSPARENT);
if(pMe->showHelp)
{
IDISPLAY_EraseRect(pMe->a.m_pIDisplay, &pMe->screenAPI3DRect);
nLine = 0;
xText = pMe->menuTopRect.x + 1;
yText = pMe->menuTopRect.y + pMe->menuTopRect.dy + 5;
STR_TO_WSTR("Up: +", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText+nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("Down: -", szBuf, sizeof(szBuf));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -