Home > 计算机与 Internet > 基于像素拾取的交点精确定位

基于像素拾取的交点精确定位

1 创建DepthStencilSurface,类型应当是D16_LOCKABLE, Discard应当是false,否则无法Lock;
2 设置为深度渲染对象,渲染场景;
3 LockRectangle at 查询点所在像素(x, y),类型UInt(WORD);
4 取出的值计为depthArray[0], (UInt型);
5 计算Vector3(x, y, (float)depth/65535.0f).UnProject(…)。
 
感谢 http://bbs.gameres.com/showthread.asp?postid=144490 在解读D16型ZBuffer方面做出的突出贡献。
Advertisements
Categories: 计算机与 Internet
  1. 2010年01月22日 at 9:57 am

    _device.DepthStencilSurface = _device.CreateDepthStencilSurface(_rendControl.Width, _rendControl.Height, DepthFormat.D16Lockable, MultiSampleType.None, 0, false);当执行:_display.Device.DepthStencilSurface.LockRectangle(LockFlags.ReadOnly);_display.Device.DepthStencilSurface.UnlockRectangle();时能锁定,但解锁时出错了。能帮看看是什么原因吗?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: