將頂點和索引緩衝區轉換為文件格式


0

我想在屏幕上渲染許多頂點和索引緩衝區。理想情況下,每個模型都位於世界空間內的不同位置。我實際上是在對世界空間模型之間的空間關係進行統計研究。

我已經在DirectX圖形管道上進行了大量閱讀,以嘗試並基本了解其工作方式。

我想從頭開始編寫自己的模型查看器,而不是從頭開始編寫程序,因此我想先看看一些預製的解決方案,以節省時間。我發現了:https://github.com/walbourn/directxtkmodelviewer

據我所知,它僅支持從DirectX SDK .SDKMESH文件和.VBO文件加載模型。所以有兩個問題:

1)如何將頂點和索引緩衝區轉換為這些文件格式之一?

2)要在查看器中更改模型的世界空間,不是在上傳模型之前通過更改視圖矩陣來完成的嗎?

此外,如果可以在標準3D建模應用程序中完成此操作,那將是理想的選擇。我要做的就是查看彼此之間的模型。但是,我找不到任何接受原始格式的頂點和索引緩衝區的應用程序。

謝謝。

3

No idea about DirectX, but in OpenGL the buffers are just a block of binary data so you can easily load and save them.

In any 3D framework, changing the object position to achieve a different relative arrangement of a scene is not done through the view matrix (that represents the camera position and viewing direction) but through the model matrix of each model. Note that the vertex and index buffers stay unaffected by matrix transformations, that is the main benefit of such pipelines.

Perhaps you could do your study with less effort using a 3D game engine, to list just a few:

I am not aware that any of them would support loading the raw buffers straight away, but they can load OBJ files. OBJ is one of the oldest text-based 3D model formats. It has a simple structure, so you can easily convert your buffer data to an OBJ file.