How to get a separate plane from merged mesh?

Software: Away3D 4.x

Avatar
Morpher, Newbie
Posted: 30 August 2011 12:47 PM   Total Posts: 1

Hi guys!
I’m trying to merge a group of textured planes. Some with the same materials and others with the unique materials. 
I can’t figure out how to get a vertices of 1 separate plane to move it.

This is working for all planes (modified MergeTest.as example):

private function populateWithVectorsMass() : void { 
..
{
  
.. 
  
meshes.push(Mesh(plane));

..  
meshResult merge.applyToMeshes(Mesh(meshes.shift()), meshes); 
private function handleEnterFrame(e:Event):void {
..
for 
each(var sub:SubMesh in meshResult.subMeshes)
{
 
var buffer:VertexBuffer3D sub.getVertexBuffer(Stage3DManager.getInstance(stage).getStage3DProxy(0));
 var 
vec:Vector.<Number> = sub.subGeometry.vertexData;
 var 
random:Number Math.random();
 for(var 
i:uint vec.length += 3)
 
{
  
var amount:Number random 40 20;
  
vec[i] += amount//x
  
vec[i 1] += amount//y
  
vec[i 2] += amount//z
 
}
 buffer
.uploadFromVector(vec0vec.length 3);

I thought that 1 segment plane has 12 vertex coordinates (4 vertices * 3 coordinates). So, first at 0-12, second at 12-24 and so on. But I was wrong. First at 0-12, but second at 12-28 and third at 28-46! Wtf, I can’t understand that((
Another problem with materials. plane.material that was before merging != sub.material :( So I don’t know how to get vertex coordinates for a plane and how to get a proper subMesh from a merged mesh. Any ideas? 

 

   

Avatar
Fabrice Closier, Administrator
Posted: 31 August 2011 10:22 AM   Total Posts: 1265   [ # 1 ]

One way to practice would be to store the vertices count and subgeom id during the loop/merge. With the latest update of the Merge class the apply method (just receiver and one mesh) is now way more efficient, so you could read and generate plane by plane during your loop.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X