2011-11-26 3 views
4

나는 조작 된 애니메이션이있는 Blender (2.6+)에서 모델을 가지고 있습니다. FBX로 엑스포트하고 XNA로 가져 왔습니다. 나는 그것을 화면에 그리기 위해 호를 알고 있지만 애니메이션 (예 : "실행"이라고 함)을 어떻게 실행할 수 있습니까?XNA 4.0에서 블렌더 애니메이션을 어떻게 사용할 수 있습니까?

감사합니다.

+2

참조 http://create.msdn.com/en-US/education/catalo g/sample/custom_model_rigid_and_skinned 및 http://blog.diabolicalgame.co.uk/2011/07/exporting-animated-models-from-blender.html –

답변

7

SkinnedModelSample은 Microsoft에서 사용할 수 있습니다. 당신이 속성 상자에 SkinnedModelProcessor에 FBX 파일의 ContentProcessor 속성을 설정 확인, 그럼 당신은 (필요 최적화) 수행 할 수 있습니다

메인 게임 클래스 :

AnimationPlayer player;// This calculates the Matrices of the animation 
AnimationClip clip;// This contains the keyframes of the animation 
SkinningData skin;// This contains all the skinning data 
Model model;// The actual model 

LoadContent 방법 :

model = Content.Load<Model>("path_to_model"); 
skin = model.Tag as SkinningData;// The SkinnedModelProcessor puts skinning data in the Tag property 

player = new AnimationPlayer(skin); 
clip = skin.AnimationClips["run"];// The name of the animation 

player.StartClip(clip); 

그리기 방법 :

Matrix[] bones = player.GetSkinTransforms(); 

// Compute camera matrices. 
Matrix view = Matrix.CreateLookAt(new Vector3(0, 0, -30), // Change the last number according to the size of your model 
              new Vector3(0, 0, 0), Vector3.Up); 

Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 
                 device.Viewport.AspectRatio, 
                 1, 
                 10000); 

// Render the skinned mesh. 
foreach (ModelMesh mesh in model.Meshes) 
{ 
    foreach (SkinnedEffect effect in mesh.Effects) 
    { 
     effect.SetBoneTransforms(bones); 

     effect.View = view; 
     effect.Projection = projection; 

     effect.EnableDefaultLighting(); 

     effect.SpecularColor = new Vector3(0.25f); 
     effect.SpecularPower = 16; 
    } 

    mesh.Draw(); 
} 
관련 문제