Sign in to follow this  
  • entries
    686
  • comments
    1952
  • views
    386313

3D!

Sign in to follow this  

257 views

One of the new things I'm trying to do, that I've been wanting to do for a long time, is learn how to program 3D graphics(at least with XNA). So, sunday I started off with a few tutorials, learning how to load and render 3D models, and how to rotate them and move the camera.

I downloaded Anim8or as my 3D modeling program, mostly because it's free, but also because it is very simple to use. Today I attempted to apply texture mapping to a basic cube. I first tried what I thought would work:

foreach(ModelMesh mesh in _model.Meshes)
{
foreach(BasicEffect effect in mesh.Effects)
{
effect.View = view;
effect.Projection = projection;
effect.TextureEnabled = true;
effect.Texture = texture;
effect.World = _boneTransforms[mesh.ParentBone.Index] * x_rot_matrix * y_rot_matrix * z_rot_matrix * trans_matrix;
}
mesh.Draw();
}



and...It didn't work too well:


So, I'm going to start looking for some good tutorials on texture mapping. Unlike the last times I've tried to learn 3D graphics, I'm going to take this slow and try to learn the basics. So far it's going well.
Sign in to follow this  


6 Comments


Recommended Comments

It helps alot this time that I understand more of the math concepts behind 3D graphics, which before I had no clue about. But yeah, I'm going to keep my goals modest for now, so no First Person Shooters[grin]

Share this comment


Link to comment
Quote:
Original post by Stompy9999
effect.World = _boneTransforms[mesh.ParentBone.Index] * x_rot_matrix * y_rot_matrix * z_rot_matrix * trans_matrix;


I don't know if it's just how XNA or your modeling package works, but skeletal animations seem a bit ...overkill for some rotating cubes.

All in all, your first attempt isn't that bad. You do pretty clearly have some cubes that appear to be rotating around in your world, you just need to get your texture coords in order.

Welcome to the world of 3D!

Share this comment


Link to comment
I got that portion of the code from a tutorial(the original version draws a bunch of dice models to the screen). I'm actually loading the cubes from file, which is definetly a bit much, but I'm really not sure how else to do it. I'll have to see if there is a way to texture map the cube in it's current state, like applying the texture in the 3D editor.

Share this comment


Link to comment
Yeah, unless you're working with skeletal animation, you don't need to care about bones. Just replace the _boneTransforms[mesh.ParentBone.Index] with Matrix.Identity and it should work fine.

And welcome to the world of 3D. It can be an exercise in frustration, but I've never been able to go back to 2D.

Share this comment


Link to comment
Thanks! I do need to fix how I'm drawing the models, considering I'm not planning on using anything really complex, at least not for awhile.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now