On 25-Jul-05, at 4:37 PM, Lo Saeteurn wrote:
Yes unfortunately the built-in Trimesh3D methods have to make data
copies for certain things in order to work without requiring
special maintenance of the blocks elsewhere. But as you've
noticed, the Trimesh3D class provides constants for all the
offsets and methods to grab/return the raw data directly from/to
Quesa, so hopefully that'll make things easier.
One problem I'm encountering is how to register my Trimesh data to
Quesa. Does this even need to be done?
With Quesa you can use Trimesh3D.LockData and Trimesh3D.UnlockData.
This won't work on Quickdraw3D however, so it makes sense to keep a
copy of the trimesh data locally and calling Trimesh3D.SetData in
that case.
Is the object handle pretty much the pointer? If not, how do I get
an object handle from this custom trimesh?
Trimesh3D.GetHandle will give you the Quesa object handle if you need
it for custom declares.
If I'm replacing an existing data (such as the vertex array), how
do I dispose of it manually?
If you're keeping local memory blocks you'll have to hang on to them
as long as Quesa needs them. This could be a little tricky, but if
you create some wrapper classes and keep the Trimesh3D with your data
it everything will be in sync and just work automatically. A
simplified example would be:
AnimatedObject
.Mesh As Trimesh3D
.VertexPositions As MemoryBlock
.TriangleIndices As MemoryBlock
.TextureUVs As MemoryBlock
// normals, and any other vertex data...
Clones will have their own VertexPositions blocks and the others will
just be pointers to the original's blocks. This'll work even if you
trash the original before the clones since RB's reference counting
will keep the blocks around until all the clones are destroyed (you
can also clone a clone just fine).
One thing I didn't add was a public interface to pick out vertex/
face attribute data (which you'll need for UV's and normals) but
if you change the "Trimesh3D.GetAttributeDataPtr" function from
private to public, it should do everything you'll need.
Thanks for the info. How do I apply this to the new Trimesh data?
Trimesh attribute data is ugly and a pain to work with, but as long
as a lump is already there (i.e. the trimesh has UVs, or Normals,
etc) then all you have to do is grab the right pointer with
GetAttributeDataPtr and assign it to your block. Texture UVs would
work something like this:
Dim uvdataPtr, tmshData As Memoryblock
tmshData = tmsh.LockData
uvdataPtr = tmsh.GetAttributeDataPtr
(tmsh.kAttributeTypeShadingUV, tmsh.kOfsVertexAttributeTypes, tmshData)
// NOTE: if uvdataPtr is Nil, the mesh doesn't have UVs
if uvdataPtr <> Nil then uvdataPtr.Ptr(0) = myLocalUVdata
tmsh.UnlockData
I think that should do it, but I've never tried it myself so there
might be some nasty surprises. For example, I'm not sure what Quesa
will do with its internal uv data copy...
Frank.
–––––––––––––––––––––––––––––––––
Open Source RB Goodies and Shareware
<http://developer.chaoticbox.com/>
<http://www.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>
|