|
catad83, Newbie
Posted: 26 July 2016 10:36 AM Total Posts: 5
I’m working on an AIR app that uses away3d to load animated models. You can browse foe awd2 files, load and display them on screen.
When loading the same model first, all is ok, but when loading it again(by browsing and selecting the same awd file) i gen an error: “Error: A Material instance cannot be shared across renderables with different animator libraries”
the awd file is an animated one. I’m just using simple Loader3D.load() and when all loaded, adding it tu stage by view.scene.addChild(loader);
how do I load the same model multiple times without that error?
I’m very, very new to the 3d thing, sorry if this is a silly question.
|
cyberix3d, Jr. Member
Posted: 26 July 2016 01:47 PM Total Posts: 34
[ # 1 ]
You need to use a clone of the real model for each model instance you want to use.
loader.clone();
You also need to clone your skeleton, animationSet, and animationController, Otherwise, when you play the animation in one model, it will affect the other models.
|
catad83, Newbie
Posted: 26 July 2016 02:53 PM Total Posts: 5
[ # 2 ]
Thanks for replying.
I have gone that way also but can’t realy figure it out. Do you a link to an example doing this?
I’m realy stuck at this for the last couple of days and could use some help.
|
cyberix3d, Jr. Member
Posted: 26 July 2016 03:14 PM Total Posts: 34
[ # 3 ]
oh, and I forgot, You also need to clone the original material for every model instance:
loader.material = new TextureMaterial(originalMaterial.texture)
|
catad83, Newbie
Posted: 26 July 2016 03:27 PM Total Posts: 5
[ # 4 ]
sorry, but unless you put some code, these don;t make sense to me.
I know that I need to clone stuff but don’t know how to.
first of all “loader.material” - material does not exist in loader3d unless I’m missing something
second: originalMaterial.texture - original material - how do I get thet from the Loader3D instance? when I use mesh’s <material> property I get a MaterialBase instance with no texture property
I’ve tried just cloning the mesh and using
private function onAssetComplete(event:AssetEvent) : void
{
if (event.asset.assetType == AssetType.MESH)
{
model = (event.asset as Mesh).clone();
model.material = new TextureMaterial();
}
}
but still bet the original material on the model
|
cyberix3d, Jr. Member
Posted: 26 July 2016 04:04 PM Total Posts: 34
[ # 5 ]
I’m working on Away3D 4.0.9 so it might be different.
I also had this problem and cloning the material helped.
Maybe someone else know how to solve this issue in Away3D 4.1
|
catad83, Newbie
Posted: 27 July 2016 08:24 AM Total Posts: 5
[ # 6 ]
still, any help is much appreciated
|
catad83, Newbie
Posted: 27 July 2016 11:54 AM Total Posts: 5
[ # 7 ]
can’t seem to find a solution and there is no example loading a model twice on stage with independent animations, unlike any other engine.
I’m at the point of giving up on away3d
|
Yann, Newbie
Posted: 02 August 2016 12:20 AM Total Posts: 16
[ # 8 ]
I’m not really good at it but I understood the loader3d is a container, it’s like a box where your model is loaded. If you put the same model (same components etc…) several times in the same box it get messy.
If you use a second loader3D (a new one) to load the second model? 2 models = 2 loader3D… It’s the easiest solution I think.
after that if you want to optimise, maybe you can use clones, share between the models what can be shared (the geometry, the texture… the animationset as well? I’m not sure) and duplicate the remaining stuff (materials, animator, skeleton etc…)
Again I’m not confident about what I say
|