About the Model (Java)

[Last update: 10/06/2022]

Cubism SDK for Java is currently in alpha version, and the specifications may change in the beta or official version.

 

 

 

Editing Model Information

Model information is basically created in the model workspace of the Cubism Editor.
The movement of vertices and other objects relative to the parameters is recorded in the .moc3 file.
Other physics operations and user data attached to the art mesh are output as separate files, and the .model3.json file is used to keep track of all file references related to the model.

These can be output simultaneously when outputting a .moc3 file. Exporting Data for Embedded Applications
In addition, Cubism Viewer (for OW) can be used to add built-in settings for motion and facial expression files and pose files.

 

Reading from .model3.json file using Framework

In loading using the Framework, it is assumed that the necessary information for the model is extracted from the .model3.json file and an instance inheriting from the CubismUserModel class is maintained for use.

Each element extracted in the ICubismModelSetting class can be loaded by the CubismUserModel.load ~~ system function.

The overall loading flow from the .model3.json file is easy to grasp by following the flow of the following functions from the LAppmodel.loadAssets function in the sample.

  • LAppModel.setupModel function
  • CubismUserModel.createRenderer function
  • LAppModel.setupTextures function

 

Instance creation (loading of .moc3 file)

First, load the .moc3 file into memory.
Pass the read buffer to the CubismMoc.create function to first create a CubismMoc instance.
Next, call the CubismMoc.createModel function to create a CubismModel instance.
From this CubismModel instance, the user manipulates parameters and acquires information for drawing.

The CubismMoc.createModel function counts the number of models generated by the function inside CubismMoc, and when CubismMoc is destroyed, all CubismModels generated from that CubismMoc must be destroyed.

 

 

Graphic Environment Associations

The Framework uses classes derived from the CubismRenderer class to make the model texture information independent of the graphics API.
All graphics-related information associated with the model is managed by classes derived from the CubismRenderer class.
As of SDK for Java R1 alpha1, there is no need for the derived classes to be managed since they only support Android. However, this specification is made in consideration of the possibility of adding a graphics API in the future and the aspect of unifying specifications with existing SDKs.

First, specify the type of graphics environment you wish to generate with the RendererType enumeration and call it as an argument to the CubismUserModel.createRenderer function.
(In SDK for Java R1 alpha1, only Android is supported.)
Inside the createRenderer function, a derived class for the graphics API corresponding to the argument is created, and by registering a CubismModel instance with the CubismRenderer.initialize function, the CubismRenderer instance and CubismRenderer instance and the CubismModel instance are linked.

 

 

Texture association

The textures that models have in the Framework are managed by a class derived from the CubismRenderer class.
The Android OpenGL ES 2.0 process uses the CubismRendererAndroid.bindTexture function in the CubismRendererAndroid class, which is a derived class of the CubismRenderer class, to register.
The first argument is the texture number of the model, identified on the Editor by the number of the texture atlas.
The second argument is the texture's OpenGL ES 2.0 control number.

 

 

Specify display position and size

With the previous settings, the model can be drawn, but in many cases the display position and scale are too different to be displayed on the screen as is.
For the vertex range returned by the CubismModel.getDrawableVertexPositions function, see "DrawableVertexPosition Ranges".
Use the CubismModelMatrix class and the CubismModel.getCanvasWidth and CubismModel.getCanvasHeight functions to adjust the size.

This matrix is multiplied by the Projection matrix before drawing and passed to the renderer as an MVP matrix.

 

 

Vertex Update

Execute the CubismModel.update function to reflect parameter operations on the CubismModel instance to the vertices of the ArtMesh.

 

 

Drawing

Drawing is not performed from the CubismModel instance, but by commanding the renderer to which it is tied.

 

 

Discard

In destroying an instance, all CubismModels must be destroyed before destroying CubismMoc.
To preserve this order, CubismModel is destroyed with the CubismMoc.deleteModel function.
If not via this function, a warning will be issued because the number of models checked inside CubismMoc does not match.

 

 

Using parameter IDs that do not exist in the model in the CubismModel class

The CubismModel class parameters and part opacity operations have the ability to handle IDs that do not exist in the .moc file.
This function is used by the CubismMotion class, CubismPose class, etc. When creating a new mechanism using this function, please be careful to use an ID that does not conflict with existing functions.
Also, when reading the Framework, keep in mind that it may be linked to other functions using created parameters.
* Accessing a non-existent maximum, minimum, or initial value will result in an error.

© 2010 - 2022 Live2D Inc.