Coder Social home page Coder Social logo

Comments (4)

javagl avatar javagl commented on August 16, 2024

The global transform is explained in this section. The pseudocode for the computation of the global transform could be

Matrix computeGlobalTransformOf(Node node) {
    if (!hasParent(node)) return node.transform;
    else return computeGlobalTransformOf(node.parent) * node.transform;
}

(Note: The "parent" is not stored directly in the JSON. This pseudocode should just illustrate the idea about how it is computed in theory).

The inverse of that transform is ... just the inverse of this matrix :-) Depending on the programming language/environment that you are using, you'll almost certainly have some sort of Matrix class that already offers some invert function.

(Here is one implementation of such a function (in Java, but so low-level that it only needs arrays, and thus, could trivially be ported to any other language), but usually, you do not have to write this sort of code on your own - every 3D vector/matrix library already offers that).

from gltf-tutorials.

icEngineer-tech avatar icEngineer-tech commented on August 16, 2024

cool, thank you.
if my node doesn't contain any scale vector, rotation vector or translation vector. the default value for rotation are all 0? the default value for scale are all 1? and the default value for translation are all 0?
my last question is: how to convert this vector [ 0.259, 0.0, 0.0, 0.966 ] to the matrix rotation given in this tutorial https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_004_ScenesNodes.md#global-transforms-of-nodes

from gltf-tutorials.

javagl avatar javagl commented on August 16, 2024

Yes,

  • the default rotation is 0
  • the default scale is 1
  • the default translation is 0

meaning that the resulting matrix will be an identity matrix in this case.

how to convert this vector [ 0.259, 0.0, 0.0, 0.966 ] to the matrix rotation

The value for the rotation is (in some sense not a "vector", but) a quaternion that describes the rotation. Again, most libraries for 3D vector math should already have some function to convert a quaternion into a 4x4 rotation matrix. (In doubt, another very low-level implementation is shown here , but one should preferably use an existing function for this if it is available...)

from gltf-tutorials.

icEngineer-tech avatar icEngineer-tech commented on August 16, 2024

thanks for these precious info

from gltf-tutorials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.