📄 projection.c
字号:
return TRUE;
case EVT_COMMAND:
return TRUE;
default:
return FALSE;
}
}
/*===========================================================================
FUNCTION
TutorI3D_ProjectionViewDepthHandleEvent
DESCRIPTION
This is the Event Handler for the view depth tutorial. All events while in
the projection view depth state are processed by this event handler.
PROTOTYPE:
static boolean TutorI3D_ProjectionViewDepthHandleEvent(TutorI3D* pMe,
AEEEvent event,
uint16 wParam,
uint32 dwParam)
PARAMETERS:
pMe [In] : Pointer to TutorI3D sturcture
ecode [In]: Specifies the Event sent to the event handler
wParam, dwParam [In]: Event specific data.
DEPENDENCIES
none
RETURN VALUE
TRUE: If the event handler has processed the event
FALSE: If the event handler did not process the event
SIDE EFFECTS
none
===========================================================================*/
static boolean TutorI3D_ProjectionViewDepthHandleEvent(TutorI3D* pMe, AEEEvent event,
uint16 wParam, uint32 dwParam)
{
uint16 distanceNear;
uint16 distanceFar;
switch(event)
{
case EVT_KEY_RELEASE:
pMe->keyIsPressed = FALSE;
return TRUE;
case EVT_KEY_PRESS:
pMe->lastKeyPresswParam = wParam;
pMe->lastKeyPressdwParam = dwParam;
pMe->keyIsPressed = TRUE;
switch(wParam)
{
// increase plane distance
case AVK_UP:
I3D_GetViewDepth(pMe->m_p3D, &distanceNear, &distanceFar);
if(pMe->viewDepthPlane == NEAR_PLANE)
{
if(distanceNear + 10 < 32768) // check upper limit for near plane
distanceNear += 10;
}
else if (pMe->viewDepthPlane == FAR_PLANE)
{
if(distanceFar + 10 < 32768) // check upper limit for far plane
distanceFar += 10;
}
I3D_SetViewDepth(pMe->m_p3D, distanceNear, distanceFar);
break;
// decrease plane distance
case AVK_DOWN:
I3D_GetViewDepth(pMe->m_p3D, &distanceNear, &distanceFar);
if(pMe->viewDepthPlane == NEAR_PLANE) // check lower limit for near plane
{
if(distanceNear - 10 > 0)
distanceNear -= 10;
}
else if (pMe->viewDepthPlane == FAR_PLANE) // check lower limit for far plane
{
if(distanceFar - 10 > 0)
distanceFar -= 10;
}
I3D_SetViewDepth(pMe->m_p3D, distanceNear, distanceFar);
break;
default:
return FALSE;
}
return TRUE;
case EVT_KEY:
switch(wParam)
{
// change plane
case AVK_1:
pMe->viewDepthPlane = NEAR_PLANE;
break;
case AVK_2:
pMe->viewDepthPlane = FAR_PLANE;
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.
*/
pMe->nextState = STATE_PROJECTION;
pMe->changeState = TRUE;
break;
default:
return FALSE;
}
return TRUE;
case EVT_COMMAND:
return TRUE;
default:
return FALSE;
}
}
/*===========================================================================
FUNCTION
TutorI3D_ProjectionScreenMapHanldeEvent
DESCRIPTION
This is the Event Handler for the screen mapping tutorial. All events while in
the projection screen mapping state are processed by this event handler.
PROTOTYPE:
static boolean TutorI3D_ProjectionScreenMapHanldeEvent(TutorI3D* pMe, AEEEvent event,
uint16 wParam, uint32 dwParam)
PARAMETERS:
pMe [In] : Pointer to TutorI3D sturcture
ecode [In]: Specifies the Event sent to the event handler
wParam, dwParam [In]: Event specific data.
DEPENDENCIES
none
RETURN VALUE
TRUE: If the event handler has processed the event
FALSE: If the event handler did not process the event
SIDE EFFECTS
none
===========================================================================*/
static boolean TutorI3D_ProjectionScreenMapHanldeEvent(TutorI3D* pMe, AEEEvent event,
uint16 wParam, uint32 dwParam)
{
int32 xscale;
int32 yscale;
int32 xshift;
int32 yshift;
switch(event)
{
case EVT_KEY_RELEASE:
pMe->keyIsPressed = FALSE;
return TRUE;
case EVT_KEY_PRESS:
pMe->lastKeyPresswParam = wParam;
pMe->lastKeyPressdwParam = dwParam;
pMe->keyIsPressed = TRUE;
switch(wParam)
{
// increase screen map option
case AVK_UP:
I3D_GetScreenMapping(pMe->m_p3D, &xscale, &yscale, &xshift, &yshift);
// depending on which parameter is selected, increase it
if(pMe->screenMapOp == XSCALE)
xscale += SCALE_UNIT;
else if (pMe->screenMapOp == YSCALE)
yscale += SCALE_UNIT;
else if (pMe->screenMapOp == XSHIFT)
xshift++;
else if (pMe->screenMapOp == YSHIFT)
yshift++;
I3D_SetScreenMapping(pMe->m_p3D, xscale, yscale, xshift, yshift);
break;
// decrease screen map option
case AVK_DOWN:
I3D_GetScreenMapping(pMe->m_p3D, &xscale, &yscale, &xshift, &yshift);
// depending on which parameter is selected, decrease it
if(pMe->screenMapOp == XSCALE)
{
if( xscale - SCALE_UNIT > 0) // don't let scale get less than 0
xscale -= SCALE_UNIT;
}
else if (pMe->screenMapOp == YSCALE)
{
if( yscale - SCALE_UNIT > 0)
yscale -= SCALE_UNIT;
}
else if (pMe->screenMapOp == XSHIFT)
xshift--;
else if (pMe->screenMapOp == YSHIFT)
yshift--;
I3D_SetScreenMapping(pMe->m_p3D, xscale, yscale, xshift, yshift);
break;
default:
return FALSE;
}
return TRUE;
case EVT_KEY:
switch(wParam)
{
case AVK_1:
pMe->screenMapOp = XSCALE;
break;
case AVK_2:
pMe->screenMapOp = YSCALE;
break;
case AVK_3:
pMe->screenMapOp = XSHIFT;
break;
case AVK_4:
pMe->screenMapOp = YSHIFT;
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.
*/
pMe->nextState = STATE_PROJECTION;
pMe->changeState = TRUE;
break;
default:
return FALSE;
}
return TRUE;
case EVT_COMMAND:
return TRUE;
default:
return FALSE;
}
}
/*===========================================================================
FUNCTION
TutorI3D_ProjectionClipRectHanldeEvent
DESCRIPTION
This is the Event Handler for the clipping rect tutorial. All events while in
the projection clip rect state are processed by this event handler.
PROTOTYPE:
static boolean TutorI3D_ProjectionClipRectHanldeEvent(TutorI3D* pMe, AEEEvent event,
uint16 wParam, uint32 dwParam)
PARAMETERS:
pMe [In] : Pointer to TutorI3D sturcture
ecode [In]: Specifies the Event sent to the event handler
wParam, dwParam [In]: Event specific data.
DEPENDENCIES
none
RETURN VALUE
TRUE: If the event handler has processed the event
FALSE: If the event handler did not process the event
SIDE EFFECTS
none
===========================================================================*/
static boolean TutorI3D_ProjectionClipRectHanldeEvent(TutorI3D* pMe, AEEEvent event,
uint16 wParam, uint32 dwParam)
{
AEERect clipRect;
switch(event)
{
case EVT_KEY_RELEASE:
pMe->keyIsPressed = FALSE;
return TRUE;
case EVT_KEY_PRESS:
pMe->lastKeyPresswParam = wParam;
pMe->lastKeyPressdwParam = dwParam;
pMe->keyIsPressed = TRUE;
switch(wParam)
{
// increase clip rect
case AVK_UP:
I3D_GetClipRect(pMe->m_p3D, &clipRect);
if(pMe->clipRectOp == UPPER_LX)
{
// make sure right edge of clip rect doesn't exceed the screen
// area boundry on the right
if( (clipRect.x+1) + clipRect.dx <= pMe->screenAPI3DRect.x +
pMe->screenAPI3DRect.dx )
(clipRect.x)++;
}
else if (pMe->clipRectOp == UPPER_LY)
{
// make sure the bottom edge of clip rect stays within the screen
// area boundry at the bottom
if ( (clipRect.y+1) + clipRect.dy <= pMe->screenAPI3DRect.y +
pMe->screenAPI3DRect.dy )
(clipRect.y)++;
}
else if (pMe->clipRectOp == CLIP_WIDTH)
{
// make sure right edge of clip rect doesn't exceed the screen
// area boundry on the right
if( clipRect.x + (clipRect.dx+1) <= pMe->screenAPI3DRect.x +
pMe->screenAPI3DRect.dx )
(clipRect.dx)++;
}
else if (pMe->clipRectOp == CLIP_HEIGHT)
{
// make sure the bottom edge of clip rect stays within the screen
// area boundry at the bottom
if ( clipRect.y + (clipRect.dy+1) <= pMe->screenAPI3DRect.y +
pMe->screenAPI3DRect.dy )
(clipRect.dy)++;
}
I3D_SetClipRect(pMe->m_p3D, &clipRect);
break;
// decrease clip rec
case AVK_DOWN:
I3D_GetClipRect(pMe->m_p3D, &clipRect);
if(pMe->clipRectOp == UPPER_LX)
{
// make sure left edge of clip rect stays in draw window
if (clipRect.x-1 >= pMe->screenAPI3DRect.x )
(clipRect.x)--;
}
else if (pMe->clipRectOp == UPPER_LY)
{
// make sure top edge of clip rect stays in draw window
if (clipRect.y-1 >= pMe->screenAPI3DRect.y+1)
(clipRect.y)--;
}
else if (pMe->clipRectOp == CLIP_WIDTH)
{
// don't allow negative width
if (clipRect.dx - 1 > 0)
(clipRect.dx)--;
}
else if (pMe->clipRectOp == CLIP_HEIGHT)
{
// don't allow negative height
if (clipRect.dy - 1 > 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -