Nope… Quaternion.Inverse does not work either… I tried this:
if (transform.parent != null) {
this._tempVector.set(this.m_tempPosition.x(), this.m_tempPosition.y(), this.m_tempPosition.z());
BABYLON.Utilities.InverseTransformPositionToRef(transform.parent as BABYLON.TransformNode, this._tempVector, transform.position);
this._tempQuaternion.set(this.m_tempRotation.x(), this.m_tempRotation.y(), this.m_tempRotation.z(), this.m_tempRotation.w());
BABYLON.Quaternion.InverseToRef(this._tempQuaternion, transform.rotationQuaternion);
transform.addRotation(0, Math.PI, 0);
}
else
{
transform.position.set(this.m_tempPosition.x(), this.m_tempPosition.y(), this.m_tempPosition.z());
transform.rotationQuaternion.set(this.m_tempRotation.x(), this.m_tempRotation.y(), this.m_tempRotation.z(), this.m_tempRotation.w());
transform.addRotation(0, Math.PI, 0);
}
Still not rotating properly after i Inverse transform the position.
I will try make a little video showing the problem (Cant really make a playground yet)
Yea a playground would make it clearer.
Is this one similar to what you want? Babylon.js Playground
If you get the global matrix of a child object you can multiply it by the inverse of the parent to get the local matrix and decompose it to get local rotation
Yeah its kinda hard to re-produce in playground… im on a whole nother level with my pro toolkit and in low-level physics API… I dont have all the libraries ready to go for playground yet.
But if understand you… I should be able to create a TEMP Matrix (I am try to update a child position and rotation from is GHOST PHYSICS WORLD TRANSFORM)
But i should be able to COMPOSE a temp matrix from the Ammo.btTransform (The wheel world tranform from bullet). This will serve as the CHILD transform matrix.
Then get the Parent Inverse World Matrix … Multiply those together into another temp matrix then then DECOMPOSE that temp matrix… And i should have a local position and rotation and scale… which i can then set as the local transform position and rotation of the actual wheel mesh … ???
Im gonna try that out 
Freaking Awesome… Thanks @trevordev… Yet again 
FYI…
This is how i got Native Bullet Wheel Info Updates:
private _tempMatrixA:BABYLON.Matrix = BABYLON.Matrix.Zero();
private _tempMatrixB:BABYLON.Matrix = BABYLON.Matrix.Zero();
private _tempMatrixC:BABYLON.Matrix = BABYLON.Matrix.Zero();
protected updateWheelInformation():void {
const wheels:number = this.getNumWheels();
if (wheels > 0) {
for (let index:number = 0; index < wheels; index++) {
this.updateWheelTransform(index, true);
this.m_tempTransform = this.getWheelTransform(index);
this.m_tempPosition = this.m_tempTransform.getOrigin();
this.m_tempRotation = this.m_tempTransform.getRotation();
const info:any = this.getWheelInfo(index);
if (info != null && info.transform != null) {
const transform:BABYLON.TransformNode = info.transform as BABYLON.TransformNode;
if (transform.parent != null) {
this._tempMatrixA.reset();
this._tempMatrixB.reset();
this._tempMatrixC.reset();
// Setup Temp Child Matrix From Ghost World Transform
this._tempVectorPos.set(this.m_tempPosition.x(), this.m_tempPosition.y(), this.m_tempPosition.z());
this._tempQuaternion.set(this.m_tempRotation.x(), this.m_tempRotation.y(), this.m_tempRotation.z(), this.m_tempRotation.w());
this._tempVectorScale.set(1.0, 1.0, 1.0);
BABYLON.Matrix.ComposeToRef(this._tempVectorScale, this._tempQuaternion, this._tempVectorPos, this._tempMatrixA);
// Compute Ghost Wheel World Matrix To Local Matrix
transform.parent.computeWorldMatrix();
transform.parent.getWorldMatrix().invertToRef(this._tempMatrixB);
this._tempMatrixA.multiplyToRef(this._tempMatrixB, this._tempMatrixC);
// Update The Actual Wheel Local Position And Rotation
this._tempMatrixC.decompose(this._tempVectorScale, transform.rotationQuaternion, transform.position);
transform.addRotation(0, Math.PI, 0);
}
else
{
transform.position.set(this.m_tempPosition.x(), this.m_tempPosition.y(), this.m_tempPosition.z());
transform.rotationQuaternion.set(this.m_tempRotation.x(), this.m_tempRotation.y(), this.m_tempRotation.z(), this.m_tempRotation.w());
transform.addRotation(0, Math.PI, 0);
}
}
}
}
}
Works like a charm and FASTER than i thought it would with all that matrix composing and decomposing. Its very much like what i have to do for each bone in my animation system when i play weighted animations… I do a SampleAnimationFrame() that gives me the animation matrix for a given frame… I decompose that matrix… doing FAST SLERPING on the parts with a weight and then put back into a matrix that gets assigned to bone._matrix
Same thing kinda… I should have thought of this before 
2 Likes
do you have the character model? like dummy3.babylon.
Yo @xiangjinhua1994
The dummy3.babylon was made from the Mixamo Y-Bot… So if you want the original FBX of that model… Visit mixamo.com