realbasic-games
[Top] [All Lists]

Re: Animation and memory issue

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Animation and memory issue
From: Frank Condello <developer at chaoticbox dot com>
Date: Mon, 25 Jul 2005 02:23:50 -0400
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <FF3D4383-F5B1-4405-A67F-BDF52954811A at miensoftware dot com> <D52AC133-DDD0-4558-8725-9508D39F6E79 at chaoticbox dot com> <F29BF550-E17D-4DD4-B907-AD971BCB8823 at miensoftware dot com> <8F479F6E-AC0F-4117-8F81-68A68C3A43E1 at chaoticbox dot com> <DE4335D4-957D-49C7-86EC-C6304D6238FA at miensoftware dot com>
On 24-Jul-05, at 7:00 PM, Lo Saeteurn wrote:

I don't know how you're creating trimeshes though - you really need to make them from scratch to ensure the data is yours and not just a copy you got from Quesa.

I'm working on this part right now. I'm still trying to learn how to use the Quesa Wrappers.

Here's what I have so far. I'm basically just trying to clone the Object.
//GetTriMesh returns the pointers to all the Trimeshes
  dim dis as DisplayGroup3D
  dim t,t2 as Trimesh3D
  Dim tmshes(0),i,c as integer, mem as MemoryBlock

  GetTriMesh(GetShapeHandle(mShape),tmshes)
  dis=new DisplayGroup3D

  c=UBound(tmshes)
  for i=1 to c
    t=new Trimesh3D(tmshes(i))
    mem=t.GetData
    t2=new Trimesh3D(mem)
    dis.AddObject t2
  next

Addshapefromhandle  dis.GetHandle

Here's where Quesa gets all convoluted...

The GetData call will create a copy inside Quesa of all the vertex data inside the trimesh (points, triangles, uvs, etc.). It doesn't copy the attribute set or textures however - it only grabs a reference to that stuff. So "t2" will be a copy of "t", with it's own points, triangles, uvs, (etc.), but it will share the same attribute set and texture shader.

Although it should be easy enough to share triangle indices with a couple Trimesh3D Lock/Unlocks and a pointer assignment it will be more difficult to share texture UV's since they're mashed in with normals and other crap inside the vertex attribute lump. You can thumb through the Trimesh3D class source to see how to get a particular vertex attribute data pointer, but if you get stuck I can try to walk you through it (honestly I've forgotten how it all works!) Alternately you can just live with the extra triangle and UV copies in the clones - at least the textures will be shared.

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>

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