Code java:

import java.applet.Applet; import java.awt.*; import java.util.Timer; import java.util.TimerTask; public class ThreeD extends Applet { float[] x = new float[4]; float[] y = new float[4]; float[] z = new float[4]; int angle = 10; int[] sx = new int[3]; int[] sy = new int[3]; public void init() { setSize(854,480); Timer t = new Timer(); t.schedule(new TimerTask(){ public void run(){ float angle2 = (float) Math.toRadians(angle++); x[0] = -50; y[0] = 10; z[0] = 1; x[1] = 50; y[1] = 10; z[1] = 1; x[2] = 10; y[2] = -150; z[2] = 1; float newx0 = (float) (y[0] * Math.cos(angle2) - z[0] * Math.sin(angle2)); float newy0 = (float) (y[0] * Math.sin(angle2) + z[0] * Math.cos(angle2)); float newx1 = (float) (y[1] * Math.cos(angle2) - z[1] * Math.sin(angle2)); float newy1 = (float) (y[1] * Math.sin(angle2) + z[1] * Math.cos(angle2)); float newx2 = (float) (y[2] * Math.cos(angle2) - z[2] *Math.sin(angle2)); float newy2 = (float) (y[2] * Math.sin(angle2) + z[2] *Math.cos(angle2)); /* * X-ROT * float newY = y*cosAngle - z*sinAngle; * float newZ = y*sinAngle + z*cosAngle; * * Y-ROT * float newX = z*sinAngle + x*cosAngle; * float newZ = z*cosAngle - x*sinAngle; * * Z-ROT * * float newX = x*cosAngle - y*sinAngle; * float newY = x*sinAngle + y*cosAngle; * */ y[0] = newx0; z[0] = newy0; y[1] = newx1; z[1] = newy1; y[2] = newx2; z[2] = newy2; sx[0] = (int) (((x[0])/z[0]) + (854/2)); sy[0] = (int) (((y[0])/z[0]) + (480/2)); sx[1] = (int) (((x[1])/z[1]) + (854/2)); sy[1] = (int) (((y[1])/z[1]) + (480/2)); sx[2] = (int) (((x[2])/z[2]) + (854/2)); sy[2] = (int) (((y[2])/z[2]) + (480/2)); repaint(); } }, 20,20); } public void paint(Graphics g) { g.drawLine(sx[0], sy[0], sx[1], sy[1]); g.drawLine(sx[1], sy[1], sx[2], sy[2]); g.drawLine(sx[2], sy[2], sx[0], sy[0]); } }

Hello All,

My name is Donny and I'm very proficient at a few programming languages, my problem is this:

I'm new to 3D Math, so forgive me if it is a simple fix, but any rotation other than Z will not produce a desired result!.

The above code is an example of what I'm trying to do, and produces the same result. When I try to do a rotation on the X or Y axis they do not work like they should.

I'm trying to make a basic 3D game (software rendered, without any libraries needed by the user) that is multi-platform and multi-player. I have the server and basic client(a 2d variation) completed, I'm just trying to employ a nicer client.

Any help is greatly appreciated, sorry for my ignorance with the concept, I'm sure I'll get it down someday.

Thanks,

Donny.

EDIT: Sorry about the formatting, it didn't carry over well.