Main Menu

3d Line

Started by AGP, December 13, 2006, 07:35:16 PM

Previous topic - Next topic

AGP

How do I draw a line between two 3d coordinates?

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);

Melssj5

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.
Nada por ahora

AGP

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.

Melssj5

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.
Nada por ahora

cyberkilla

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:).
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

manumoi

wow people are nervous today  :wink: