- 积分
- 0
- 帖子
- 15
- 主题
- 2
- 精华
- 0
- 最后登录
- 2018-1-4
- 在线时间
- 24 小时
- 私信
|
发表时间 : 2011-5-24 17:25:54
|
浏览 : 1077 评论 : 3
新手一个 最近写了一个vega的键盘控制 可是h变化后,方向老是不对 现在把代码贴出来 请帮忙看看 谢谢
void CMYMFCVegaView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
// MessageBox (TEXT(" 121")) ;
obs = vgGetObserv(0);
myPos = vgNewPos();
vgGetPos (obs, myPos);
vgGetPosVec (myPos, &x, &y, &z, &h, &p, &r) ;
if(nChar == VK_ESCAPE)
{
if(m_pMainFrame->m_bFullScreen)
m_pMainFrame->FullScreenOff();
}
if (nChar == 'w')
{
y =y+ 5*cos(h) ;
x =x- 5*sin(h) ;
}
if (nChar == 'd')
{
// x =x+ 5sin(h) ;
}
vgPosVec( myPos, x, y, z, h, p, r );
vgPos ( obs, myPos );
vgDelPos(myPos );
CView::OnChar(nChar, nRepCnt, nFlags);
}
void CMYMFCVegaView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
//MessageBox (TEXT ("12")) ;
//toggleGfx ( VGGFX_TEXTURE) ;
vegaMove = TRUE ;
CView::OnLButtonDown(nFlags, point);
}
void CMYMFCVegaView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if(getVegaRunning() ==TRUE
&&(vegaMove))
{
obs = vgGetObserv(0);
myPos = vgNewPos();
vgGetPos (obs, myPos);
vgGetPosVec (myPos, &x, &y, &z, &h, &p, &r) ;
h = h-5 ;
vgPosVec( myPos, x, y, z, h, p, r );
vgPos ( obs, myPos );
vgDelPos(myPos );
}
CView::OnMouseMove(nFlags, point);
}
void CMYMFCVegaView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
vegaMove = FALSE ;
CView::OnLButtonUp(nFlags, point);
}
|
|