realbasic-games
[Top] [All Lists]

Re: Cloning Trimesh

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Cloning Trimesh
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Tue, 8 Nov 2005 12:03:04 -0700
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <14e78666b84e09bd1739f7ef5e4a01b6 at pyramiddesign dot us> <a0620070bbf967cab0ba4 at [10 dot 0 dot 1 dot 4]> <ba36e5adaa59b4786c9fd43570d48b38 at pyramiddesign dot us>
At 1:43 PM -0500 11/8/05, Joseph Nastasi wrote:

Here's what I did and it worked, but I did not get any noticeable speed increase.

Speed increase as compared to what?

In this case, I am loading 200 trimeshes, each a plane created with two triangles. The same 5k image is used as a texture.

Probably all that time is going into this line:

  clone.Material.Texture = original.Material.Texture

...which converts the internal texture into a Picture (on the right-hand side), and then converts a Picture into an internal texture (on the left-hand side). These are very expensive operations.

But I think you should be able to share the texture, like so:

  clone.Material = original.Material

which means you don't have a fully separate clone; a change to the material in one place would affect it in the other. But it sounds like that is fine for your purposes, and would be much faster.

Also... if you really do want to have the same object appearing multiple times in the scene, all with the same texture, then you'd be better off not using TriMesh at all, but using Object3D, which you could load once and then .Clone it (which really does share all the geometry data, unlike our trimesh cloning here). Is there some reason you can't do that -- the image not being available until runtime, perhaps?

If so, we may be able to hack something out using Object3D.AddShapeHandle, given the Trimesh handle -- I don't have the code or docs handy at the moment, so I can't be sure this is supported, but it might be. Let me know where you are and we'll keep working on it.

Best,
- Joe

--
Joe Strout                          REAL Software, Inc.

Vote for REALbasic (twice!) in the LinuxWorld Reader's Choice Awards:
http://linux.sys-con.com/general/readerschoice.htm
_______________________________________________
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>