Heylo!
i want to display 3D objects on a JPanel, or make it look like it's 3D, by changing the points of a certain shape... maybe that sounded a bit complex but here's a video of what I quickly punched together today (don't mention the bugs):
obviously i'm using x,y, and z.
Now assume: i drop the Y factor, just x and Z AND I will only move my mouse horizontally.
So if i move my mouse to the right, a point drawn should move to the right, but at the same time the z should lower(which isn't visible, due to 2D screens). Think of it like a point on a circle. if the point goes to the right or left, it also goes up or down.
Now i'm looking for a formula which lets me calculate that when i move my mouse 100px to the right, how much i should increase/decrease the x value, and how much i should decrease/increase the z-value. It's probably something with cos and sin, but i can't find it.. Any smart person that could help me? (2z = circle's diameter me thinks)
currently i don't do that, so at the bottom of my frame, in the 3th textfield i display the distance between point A & B .. that should normally be pretty constant
It's just a JPanel basicly where i draw lines on
i'm using a 'master point' for each point so the same line doesn't get drawn multiple times. in the example i use 3 points:Code:for (Point point : points) { for (Point neighbor : point.getNeighbors()) { if (neighbor.getMaster() == point) g.drawLine((int) point.getX(), (int) point.getY(), (int) neighbor.getX(), (int) neighbor.getY()); } }
master of A = C
master of B = A
master of C = B
so even though C will look at A because it's his neighbour, it hasn't got the authoroty(C isn't the master of A) to draw a line between him and point A. something i learned from my networking class for a broadcasting algorythm
PS(Where did the [highlight=java] tag go to?)
Okay, got it, Can't believe i didn't think of this last night. My brain probably went to bed early
It's like this
i know z, and dX is the amount of px i moved my mouse to the right.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks