XNA Game Development Forums
2012/02/09 14:34:08 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Tut 6: Model Class  (Read 2207 times)
MicahN
Newbie
*
Offline Offline

Posts: 8


View Profile
« on: 2006/11/14 16:53:57 »

Mike,

I have really enjoyed your tutorials and have refactored a lot of my game code to model after yours.? So, I already had a model class written for Beta 2 before your tutorial and I have a question about your design.

In the RenderChildren method why did you NOT do somthing like this...

 /// <summary>
? ? ? ? /// Draws the model to the graphics stream
? ? ? ? /// </summary>
? ? ? ? /// <param name="device">Graphics Device object</param>
? ? ? ? public void RenderChildren(GraphicsDevice device)
? ? ? ? {


? ? ? ? ? ? // get the shader using the Shader object from the GEObject class

NOTE:? I moved this line in to the LoadGraphicsContent and made the shader object Class Level.
? ? ? ? ? ? Shader shader = ShaderManager.GetShader(this.shaderName);? ?
 ? ? ? ? shader.SetParameters(this);

? ? ? ? ? ? // loop through the meshes in the model.Meshes collection
? ? ? ? ? ? foreach (ModelMesh mesh in model.Meshes)
? ? ? ? ? ? {
? ? ? ? ? ? ?
? ? ? ? ? ? ? ? // loop through all of the child meshes
? ? ? ? ? ? ? ? foreach (ModelMeshPart part in mesh.MeshParts)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? // set the effect
? ? ? ? ? ? ? ? ? ? part.Effect = shader.EffectObject;


? ? ? ? ? ? ? ? } // end ModelMeshPart foreach

? ? ? ? ? ? ? ? mesh.Draw();

? ? ? ? ? ? } // end mesh foreach
? ? ? ? }


Your code seemed more complex and I was going for more of the "Let XNA do the work" with the Mesh.Draw().? I get the same effect with your code and mine.


Also, your camera causes my models to not be drawn 100% ( lots of culling going on ), where as if I use another camera ( Matrix based? ), my model is renderded correctly.

Anyway, just wondering if you noticed.

Thanx

Micah
« Last Edit: 2006/11/14 17:08:50 by MicahN » Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #1 on: 2006/11/15 05:59:44 »

The culling you are experiencing is probably due to the near and far clipping planes. These values are very adjustable and are usually tuned to the preference of the engine designer, so feel free to play with them. The main reason I went about my method of rendering the meshes was because the textures were not being set correctly on the device when the mesh parts were being rendered after I set my own effect on them. This may be just a Vista bug that isn't showing up in the "supported" versions of everything, but the suggestion for my method came straight from Shawn Hargreaves of the XNA team so I figured it would work fine. Originally I had exactly the same code you are using there, but tiny didn't look too good with a sky for a face Smiley
Logged
MicahN
Newbie
*
Offline Offline

Posts: 8


View Profile
« Reply #2 on: 2006/11/15 09:43:47 »

Mike,

I get the same face culling effect with your Demo 6 solution out of the box.? As I move the camera around, lots of faces of the tiger model are not getting drawn.? It is like only half of a quad is getting drawn as you move the model around.?

It is just confusing at first, but you are right, adjusting the clipping plane or just translating on the Z ( using the mouse buttons ) the model then renders completely and once is is out of the clipping plane it is gone, etc.  I get it now

Otherwise, a very solid reply to my question, your model rendering method has a little extra insurance in it.

Micah
« Last Edit: 2006/11/15 10:17:53 by MicahN » Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Tutorial 6 :: Getting a Model on Screen Tutorial Discussion mikeschuld 11 5368 Last post 2007/02/18 10:35:28
by Iarus
How To: Render a model with a texture?? Hazy Mind XNA Engine Quinn 6 2252 Last post 2007/01/07 00:33:58
by mikeschuld
Changing Sprite class texture coords? Hazy Mind XNA Engine Mithaearon 1 1953 Last post 2007/01/29 13:46:11
by h4rdc0m
Detecting Model Collision...? General Discussion « 1 2 » DaphydTheBard 15 4126 Last post 2007/03/27 01:29:52
by Nemo Krad
Model & Shader Problems Hazy Mind XNA Engine Themodem 5 1994 Last post 2007/03/26 11:12:53
by Tiago
Model exporters General Discussion EclipsE 13 3610 Last post 2007/04/26 12:25:03
by EclipsE
Loading a model in runtime? General Discussion XNASorcerer 10 3172 Last post 2007/05/06 21:22:42
by XNASorcerer
tut 5 Hazy Mind 3D Engine precious roy 2 1925 Last post 2007/08/03 12:17:08
by mikeschuld
Trouble with The ObjectComponent Class Hazy Mind XNA Engine Tyler 9 3074 Last post 2007/05/30 07:36:39
by Tyler
Tranforming a model's vertices Hazy Mind XNA Engine « 1 2 » DoomMarine 29 6666 Last post 2007/08/28 05:15:34
by DoomMarine
Game-ready model shops General Discussion Balosh 0 1564 Last post 2009/07/10 02:37:54
by Balosh
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.276 seconds with 21 queries.