XNA 4:导入FBX问题 [英] XNA 4: import FBX problem

查看:190
本文介绍了XNA 4:导入FBX问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从FBX文件导入3D模型时遇到问题。

I have a problem with importing 3D model from FBX file.

源模型包含575个对象+ 1个摄像头,如下所示: http://habreffect.ru/files/23d/542fa7f67/source_model.png

Source model contains 575 objects + 1 camera and looks like this: http://habreffect.ru/files/23d/542fa7f67/source_model.png

在XNA中准备的内容管道模型包含82个网格和576个骨骼。
因此,当我绘制模型时,我只看到源模型的一部分。结果图如下:
http://habreffect.ru/files/28a/ 6e61c0215 / Result_view.png

In XNA prepared with content pipeline model contains 82 meshes, and 576 bones. So, when I draw my model, I see only part of source model. Result picture like following: http://habreffect.ru/files/28a/6e61c0215/Result_view.png

我的绘图代码:

GraphicsDevice.Clear(Color.CornflowerBlue);

Matrix[] transforms = new Matrix[_model.Bones.Count];
_model.CopyAbsoluteBoneTransformsTo(transforms);

foreach (var mesh in _model.Meshes)
{
    foreach (BasicEffect effect in mesh.Effects)
    {
        effect.LightingEnabled = true;
        effect.EnableDefaultLighting();
        effect.World = transforms[mesh.ParentBone.Index] * _world;
        effect.View = _view;
        effect.Projection = _proj;
    }
    mesh.Draw();
}
base.Draw(gameTime);

如何在XNA中的Model实例中获取所有575个网格物体?

How can I get all 575 meshes in my Model instance in XNA?

谢谢!

UPD 我尝试将我的FBX模型导入3ds max,全选网格并使用导出选定。结果FBX文件大11倍。然后我将其作为内容添加到XNA项目中,加载的模型包含所有575个网格,并且它正确呈现。

不幸的是,这种手动转换方法不适合我 - 我需要从可变存储库中渲染各种fbx模型。

那么,什么FBX文件对XNA好内容处理器(我使用XNA 4)?

推荐答案

所以,在 MSDN 我发现FbxImporter设计用于2006.11版本的FBX格式。

So, on MSDN I found that FbxImporter designed to work with 2006.11 version of FBX format.

最近Autodesk发布了 FBX Converter 2012.1 ,其中包含其他工具,如FBX Eplorer,FBX Viewer。

Recently Autodesk released FBX Converter 2012.1, which contains other tools, like FBX Eplorer, FBX Viewer.

FBX explorer可以显示FBX文件的结构,我比较从3D MAX文件和源FBX文件导出。它们具有不同的内部格式。我尝试进行以下转换:FBX - > Collada - > FBX,结果FBX文件包含类似于从MAX数据结构导出的内容。

FBX explorer can show structure of FBX file, and I compare exported from 3D MAX file, and source FBX file. They have different internal format. I tried to make following conversion: FBX -> Collada -> FBX, and the result FBX file contains similar to exported from MAX data structure.

所以,我只需添加结果FBX到我的XNA应用程序的内容,并且它渲染得很好:)

So, I simply add the result FBX to Content of my XNA app, and it's rendered well :)

使其工作的另一种方法是使用Autodesk FBX SDK手动读取模型,并绘制它在XNA。

Another way to make it work is to use Autodesk FBX SDK to manually read model, and draw it in XNA.

结论


  1. XNA FbxImporter正确的工作不依赖于FBX文件的版本(2006,2011等)和格式(二进制,ascii)。内部FBX数据结构更加重要。

  2. 为了使FBX对XNA Importer可读,你可以使用像FBX这样的双重转换 - > Collada - > FBX

  3. 您也可以使用FBX SDK从FBX手动加载数据

这篇关于XNA 4:导入FBX问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆