Animated drawing of a line?

I would like to animate the drawing of a continuous line.

I managed to create a loop that draws the line segment by segment, but I should somehow bind it to the time, so that the animation doesn't just run through as fast as possible. The animation should also be triggered by key input.

Should I use a controller or what? I didn't find any tutorial for this one.

Please, I want to animate a person who was loading a file. XML with the good. I sweated to import the 3D object, but there is a problem of the animated character with the good .

public class JmeXMLImporter extends SimpleGame {

private XMLImporter xmlImporter = XMLImporter.getInstance();

private Node t;

private static final Logger logger = Logger.getLogger(JmeXMLImporter.class.getName());

AnimationController ac;

boolean boneOn = false;

public static void main(String[] args) {

JmeXMLImporter app = new JmeXMLImporter();




protected void simpleUpdate() {

if( KeyBindingManager.getKeyBindingManager().isValidCommand( “bones”, true ) ) {

boneOn = !boneOn;




protected void simpleRender() {

//If we want to display the skeleton use the BoneDebugger.

if(boneOn) {

BoneDebugger.drawBones(rootNode, display.getRenderer(), true);



protected void simpleInitGame() {

String XMLFileName = “elMensajeroDePekin/xurri-jme.xml”;

URL modelURL = JmeXMLImporter.class.getClassLoader().getResource(XMLFileName);

System.out.println("Carrego el model: "+modelURL);

KeyBindingManager.getKeyBindingManager().set( “bones”, KeyInput.KEY_SPACE );

KeyBindingManager.getKeyBindingManager().set(“canviarAnimacio”, KeyInput.KEY_9);

try {



new SimpleResourceLocator(JmeXMLImporter.class



} catch (URISyntaxException e1) {

logger.warning("Unable to add texture directory to RLT: "

  • e1.toString());


    try {

    System.out.println(“Estic dintre del try”);

    Object o = xmlImporter.load(modelURL);

    System.out.println("Objecte o: "+o);

    if (!(o instanceof Spatial)){

    throw new IOException("File contains non-spatial root: " + o.getClass().getName());

    } else {

    Spatial loadedSpatial = (Spatial) o;

    t = (Node) loadedSpatial;


    t.setLocalTranslation(new Vector3f(0f,0f,0f));

    System.out.println("LoadBlenderModel: "+ XMLFileName + “.xml loaded.”);


    } catch (IOException e) { // Just in case anything happens

    System.out.print(“Severe Error: " + e);



    t.setModelBound(new BoundingBox());



    ac = getAnimationController();

    System.out.println(“Available animations:”);

    for (BoneAnimation anim : ac.getAnimations())

    System.out.println(” " + anim.getName());


    System.err.println(“Executing animation '”
  • ac.getActiveAnimation().getName() + “’”);

    // The default update loop will update world bounding volumes.



    public AnimationController getAnimationController() {


    List armatures =

    rootNode.descendantMatches(Bone.class, “.+SuperBone”);

    if (armatures.size() < 1)

    throw new IllegalStateException("Sorry. Program assumes "
  • “you have a node named with suffix ‘SuperBone’”);

    if (armatures.get(0).getControllerCount() != 1)

    throw new IllegalStateException(

    "Armature should have 1 controller, but has "
  • armatures.get(0).getControllerCount());

    Controller controller = armatures.get(0).getController(0);

    if (!(controller instanceof AnimationController))

    throw new IllegalStateException(

    "Controller is of unexpected type: "
  • controller.getClass().getName());

    return (AnimationController) controller;