Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Rasta

Rendering a 3D Scene

This topic is 6644 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Maybe I am missing the concept a little, but can someone please explain this. I''m using D3D IM. If I have a large terrain with lots of 3D objects, and I am only pointing the camera at a small section of it, how would I tell the renderer to process only the objects that the camera sees? I know the renderer clips and draws what the camera can see (whether you give it some data or all of it), but what I am trying to ask is how do I let the renderer process only the objects that are currently visible in the range of the camera? Do I have to loop through all the objects in my world when rendering my scene? Rasta

Share this post


Link to post
Share on other sites
Advertisement
I think it automatically only renders what the camera can see...but I''m probably wrong (I just started D3D recently)

"When people tell you they want to hear the truth, you know that their lying."

Share this post


Link to post
Share on other sites
Although D3D clips all triangles so that nothing that is not seen is rendered it still has to process all triangles that are sent to it with DrawPrimitive() or DrawIndexedPrimitive(). What you want to do is to make sure the object is within the viewfrustum before rendering it. One common way of doing this is to check if the bounding sphere of the object is outside the frustum, if it is the object is culled, hence not rendered.

So yes you''ll will need to loop through all objects in the world. However with some clever structures you can cull several objects at a time (you can worry about this later though, when you have come far enough that it actually does any difference).

Share this post


Link to post
Share on other sites
What you actually want information about are space partitioning algos. BSP trees, Portals, Octrees, Quadtrees, etc. What these are used for is culling away all the non-visible polygons in a huge scene, greatly reducing overhead to the rasterizer, which speeds up the program.

Since you are just starting out, and this is an advanced topic, I would recommend using the technique mentioned above, using either bounding spheres (which is wasteful and less acurate than) or bounding boxes.

Any of these topics can be found on gamedev.net or flipcode.com

Share this post


Link to post
Share on other sites
Let''s say I''m trying to do something like a top-down isometric view of
a 2D tile-based game, but instead in 3D. I could have a large world
map with over 200 units, buildings, etc., so I would have a lot of
objects in my world to process.

If I am using an orthogonal projection, how would I treat my frustum?
Could I treat it as a 3D rectangle in space (with 90 deg angles), loop
through all my objects (I could treat them as 3D rectangles as well)
and test them to see if any intersect?

Hmmmm...now I wondering how I would test my terrain, as I''m thinking
if it''s treated as one object, wouldn''t it be huge to process?

Rasta

Share this post


Link to post
Share on other sites
Since you are doing a topdown view everything is very much simplified. Basically you can divide your world into a grid. Then you only need to process the gridsquares in the immediate vicinity of the viewfrustum. If you also let each these gridsquares have a list to the objects that are in the square, all those objects are culled if the square is outside the view.

With orthogonal projection the clipplanes of the frustum are all orthogonal to each other so, yes you can treat the view as a rectangle.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!