+ -
当前位置:首页 → 问答吧 → [300分]关于D3D中GenerateAdjacency函数的使用~~~~~~~~~~~~~~~~~~~~

[300分]关于D3D中GenerateAdjacency函数的使用~~~~~~~~~~~~~~~~~~~~

时间:2011-11-28

来源:互联网

Generate a list of mesh edges, as well as a list of faces that share each edge.

Syntax
Copy
 HRESULT GenerateAdjacency(
  [in] FLOAT Epsilon,
  [in] DWORD *pAdjacency
);
Parameters
Epsilon [in]
Type: FLOAT

Specifies that vertices that differ in position by less than epsilon should be treated as coincident.

pAdjacency [in]
Type: DWORD*

Pointer to an array of three DWORDs per face to be filled with the indices of adjacent faces. The number of bytes in this array must be at least 3 * ID3DXBaseMesh::GetNumFaces * sizeof(DWORD).

Return value
Type: HRESULT

If the method succeeds, the return value is D3D_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, E_OUTOFMEMORY.

Remarks
After an application generates adjacency information for a mesh, the mesh data can be optimized for better drawing performance.

The order of the entries in the adjacency buffer is determined by the order of the vertex indices in the index buffer. The adjacent triangle 0 always corresponds to the edge between the indices of the corners 0 and 1. The adjacent triangle 1 always corresponds to the edge between the indices of the corners 1 and 2 while the adjacent triangle 2 corresponds to the edge between the indices of the corners 2 and 0.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb205737(v=vs.85).aspx

上面是这个函数的基本介绍。俺在使用时发现,当mesh的顶点数超过2万时,此时大约有15000个三角面,此函数调用失败,2w个点以下函数调用成功。失败时返回值是E_FAIL,并木有返回上面提到的D3DERR_INVALIDCALL, E_OUTOFMEMORY.
俺的问题是:
这个D3D函数使用时,是否有内存大小或者显存大小的限制或者其他方面的限制。这个函数调用失败可能的原因有哪些?

望各位不吝赐教。

作者: Demon__Hunter   发布时间: 2011-11-28

该回复于2011-11-28 11:10:08被管理员删除

  • 对我有用[0]
  • 丢个板砖[0]
  • 引用
  • 举报
  • 管理
  • TOP
  • pengzhixi
  • (向taodm学习)
  • 等 级:
  • 2

    2

    3

#3楼 得分:0回复于:2011-11-28 11:13:15
GetError的结果是什么呢?

作者: Demon__Hunter   发布时间: 2011-11-28

俺说错了

是OptimizeInplace函数。
基本说明:http://msdn.microsoft.com/en-us/library/windows/desktop/bb174072(v=vs.85).aspx
俺在使用时发现,当mesh的顶点数超过2万时,此时大约有15000个三角面,此函数调用失败,2w个点以下函数调用成功。失败时返回值是E_FAIL(0x80004005),并木有返回D3DERR_INVALIDCALL, D3DXERR_CANNOTATTRSORT,E_OUTOFMEMORY.
俺的问题是:
这个D3D函数使用时,是否有内存大小或者显存大小的限制或者其他方面的限制。这个函数调用失败可能的原因有哪些?

作者: pengzhixi   发布时间: 2011-11-28

引用 3 楼 pengzhixi 的回复:
GetError的结果是什么呢?

GetLastError=0

作者: Demon__Hunter   发布时间: 2011-11-28

我记得0x80004000就是一个分界线了。估计是内存不够了。

作者: Demon__Hunter   发布时间: 2011-11-28

引用 6 楼 pengzhixi 的回复:
我记得0x80004000就是一个分界线了。估计是内存不够了。

2w个点不多啊,一个点假设占12Byte 240000Byte=240KB,不至于内存不够吧

作者: pengzhixi   发布时间: 2011-11-28

哎,权当散粉了~~~
300分的帖子沉的这么快

作者: Demon__Hunter   发布时间: 2011-11-28

2W个点,不仅仅是点占内存(显存),三角面也要占显存的,而且应该比点占得多,它应该中以像素形式存的的
可能的问题是显存不够


作者: Demon__Hunter   发布时间: 2011-11-28

显存不足应该不至于的。
d3d不熟,www.codesampler.com找找有没有类似的例子。

作者: keiy   发布时间: 2011-11-28

lz是搞3D的么?敢问现在工作内容是啥?

作者: dizuo   发布时间: 2011-11-28

win debug找找原因。

作者: dizuo   发布时间: 2011-11-28

引用 11 楼 dizuo 的回复:
lz是搞3D的么?敢问现在工作内容是啥?

俺搞GIS的,3D用到一些东西,主要是做三维地形啥的。

作者: zanfeng   发布时间: 2011-11-28

引用 12 楼 zanfeng 的回复:
win debug找找原因。

可以说详细些吗?木有看懂。。。

作者: Demon__Hunter   发布时间: 2011-11-28

引用 9 楼 keiy 的回复:
2W个点,不仅仅是点占内存(显存),三角面也要占显存的,而且应该比点占得多,它应该中以像素形式存的的
可能的问题是显存不够

多谢您的回帖。恩应该不是显存不够的原因,有些东西忘说了:
超过2w个点的时候,不用OptimizeInplace函数优化,可以绘制这些点构成的三角网,只是很卡。
但用OptimizeInplace优化,OptimizeInplace函数就会调用失败。

作者: Demon__Hunter   发布时间: 2011-11-28

换马甲顶上来吧,沉的太厉害了

作者: Demon__Hunter   发布时间: 2011-11-28

我觉得是显存不够,在调用OptimizeInplace前后,输出剩余显存是多少
如果2w个点太多,先慢慢减少这个值

作者: Dai_Dai_Cat   发布时间: 2011-11-29