📄 projection.c
字号:
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText+nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("1: near plane", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("2: far plane", 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: ProjectionScreenMapManipulateBuf
DESCRIPTION
This function adds text and 2D graphics to the frame buffer after
3D frame render is complete for the screen mapping tutorial.
PROTOTYPE:
void ProjectionScreenMapManipulateBuf(TutorI3D* pMe)
PARAMETERS:
pMe: [in]: Pointer to TutorI3D sturcture
DEPENDENCIES
none
RETURN VALUE
none
SIDE EFFECTS
none
===========================================================================*/
void ProjectionScreenMapManipulateBuf(TutorI3D* pMe)
{
AECHAR szBuf[50];
char chBuf[50];
int32 xscale, yscale;
int32 xshift, yshift;
AEEClip currentClipGraphics;
AEEClip screenClip;
AEERect currentClipRectDisplay;
// for drawing the origin point
AEEPoint origin;
uint8 oldPointSize;
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);
// change max width for the title output (because of long text width)
maxWidth = pMe->di.cxScreen;
SPRINTF(chBuf, "I3D_SetScreenMapping(sx,sy,sfx,sfy)" );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
outputColorText(pMe, szBuf, 21, 13, xText, yText,
maxWidth, CLR_API_VAR_TEXT);
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, MENU_TEXT_CLR );
maxWidth = pMe->di.cxScreen - 5;
// We need to set the IGRAPHICS and IDISPLAY clip rects here in order
// to draw the point and the associated text only in the 3D draw area.
// Get the original IGRAPHICS and IDISPLAY clip area, and set the new
// area.
IGRAPHICS_GetClip(pMe->m_pGraphics, ¤tClipGraphics);
makeAEEClipRectFromRect(&pMe->screenAPI3DRect, &screenClip );
IGRAPHICS_SetClip(pMe->m_pGraphics, &screenClip, (uint8) NULL);
IDISPLAY_GetClipRect(pMe->a.m_pIDisplay, ¤tClipRectDisplay);
IDISPLAY_SetClipRect(pMe->a.m_pIDisplay, &pMe->screenAPI3DRect);
I3D_GetScreenMapping(pMe->m_p3D, &xscale, &yscale, &xshift, &yshift);
// this is the new 3D origin taking into account the screen mapping
origin.x = (int16) xshift;
origin.y = (int16) yshift;
// draw a point at the origin
oldPointSize = IGRAPHICS_GetPointSize(pMe->m_pGraphics);
IGRAPHICS_SetPointSize(pMe->m_pGraphics, 5);
IGRAPHICS_SetColor(pMe->m_pGraphics, 100, 100, 200, 255);
IGRAPHICS_DrawPoint(pMe->m_pGraphics, &origin);
IGRAPHICS_SetColor(pMe->m_pGraphics, 0,0,0,255);
IGRAPHICS_SetPointSize(pMe->m_pGraphics, oldPointSize);
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, MAKE_RGB(100,100,200));
STR_TO_WSTR("I3D Origin", szBuf, sizeof(szBuf));
IDISPLAY_DrawText(pMe->a.m_pIDisplay, AEE_FONT_BOLD, szBuf,
-1, origin.x + 2, origin.y - 10, NULL,
IDF_TEXT_TRANSPARENT);
// restore the original clip areas
IGRAPHICS_SetClip(pMe->m_pGraphics, ¤tClipGraphics, (uint8) NULL);
IDISPLAY_SetClipRect(pMe->a.m_pIDisplay, ¤tClipRectDisplay);
// 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);
//IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_API_VAR_TEXT );
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, MENU_TEXT_CLR );
if(pMe->screenMapOp == XSCALE)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "x scale: sx = %d", xscale );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth,
&textWidth );
if(pMe->screenMapOp == XSCALE)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
else if(pMe->screenMapOp == YSCALE)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "y scale: sy = %d", yscale );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText + nLine*pMe->charHeight,
-1, maxWidth, &textWidth );
if(pMe->screenMapOp == YSCALE)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
else if(pMe->screenMapOp == XSHIFT)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "x shift: sfx = %d", xshift );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText + nLine*pMe->charHeight,
-1, maxWidth, &textWidth );
if(pMe->screenMapOp == XSHIFT)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
else if(pMe->screenMapOp == YSHIFT)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "y shift: sfy = %d", yshift );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText + nLine*pMe->charHeight,
-1, maxWidth, &textWidth );
if(pMe->screenMapOp == YSHIFT)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
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_RIGHT | 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));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText+nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("1: x scale", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("2: y scale", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("3: x shift", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("4: y shift", 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: ProjectionClipRectManipulateBuf
DESCRIPTION
This function adds text and 2D graphics to the frame buffer after
3D frame render is complete for the clipping rectangle tutorial.
PROTOTYPE:
void ProjectionClipRectManipulateBuf(TutorI3D* pMe)
PARAMETERS:
pMe: [in]: Pointer to TutorI3D sturcture
DEPENDENCIES
none
RETURN VALUE
none
SIDE EFFECTS
none
===========================================================================*/
void ProjectionClipRectManipulateBuf(TutorI3D* pMe)
{
AECHAR szBuf[50];
char chBuf[50];
AEERect clipRect;
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);
I3D_GetClipRect(pMe->m_p3D, &clipRect);
// draw the clip rect borders
IDISPLAY_DrawRect(pMe->a.m_pIDisplay, &clipRect, CLR_BLACK,
(RGBVAL) NULL, IDF_RECT_FRAME);
rgb = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, CLR_API_TEXT);
SPRINTF(chBuf, "I3D_SetClipRect(rect)" );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
outputColorText(pMe, szBuf, 16, 4, 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);
if(pMe->clipRectOp == UPPER_LX)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "left x: rect.x = %d", clipRect.x );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText, -1, maxWidth,
&textWidth );
if(pMe->clipRectOp == UPPER_LX)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
else if(pMe->clipRectOp == UPPER_LY)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "top y: rect.y = %d", clipRect.y );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText + nLine*pMe->charHeight,
-1, maxWidth, &textWidth );
if(pMe->clipRectOp == UPPER_LY)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
else if(pMe->clipRectOp == CLIP_WIDTH)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "width: rect.dx = %d", clipRect.dx );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText + nLine*pMe->charHeight,
-1, maxWidth, &textWidth );
if(pMe->clipRectOp == CLIP_WIDTH)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
else if(pMe->clipRectOp == CLIP_HEIGHT)
{
rgb1 = IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, ITEM_SELECT_COLOR);
}
SPRINTF(chBuf, "height: rect.dy = %d", clipRect.dy );
STR_TO_WSTR (chBuf, szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText, yText + nLine*pMe->charHeight,
-1, maxWidth, &textWidth );
if(pMe->clipRectOp == CLIP_HEIGHT)
{
IDISPLAY_SetColor(pMe->a.m_pIDisplay, CLR_USER_TEXT, rgb1);
}
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_RIGHT | 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));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText+nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("1: left x", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("2: top y", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("3: clip width", szBuf, sizeof(szBuf));
nLine += outputMultiLineStr(pMe, szBuf, -1, xText,
yText + nLine*pMe->charHeight,
-1, pMe->di.cxScreen -5, &textWidth);
STR_TO_WSTR("4: clip height", 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);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -