Skip to main content
gamedev.net
🔒 Locked

Rendering a 3D Scene

Started by Rasta 4 replies 650+ views
Original Post
Rasta
Rasta
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
Cloxs
Cloxs
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."
Spellbound
Spellbound
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).
Joviex
Joviex
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
Rasta
Rasta
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
Spellbound
Spellbound
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.