realbasic-games
[Top] [All Lists]

Re: Clone

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Clone
From: Jeff Quan <jquan at mindspring dot com>
Date: Sat, 9 Dec 2006 16:42:29 -0800
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-games at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=mindspring.com; b=IBIcFU0SuKi2qwMQkkq8X/LMtHjwdKz67+ogl9rhA7ODmGLWVBH7wT0dRoiuCbxD; h=Received:Mime-Version:In-Reply-To:References:Content-Type:Message-Id:From:Subject:Date:To:X-Mailer:X-ELNK-Trace:X-Originating-IP;
References: <536c96bc02ef2c952568ee7f8ae31cce at 98115 dot net>

On Dec 8, 2006, at 11:15 PM, Craig M. wrote:
I want to clone an object3D's subclass, but change their material (just color in this case) independently. It appears I can not use clone, but I can not find any way to copy the geometry. I can copy everything else I need (properties and such), but not the actual geometry.

What can I do?

That's how cloning works.

If your model has only one trimesh in it, (to quote Joe Strout:)
"So, to clone a TriMesh, you would make a new TriMesh, set its number of vertices and triangles and such to the same as your original, and then call Copy on the VertexPositions, VertexNormals, Triangles, VertexColors (if applicable), and VertexUVs (ditto)."
Now you can change the Material on that Trimesh.

Another way you can make a copy is to reload the model each time you need a new instance and then change that instance's material (or materials if you have several textures in your model) after loading. This is done for Zombies (source at: http://www.codenautics.com/ zombies).

So in both cases, you'd need to create a New Object3D for each copy, thus ensuring that they don't have any vertices and materials in common. Note that changing materials on an object can be slow.

==
Jeff Quan
jquan at mindspring dot com
http://www.jcquan.com/JQportfolio


_______________________________________________
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>