Error: A Material instance cannot be shared across renderables with different animator libraries

Software: Away3D 4.x

Ankur, Jr. Member
Posted: 12 February 2013 04:38 PM   Total Posts: 43

Error I get is:

ErrorA Material instance cannot be shared across renderables with different animator libraries
 at away3d
.materials::MaterialBase/addOwner()
 
at away3d.entities::Mesh/set material()
 
at away3d.entities::Mesh/set animator()..... 

 

When I comment this line out (see in the comments below), the error goes away.

 

_meshVector = new Vector.<Mesh>;
   
_skeletonVector = new Vector.<Skeleton>;
   
_breatheStateVector = new Vector.<SkeletonClipNode>;
   
_walkStateVector = new Vector.<SkeletonClipNode>;
   
_animationSetVector = new Vector.<SkeletonAnimationSet>;
   
_animatorVector = new Vector.<SkeletonAnimator>;
   
   
_skeleton Skeleton(AssetLibrary.getAsset("pelvis_bone"));
   
_breatheState SkeletonClipNode(AssetLibrary.getAsset("toes"));
   
_walkState SkeletonClipNode(AssetLibrary.getAsset("bend"));
   
_mesh Mesh(AssetLibrary.getAsset("male")) 
for (var i:int=0i<4i++)
   
{
    _meshVector
.push(Mesh((_mesh as Object3D).clone()));
    
_meshVector[i].castsShadows true;
    
_meshVector[i].material.lightPicker _lightPicker;
    
_container.addChild(_meshVector[i]);


    
_breatheStateVector.push(_breatheState);
    
_walkStateVector.push(_walkState);  
    
_animationSetVector.push(_animationSet);
    
_animationSetVector[i].addAnimation(_breatheStateVector[i]);
    
_animationSetVector[i].addAnimation(_walkStateVector[i]);
    
    
_skeletonVector.push(_skeleton);

    
_animator = new SkeletonAnimator(_animationSetVector[i]_skeletonVector[i]);
    
_animatorVector.push(_animator);
    
_meshVector[i].animator _animator;///////THIS IS THE LINE
   //WHICH IF REMOVED, ALSO REMOVES THE ERROR/////////////////
   

John Brookes, Moderator
Posted: 12 February 2013 06:25 PM   Total Posts: 732   [ # 1 ]

What you trying to do?

clone the animations and mesh so all play with one animator?

In that case just clone the mesh any clones will play the same animation.
Have a look at the examples Intermediate_OnkbaAWDAnimation.as

or
clone the mesh and have individual animators?
Not sure if its right way (quick test) but seems to work..

private function onAssetComplete(event:AssetEvent):void
{
 
if (event.asset.assetType == AssetType.SKELETON)
 
{
  
//create a new skeleton animation set
  
skeletonAnimationSet = new SkeletonAnimationSet(3);
  
  
//wrap our skeleton animation set in an animator object and add our sequence objects
  
skeletonAnimator = new SkeletonAnimator(skeletonAnimationSetevent.asset as Skeletonfalse);
  
  
trace("####### "+event.asset.name//traces joint1
 
}
 
else if (event.asset.assetType == AssetType.ANIMATION_NODE)
 
{
  
//create animation objects for each animation node encountered
  
var animationNode:SkeletonClipNode event.asset as SkeletonClipNode;
  
skeletonAnimationSet.addAnimation(animationNode);
 
}
 
else if (event.asset.assetType == AssetType.MESH)
 
{
  
if (event.asset.name == "mySkin")
  
{
   
   
//create mesh object and assign our animation object and material object
   
fatGuyMesh event.asset as Mesh;
   
scene.addChild(fatGuyMesh);
   
fatGuyMesh.animator skeletonAnimator;
   
fatGuyMesh.material.lightPicker slp;
  
}
 }
}
  
  
private function makeClone(pos:Vector3D):SkeletonAnimator 
{
  
var sA:SkeletonAnimator = new SkeletonAnimator(skeletonAnimationSetskeletonAnimator.skeletonfalse);
  var 
g:Mesh Mesh((fatGuyMesh).clone());
  
g.position pos;
  
scene.addChild(g)
  
g.animator sA;
  return 
sA;
}  

//...
//var skeletonAnimator2:SkeletonAnimator =  makeClone(new Vector3D(100, 0, 0));
//skeletonAnimator2.play("jump") 

erm above is for 4.1 alpha

   

Ankur, Jr. Member
Posted: 12 February 2013 08:53 PM   Total Posts: 43   [ # 2 ]

hi JohnBrookes,

Thanks for the reply. Sorry for being unclear.
What I am trying to do is create about 8-10 different meshes each with their separate skeleton system and animators (so that they can all be animated differently) I have managed to duplicate meshes successfully using the clone method. The problem is cloning the skeleton, animationSets and the animators. How can I clone these and apply these to their respective meshes?

The code you have written above does not seem to show how I can clone these?

Thanks for all the help

   

John Brookes, Moderator
Posted: 13 February 2013 12:27 PM   Total Posts: 732   [ # 3 ]

Edited the above code. Didnt need some of it.

What I posted creates cloned meshes and an animator for each.
It shares a single common skeleton and animations, but each mesh can be animated individually.
So one can be walking while the other plays jump.

skeletonAnimator(“jump”)

var skeletonAnimator2:SkeletonAnimator =  makeClone(new Vector3D(100, 0, 0));
skeletonAnimator2.play(“jump”)

Sorry if thats not what your after.

   

Vice, Member
Posted: 13 February 2013 01:02 PM   Total Posts: 58   [ # 4 ]

Hi John,

i’ve the same issue. using code like the example one has the following effect: starting e.g. the walk example for each mesh to a different time shows each mesh the same pose at the same time. the result should be the walk animation with different poses, so the don’t walk in an uniformly way. Do you have any idea?

   

John Brookes, Moderator
Posted: 13 February 2013 01:33 PM   Total Posts: 732   [ # 5 ]

@Vice
Arrg yeah it does, didnt notice that.
It will play different animations but when you play the same one (walk) they sync up.

Going to have to stop random guessing wink and try again.

@Ankur
Just got the same error message (finally) while trying something.
Got round it by adding a new material to the mesh.

   

John Brookes, Moderator
Posted: 13 February 2013 01:56 PM   Total Posts: 732   [ # 6 ]

@Vice
Actually all you need to do is pass 0 to the last parameter of play.

eg I have

case Keyboard.C
   var 
skeletonAnimator2:SkeletonAnimator =  makeClone(new Vector3D(10000));
   
skeletonAnimator2.play("walk",null,0)
 break;
case 
Keyboard.V
   var 
skeletonAnimator3:SkeletonAnimator =  makeClone(new Vector3D(20000));
   
skeletonAnimator3.play("walk",null,0)
 break; 

They dont sync up with that and the above code.

   

Ankur, Jr. Member
Posted: 13 February 2013 05:38 PM   Total Posts: 43   [ # 7 ]
JohnBrookes - 13 February 2013 01:33 PM

@Ankur
Just got the same error message (finally) while trying something.
Got round it by adding a new material to the mesh.

Hey JohnBrookes,

Thanks. It worked. I created a array for materials and filled it with copies of same material. Applied the materials from the array to correspondent meshes in the mesh array and now it works. Sweet.

Amazing. Thanks for all the help.

   

Vice, Member
Posted: 14 February 2013 11:51 AM   Total Posts: 58   [ # 8 ]

@John:

thanks John, thats it!!!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X