Altering uv data of SubMesh with/after Merge

Software: Away3D 4.x

Danny Brown, Newbie
Posted: 28 January 2013 04:22 PM   Total Posts: 2

Hi all,

firstly, I’m completely new to Away, but looks like a fab tool. I’ve lots of experience writing shaders, so down the line hope to contribute on that front.

First of all tho, I have to get my head round Away3D!

I’m having an ‘issue’

I’m creating hundreds of Meshes based on PlaneGeometry. Each uses the same bitmap texture, but different uv co-ords / uvScale. This works as individual Meshes.

I’m then using Merge to create a single mesh. However after this, every plane subMesh has the same uv geometry, so has the same uv co-ords.

Here’s a snippet of code:

var squaresMesh:Mesh;
   
squaresMesh = new Mesh(nullplaneMaterial );
   
squaresMesh.100;
   
   
//
   
   
var subMeshes:Vector.<Mesh> = new Vector.<Mesh>;
      
   for (var 
i:int=i<2000 i++) {
   
    
var singleMesh:Mesh = new Mesh(new PlaneGeometry(20,20,1,1,false),planeMaterial);
                 
singleMesh.rotati     singleMesh.rotati     singleMesh.rotati
    
    singleMesh
.x=Math.random()*800-400;
    
singleMesh.y=Math.random()*800-400;
    
singleMesh.z=Math.random()*800-400;
    
    for (var 
j:int=j<singleMesh.subMeshes.length j++) {
     
     singleMesh
.subMeshes[j].scaleU=1/32.00;
     
singleMesh.subMeshes[j].scaleV=1/32.00;
     
singleMesh.subMeshes[j].offsetU=MagicMath.randomInt(32)/32.00;
     
singleMesh.subMeshes[j].offsetV=MagicMath.randomInt(32)/32.00;
     
    
}
         
    subMeshes
.push(singleMesh);
        
   
}
   
   
var merge:Merge = new Merge();
   
merge.keepMaterial=true;
   
merge.applyToMeshes(squaresMesh,subMeshes); 

After this point every plane in squaresMesh has the same uv data, and altering it changes all of the planes uv. I want each plane to have different uv

Think I’m misunderstanding the way to use merge, but I can’t find anything on forums etc.

Thanks in advance grin

Danny

 

   

Avatar
Fabrice Closier, Administrator
Posted: 28 January 2013 05:02 PM   Total Posts: 1265   [ # 1 ]

First, I assume you use 4.0 and not 4.1. The update of this class is currently broken in 4.1.
Merge should keep your uv’s as you defined them.
I never loop over submeshes like this, I loop on subgeometries and usually affect directly the buffers and update them. Tho it should work.
For the sake of test, can your pass with a setTimeout the vector submeshes that you have collected and merge after at least once frame has rendered?

Oh and from what I see, you perfectly get the principle of this class.

   

Danny Brown, Newbie
Posted: 28 January 2013 05:36 PM   Total Posts: 2   [ # 2 ]

Hi Fabrice-

Away3D.MINOR_VERSION returns 0 so I’m guessing it’s 4.0? (I didn’t add it to the project - someone else did)

I did a time delayed test but even after 100 render() calls it didn’t affect anything.

I’m wondering if I should be calling bakeTransformations() at some point in the process? I assume this should replace dependent geometry with cloned independent geometry?

[on a side note, if I perform the same subMesh (for) iteration on the post-merged squaresMesh, it will change the uv but it changes all 2000 planes to identical uv]

Totally stumped. Thanks for your help

Danny

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X