[SOLVED] Sphere Attached To Linked Joint Scales Down

Hello,
Does it make sense that when I attach a Sphere (I didn’t check other geometries yet) to a DAC linked joint (in this case “Joint12” of the Ninja model), it scales down until you cant even see it. see it happening in the attached video.
I’m not 100% percent sure but I think it is a regression from previous version of Minie…
WDYT?


Adi

I’ve not seen this issue before. If you post a simple, self-contained example, I’ll look into it.

1 Like

Well… doesn’t reproduce in the test app :slight_smile: , so need to check the differences…

1 Like

Note: without knowing anything about this problem at all the symptoms beg me to drop a hint that “scale(f)” is different than “setLocalScale(f)”.

1 Like

OK, I managed to reproduce the issue. What happening is that the collision shape stays in the original size but the geometry itself scales down. here is the source test code:
https://drive.google.com/file/d/1sg9gGcqk4YKj0mwMKt6DWTBTQBbWSFjz/view?usp=sharing

It worked fine in the past so I think it is related to some upgrade I have recently made. Maybe Minie 2.x.x but I;'m not sure… need to check.
*Edit: I downgraded Minie to 2.0.0, 1.7.0, 1.6.0, and it still happens so probably not a Minie issue

1 Like

I’ll check about that. I’m using scale in my code

What’s the world scale of the Node you’re attaching the sphere to?

I’m attaching the sphere to Ninja’s Joint12 - world scale = 0.02,0.02,0.02
So the Joint’s world scale will affect any geometry attached to it ? in my case scaling the sphere to 0.02,0.02,0.02? this is by design?

1 Like

Yes.

So in order to preserve original size of the attached object, I need to be aware of the scaling of the object I’m attaching to, compensate that by scaling the attached object and change scale again when detached and return to root node - right?
I’ll do that. Thanks!

1 Like

If you load ninja next to another model like oto you will find out it is MASSIVE.

Its reduced in size by 95% in the tutorials just to use it.
https://wiki.jmonkeyengine.org/docs/3.3/tutorials/beginner/hello_asset.html#code-sample

ninja.scale(0.05f, 0.05f, 0.05f);

Standard sphere would be a pimple on this thing.

Or add a node that is unscaled and attach your object to that.

Let me see if I understand what you are suggesting - create a new node, attach my Sphere to that node and then attach this node to the Ninja’s joint, right? this will preserve the original scale of the Sphere?

If you unscale that node.

At this point it’s almost required that I mention the scene graph tutorial. https://wiki.jmonkeyengine.org/tutorials/scenegraph/assets/fallback/index.html

What does it mean “unscale”?
I updated the test code to have a tmp Node holding the Sphere then attached the tmp Node to the Joint. here is the full function code:

    private void attachSphereToNinjaJoint() {
        Spatial target = ninjaNode;
        Spatial attachEntity = sphere;
        SkeletonControl sc = findSkeletonControl(target);
        Node joint= sc.getAttachmentsNode("Joint12");

        Node tmp = new Node();
        tmp.attachChild(attachEntity);
        joint.attachChild(tmp);
        Vector3f ws = joint.getWorldScale();

        CharacterControl ctl = target.getControl(CharacterControl.class);
        if(ctl!=null) {
            SceneGraphVisitor visitor = new SceneGraphVisitor() {

                @Override
                public void visit(Spatial sp) {
                    if (sp instanceof Geometry) {
                        RigidBodyControl rctl = sp.getControl(RigidBodyControl.class);
                        if(rctl!=null) {
                            ctl.getCharacter().addToIgnoreList(rctl);
                        }
                    }
                }
            };

            attachEntity.breadthFirstTraversal(visitor);
        }

        attachEntity.setLocalTranslation(0,0,0);

    } 

But still the same results since now the tmp Node was scaled to 0.02,0.02,0.02 and affected the Sphere. So what is “Unscale”?

Thanks. I have read it before and now again. Good document

1 Like

Scale 0.5
Unscale 2.0

Scale 0.1
Unscale 10.0

Do you see? One thing is scaling “the space” and you need to unscale “the space”.

1/scale

That I understand. What confused me was the motivation of adding a parent node to the Sphere. I thought it will make some kind of magic / short-cut for preserving the original scale of the Sphere. If I need to scale & Unscale the Node then I can do it directly on the Sphere hence the confusion.
Maybe there is a performance gain using the parent Node technique… Don’t know.
I understand how to fix my problem. Thanks!

1 Like

You add the unscale node so that you don’t have to unscale your item just to add it… and then you don’t have to remember how to unscale it when you remove it (because maybe the item already had its own scale).

The idea is that you can setup your model in one place and keep track of the new attachment unscaled nodes… then you don’t need to remember that this model is 0.02 and this one is 0.4 and that one is 1.0, etc. You just attach and unattach as needed.

1 Like