向 2D 对象添加 3D 效果 - DirectX
I wrote a simple program to load a directX .x mesh file. My loaded image is displayed like this
.
But the one which the MeshViewer shows is like this
.
What should be done to get the 3D look? Which call in the DirectX library should I make?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否将相同的文件加载到查看器中,就像加载到您自己的应用程序中一样?因为它实际上看起来网格中没有任何法线。如果您使用与查看器相同的文件,它们应该位于网格文件中。
除此之外,您的照明非常明亮(所有值均为 1.0),我会将漫反射值设置为 0.0 并尝试将环境设置为 0.5 红色。那么至少你可以判断你的灯是否正常工作。
Are you loading the same file into the viewer as into your own application? 'Cause it actually looks like you don't have any normals in the mesh. If your using the same file as the viewer, they should be in the mesh file though.
Other than that, your lighting is incredibly bright (all values at 1.0), I would set the diffuse values to 0.0 and try setting the ambient to 0.5 red. Then at least you can tell if your light is working.
看来你还没有设置任何灯光。
您必须加载网格中定义的材质,并设置至少一盏灯。
设置灯光后,使用 DirectX 9 中的固定管道的渲染代码如下所示:
如果您仍然看不到任何内容,请设置您自己定义的材质。
Looks like you haven't set any light.
You have to load the materials defined in the mesh, and set at least one light.
Once you've set a light, the rendering code using the fixed pipeline in DirectX 9 looks like this:
If you still don't see anything, set a material you've defined yourself.