您的位置:首页 > 其它

AE SceneControl 滚轮实现缩放功能

2012-05-07 16:59 567 查看
private void axSceneControl_OnMouseWheel(object sender, MouseEventArgs e)
{
try
{
System.Drawing.Point pSceLoc = axSceneControl1.PointToScreen(this.axSceneControl1.Location);
System.Drawing.Point Pt = this.PointToScreen(e.Location);
if (Pt.X < pSceLoc.X || Pt.X > pSceLoc.X + axSceneControl1.Width || Pt.Y < pSceLoc.Y || Pt.Y > pSceLoc.Y + axSceneControl1.Height)
{
return;
}
double scale = 0.2;
if (e.Delta < 0) scale = -0.2;
ICamera pCamera = axSceneControl1.Camera;
IPoint pPtObs = pCamera.Observer;
IPoint pPtTar = pCamera.Target;
pPtObs.X += (pPtObs.X - pPtTar.X) * scale;
pPtObs.Y += (pPtObs.Y - pPtTar.Y) * scale;
pPtObs.Z += (pPtObs.Z - pPtTar.Z) * scale;
pCamera.Observer = pPtObs;
axSceneControl1.SceneGraph.RefreshViewers();
}
catch
{
}
}


//添加滚轮事件

this.MouseWheel += new System.Windows.Forms.MouseEventHandler(axSceneControl_OnMouseWheel);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: