Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How to offset 3D objects or limbs?

Author
Message
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 12:19
Hello everybody.

I'm trying to offset a 3D model or its limbs from its 'model centre'.
We used to do this on DBPro using offset limb command.

The benefit to this is that, when we need to position a 3D model to another 3D model, and wants to mimic the rotation and movement of the latter model.
A lot of 3D model came a little bit deviated from its 'centre of universe'
So if we position the 3D model to the location and rotation of another 3D model, the 3D model will not rotate on the intended axis.

For example, if you have a 3D model that contain an animation, and want to use another 3D model as its 'hat'
If the 'hat' model is not centered correctly, the 'hat' will not rotate correctly along with the 'head'.
It will appears to 'orbit' around the head when the head is rotated.

But we can remedy this by offsetting the 'hat' so that its 'centre of universe' to be the same as the 'head' bone position. Then they will rotate along nicely.

Modifying the 'hat' model position in 3D modelling programs is too much work, because the hat will need to have different offset for different uses.
And fine-tuning will be a nightmare.

So, is there any way to offset 3D model, or its limbs?
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Feb 2016 12:58
Well there are bone commands now that might be able to do that. Traditionally in DBPro, no matter if your object is animated or not, the limb can be adjusted and limbs = bones = limbs.... so maybe you can use the bone commands to offset the limb. You might have to use the 'load object with children' command though, so it knows not to just assume it's a mesh - that might not matter too much when you only have 1 mesh/limb - but it might be necessary to enable those bone commands.
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 12th Feb 2016 13:12
If the hat is a separate object , you could use SetObjectPosition and then FixObjectPivot , that should enable you to change the center of the object so rotation will work as it should..

best regards Preben Eriksen,
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 13:22
I got it working!
I used MoveObjectLocalX() nad its equivalent of Y and Z

1 - First we position the hat using SetObjectPosition()
2 - Then we offset the hat object using MoveObjectLocalX()
3 - Then we rotate the hat
4- Win


I need to try out that FixObjectPivot thingy though. It might be better.
And it also might be achievablle with that new limb manipulation command, SetObjectBonePosition( objID, boneIndex, x, y, z )
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 12th Feb 2016 14:05
Here is the way I get the camera to follow an object using the FixObjectToObject() command.
The trick is when you position the object it is an offset and not a world position.
The rotation is automatically handled.

The coffee is lovely dark and deep,and I have code to write before I sleep.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 15:11 Edited at: 12th Feb 2016 15:22
Noted something problematic when trying to put the hat on my character head.

GetObjectBoneAngleX( objID, boneIndex ) only get the local angle of the bone specified only,

It does not return the limb angle based on the world angle
Why I think this is problematic, is because of the case of multiple chaining of parent-child limbs

For example, I have a model that have a 'neck' limb, and a 'head' limb.
I want to pivot another model to the 'head' limb, as it's hat.
So, I SetObjectRotation() the hat model to the angles that was returned from GetObjectBoneAngleX( objID, boneIndex )
But, the hat only rotates when the 'head' limb rotates, but not when the 'neck' limb rotates.
When the character itself rotates, the hat does not. The hat only rotates if the 'head' limb rotates
This results in incomplete movement of the hat object.

To remedy this, we need to calculates all the differences of the angle of all the parent limbs involved.
But this workaround is too messy. It'll be a nightmare if there are multiple parents limb

It would be great if there are commands that return a limb angle based on the real world angle.
Or commands that can glue objects to limbs.
In DBPro there are commands that can do this. It's like a godsend

Is there any good way to 'glue' the hat to the limbs?
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 12th Feb 2016 15:35 Edited at: 12th Feb 2016 15:38
Yes we need a command GetObjectBoneWorldAngleX
The coffee is lovely dark and deep,and I have code to write before I sleep.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 15:39 Edited at: 12th Feb 2016 15:41
-snip-
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 12th Feb 2016 18:25
Quote: "Yes we need a command GetObjectBoneWorldAngleX"

Not sure why I didn't add those originally, it's easy to add so it's in the next version.
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 12th Feb 2016 18:34
God be praised

Login to post a reply

Server time is: 2024-09-29 11:28:31
Your offset time is: 2024-09-29 11:28:31