XNA Essentials

Game Programming for Xbox 360, PC + Windows Phone


Help Needed - 3D Models

Hi Chad,

Hope you are well - im still ploughiung through the book, but thought i would take a breather and cement what i have learnt!


I have posted a forum page on Creators Club, but still an issue for me:




Your thoughts would be helpful if you have time.

Thanks Chad, diamond as always :)

garfbradaz - Wednesday, October 6, 2010 @ 11:24 AM

Re: Help Needed - 3D Models

You will still need to set the EnableTexture property on the BasicEffect.
Chad Carter - Monday, October 18, 2010 @ 7:45 PM

Re: Help Needed - 3D Models

The XNA CCO forums were down during the upgrade this entire time.  Did you get your problem resolved based on the feedback from the other forum?

Chad Carter - Tuesday, October 12, 2010 @ 3:33 PM

Re: Help Needed - 3D Models

Hey Chad,

Hope you are well? Yes, i was completely lost with CC FOrums...or should i say App Hub now! :)


The post is now:




I got lost again after trying a new model. Ive stopped at the moment moving on past the Skybox chapter, as it then starts to move onto 2D, and i really want to makesure ive understood what you have taught me so far. Its bloody hard, but im enoying it. My plan is to create a simple 2D game, and extend your Camera class to make a fixed camera. I want to use 3D models though for this - which is a simple side scrolling space shooter. Its also part of a 8Week competition to make a game!

garfbradaz - Wednesday, October 13, 2010 @ 2:07 PM

Re: Help Needed - 3D Models

I commented on that forum post. You may also want to check out the Transformations, Transformations Reloaded and Transformations Revolutions sections in Chapter 4.  (Pages 56-57,76-80)

Chad Carter - Wednesday, October 13, 2010 @ 2:43 PM

Re: Help Needed - 3D Models

Thanks Chad, im re-reading as i go on, and have to remember that the world matrix is used to transform from model to world space. I get alittle confuzzed with this sometimes. Can you have mulitple world matrices within the game? Is the world matrix just used ie the model is rendered relative to the world space?

garfbradaz - Wednesday, October 13, 2010 @ 3:10 PM

Re: Help Needed - 3D Models

You can definitely have mulitple world matrices in a game.  In fact, I typically have each 3D object have it's own world matrix. You can think of this value as "where do I want to be placed in the world?".

So I have a car with a world matrix that puts it in the origin of the world (0,0,0).

I have a person with a world matrix that puts it behind the car (-10,0,0).

I hope that helps.  Congratulations with all of the progress you are making!

Chad Carter - Thursday, October 14, 2010 @ 12:21 PM

Re: Help Needed - 3D Models

I think im getting myself in a pickle again - apoloies Chad - Its sinking in im sure. To recap:

1. I have removed the manual rotation values from the Model->Properties->Content Processer within VS.

2. Added the following 3 class members to my MovingModel class:

_rotate.X = 0.0f;

_rotate.Y = 90.0f;

_rotate.Z = 0.0f;

Added the following world matrix based on ISROT in Update:

if (keyboard.IsKeyDown(Keys.OemPeriod)) //"." - Move Right

_position.X += 1;


if (keyboard.IsKeyDown(Keys.OemComma)) //"," - Move Left

_position.X -= 1;


if (keyboard.IsKeyDown(Keys.P)) // - Move Up

_position.Y += 1;


if (keyboard.IsKeyDown(Keys.L))

_position.Y -= 1; // - Move Down


world = Matrix.Identity
* Matrix.CreateRotationX(MathHelper.ToRadians(_rotate.X))

* Matrix.CreateRotationY(MathHelper.ToRadians(_rotate.Y))

* Matrix.CreateRotationZ(MathHelper.ToRadians(_rotate.Z))

* Matrix.CreateTranslation(_position);

4. In the Draw method i have the following - Ive done the transform first for the world, because i presumed the bones (Count=3) would need to be transformed based on the origin of the parent bone first, then world space(?):

Matrix[] _transforms = new Matrix[model.Bones.Count];


foreach (ModelMesh _mesh in model.Meshes)


foreach (BasicEffect _be in _mesh.Effects)



_be.Projection = camera.Projection;

_be.View = camera.View;

_be.World = _transforms[_mesh.ParentBone.Index] * world;

//_be.World = world * _mesh.ParentBone.Transform;





THe probem is now, my texture isnt loaded and the model is all white. Is this an indication im doing something wrong. Sorry to keep asking the same sorts of questions Chad. Ive re-read the Transformations Reloaded, and i think im on the right track, just wanted an expert opinion, because the Texture isnt rendering i thought i must be doing something wrong.

garfbradaz - Thursday, October 14, 2010 @ 3:23 PM

Re: Help Needed - 3D Models

Sorry, missed this question.  The texture should be loaded if you set the .Texture property of your basic effect.  Check out the Texturing 3D Models section on pages 119-120.

Good luck!

Chad Carter - Sunday, October 17, 2010 @ 9:43 PM

Re: Help Needed - 3D Models

Hey Chad,

Done all that. In the .X file it references the following:


TextureFilename {    "SpaceShipUV.jpg";  }


NOw i have this texture saved within the same directory as the model, so when i compile it should be inlcuded within the .xnb. Now i can get it to load the texture from changing from:

_be.World = _transforms[_mesh.ParentBone.Index] * world;



 _be.World = _mesh.ParentBone.Transform * world;


Now in the XNA forums, Steve said to use _be.World = _transforms[_mesh.ParentBone.Index] * world; but this isnt working. Is the 2nd statement still correct?


garfbradaz - Monday, October 18, 2010 @ 3:19 PM