www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on December 13, 2006, 07:35:16 pm

Title: 3d Line
Post by: AGP on December 13, 2006, 07:35:16 pm
How do I draw a line between two 3d coordinates?
Title: 3d Line
Post by: AGP on December 13, 2006, 08:03:14 pm
I can't try it here but I expect I figured it out (if it's wrong, please somebody say so):

SimpleVector p1 = Interact2D.project3D2D(camera, buffer, vertex1);
SimpleVector p2 = Interact2D.project3D2D(camera, buffer, vertex2);
graphicsInstance.drawLine(p1.x, p1.y, p2.x, p2.y);
Title: 3d Line
Post by: Melssj5 on December 13, 2006, 08:18:27 pm
No, first of all, I dont know if using the Graphics object works on  openGl.

Then, simpleVector coordinates and position of vector are not in a relationship with the x and y of the screen. you can have a 800 x 600 screen resolution but inside your Worlc you can have more that that amount of points, so you may need get the projection of each of those 2 points on the screen and then you can use the X and Y to draw the line.
Title: 3d Line
Post by: AGP on December 14, 2006, 02:27:02 am
And yet it worked. Read the documentation before saying I'm wrong. I appreciate the attention, but you might want to read the code before criticising it.
Title: 3d Line
Post by: Melssj5 on December 14, 2006, 03:28:40 am
Yeah it worked because you are getting the projection of the 3d on the screen with the interact 2d, your code did exactly what I suggested to project the 3d over the 2d.

The problem was not ignoring how to do it, but putting few attention on your code to notice you were right. Check what I wrote and you will se that is exactly what you did.
Title: 3d Line
Post by: cyberkilla on December 14, 2006, 09:42:41 am
Quote from: "AGP"
I can't try it here but I expect I figured it out (if it's wrong, please somebody say so):

SimpleVector p1 = Interact2D.project3D2D(camera, buffer, vertex1);
SimpleVector p2 = Interact2D.project3D2D(camera, buffer, vertex2);
graphicsInstance.drawLine(p1.x, p1.y, p2.x, p2.y);


I could have sworn that code was different the last time I looked:P

This code looks right though:).
Title: 3d Line
Post by: manumoi on December 15, 2006, 08:06:25 am
wow people are nervous today  :wink: