English 中文(简体)
Xna进口场
原标题:import scene in xna
  • 时间:2012-01-12 10:01:56
  •  标签:
  • c#
  • xna

I have a scene that contains mutiple objects. How can i import it in xna and mentain each objects position? right now i export the scene in .fbx and load it in a model like this :

 cube.model = contentManager.Load<Model>("cub");

但是,这些物体并没有保留其立场,而且所有物体都在某一点收集。

我需要一种办法,把所有物体作为单个物体进口,但保留现场的物体位置?

(一) 需进口现场,以便一、可以操纵物体并保留其在现场的位置,以便我自己重新定位所有物体)

最佳回答

每一物体的现场位置都在 f。 实现这一转变和实施的方法是建立一个矩阵阵列,以掌握与现场有关的每个物体的转变,然后在设定效果时利用适当的转变。 每一物体在时间段内的世界。

//class variables
Matrix[] objectTransforms;

//LoadContent section
cube.model = contentManager.Load<Model>("cub");
objectTransforms = new Matrix[cube.model.Bones.Count];
cube.model.CopyAbsoluteTransformsTo(objectTransforms);// the magic is done here

//draw method
foreach(ModelMesh mm in cube.model.Meshes)
{
foreach (BasicEffect bfx in mm.Effects)
{
   bfx.World = objectTransforms[mm.ParentBone.Index] * whateverLocalTransformYouWant;
   //draw here
}
}

Without utilizing objectTransforms all objects will be drawn with their local origins located at the world origin, which sounds like what you are experiencing.

问题回答

我个人为我的游戏中的大部分事情做了一个级别编辑,但我确实有大量的画面,与其他模式相联。 这样,我就可以安排所有层次的模糊。 当我出口每件物品时,它确实保持了全球立场,在游戏中正确地进口。 我要说的是,这个问题在贵轴输出国。 应当选择保留地点。

你们使用哪些建模方案? 如果你使用bl子,就有一个专供XNA使用的纤维出口器。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签