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.
Okay, but if the data is from Quesa how do I release it? If I copy
the entire trimesh, re-reference all the data back to the original
data, then how do I dispose of the copies of the data that Quesa made
when creating a copy of the object.
Basically what I'm confused about is: if I use the New Trimesh
(existingtrimeshdata) to construct a new trimesh, does it create a
copy of everything (points, triangles, edges, etc.) or does it just
reference all the items?
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.
Okay, but what I meant was what if I create it completely from scratch:
//tmsh is an existing trimesh
dim tmsh as Trimesh3D
dim mem1, mem2 as memoryblock
mem1=tmsh.GetData
mem2=NewMemoryBlock(tmsh.kDataSize)
mem2.StringValue(0,mem2.Size)=mem1.StringValue(0,mem2.Size)
mem2.Ptr(tmsh.kOfsPoints)= NewMemoryBlock(NumberOfPoints*12)//
copy the points here
mem2 is the new trimesh and also a memoryblock, how do I add it to a
display group? This is assuming that calling "New Trimesh" copies all
the data including the points, triangles, etc. If it references
these, I should have no problem keeping just the Vertices locally.
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).
Okay I understand this.
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...
Okay.
_______________________________________________
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>
|