Buffer too big, AWD2 and Merge

Software: Away3D 4.x

John Brookes, Moderator
Posted: 07 October 2011 12:43 PM   Total Posts: 732

Been trying to do a way of automagically splitting meshes that are too large from an awd2 file into subgeometries.

So did a little test a cube 44, 44, 44 sub divisions from maya to awd2

private function assetComplete(e:AssetEvent):void 
{
 
if (e.asset is Mesh)
 
{
  
  
if (Mesh(e.asset).geometry.subGeometries[0].numTriangles 20000)
  
{
   trace
("Too many vertices.. Merging " Mesh(e.asset).name);
   var 
merge:Merge = new Merge(falsefalse);
   var 
m:Mesh = new Mesh(Mesh(e.asset).material);
    
   
merge.apply(mMesh(e.asset))
   
   
Mesh(e.asset).parent.addChild(m)
   
Mesh(e.asset).parent.removeChild(Mesh(e.asset));
  
}
 }


For some reason that only does 1 subG. No errors but part of the cube is missing.
Actually tried similar to the above in the awd2 parser parseMeshInstance() function did the same, only the first subg.

 

But if I use a basic away primitive it works fine.
I get 2 sub geometries
eg

var cube:Cube = new Cube(new BitmapMaterial(new BitmapData(256256false0xff0000)), 500500500444444);

var 
merge:Merge = new Merge(falsefalse);
var 
m:Mesh = new Mesh(cube.material);

merge.apply(mcube)
scene.addChild(m

 

So erm what me missing? Does AWD2 exporter do something different?

   

John Brookes, Moderator
Posted: 08 October 2011 11:37 AM   Total Posts: 732   [ # 1 ]

For some reason the second set of subgeometries is in the wrong position also faces missing.

A 44x44x44 subdivision cube from Maya via awd2

used
BitmapMaterial(Mesh(AssetLibrary.getAsset(“pCube1”)).material).alpha = 0.1

var merge:Merge = new Merge(false, false);
var m:Mesh = new Mesh(Mesh(AssetLibrary.getAsset(“pCube1”)).material);

merge.apply(m, Mesh(AssetLibrary.getAsset(“pCube1”)))
scene.addChild(m);

m.subMeshes[1].material = new ColorMaterial(0x0000ff);
m.subMeshes[1].material.bothSides = true;


Ends up like this.
http://www.shrewballooba.co.uk/splitMesh/

   

John Brookes, Moderator
Posted: 10 October 2011 04:13 PM   Total Posts: 732   [ # 2 ]

OK while I’m talking to myself ;/


In Merge.as the collect function
If you do something like

line 408
for (var i:uint = 0; i < geoms.length; ++i) {
for (var k:uint = 0; k < geoms.vertexData.length; k += LIMIT)
{ //add this
...

_vectorsSource.push(ds);
  }
} //add this

Then it works, you can load a mesh with ‘too many vetrices’ merge it and get a single mesh split into subgeometries.

Not fully tested much though. wink

   

Avatar
Fabrice Closier, Administrator
Posted: 10 October 2011 07:11 PM   Total Posts: 1265   [ # 3 ]

The awd2 parser will take care of this for you soon.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X