I’ve noticed that most 3d gaming/rendering environments represent solids as a mesh of (usually triangular) 3d polygons. However some examples, such as Second Life, or PovRay use solids built from a set of 3d primitives (cube, sphere, cone, torus etc) on which various operations can be performed to create more complex shapes.
So my question is: why choose one method over the other for representing 3d data?
I can see there might be benefits for complex ray-tracing operations to be able to describe a surface as a single mathematical function (like PovRay does), but SL surely isn’t attempting anything so ambitious with their rendering engine.
Equally, I can imagine it might be more bandwidth-efficient to serve descriptions of generalised solids instead of arbitrary meshes, but is it really worth the downside that SL suffers from (ie modelling stuff is really hard, and usually the results are ugly) – was this just a bad decision made early in SL’s development that they’re now stuck with? Or is it an artefact of what’s easiest to implement in OpenGL/DirectX?
EDIT:
Having read the answers so far, I’m now thinking that my two examples have very different reasons for using prims:
-
For PovRay, prims may be a side-effect of describing solids as maths functions, which gives benefits for complex ray-tracing.
-
Second Life seems mostly concerned with parametrizing their 3-d elements (both as prims, and as parametric human figures) for performance reasons… it makes perfect sense for an on-line game, I guess.
Higher-level “primitives” (spheres, cubes, etc.) carry with them more semantic information about what exactly they are, along with lower bandwidth/storage requirements (a sphere requires 2 parameters – center position and radius – while, say, an isosphere requires as many triangles as necessary to render the sphere).
Going with the primitives also allows the client-side engine to adjust its rendering based on local capabilities. If you say “sphere”, one client can render with M subdivisions and another with N; if you send the triangles, then the information necessary to re-render at a different resolution is missing. Also, it gives you opportunity to do things such as increase the subdivision count as you move closer to the object.
I don’t know what Linden Labs was thinking, as I have never worked with Second Life, but if I were building something like SL I would probably lean towards the primitives as the definition and transport format because they carry with them more information which can be used for things like re-rendering, hit detection, etc. Of course, in the end they’ll be converted to polygons for rendering, but that is an implementation detail.