XNA Game Development Forums
2012/05/18 05:29:05 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: 1 [2]
  Print  
Author Topic: Tutorial 11 :: Finishing our Culling, Complete Octree Funcionality  (Read 9016 times)
splr
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #15 on: 2007/08/10 11:49:39 »

hi, it's first post though i visit this site for a long time (from MDX times...). great tutorials, great forum, mike. thanks.

there is a question about octree.

when some object is rather large and it happens that it's located in 2 or more octnodes, the culling method that was described in tutorial is not suitable.
look at a picture for example. if node A is not visible by camera, but node B is, the object will be culled and we won't see it's part in node B. maybe it's not a real problem for small objects, but it's catastrophic for big ones.

maybe it's better to get bounding box (or sphere) for the object in LoadGraphicsContent method and just check if frustum contains it (yes, it won't be octree functionality, but i suppose it will look much more realistic).

i just don't know at the moment how to get bounding box for model (maybe just need to combine in some way bounding boxes from meshes?). will be happy if someone help with this.

..and sorry for my english if there are too many errors. it's just not my native language.

[attachment deleted by admin]
Logged
Nemo Krad
Global Moderator
Hero Member
*****
Offline Offline

Posts: 512


I have seen the fnords


View Profile WWW
« Reply #16 on: 2007/08/10 12:05:21 »

Had a discussion before on bounding box's here.

I have added some code to my content pipeline to create bounding box data. In the thread where we started to discuss bounding box's I gave an example of how I did it herehttp://www.thehazymind.com/smf/index.php/topic,212.msg6428.html#msg6428

The example allows you to create a bounding box for an X file mesh, if you have FBX models and the models have multiple mesh's then it will create a bounding box per mesh.

Hope this helps.
Logged
splr
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #17 on: 2007/08/10 20:05:23 »

thanks, i know how to get bounding box for a mesh. just think that some math is needed to create a box for a model. will look what can be done...
but it will be good to hear any other advice.
Logged
splr
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #18 on: 2007/08/11 00:58:27 »

i did it..
everything is much more easy than i thought. in fact, octree classes are not needed anymore!

made a small change to Model.Draw (or RenderChildren, if you use it) method and added new static field to SceneGraph to toggle culling:

Code:
//in EngineMode.Draw
public void Draw(GraphicsDevice device)
{
     //existing code
     foreach (ModelMesh mesh in model.Meshes)
            {
                BoundingSphere sphere = new BoundingSphere(mesh.BoundingSphere.Center, mesh.BoundingSphere.Radius);
                sphere.Center += position;
               
                if ((CameraManager.ActiveCamera.Frustum.Contains(sphere) != ContainmentType.Disjoint
                    && SceneGraph.IsCullingEnabled)
                    || !SceneGraph.IsCullingEnabled)
                {
                     //draw code.
                }
             }
}

//in SceneGraph
public static bool IsCullingEnabled = true;

It works fine.. Of course, with this you will not render those beatiful boxes (i mean octnodes) Smiley, but i suppose is't not a problem.
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #19 on: 2007/08/11 15:11:32 »

The octree method of culling will provide more speed up (because you can cull whole groups of objects out of a scene all at once), but for it to be completely effective we do need to get some bounding box stuff built in to the octree as well. There was a note for this mentioned at the end of the octree tutorial (I think Wink). Just haven't gotten around to it yet. Bounding boxes in my custom model type are coming in about 2 tutorials so we should be able to extend the octree functionality fairly soon as well. Thanks for all the great suggestions and background work you guys always do, it makes deciding on what to put in the tutorial engine next a lot easier
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Tutorial 14 Hazy Mind 3D Engine serus 3 3895 Last post 2008/12/19 10:32:01
by mikeschuld
Next Tutorial Hazy Mind XNA Engine mikeschuld 12 4868 Last post 2006/11/12 15:40:51
by mikeschuld
Having issues with tutorial 3 Hazy Mind XNA Engine siferion 4 2375 Last post 2006/11/26 14:04:03
by mikeschuld
360Homebrew Contest Complete General Discussion Chr0n1x 1 1524 Last post 2006/12/11 01:21:03
by endre
Tutorial 10 :: Preparing for Object Culling, a Simple Octree Tutorial Discussion « 1 2 » mikeschuld 17 7358 Last post 2010/11/23 09:07:20
by Neil_Knight
Tutorial 3 Hazy Mind XNA Engine hansonc 4 2480 Last post 2007/03/27 09:23:23
by hansonc
SceneGraph vs. Octree Hazy Mind XNA Engine Jonotron 7 4480 Last post 2007/08/14 06:22:27
by muchrejoicing
Tutorial 2 Hazy Mind XNA Engine Classicwarrior 5 2687 Last post 2008/05/17 23:01:31
by Classicwarrior
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.066 seconds with 19 queries.