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

Software: Away3D 4.x

Kicker, Member
Posted: 02 May 2017 08:18 AM   Total Posts: 52

Hi,

I’m having a weird problem whem loading several animated meshes into the game…

Here’s the code called on ASSET_COMPLETE:

private function onMD5ResourceComplete($e:AssetEvent):void
{
 
var node:SkeletonClipNode;
 var 
animator:SkeletonAnimator;
 var 
asset:IAsset $e.asset;
 var 
name:String asset.assetNamespace;
 var 
animation_set:SkeletonAnimationSet;

 
LightLogger.log("onMD5ResourceComplete " name " " asset.assetType);

 if (
asset.assetType == AssetType.ANIMATION_SET)
 
{
  animation_set 
asset as SkeletonAnimationSet;
  
animator = new SkeletonAnimator(animation_set_md5Meshes[name].skeleton);
  
_md5Meshes[name].mesh.animator animator;
  
_md5ReadyRope.cutFiber(name);
 
}
 
else if (asset.assetType == AssetType.SKELETON)
 
{
  
if(_md5Meshes[name] == null)
   
_md5Meshes[name] {};
  
_md5Meshes[name].skeleton asset as Skeleton;
 
}
 
else if (asset.assetType == AssetType.MESH)
 
{
  
if(_md5Meshes[name] == null)
   
_md5Meshes[name] {};
  
_md5Meshes[name].mesh asset as Mesh;
  
_md5Meshes[name].mesh.castsShadows true;
 
}

And here’s the logged result:

onMD5ResourceComplete Sleepy.md5mesh geometry
onMD5ResourceComplete Sleepy
.md5mesh mesh
onMD5ResourceComplete Sleepy
.md5mesh skeleton
onMD5ResourceComplete Sleepy
.md5mesh animationSet
onMD5ResourceComplete Angry
.md5mesh geometry
onMD5ResourceComplete Angry
.md5mesh mesh
onMD5ResourceComplete Angry
.md5mesh skeleton
onMD5ResourceComplete Angry
.md5mesh animationSet
[Fault] exception
information=ErrorA Material instance cannot be shared across renderables with different animator libraries 

Thanks in advance.

   

Avatar
Fabrice Closier, Administrator
Posted: 02 May 2017 08:47 AM   Total Posts: 1265   [ # 1 ]

The error is pretty clear. you have meshes with animators that are sharing same material. Simply make a new material for each new mesh. You can share the texture(s) if its a TextureMaterial that you need.

If you do not assign the material yourself, and it’s the work of the parser/library
simply generate a new material before addChild the mesh to the scene, reusing the textures from the previous one.

   

Kicker, Member
Posted: 02 May 2017 09:03 AM   Total Posts: 52   [ # 2 ]

Oh, I think I see what’s happening, thanks.

I added this line:

_md5Meshes[name].mesh.material = new ColorMaterial(); 

And now it works.

Apparently, when you load a mesh file with no material, a default one is automatically attributed to it, so if you load several files in a row without giving them a new material in between, they will share the default material…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X