Class GltfScene

java.lang.Object
com.codename1.gpu.GltfScene

public final class GltfScene extends Object

The whole of a glTF 2.0 file as plain data: every node of the scene graph, every triangle primitive, the materials, the skins and the animation clips. Produced by GltfLoader#loadScene(byte[]).

Nothing here is uploaded to a GraphicsDevice; the vertex data is kept on the CPU so a renderer can pose it. com.codename1.gaming.AnimatedModel is the ready made consumer: it samples the clips, skins the vertices and draws the result as ordinary Meshes.

Node transforms follow the glTF convention: a node's local matrix is T * R * S of its translation, rotation (an x, y, z, w quaternion) and scale, and its world matrix is its parent's world matrix times that.

  • Method Details

    • getNodeCount

      public int getNodeCount()
      The number of nodes in the file.
    • getNode

      public GltfScene.Node getNode(int index)
      The node at index.
    • findNode

      public int findNode(String name)
      The index of the first node named name, or -1.
    • getRoots

      public int[] getRoots()
      The indices of the scene's root nodes, parents before children.
    • getPrimitiveCount

      public int getPrimitiveCount()
      The number of triangle primitives across every mesh node.
    • getPrimitive

      public GltfScene.Primitive getPrimitive(int index)
      The primitive at index.
    • getMaterialCount

      public int getMaterialCount()
      The number of materials.
    • getMaterial

      public GltfScene.MaterialInfo getMaterial(int index)
      The material at index.
    • getImage

      public Image getImage(int index)
      The decoded embedded image at index, or null when it could not be read.
    • getTexture

      public Texture getTexture(GraphicsDevice device, int index)
      The texture for image index on device, uploaded on first use and then shared by every model drawn from this scene. Returns null when the image could not be decoded. Asking with a different device uploads afresh.
    • getSkinCount

      public int getSkinCount()
      The number of skins.
    • getSkin

      public GltfScene.Skin getSkin(int index)
      The skin at index.
    • getAnimationCount

      public int getAnimationCount()
      The number of animation clips.
    • getAnimation

      public GltfScene.Animation getAnimation(int index)
      The clip at index.
    • findAnimation

      public GltfScene.Animation findAnimation(String name)
      The first clip named name, or null.