A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: 3d menu math script hell! ahhh!

  1. #1
    disco monkey monkeysquid's Avatar
    Join Date
    Jan 2003
    Location
    Glasgow - the armpit of the north.
    Posts
    306

    3d menu math script hell! ahhh!

    hi, i origionally posted this in the actionscript forum but it was lost in a sea of other posts and left pretty much un-answered so i'm posting it here to see if i can get any help. i am novice user of flash, i've done a bit of c++ but am eager to learn.

    i've been playing about with a few of the tutorials and i came across the very well written 3d flower tutorial and low and behold managed to get it working. you can see my results at my homepage . anyway, i was thinking of useing it in a project at collage as the menu system in a report, i.e. spin it around and choose an arm to go to each page, i know its not the best for ease of navigation but the lecturer was suitably impressed and hinted if i got it working it would be worth my while.

    now to my problem, the code is quite complicated and its not really like anything i've done before, its out of the scope of the lecturer at collage so i've been haveing a bash at it myself. heres the code:



    Code:
    Points = 11;
    Lines = 10;
    
    Viewport = 500;
    
    rad = (3.14*2)/360;
    
    line = new Array(Lines);
    vertex = new Array(Points);
    
    fscommand ("fullScreen", true);
    
    for (i=0; i != Lines; i++) {
    wire.DuplicateMovieClip("l" add i, i);
    line[i] = eval("l" add i);
    }
    for (i=0; i != Points; i++) {
    point.DuplicateMovieClip("v" add i, (Lines*2)+i);
    vertex[i] = eval("v" add i);
    }
    
    vertex[0].x = 0; 
    vertex[1].x = -100;
    vertex[2].x = -150;
    vertex[3].x = -150;
    vertex[4].x = 0;
    vertex[5].x = 100;
    vertex[6].x = 150;
    vertex[7].x = 100;
    vertex[8].x = 150;
    vertex[9].x = 0;
    vertex[10].y = 0;
    vertex[0].y = 0;
    vertex[1].y = -100;
    vertex[2].y = 0;
    vertex[3].y = 100;
    vertex[4].y = 150;
    vertex[5].y = 100;
    vertex[6].y = 0;
    vertex[7].y = -100;
    vertex[8].y = -150;
    vertex[9].y = 0;
    vertex[10].y = 0;
    vertex[0].z = 0;
    vertex[1].z = -100;
    vertex[2].z = 0;
    vertex[3].z = 100;
    vertex[4].z = 0;
    vertex[5].z = 100;
    vertex[6].z = 0;
    vertex[7].z = -100;
    vertex[8].z = 0;
    vertex[9].z = -150;
    vertex[10].z = 150;
    
    line[0].a = 0;
    line[0].b = 1;
    line[1].a = 0;
    line[1].b = 2;
    line[2].a = 0;
    line[2].b = 3;
    line[3].a = 0;
    line[3].b = 4;
    line[4].a = 0;
    line[4].b = 5;
    line[5].a = 0;
    line[5].b = 6;
    line[6].a = 0;
    line[6].b = 7;
    line[7].a = 0;
    line[7].b = 8;
    line[8].a = 0;
    line[8].b = 9;
    line[9].a = 0;
    line[9].b = 10;
    
    function Rotate (x, y, z) {
    radx = rad*x;
    rady = rad*y;
    radz = rad*z;
    for (i=0; i != Points; i++) {
    vertex[i].x1 = vertex[i].x;
    vertex[i].y1 = (Math.cos(radx)*vertex[i].y)-(Math.sin(radx)*vertex[i].z);
    vertex[i].z1 = (Math.sin(radx)*vertex[i].y)+(Math.cos(radx)*vertex[i].z);
    vertex[i].x2 = (Math.cos(rady)*vertex[i].x1)-(Math.sin(rady)*vertex[i].z1);
    vertex[i].y2 = vertex[i].y1;
    vertex[i].z2 = (Math.sin(rady)*vertex[i].x1)+(Math.cos(rady)*vertex[i].z1);
    vertex[i].x3 = (Math.cos(radz)*vertex[i].x2)-(Math.sin(radz)*vertex[i].y2);
    vertex[i].y3 = (Math.sin(radz)*vertex[i].x2)+(Math.cos(radz)*vertex[i].y2);
    vertex[i].z3 = vertex[i].z2;
    }
    }	
    
    function toScreen () {
    for (i=0; i != Points; i++) {
    vertex[i].dx = (vertex[i].x3*viewport)/(vertex[i].z3+600)+350;
    vertex[i].dy = (vertex[i].y3*viewport)/(vertex[i].z3+600)+262.5;
    }
    }
    
    function render () {
    for (i=0; i != lines; i++) {
    with (line[i]) {
    _visible = true;
    _x = vertex[line[i].a].dx;
    _y = vertex[line[i].a].dy;
    _xscale = vertex[line[i].b].dx-vertex[line[i].a].dx;
    _yscale = vertex[line[i].b].dy-vertex[line[i].a].dy;
    }
    }
    for (i=0; i != points; i++) {
    with (vertex[i]) {
    _x = dx;
    _y = dy;
    _xscale = 75+(((((500-z3[i])/10)*30)/100)*(-1));
    _yscale = 75+(((((500-z3[i])/10)*30)/100)*(-1));
    _alpha = ((((z3[i]*(-1))+500)/10));
    }
    }
    }
    var ax, ay, az, oldx, oldy, bx, by, bz, nu;

    now from what i understand from reading various texts and such for starters i should be makeing more movie clips titled "links" "page 1" etc and then declareing them at the top of the script in place of one of the parts of the points array. then i need to create arrays for the instances name, both of these i have done then in the bits i have coloured blue insert the names of the new movie clips but keep the values they are assigned i.e. the -150, etc. which i have also given a shot. then we bypass the red which i will get to later and go to the green which i think is to be duplicated with the appropriote names substituted much the same as the blue bits. now to the red, i have absolutly no idea what i should be doing with these bits of code, i'm not sure if i'm just getting blinded by all the maths especially the top red bit.

    anyway thanks for reading this, i would really appreciate some help if possible, even just directing me to somewhere where i could find some stuff to read up on that would help.

    p.s. i've also attatched the .fla file if anyones curious.

    cheers, monkeysquid.


    w
    Attached Files Attached Files

  2. #2
    disco monkey monkeysquid's Avatar
    Join Date
    Jan 2003
    Location
    Glasgow - the armpit of the north.
    Posts
    306
    managed to get it sorted, it wasn't a case of declareing new bits i just had to put different movie clips in each part of the array, i was going off in completly the wrong direction but its sorted now and looking rather nice even if i do say so myself. however, another problem has arose. i can't actually attatch mouse activated scripts to movie clips, it has to be a button and the script doesn't work with buttons i've tried imbedding buttons in the movie clips but that doesn't work.

    does anyone know if there is anyway i could put a:
    Code:
    on (release) {
    	gotoAndPlay("Scene 2",1);
    }
    in the main body of the script? or some other solution, or am i up the proverbial **** creak?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center