3D graph drawing algorithm

Hi everyone,just wanted to ask if somebody knows a nice algorithm for drawing 3d-graphs.ThanksChris
[127 byte] By [abenstexa] at [2007-10-2 6:13:01]
# 1

Hey bebi. It's very simple. Let's say u need to draw line between 2 points in 3d. 1st point: x1, y1, z1. 2nd point: x2, y2, z2. Camera 0, 0, 0.

int x1Screen = (int)(x1/z1*SCREEN_X_SIZE/2 + (SCREEN_X_SIZE/2));

int y1Screen = (int)(y1/z1*SCREEN_X_SIZE/2 + (SCREEN_X_SIZE/2));

int x2Screen = (int)(x2/z2*SCREEN_X_SIZE/2 + (SCREEN_X_SIZE/2));

int xyScreen = (int)(y2/z2*SCREEN_X_SIZE/2 + (SCREEN_X_SIZE/2));

Then just draw 2d line using Graphics class. Good luck. Have a question? Feel free to luck. I am mega mind in 3d gfx. U know...

MaxJusta at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 2
Instead of "xyScreen" ofcourse is "y2Screen". I am so f*cking sorry about this bad mistake.
MaxJusta at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 3
Bad news. Another mistake. Second and forth SCREEN_X_SIZE replace with SCREEN_Y_SIZE. I realy hope after this everything in your tiny life will be allright.
MaxJusta at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 4
MaxJust: Do you also know the algorithm to draw a surface in 3d?ThanksR. HollensteinPD: What if the cam moves?
r.hollensteina at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 5
Ok, sorry for asking about the surface, you just draw a 2d rect with these four points.But still, what happens if the cam moves?R. Hollenstein
r.hollensteina at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 6

r.hollenstein. I know everything i need to know about 3d gfx. 3d surface - no problem. there are many variants it could be done. if cam moves then the formulas for points is a little bit longer:

let's say we have point (x, y, z) and cam (xCam, yCam, zCam)

int xScreen = (int)((x-xCam) / (z-zCam) * X_SCREEN_SIZE /2 + (X_SCREEN_SIZE/2));

if cam turns the formula will be much more longer.

MaxJusta at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 7

So, the formula would be:

int xScreen = (int)((x-xCam)/(z-zCam)*X_SCREEN_SIZE/2+(Y_SCREEN_SIZE/2));

int yScreen = (int)((y-yCam)/(z-zCam)*SCREEN_X_SIZE/2+(SCREEN_Y_SIZE/2));

Is this correct? Because I think in the formula you posted that considers the cam, the second SCREEN_X should be SCREEN_Y?

To which direction is the camera looking in this formula (anlge: x,y,z)?

R. Hollenstein

r.hollensteina at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 8
int xScreen = (int)((x-xCam)/(z-zCam)*X_SCREEN_SIZE/2+(X_SCREEN_SIZE/2));int yScreen = (int)((y-yCam)/(z-zCam)*Y_SCREEN_SIZE/2+(Y_SCREEN_SIZE/2));camera is looking in Z direction
MaxJusta at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 9
Thank you. Don't you know an algorithm which could render this point were talking all about and with the cam you added to the algorithm, but as an optional parameter there would also be another point to which the cam would be looking?R. Hollenstein
r.hollensteina at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 10
Hello I have values of X Y Z coordinates.I want to draw a curve by using this in java 3d. I am new in java 3d .so please help me in this regards in detail.torkmishramca@yahoo.com
rakeshkumarmishraa at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 11

Hi MaxJust,

It sounds like you are just the person to help me out here.

I have a graphing requirement to render a data set in the same way as you can in Excel, using a 3d surface render.

I am a little stuck as to how to accomplish this. Say for example my data set is something like this:

1Y2Y3Y

1M11.417.918.9

2M12.618.519.5

3M13.718.919.8

4M16.519.920.6

I will assume my X are rows and Y are columns and Z is the value. I could calculate the X and Y using the screen size / number of points I think.

I saw your algorithm earlier in the group, I was wondering how I would apply that to this data set?

Cheers,

Steve

S_P_Ga at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 12
why X_SCREEN_WIDTH and Y_SCREEN_WIDTH is used in the formula.
jack123a at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 13
> why X_SCREEN_WIDTH and Y_SCREEN_WIDTH is used in the formula.To get a consistent field of view, regardless of the screen size.
YAT_Archivista at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 14
CHILDREN!!!!GOOGLE "3D pipeline rendering"This will solve all of your problems...There is a sequence of events you must do before rendering a 3d world/image. The 3d pipeline will explain this sequence and how to implement it... good luck young ones :)
ArikArikArika at 2007-7-16 13:14:25 > top of Java-index,Other Topics,Algorithms...
# 15
> CHILDREN!!!!> GOOGLE "3D pipeline rendering"The first match in google points back to this thread. We are in an infinite loop...
perkelea at 2007-7-20 18:50:58 > top of Java-index,Other Topics,Algorithms...