Using the Merge class with Away3D primitives.

Software: Away3D 4.x

empend, Member
Posted: 18 November 2011 12:04 AM   Total Posts: 77

Merging Away3D primitives doesn’t work.
Is there any way I can merge two primitive shapes?

   

Avatar
Fabrice Closier, Administrator
Posted: 18 November 2011 10:02 AM   Total Posts: 1265   [ # 1 ]

Are you using the latest git repo? There were issues in the past with Primitive merging because these have buffers with fixed sizes. This is resolved in latest builds.

If you are, please provide some code so i can reproduce. I have on my machine code merging spheres and cubes running with no issues.

   

empend, Member
Posted: 18 November 2011 08:39 PM   Total Posts: 77   [ # 2 ]

I am using the latest, and even re-downloaded it to make sure.

I’d send you the ZIP with all the code if I knew your email, but for now here’s the merging snippet…

var elevation:int=thisTile[TILE_ELEVATION];
    var 
surrounding:Array=checkSurroundingTiles(x,y);
    
    var 
newMesh:Mesh;
    var 
mergeContainer:ObjectContainer3D = new ObjectContainer3D();
    
//planes
    
var middle:Planenull;
    var 
up:Plane=null;
    var 
down:Plane=null;
    var 
left:Plane=null;
    var 
right:Plane=null;

    
//GlobalVar.defaultMaterial is just a color material
    //GlobalVar.tileSize is an int with the value of 1
    
    //MIDDLE TILE
    
middle = new Plane(GlobalVar.defaultMaterial,GlobalVar.tileSize,GlobalVar.tileSize);
    
middle.x=x;
    
middle.z=y;
    
middle.y=elevation;
    
mergeContainer.addChild(middle);
    
//END OF MIDDLE TILE
    
    //DOWN TILE
    
down=new Plane(GlobalVar.defaultMaterial,GlobalVar.tileSize,GlobalVar.tileSize);
    
down.x=x;
    
down.y-(GlobalVar.tileSize/2);
    
down.elevation-(GlobalVar.tileSize/2);
    
down.rotationX=-90;
    
mergeContainer.addChild(down);
    
//END OF DOWN TILE

    //Merge the tiles
    
var merge:Merge=new Merge();
    
newMesh merge.applyToContainer(mergeContainer"");
    
    
//Set new material?
    
newMesh.material=GlobalVar.defaultMaterial;
    
    
//add mesh to objectContainer3D
    
tileContainer.addChild(newMesh);
    
//LinearElevation class please!!! :(:(:( 

I hope you can help!
Thanks!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X