First Attempt At 3D Spatial Partitioning

Last post 03-24-2008, 4:14 PM by Nick Gravelyn. 11 replies.
Sort Posts: Previous Next
  •  04-10-2007, 5:22 PM

    First Attempt At 3D Spatial Partitioning

    I stayed up til 7am last night trying to get my spatial partitioning to work and I think I've got it. It works with a few test objects, but I'm still not sure about it. I don't want to go onto the rest of my project and have this break down later, so I was wondering if anyone wouldn't mind checking it out to see if it looks alright. It might not be the most efficient overall, but it certainly cuts back on drawing nonetheless.

     Here's my Scene class. The update function has the rotating view just to give me an idea of what's going on. I've yet to get my camera system hooked into it yet.

    http://xna.multigan.com/pastebin/?page=view&id=1176239957

     

    And here's my PlaneSpaceTreeNode class. I tried commenting most of what I was doing when adding scene nodes so that someone reading it wouldn't have too much trouble understanding what I was going for.

    http://xna.multigan.com/pastebin/?page=view&id=1176239970

     

    Thanks for any advice or proofreads.
     



    Nick Gravelyn -- Microsoft XNA MVP
    XNA Wiki | Zune Games
  •  04-11-2007, 3:48 AM

    Re: First Attempt At 3D Spatial Partitioning

    Just a quick update for anyone interested. I did a few tweaks for stability (at a small performance hit) and now it's working great. I can create a cube that is 1000 units on all sides and fill it with 1500 very inefficiently drawn bounding boxes (not up to models yet). Each box sets some vertices and sets a vertex buffer. No batching or anything. I'm currently using a 1000 unit far plane distance. About the worst I've seen is a little over 200 being drawn at once (as far as normal flying around; obviously if I get right up to the edge and look back it's a bit worse). I rarely see a frame rate drop. And I assume all that could even be fixed by cleaning up the way I draw the boxes, but they're just debug displays so I'm not worried.


    Nick Gravelyn -- Microsoft XNA MVP
    XNA Wiki | Zune Games
  •  04-11-2007, 6:13 AM

    Re: First Attempt At 3D Spatial Partitioning

    Looks neat and straight forward, very nice code. Do you have any example programs that we can run?
  •  04-11-2007, 4:12 PM

    Re: First Attempt At 3D Spatial Partitioning

    Not yet. I want to get some model loading stuff in there and a few others before I put anything out. But hopefully not  too long.


    Nick Gravelyn -- Microsoft XNA MVP
    XNA Wiki | Zune Games
  •  04-11-2007, 4:31 PM

    Re: First Attempt At 3D Spatial Partitioning

    It's a bit much to look at without running the code. It does appear to use a bit more code than I would expect for what it is accomplishing however if it works and is faster than rendering the entire scene then its gold :)

     

     


    Ziggyware XNA News and Tutorials
  •  04-11-2007, 4:42 PM

    Re: First Attempt At 3D Spatial Partitioning

    Yeah. I'm not sure if I can cut back on code, but it does work so it's staying for now. :)


    Anyway, I finally got models to load and get inserted into the tree. So far the tree only manages static objects, but I'm trying to find an efficient way to let it store dynamic objects as well. But I have a demo. Just use the joysticks of a controller to move and look around, the triggers roll the camera, and A spawns 10 more models into the tree.

     Download Here.
     

    Let me know of any issues you find or any crashes. I haven't had any problems in a long time so I think I got most of them for now. 



    Nick Gravelyn -- Microsoft XNA MVP
    XNA Wiki | Zune Games
  •  04-11-2007, 4:49 PM

    Re: First Attempt At 3D Spatial Partitioning

    Works fine on my pc here at work without a controller and an Intel gfx chip :)

     

     


    Ziggyware XNA News and Tutorials
  •  04-12-2007, 4:03 AM

    Re: First Attempt At 3D Spatial Partitioning

    Any ideas on how to do some basic visibility testing? For instance I have some large objects loaded now that are completely blocking out objects and tree nodes, but they still render. What's a good approach to this? Even just the name of some system people use and I can google it. I've heard of "portals". Is that what they are for?


    Nick Gravelyn -- Microsoft XNA MVP
    XNA Wiki | Zune Games
  •  04-15-2007, 5:04 PM

    Re: First Attempt At 3D Spatial Partitioning

    So now that I feel confident in my solution for managing outdoor scenes of static objects, does anyone have any suggestions for either how to transition into solutions for indoor scenes or managing dynamic objects? I tried an idea I had but it failed miserably so I'm trying to think of a new way to handle it.


    Nick Gravelyn -- Microsoft XNA MVP
    XNA Wiki | Zune Games
  •  04-15-2007, 9:12 PM

    Re: First Attempt At 3D Spatial Partitioning

    SimReality:
    Any ideas on how to do some basic visibility testing? For instance I have some large objects loaded now that are completely blocking out objects and tree nodes, but they still render. What's a good approach to this? Even just the name of some system people use and I can google it. I've heard of "portals". Is that what they are for?

     

    I think what you're looking for is occlusion culling. There's a variety of methods to do it so I'd suggest you do some research on each and find out what method works best for you.


    XNA Game Blog - http://rhysyngsun.spaces.live.com/ and Personal Site
  •  03-24-2008, 4:02 PM

    Re: First Attempt At 3D Spatial Partitioning

    Hi I'm really interested in spatial partitioning do you have any example of this work ? I can provide you a level.

    I did the rhysyngsun tutorial and it don't seem to work for me. Maybe I don't know what kind of using I need to make the Geometry enter in the list.

    Anyway do you have a new version of your script ?

    cheers
  •  03-24-2008, 4:14 PM

    Re: First Attempt At 3D Spatial Partitioning

    akai kaze:
    Hi I'm really interested in spatial partitioning do you have any example of this work ? I can provide you a level.

    I did the rhysyngsun tutorial and it don't seem to work for me. Maybe I don't know what kind of using I need to make the Geometry enter in the list.

    Anyway do you have a new version of your script ?

    cheers


    I'll try and recreate it at some point (it's something I've been meaning to do), but it was pretty much a standard octree set up. Nothing special, really.


    Nick Gravelyn -- Microsoft XNA MVP
    XNA Wiki | Zune Games
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback