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

public interface PlatformModels

3D models for actors in 2.5D (PlatformView#setDepth(boolean)). Without one, depth mode stands each actor up as a flat billboard of its sprite; with one, an actor whose kind has a model is drawn as that skinned glTF model instead, turned to face where it walks and playing the clip its state asks for. The simulation is untouched: the same level and the same replay, drawn with models.

import com.codename1.gaming.platformer.*;
import com.codename1.gaming.platformer.view.*;
import com.codename1.gaming.AnimatedModel;
import com.codename1.gpu.*;

LevelData level = LevelData.parse("{\"tileSize\":16,\"spawn\":[1,1],\"tiles\":[\"........\",\"........\",\"########\"]}");
PlatformView view = new PlatformView(level.createWorld(1), new ProceduralArt(16));
GltfScene heroScene = GltfLoader.loadScene(Display.getInstance().getResourceAsStream(null, "/hero.glb"));
view.setModels(new PlatformModels() {
    public AnimatedModel model(GraphicsDevice d, Actor a) {
        return "hero".equals(a.getKind()) ? new AnimatedModel(d, heroScene) : null;
    }
    public String clip(Actor a) {
        return a.getState() == MovementState.RUNNING ? "Run" : "Idle";
    }
    public float height(Actor a) {
        return 1.1f;
    }
});

Methods

public abstract AnimatedModel model(GraphicsDevice device, Actor actor)Makes the model for an actor, once per actor.
public abstract String clip(Actor actor)The animation clip for an actor’s current state.
public abstract float height(Actor actor)How tall the model stands, in tiles.

Method details

model

public abstract AnimatedModel model(GraphicsDevice device, Actor actor)
Makes the model for an actor, once per actor. Called on the render thread after the GPU device exists.

Parameters

device GraphicsDevice
the device the model will draw on
actor Actor
the actor; Actor#getKind() says which model

Returns

a new model, or null to keep the billboard for this actor

clip

public abstract String clip(Actor actor)
The animation clip for an actor’s current state.

Parameters

actor Actor
the actor

Returns

a clip name in the model’s scene, or null to keep the current one

height

public abstract float height(Actor actor)
How tall the model stands, in tiles. The model is scaled so its bounds are this tall and placed standing on the actor’s feet.

Parameters

actor Actor
the actor

Returns

the height in tiles