Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class GltfScene

  1. Object
  2. GltfScene

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.

Nested types

class GltfScene.NodeOne node of the scene graph.
class GltfScene.PrimitiveOne triangle primitive, with its vertex data in the node’s local space.
class GltfScene.MaterialInfoThe parts of a glTF material a Material can express.
class GltfScene.SkinA skeleton: the joint nodes and the matrices that take a vertex from the mesh’s bind pose into each joint’s space.
class GltfScene.AnimationA named animation clip.
class GltfScene.ChannelKeyframes for one property of one node.

Methods

public int getNodeCount()The number of nodes in the file.
public GltfScene.Node getNode(int index)The node at index.
public int findNode(String name)The index of the first node named name, or -1.
public int[] getRoots()The indices of the scene’s root nodes, parents before children.
public int getPrimitiveCount()The number of triangle primitives across every mesh node.
public GltfScene.Primitive getPrimitive(int index)The primitive at index.
public int getMaterialCount()The number of materials.
public GltfScene.MaterialInfo getMaterial(int index)The material at index.
public Image getImage(int index)The decoded embedded image at index, or null when it could not be read.
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.
public int getSkinCount()The number of skins.
public GltfScene.Skin getSkin(int index)The skin at index.
public int getAnimationCount()The number of animation clips.
public GltfScene.Animation getAnimation(int index)The clip at index.
public GltfScene.Animation findAnimation(String name)The first clip named name, or null.

Inherited methods

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.