Attaching model to another model bone

Anything libgdx related goes here!

Attaching model to another model bone

Postby Oen44 » Sat Sep 15, 2018 5:29 pm

Hi,

I'd like to make attachable models (like sword, shield etc.) using bones from main model (character model).

What have I tried?
Get node "hand.R" (bone for right hand), then addChild using node "main" (bone from model I want to attach) - that did nothing, nothing is shown.
Code: Select all
Model ship = assets.get("models/low_poly_character.g3db", Model.class);
Model sword = assets.get("models/low_poly_sword.g3db", Model.class);
ModelInstance shipInstance = new ModelInstance(ship);
Node handNode = shipInstance.getNode("hand.R");
Node swordNode = sword.getNode("main");
handNode.addChild(swordNode);
instances.add(shipInstance);


Using "hand.R" globalTransform to set attachable model transform - worked, rotation, etc changed but... it's scaled to very large, no idea how to deal with that.
Code: Select all
Model ship = assets.get("models/low_poly_character.g3db", Model.class);
Model sword = assets.get("models/low_poly_sword.g3db", Model.class);
ModelInstance shipInstance = new ModelInstance(ship);
ModelInstance swordInstance = new ModelInstance(sword);
Node handNode = shipInstance.getNode("hand.R");
swordInstance.transform.set(handNode.globalTransform);
instances.add(shipInstance);
instances.add(swordInstance);

Image

I feel like setting position for attachable model with every frame is costly and not practical. Or is it?
Oen44
 
Posts: 7
Joined: Tue Aug 28, 2018 3:31 pm

Return to Libgdx

Who is online

Users browsing this forum: Google [Bot] and 1 guest