Author Topic: How to draw a line?  (Read 3090 times)

Offline angel-0ne

  • byte
  • *
  • Posts: 2
    • View Profile
How to draw a line?
« on: February 05, 2010, 01:55:02 pm »
Hello everyone.
I just wonna draw a line from (0,0,0) to (1,1,1) for example.
How can i do this?
Or, please, point into api.
« Last Edit: February 06, 2010, 08:34:41 pm by EgonOlsen »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Haw to draw a line?
« Reply #1 on: February 05, 2010, 05:47:59 pm »
Using which renderer? jPCT itself doesn't expose any line drawing capabilities, but depending on the renderer, you may use either Java2D or OpenGL yourself.

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: Haw to draw a line?
« Reply #2 on: February 05, 2010, 09:27:31 pm »
you can use this

Code: [Select]
     Graphics g = frameBuffer.getGraphics();
     Camera cam = world.getCamera();

      //use whatever source vectors you want. if you want to show lines between children and parents
      // use Object3D.getTransformedCenter() instead of a new SimpleVector()
      SimpleVector pointA = Interact2D.project3D2D(cam, frameBuffer, new SimpleVector(0,0,0)); // start
      SimpleVector pointB = Interact2D.project3D2D(cam, frameBuffer, new SimpleVector(1,1,1)); // to

      g.drawLine((int)pointA.x, (int)pointA.y, (int)pointB.x, (int)pointB.y);

Offline angel-0ne

  • byte
  • *
  • Posts: 2
    • View Profile
Re: Haw to draw a line?
« Reply #3 on: February 06, 2010, 12:45:42 pm »
Thank you. It helps a lot ;)