realbasic-nug
[Top] [All Lists]

Re: gray scale image to RB3d mesh?

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: gray scale image to RB3d mesh?
From: Frank Condello <developer at chaoticbox dot com>
Date: Mon, 28 Feb 2005 02:20:44 -0500
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <FCF75D6F-8903-11D9-9ED8-000A95A06DBE at divergentmedia dot com>
On 27-Feb-05, at 4:10 PM, Mike Woodworth wrote:

i have a 3d depth map encoded as a gray scale image ie. lighter pixels are higher, darker pixels are lower. i believe this format has been used a lot to encode elevation data between apps.

I'm looking for an easy way to turn this image into a 3d object i can display in RB3d *programatically*. i am generating the images periodically in Rb, and want to allow them to be displayed in 3d for the user to interact with.

Converting the image to a mesh and getting that mesh into RB3D are actually two separate problems...

You may want to google for "3D heightmap" or "3D terrain" algorithms to find something suitable for your particular application, but the easiest method is to map each pixel to a 3D vertex, varying the Y coordinates according to the grey levels, and laying the X and Z coordinates out in a regular grid. Once this grid is established you simply connect the dots to create a triangle mesh. You may also need vertex normals if the 3D image is to be lit/shaded. These can be generated from the triangle data, or calculated deterministically from the image data, depending on the desired effect and accuracy required.

Once you have vertex and triangle data, you either need to build a 3DMF string and load that into RB3D using built-in mehtods, or use declares to create a trimesh directly with Quesa/QD3D. I can only recommend the 3DMF route for static data that's precached on launch or to disk, as it will likely be clunky for dynamic or real-time updates. If you choose the declare route, I have a large number of RB3D compatible classes available here: <http://developer.chaoticbox.com> (Quesa Wrappers) that may be of interest.

Frank.
------------
Open Source RB Plugins and Classes
<http://developer.chaoticbox.com>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>