Hi, Preet,
Robert is probably offline now, so I'll attempt to pick up where he left
off...
On 02/14/2012 12:47 PM, Preet wrote:
I didn't understand what was meant by local origin here. Let's say I
have a model of the Sphinx I want to show on the surface of the Earth
(coincidentally I'm trying to display geospatial data).
Are you suggesting that I draw the model with coordinates relative to
the origin of of the scene first ('local'), then parent the
corresponding geode with a matrix transform that scales/moves/rotates
it out to the correct position on the Earth's surface ('world
coordinates')?
Exactly. This would allow the vertex coordinates (which are represented
with 32 bit floats) to work with enough precision to prevent the
instability you're seeing.
I found a few references online to a somewhat similar solution that
suggested transforming the entire scene so it's centered at the origin
before passing it to OpenGL. Is this a worse or better approach than
the suggested fix?
I'm not sure I follow this question. Centered at what origin?
I understand that numerical precision decreases when rendering a scene
further from the origin, because there are a finite set of numbers you
can represent in floating point. Using doubles for the transform and
carrying doubles throughout the scene graph traversals increases
precision right up until the data is passed to OpenGL. I didn't quite
follow your explanation about the camera and geometry translations
cancelling out though... could you expand on this a bit?
Both the camera's View matrix and the transforms in the scene (which
will be accumulated by OSG into a Model matrix) are represented with
doubles by default. This gives them plenty of precision to represent
large values.
Now, say you move the camera close to your sphinx model. This will
cause the Camera's View matrix to have a translation value that is close
to the inverse of the sphinx's accumulated Model matrix.
When the scene is traversed for rendering, the Model and View matrices
are combined into the OpenGL ModelView matrix, which must now be
represented as floats. However, the large (but opposite) translation
values will combine to a ModelView translation that is relatively small
before the matrix is sent to OpenGL. This means that the transformed
vertex coordinates will also be relatively small, and they'll still have
plenty of precision to work with when they're sent down the OpenGL
pipeline for rasterization.
--"J"
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org