Cloning works for me, i create forest using this function:
private function GenerateObjectsOnTerrain(mesh:Mesh,
coordinates:Vector.<ObjectInfo>):void
{
var offsetCoordinates:ObjectInfo = terrainObjectsCoordinates.terrain;
for (var i:int = 0, n:int = coordinates.length; i < n; ++i)
{
var meshCopy:Mesh = mesh.clone() as Mesh;
var coordinateInfo:ObjectInfo = coordinates[i];
// move to correct position (coordinates are from 3ds max so we
should flip axis)
meshCopy.x = -coordinateInfo.x + offsetCoordinates.x;
meshCopy.y = coordinateInfo.z - offsetCoordinates.z;
meshCopy.z = coordinateInfo.y - offsetCoordinates.y;
meshCopy.scaleX = coordinateInfo.scaleX;
meshCopy.scaleY = coordinateInfo.scaleZ;
meshCopy.scaleZ = coordinateInfo.scaleY;
meshCopy.rotationX = -coordinateInfo.rotationX;
meshCopy.rotationY = coordinateInfo.rotationZ;
meshCopy.rotationZ = coordinateInfo.rotationY;
terrainContainer.addChild(meshCopy);
//trace("meshCopy x " + meshCopy.x + " y " + meshCopy.y + " z "
+
meshCopy.z);
}
}
First parameter is mesh to copy, second parameter is array of
coordinates for placing objects. The only code lines you need are:
var meshCopy:Mesh = mesh.clone() as Mesh;
terrainContainer.addChild(meshCopy);
TerrainContainer is ObjectContainer3D added to view.
On 28 мар, 18:28, Chris <[email protected]> wrote:
> On Mar 28, 10:13 am, Michael Iv <[email protected]> wrote:
>
>
>
> > Are you sure it doesn't clone your object? Someone from the team has a clue
> > ?
>
> > On Mon, Mar 28, 2011 at 4:10 PM, Chris <[email protected]> wrote:
>
> > > On Mar 28, 2:34 am, Chris <[email protected]> wrote:
> > > > Yeah I know I bumped up that one topic when I probably should have
> > > > made my own...
>
> > > > Anyway!
>
> > > > I'm loading a 3ds model, but how would I use that same model multiple
> > > > times?
> > > > In other words, how would I clone it?
>
> > > > I tried using
>
> > > > " scene3D.addChild(theModelAsObjectContainer3D.clone() as
> > > > ObjectContainer3D) "
>
> > > > But that doesn't work!
>
> > > > I usually use Alternativa, but since it Away3D 4.0 is out I figured I
> > > > would just learn it instead of Alternativa 8.
> > > > I'm still learning away3D so this would help a lot!
>
> > > Come on someones got to be able to help me!
> > > Please!
>
> > --
> > Michael Ivanov ,Programmer
> > Neurotech Solutions Ltd.
> > Flex|Air |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.net
> > Tel:054-4962254
> > [email protected]
> > [email protected]
>
> Maybe just a cloning example would be nice. :D