Author Topic: Change on bone affects all models  (Read 255 times)

Jan Drabner   «   on: June 14, 2012, 11:31:00 AM »
Sorry for spamming problems here :D

As the title implies, I am manipulating a bone on a model. This works, but unfortunately the change to the bone affects all instances of this mesh. I don't want this to happen.

A change to the bone should only affect the model it actually belongs to.

Here is my code:
            var skin :SkinModifier = Mesh3D(_model.getChildByName("body")).modifier as SkinModifier;
                // Get mouth bone
            _mouth = skin.root.getChildByName("Jaw");
            _mouth.frames = null;
            _mouthMin = _mouth.getPosition().clone();
            _mouthMax = _mouthMin.clone();
            _mouthMax.x -= 1.4;

I can now fool around with _mouth, but as I said, it affects all instances of the model.

Probably of importance, this is how I assign _model:
            _model = modelLoader.clone();
            _scene.addChild(_model);

modelLoader is a Flare3DLoader. The clone() is called after it has fully loaded, of course.

Jan Drabner   «   Reply #1 on: June 14, 2012, 11:31:56 AM »
Oh, and all of the above code happens in the constructor of my character class.

Jan Drabner   «   Reply #2 on: June 14, 2012, 11:34:15 AM »
And another addition to clarify: If I create seven character instances, I have seven models. And if I change the _mouth bone of any one of these instances, every instance is affected by the change.

Ivan Vodopiviz   «   Reply #3 on: June 15, 2012, 12:19:46 PM »
Hi Jan,

Sorry for the delay. Even if you clone the object, the skin information is still shared among all copies, for performance reasons. One option would be to create separate loader instances for each object you want to load so each object will end up completely independent.

Could you tell us what are you trying to do? That way we might give you a better solution.

Cheers,

Jan Drabner   «   Reply #4 on: June 18, 2012, 04:16:42 AM »
I want use the same f3d file for all instances (well not all, but a certain number) of my character class. And I want to be able to manipulate the bones of a character instance without the changes taking effect on all other character instances that use the same f3d file.

I will try having each instance load its own f3d file, even it is the same file for all of them. Wouldn#t that negatively affect performance?

Jan Drabner   «   Reply #5 on: June 18, 2012, 04:30:53 AM »
Okay I tried that and it works.

But I still have performance concerns when loading like 10x the same f3d file. Or is the loading of an asset that has already been loaded somehow optimized?

Ivan Vodopiviz   «   Reply #6 on: June 18, 2012, 12:31:25 PM »
Hi,

If you use addChildFromFile, for example, the asset is cached and the next time you call addChildFromFile Flare3D will use the cached version. By using different loaders you're preventing this, but as long as you keep it reasonable it shouldn't be any problem.

Cheers,