Newbie, World Co-ordinate issue

Following on from my post below regarding Text. I'm really chuffed with jME and what can be done with it. I'm now working on my frontend menuing system (with flying 3d text etc). However, I'm having problems getting my head around how jME is implementing local and world translation. It makes sense in my head, but doesn't match what actually happens in the real world.



I'm mapping characters from a String into its own Quad and then translating it into position in the world. However, TTF characters are different widths (for which I can determine). So I'll create one character with a width of 40pixels and then next for say 50pixels. If I paste their images into a Quad, the smaller will expand if the quad sizes are fixed. So, I have to make the Quad sizes proportional to the text width. I've done this and it works well. However, if I then try to put the two different Quads next to each, they don't always meet. To explain, I need to illustrate with this snippet of code:



      Node n = new Node("Node");
      
      Quad q1 = new Quad("q1",3,3);
      q1.setSolidColor(ColorRGBA.red);
      q1.setLocalTranslation(new Vector3f(0,0,0));
      n.attachChild(q1);

      Quad q2 = new Quad("q2",3,3);
      q2.setSolidColor(ColorRGBA.blue);
      q2.setLocalTranslation(new Vector3f(3,0,0));
      n.attachChild(q2);

      rootNode.attachChild(n);



Ignore the fact that there is no text for now. If you run this, you'll get two flat Quads inline (press T in SimpleGame to see wireframe join). However, if I end up creating the first Quad with a width of 2 and then try to translate the second quad to 2, they don't join!


      Node n = new Node("Node");
      
      Quad q1 = new Quad("q1",2,3);
      q1.setSolidColor(ColorRGBA.red);
      q1.setLocalTranslation(new Vector3f(0,0,0));
      n.attachChild(q1);

      Quad q2 = new Quad("q2",3,3);
      q2.setSolidColor(ColorRGBA.blue);
      q2.setLocalTranslation(new Vector3f(2,0,0));
      n.attachChild(q2);
      
      rootNode.attachChild(n);



The second Quad overlaps the first. Why is this? It's almost as if the second Quad inherits something from the first. Am I missing the point? I expected both Quads to locally transform from the world co-ordinate of the root (as they share the same node).

I hope I've explained myself. Can anyone correct where I'm going wrong. I'm going to continue to play, but thought someone might put me out of my misery. I could leave all Quads the same size, but I don't like ruining the smaller width characters!

That's simply because you specify the center of the quads. So if one quad has width 2 and the next one width 3 the distance should be 2.5 not 2. :slight_smile:

Oh geez… Golden Cock award to me then! no wonder it just wasn't making sense!!! I assumed top left… but yes, thinking about it, logically it makes sense. I'm now going to go and hit myself over the head with a large and heavy object… :wink:



Thanks Irrisor

Working great now… I can give it a String and it chops it up into TTF Char Quads and then positions them on screen nicely… Right, now on to animating them.