|
Matej, Jr. Member
Posted: 27 May 2013 11:02 AM Total Posts: 38
Hello,
I used Prefab to export object as an AS3 Class for away4.0
I wanted to reuse Geometry to create dozens of objects from that class but clone is not working.
var obj1:AS3Obj = new AS3Obj(); var obj2:AS3Obj = AS3Obj.clone();
Am I missing something here or should I export Object differently or with AwayBuilder for this kind of usage?
I want to reuse the same object mupltiple of wimes with best performance possible?
Material is also the same for all objects, all I change is UV on it.
|
Fabrice Closier, Administrator
Posted: 27 May 2013 12:07 PM Total Posts: 1265
[ # 1 ]
You need to loop over the object meshes array to access your meshes.
During the loop you can check names.
for instance, you can do something like this:
new Mesh(AS3Obj.meshes[0].geometry, AS3Obj.meshes[0].material);
Note that If you change UV’s, its not the same geometry.
|
Matej, Jr. Member
Posted: 27 May 2013 12:11 PM Total Posts: 38
[ # 2 ]
Thank you.
If changing UVs is changing the geometry, how is it possible to have one spritesheet that has different faces and just navigate to different part of spritesheet for different objects?
I have 12 objects that are all the same except up until now I was mapping to a different UV for different image.
|
Fabrice Closier, Administrator
Posted: 27 May 2013 12:20 PM Total Posts: 1265
[ # 3 ]
In order to keep geometry unchanged, reuse material and define for animators. Look at the SpriteSheet tutorial (digital clock part) that I’ve posted a few weeks ago.
|
Matej, Jr. Member
Posted: 27 May 2013 01:37 PM Total Posts: 38
[ # 4 ]
While I was looking at the tutorial one thing came to my mind.
I am not changing the UVs on the objects, all I do is animating UV by changing offsetU and offsetV.
So the question is if I use
new Mesh(AS3Obj.meshes[0].geometry, AS3Obj.meshes[0].material);
and then change offsetU/V on one Mesh, would it be changed on all the others too?
|
Fabrice Closier, Administrator
Posted: 27 May 2013 02:37 PM Total Posts: 1265
[ # 5 ]
yes. thats why SpriteSheetMaterial/SpriteSheetAnimator approach is better. Because it doesn’t alter source uv’s. Sharing these would work, but all your meshes would display same cell of the sheet. While assigning same material but different animator would not, because the agal behind doesn’t affect the uv’s of the geometry, while what you do, using offsetU and V, affects the geometry, and since you want to reuse, you affect all the meshes sharing the same geometry.
Even if you need to have more animators or more materials, as they can share textures and animationSets, it will be way lighter than having new geometries.
|
Matej, Jr. Member
Posted: 27 May 2013 02:40 PM Total Posts: 38
[ # 6 ]
Your help and explanation is great
|