Interface PlatformModels
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;
}
});
-
Method Summary
Modifier and TypeMethodDescriptionThe animation clip for an actor's current state.floatHow tall the model stands, in tiles.model(GraphicsDevice device, Actor actor) Makes the model for an actor, once per actor.
-
Method Details
-
model
Makes the model for an actor, once per actor. Called on the render thread after the GPU device exists.
Parameters
device: the device the model will draw onactor: the actor;Actor#getKind()says which model
Returns
a new model, or null to keep the billboard for this actor
-
clip
-
height
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: the actor
Returns
the height in tiles
-