PDA

View Full Version : Model loading as green blob [XNA]



alexgeek
July 1st, 2008, 06:49 PM
I've got the basis of a game, a map is loaded which works fine and I'm trying to place a model onto the map which I made in Blender and exported as a directx file (car.x). I can view the car model in the directx viewer (http://i26.tinypic.com/2lvz4gi.jpg) but when it is drawn via XNA into the game it appears as a green blob and is rotated the wrong way (http://i28.tinypic.com/b7j190.jpg).
I'm using the effect file from the riemers site (http://users.pandora.be/riemer/files/effects.fx) which may be the problem but not really sure..
I use the following code to load my model:

private Model LoadModel(string assetName)
{

Model newModel = Content.Load<Model>(assetName);
foreach (ModelMesh mesh in newModel.Meshes)
foreach (ModelMeshPart meshPart in mesh.MeshParts)
meshPart.Effect = effect.Clone(device);
return newModel;
}

and this to draw the model:

private void DrawModel()
{
Matrix worldMatrix = Matrix.CreateScale(0.1f, 0.1f, 0.1f) * Matrix.CreateRotationY(MathHelper.Pi) * Matrix.CreateTranslation(new Vector3(19, 12, -5));

Matrix[ CharModelTransforms = new Matrix[Character.Bones.Count];
Character.CopyAbsoluteBoneTransformsTo(CharModelTr ansforms);
foreach (ModelMesh mesh in Character.Meshes)
{
foreach (Effect currentEffect in mesh.Effects)
{
currentEffect.CurrentTechnique = currentEffect.Techniques["Colored"];
currentEffect.Parameters["xWorld"].SetValue(CharModelTransforms[mesh.ParentBone.Index] * worldMatrix);
currentEffect.Parameters["xView"].SetValue(viewMatrix);
currentEffect.Parameters["xProjection"].SetValue(projectionMatrix);
}
mesh.Draw();
}
} I'm not sure what's going at all :|