www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: angel-0ne on February 05, 2010, 01:55:02 pm

Title: How to draw a line?
Post by: angel-0ne 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.
Title: Re: Haw to draw a line?
Post by: EgonOlsen 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.
Title: Re: Haw to draw a line?
Post by: .jayderyu 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);
Title: Re: Haw to draw a line?
Post by: angel-0ne on February 06, 2010, 12:45:42 pm
Thank you. It helps a lot ;)