Page 1 of 1

Define a 3D-Depth

PostPosted: Sun Jun 24, 2012 5:15 am
by Hblade
How would I go about making a Z-Depth for a 3D Wireframe (Very very basic model), all created with canvas? I'd like to use something like this to create a wired 3D world. It would be very very interesting

Re: Define a 3D-Depth

PostPosted: Sun Jun 24, 2012 5:37 am
by skydereign
Well, what is the wireframe? Assuming you want something like a cube, then to represent it in 3 space, you would need to have points that have an x, y, and z values. The cube is comprised of 8 of these points. So, either you can have 8 sets of 3 ints in an array, or perhaps declare a structure to represent a point in 3 space (and create an array of 8 points). Either way, it is pretty standard.

Re: Define a 3D-Depth

PostPosted: Sun Jun 24, 2012 3:26 pm
by Hblade
I"ll use this information. Thanks

Re: Define a 3D-Depth

PostPosted: Tue Jun 26, 2012 2:15 am
by SuperSonic
Hblade, if you get very far with this, please let me know. I've been trying to get into 3d programming as well :P

Re: Define a 3D-Depth

PostPosted: Sat Jun 30, 2012 12:20 am
by Hblade
So far I've gotten nowhere. I can't figure out the algorithm. And I won't have internet for about a week or 2 so that sucks xD

Re: Define a 3D-Depth

PostPosted: Thu Jul 05, 2012 5:03 pm
by savvy
You need to have an array represented as so...
vertices[numberofpoints][2][10];
coordinates
[1][[0] being x value
[1][1] being y value
[1][2] being z value

connections
[2][number] being what a line is drawn to, example:

vertices[0][1][0,1,2] = 1;
vertices[1][1][0,1,2] = 5;
then
vertices[0][2][0] = 0; <- Makes it connected to the point in vertices[0]

Then for drawing it you need to use projection, sin, cos, tan etc, to place the points prospectively on the canvas.

!!EDIT!!: You need to plot the poitns first, THEN use lineto to draw the lines in using the vertices connection in the array.

savvy

PS: I will eventually work on such a projection algorithm, but right now I'm working on something else. XD

Re: Define a 3D-Depth

PostPosted: Fri Jul 06, 2012 9:37 am
by Hblade
Sounds insanely copmlicated haha. But I bet once you understand it its simple.

Re: Define a 3D-Depth

PostPosted: Fri Jul 06, 2012 9:40 am
by savvy
It's not too complicated to grasp the concept, its more the math behind placing the depth of the coordinates that is the issue!

Re: Define a 3D-Depth

PostPosted: Sat Jul 21, 2012 9:23 pm
by Hblade
True