Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Interact with the viewer

In order for your entities to display in the viewer, you must commit your entities state. You do not need to do it manually as the module automatically commits all the entities at the end of each turn.

However, you might want to force a commit, for example, to create animations.

Usage

Two methods allow you to commit your entities:

commitEntityState(double t, Entity<?>... entities);

will commit the state of entities at the moment t (0 ≤ t ≤ 1).

commitWorldState(double t);

will commit the state all the entities you created at the moment t (0 ≤ t ≤ 1).

Note that committing will only send the entities that have changed since the last commit.

Examples

Animating a circle

//Starts invisible
circle.setRadius(0);
graphicEntityModule.commitEntityState(0, circle);

//Grow to big size
circle.setRadius(70);
graphicEntityModule.commitEntityState(0.8, circle);

//Shrinks to normal size
circle.setRadius(50);
graphicEntityModule.commitEntityState(1, circle);

Animating several entities

circle.setRadius(50);
line.setX(30);
rectangle.setAplha(0.67);
commitWorldState(0.5);

circle.setRadius(70);
line.setX(50);
rectangle.setAplha(1);
commitWorldState(1);
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content