I dare ya on this one..
No one has ever figured out how to make the z-indexing work for this puppy.
It's found live at http://www.naltabyte.se/space
It's using a shorter calculation for 3D than would otherwise have been the case, and I understand what it does - which matters to me - so I like it, except it can't crank out a correct viewport to allow calculation of the z-index.
I'll pay a 100 dollars to anyone who solves this, and I'm kidding you not, I'm that frustrated with it.
Also, anyone that can find a shorter and more efficient way of doing the same is welcome..
[pre]
//----Code beginning----
function point(y, x, a, width, height,x2,y2)
{
/*
a is the angle.
x is the x-value.
y is the y-value.
width is the width of the area used to project the shape.
height is the height of the area, and the lower this value, the more we see the shape from the side, and the higher, the more we see it from above.
If height is equal to width, we see it directly from above.
x2 and y2 is the center of the projection.
*/
var x1=sphereCos(a,width);
var y1=sphereSin(a,height);
var z=eval(cutData(a)+"+"+90);//Creates a z-value out of the angular value.
var c=-((y*height)*(z/100))/1000;
if(height < 0){c=-((y*(-height))*(z/100))/1000;}
if(x != 0)
{
if(height >= 0){ x=x-((x/1000)+(y*(height*0.0009)));}
else { x=x-((x/9.9)+(y*(height*0.0009)));}
if(y > 0){y=y-c;}
if(y < 0){y=eval(y+"+"+c);}
x=x+(z/60);
}
/*
Here I 'project' the point in space, going out in a given direction a set number of points (x) to draw the 3D-shape point by point.
Problem is, I cant figure out a natural way of defining the viewport so that I
can calculate a z-index for it.
I figure I need to use the height/width relation to decide from which angle the object is viewed.
*/
if(x >= 0){for (j=0; j <= x; j++){p1=Math.round(x2 += x1);p2=Math.round(y2 += y1);}}
else {for (j=0; j <= -x; j++){p1=Math.round(x2 -= x1);p2=Math.round(y2 -= y1);}}
if(height >= 0){tY=(((width-height)*y)/100);z=z+(-tY)}
else {tY=(((width-(-height))*y)/100);p2=-p2;z=z+(tY)}
/*
The value is returned in a format suitable for VML-polylines.
*/
return Math.round(p1-(tY/360))+","+Math.round(p2 + tY)+" ";
}
function cutData(arg,arg2)
{
/*
Basically, it returns the angular value (arg) into integers ranging from -90 to 90
meaning that the z-value is set from the back to the front.
*/
if(arg < 0){arg=-arg;}
if(arg=="0"){arg++;}
if(!arg2){arg2=0;}
if(arg > 360){ arg=arg-360;}
if(arg > 90 && arg < 270){arg=180-arg; arg=eval(arg+"+"+arg2); return arg;}
else if(arg >= 180 && arg < 270){arg=arg-180;arg=eval(arg+"+"+arg2); arg=-arg; return arg}
else if(arg >= 270 && arg <= 360){arg=eval(arg+"+"+arg2); return arg-360;}
else return eval(arg+"+"+arg2);
}
function sphereCos(arg1,arg2){return (parseInt(Math.cos(2 * Math.PI * arg1 / 360) * arg2))/160;}
function sphereSin(arg1,arg2){return (parseInt(Math.sin(2 * Math.PI * arg1 / 360) * arg2))/160;}
//-------Code ending--------
[/pre]
(^-^)b