Class Model
java.lang.Object
com.codename1.gaming.Model
A 3D mesh placed in the world: a com.codename1.gpu.Mesh plus a
com.codename1.gpu.Material and a position / rotation / scale transform. Add one
to a GameView (GameView#addModel(Model)) to draw it in the perspective camera
alongside the billboarded sprites.
Because GPU meshes need the com.codename1.gpu.GraphicsDevice to be created, build
your models from inside GameView#onSetup(com.codename1.gpu.GraphicsDevice):
protected void onSetup(GraphicsDevice device) {
Mesh cubeMesh = Primitives.cube(device, 1f);
Material gold = new Material(Material.Type.PHONG).setColor(0xffffcc33).setShininess(32);
Model crate = new Model(cubeMesh, gold);
crate.setPosition(0, 0.5f, 0);
addModel(crate);
}
Rotation is applied in Z, then Y, then X (extrinsic), in degrees. The model is
drawn with the GameView's shared com.codename1.gpu.Light, so lit material
types (com.codename1.gpu.Material.Type#LAMBERT/#PHONG) are shaded by it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetMesh()floatfloatfloatfloatgetX()floatgetY()floatgetZ()booleanvoidsetMaterial(Material material) voidsetPosition(float x, float y, float z) setRotation(float degX, float degY, float degZ) Sets the Euler rotation in degrees (applied Z, then Y, then X).setScale(float scale) setScale(float scaleX, float scaleY, float scaleZ) voidsetUserData(Object userData) voidsetVisible(boolean visible)
-
Constructor Details
-
Model
Creates a model for the given mesh with a default unlit white material. -
Model
-
-
Method Details
-
getMesh
-
setMesh
-
getMaterial
-
setMaterial
-
getX
public float getX() -
getY
public float getY() -
getZ
public float getZ() -
setPosition
-
setRotation
Sets the Euler rotation in degrees (applied Z, then Y, then X). -
getRotationX
public float getRotationX() -
getRotationY
public float getRotationY() -
getRotationZ
public float getRotationZ() -
setScale
-
setScale
-
isVisible
public boolean isVisible() -
setVisible
public void setVisible(boolean visible) -
getUserData
-
setUserData
-