文件名称:Picking
- 所属分类:
- 3D图形编程
- 资源属性:
- [Windows] [Visual.Net] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 5.08mb
- 下载次数:
- 0次
- 提 供 者:
- Jun ****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
思路: 场景中的每个mesh关联到一个唯一的COLOR值。 Pick检测时, 将当前场景渲染到纹理, (在PS中各mesh仅用自己的关键COLOR),即刻取回当前鼠标的位置的COLOR, 查找COLOR就可以知道当前被Pick的Mesh。
使用Render To Texture 的快速Picking, 无需锁住Vertex Buffer进行三角面和射线的相交测试, 仅在读取数据的时候锁住纹理的一个相素, 但是显卡要支持Render To Texture,纹理尺寸必须支持非2的n次方,D3DFMT_A8R8G8B8 或 D3DFMT_X8R8G8B8
可以改进的地方:
1。用类封装
2。Pick可以返回指向mesh的指针
需要:
DX SDK Aug, 2006以上,VC2005 -Ever mesh in the scene has a unique color value(DWORD). Picking, render the scene to target(texture), just use the unique color( see .fx file ), retrieve the mouse position(screen space ) color at once, check the color and you will get the mesh. Picking with Render to texture, Not need lock vertex buffer to check intersection ray and triangle, within retrieving just lock one pixel. Device must support render to target、D3DFMT_A8R8G8B8 or D3DFMT_X8R8G8B8、not 2^n texture size、support shader of course.
Compile Environment:
DX SDK above Aug. , 2006 vc 2005
Thinking:
1. Use a class to encapsulate
2. Picking check return the pointer of the mesh( or reference )
使用Render To Texture 的快速Picking, 无需锁住Vertex Buffer进行三角面和射线的相交测试, 仅在读取数据的时候锁住纹理的一个相素, 但是显卡要支持Render To Texture,纹理尺寸必须支持非2的n次方,D3DFMT_A8R8G8B8 或 D3DFMT_X8R8G8B8
可以改进的地方:
1。用类封装
2。Pick可以返回指向mesh的指针
需要:
DX SDK Aug, 2006以上,VC2005 -Ever mesh in the scene has a unique color value(DWORD). Picking, render the scene to target(texture), just use the unique color( see .fx file ), retrieve the mouse position(screen space ) color at once, check the color and you will get the mesh. Picking with Render to texture, Not need lock vertex buffer to check intersection ray and triangle, within retrieving just lock one pixel. Device must support render to target、D3DFMT_A8R8G8B8 or D3DFMT_X8R8G8B8、not 2^n texture size、support shader of course.
Compile Environment:
DX SDK above Aug. , 2006 vc 2005
Thinking:
1. Use a class to encapsulate
2. Picking check return the pointer of the mesh( or reference )
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Picking
.......\Common
.......\......\dxstdafx.cpp
.......\......\dxstdafx.h
.......\......\DXUT.cpp
.......\......\DXUT.h
.......\......\DXUTenum.cpp
.......\......\DXUTenum.h
.......\......\DXUTgui.cpp
.......\......\DXUTgui.h
.......\......\DXUTMesh.cpp
.......\......\DXUTMesh.h
.......\......\DXUTmisc.cpp
.......\......\DXUTmisc.h
.......\......\DXUTRes.cpp
.......\......\DXUTRes.h
.......\......\DXUTSettingsDlg.cpp
.......\......\DXUTSettingsDlg.h
.......\......\DXUTsound.cpp
.......\......\DXUTsound.h
.......\......\DXUT_2003.sln
.......\......\DXUT_2003.vcproj
.......\......\DXUT_2005.sln
.......\......\DXUT_2005.vcproj
.......\Media
.......\.....\Airplane
.......\.....\........\airplane 2.x
.......\.....\Misc
.......\.....\....\car.x
.......\.....\....\floor.bmp
.......\.....\....\sphere.x
.......\.....\UI
.......\.....\..\arrow.x
.......\.....\..\dxutcontrols.dds
.......\.....\..\DXUTShared.fx
.......\Picking.cpp
.......\Picking.manifest
.......\Picking.rc
.......\Picking_2003.sln
.......\Picking_2003.vcproj
.......\Picking_2005.ncb
.......\Picking_2005.sln
.......\Picking_2005.vcproj
.......\Picking_2005.vcproj.5E141221D0B64B8.yao.user
.......\Picking_2005.vcproj.RAINBOWKNIGHT.jqian.user
.......\resource.h
.......\ring.x
.......\room.x
.......\save.bmp
.......\Shader
.......\......\00.fx
.......\......\ObjectPickPS.psh
.......\......\ObjectPickVS.vsh
.......\......\RenderToTarget.fx
.......\......\RenderToTex.fx
.......\......\ShadowMap.fx
.......\spotlight.x
.......\Common
.......\......\dxstdafx.cpp
.......\......\dxstdafx.h
.......\......\DXUT.cpp
.......\......\DXUT.h
.......\......\DXUTenum.cpp
.......\......\DXUTenum.h
.......\......\DXUTgui.cpp
.......\......\DXUTgui.h
.......\......\DXUTMesh.cpp
.......\......\DXUTMesh.h
.......\......\DXUTmisc.cpp
.......\......\DXUTmisc.h
.......\......\DXUTRes.cpp
.......\......\DXUTRes.h
.......\......\DXUTSettingsDlg.cpp
.......\......\DXUTSettingsDlg.h
.......\......\DXUTsound.cpp
.......\......\DXUTsound.h
.......\......\DXUT_2003.sln
.......\......\DXUT_2003.vcproj
.......\......\DXUT_2005.sln
.......\......\DXUT_2005.vcproj
.......\Media
.......\.....\Airplane
.......\.....\........\airplane 2.x
.......\.....\Misc
.......\.....\....\car.x
.......\.....\....\floor.bmp
.......\.....\....\sphere.x
.......\.....\UI
.......\.....\..\arrow.x
.......\.....\..\dxutcontrols.dds
.......\.....\..\DXUTShared.fx
.......\Picking.cpp
.......\Picking.manifest
.......\Picking.rc
.......\Picking_2003.sln
.......\Picking_2003.vcproj
.......\Picking_2005.ncb
.......\Picking_2005.sln
.......\Picking_2005.vcproj
.......\Picking_2005.vcproj.5E141221D0B64B8.yao.user
.......\Picking_2005.vcproj.RAINBOWKNIGHT.jqian.user
.......\resource.h
.......\ring.x
.......\room.x
.......\save.bmp
.......\Shader
.......\......\00.fx
.......\......\ObjectPickPS.psh
.......\......\ObjectPickVS.vsh
.......\......\RenderToTarget.fx
.......\......\RenderToTex.fx
.......\......\ShadowMap.fx
.......\spotlight.x