- AVS Troubleshooting
- Help 3D ball
Archive: Help 3D ball
Burningwing
18th October 2003 14:49 UTC
Help 3D ball
im quiet new 2 superscopes but i know the basics of 2D and try 2 learn 3D
now my question is how do i make a 3D ball i did get a circle that is moving but what 2 put in z1???
INT
n=200;r=0.5; mx=0;my=0;mx=0;dst=2;rx=0;ry=0;rz=0;rdx=1;rdy=1;rdz=1;p=3.14159265;p2=2*p;p3=180/p
onbeat
rdx=rand(3)+1;rdy=rand(3)+1;rdz=rand(4)+1;
perframe
fr=fr+0.01;mz=1+sin(fr); rx=rx+rdx;ry=ry+rdy;rz=rz+rdz; xs=sin(rx/p3);ys=sin(ry/p3);zs=sin(rz/p3);xc=cos(rx/p3);yc=cos(ry/p3);zc=cos(rz/p3);
per point
d=0.7;
x1=sin(r)*d;
y1=cos(r)*d;
z1=0;
y2=y1*xc-z1*xs; z2=y1*xs+z1*xc;
x2=z2*ys+x1*yc; z3=z2*yc-x1*ys;
x3=x2*zc-y2*zs; y3=y2*zc+x2*zs;
x4=mx+x3; y4=my+y3; z4=mz+z3;
x=x4/(1+z4/dst);y=y4/(1+z4/dst);
OBS i didet write the code only changed it a bit!!
PLS HELP ME
Burningwing
18th October 2003 16:26 UTC
iv found 1 way
i=i*p;
x1=sin(i)*sin(i*30)*d;
y1=cos(i)*d;
z1=sin(i)*cos(i*30)*d;
but does it exist any other way 2 make a ball that dont look like that?
Deamon
18th October 2003 17:56 UTC
I always use the way you posted the second time.
UIUC85
18th October 2003 21:21 UTC
well maybe if you wanted to do a geodesic sphere... but the code for that would be a pain... well in comparison to the normal sphere we use. Do you understand why that second bit of code works as a sphere?
Nic01
18th October 2003 23:54 UTC
Is that as in you want to know or checking if he knows?
I don't know what a geodesic sphere is [mind explaining?], but here's another way :
(parallels/*******ns, requires 2 scopes)
(stripped from UCD's Groovy Saturn, Whacko II)
(Try to understand how it works, then customize it to your liking)
Parallels :
n=261;nc=25;nm=.2;sf=1.2
red=cr;green=cr;blue=cr;
cr=1-cv;cg=1-cv;cb=1-cv;
rad=cos(mp*1.57);
py=cos(rp/nc*6.28)*rad;pz=sin(rp/nc*6.28)*rad;px=sin(mp*1.57);
x1=px*cz+py*sz;y1=py*cz-px*sz;
y2=y1*cx+pz*sx;z2=pz*cx-y1*sx;
x3=x1*cy+z2*sy;z3=z2*cy-x1*sy+2.5;
x=if(above(z3,0.1),x3/z3,x);y=if(above(z3,0.1),y2/z3*1.33,y);
rp=if(equal(cv,0),(rp+1)%nc,rp);
mp=if(equal(cv,0),mp,mp+nm);
cv=if(equal(rp,0),1-cv,0);
x=x*sf;y=y*sf;
*******ns :
n=261;nc=50;nm=.2;sf=1.2
rad=1;
px=cos(rp/nc*6.28)*rad;py=sin(rp/nc*6.28)*rad;pz=0;
y0=py*cos(mp*3.14);z0=py*sin(mp*3.14);
x1=px*cz+y0*sz;y1=y0*cz-px*sz;
y2=y1*cx+z0*sx;z2=z0*cx-y1*sx;
x3=x1*cy+z2*sy;z3=z2*cy-x1*sy+2.5;
x=if(above(z3,0.1),x3/z3,x);y=if(above(z3,0.1),y2/z3*1.33,y);
rp=if(equal(cv,0),(rp+1)%nc,rp);
mp=if(equal(cv,0),mp,mp+nm);
cv=if(equal(rp,0),1-cv,0);
x=x*sf;y=y*sf;
--
Optimize by yourself, plug in the missing parts, it's all in the life of a coder.
UnConeD
19th October 2003 05:08 UTC
That's old code though ;). Lacks some common optimizations and correct aspect ratio correction (assume 4/3 ratio).
A geodesic sphere is where you start off with one of the platonic solids, and subdivide the faces into triangles. You then project the vertices back onto a unit sphere.
When you start with an icosahedron, you can nearly-even distribution of triangles, because the amount of triangles touching at a vertex is at least 5, at most 6.
For a tetrahedron for example, you'd have vertices where only 3 triangles touch, which is a lot different from 6.
http://www.gardendome.com/spheres.JPG
On the left, an icosahedral geosphere on the right an octahedral geosphere.
Would be lots of handwork to do this in AVS because there's no easy way to automatically generate one (lack of arrays and looping).
dirkdeftly
19th October 2003 06:06 UTC
hello. i am atero. i have been on these forums for many moons. it is a pleasure to meet you. through much spiritual meditation and chanting of the verses of the great buddha, i have become a mean bastard, and over time you will grow to loathe me, like the british hate the united states.
on that note, stop typing like a four year old you fucking retard.
welcome to the avs forums.
uNDefineD
19th October 2003 08:39 UTC
Originally posted by Atero
on that note, stop typing like a four year old you fucking retard.
Why don't you stop acting like one?
This would be a good time to re-ask the question that you never answered a few months back: why does it bother you?
BTW, am the only one that found it rather ironic that you didn't capitalise any sentences in that post? ;)
UIUC85
19th October 2003 09:08 UTC
Yeah unconed that's why I mentioned the arrays in the wishlist forums lol. Not a very plausible idea, but it'd be kinda neat just for techie purposes. Nice models too :eek:
Nic01, yeah I was asking if he understood why it works.
dirkdeftly
19th October 2003 17:55 UTC
well ndd, i could ask you why do my posts bother you, couldn't i...but that would be mean....
uNDefineD
20th October 2003 00:14 UTC
Because I'm fucking sick of you hanging shit on newbies just because they don't type in a way you'd prefer. Does that answer your question? Now for the third time: answer mine.
sidd
20th October 2003 10:48 UTC
x1=sin(i)*sin(i*30)*d;
y1=cos(i)*d;
z1=sin(i)*cos(i*30)*d;
noone is going to care explain why it works?
well:
if you have x1=sin(i*30); z1=cos(i*30) then your scope is making a circle shaped thing on the x/z plane. only the circle is drawn more than once (looksee the *30 instead of *2pi).
then you make y1=cos(i), so that it stretches the scope along the y axis, dispersing it such that most of the circles are at near -1 and 1, and it thins out around 0 on the y axis.
then you times what you have in x1 and z1 by sin(i), that way the circle get smaller and smaller as they approach the start and end of i. (which we have just assigned to -1 and 1 on the y axis.) but they are the original size in the exact middle of i (which is 0 on the y axis)
so now what you have is a spiral shaped thing that is stretched out to form a spiraly circle.. YAAAY!
then you times all the axis by your constant d to resize evenly.
You should also times i by 2pi before all this so that you know exactly what you are coding (eg, using i*30 would then make the circle have 30 spirals exactly.)
dirkdeftly
20th October 2003 15:38 UTC
ndd, you just don't get the point do you...you can't bitch about me bitching about n00bs and their typing habits and say i'm wrong for doing it, cos you're doing the exact same thing.
Burningwing
20th October 2003 15:39 UTC
hmmm did u all forget what my question was stop geting angry in here
UnConeD
20th October 2003 17:42 UTC
Atero/ndd: Mirror mirror on the wall, who's the naggiest bitch of them all?
UIUC85
20th October 2003 19:42 UTC
You guys done posting flames and fairy tale rhymes yet?
dirkdeftly
21st October 2003 06:19 UTC
i was a while ago :rolleyes: anyway i think sidd answered your question pretty clearly....