Watkins, Steven M CIV NSWCDD, G24 wrote:
Hi Robert
I am probably much more confused than you are at this point! I am working on a simulation where it was required to incorporate BRLCAD models. BRLCAD are CSG models, though there are some tools to convert these models to polygonized formats (ie. STL), these tools generally produce errors on the more complex geometries. So by including these models into OpenSceneGraph I am mixing apples with oranges! What I have done so far:
1) Incorporated the BRLCAD pre-build libs and dll's in an OpenSceneGraph app. The BRLCAD is old "C" code that you can not even think about running the .h files through the C++ compiler. Just use void * pointers and move on.
2) Load a BRLCAD model, and generate a "point cloud" to display in OpenSceneGraph. The points are all determined using the native BRLCAD ray tracer. The "point cloud" is just to show the model and move around in the scene with a decent frame rate. Because the next step just kills the frame rate.
3) Once I get the model into the position I want, I toggle into a BRLCAD ray trace mode, where prior to the swapbuffers:
- Grab the frame buffer with a glReadPixels call.
- Generate a ray from each pixel location using the SceneView projection matrix.
- Using the BRLCAD ray tracer determine where/if the ray hit and come up with a
rgb value for the model (simple diffuse lighting model).
- Intersect the OSG scene with the same ray. If there are no intersections
before the BRLCAD intersection, replace the pixel values with BRLCAD derived
rgb values.
- Overwrite the frame buffer with a glDrawPixels.
- Drink lots of coffee, waiting for the scene to render.
One thing that pops to mind is to generate a color and depth 'image'
from the BRLCAD raytracer (not sure if rt already provides depth output,
but you should be able to easily add that), load them as textures in
OSG, then use a fragment shader on a screen-sized poly to composite the
BRLCAD images into the OSG scene. Should be a lot faster than trying to
use the IntersectionVisitor to find where the OSG scene obscured the
BRLCAD output, though you're still limited by how long rt takes to run.
Don
This works, in that the BRLCAD model is displayed as a "lit" model in the OpensceneGraph scene. Close up views occasionally show some subpixel? error. I was looking for a "better" method than above. I do realize that I am out in the wilderness with this one!
Thanks
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org