dcsimg
A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: 3d engine coodinates

  1. #1
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    3d engine coodinates

    How does one make a 3d coordinate system so that you could draw lines in actionscript? for eg.-
    (30,40,-20) connected to (40,30,-30)
    This making a line though, slightly diagonal.

    Does anyone have a helpful link, or an explanation? I'm cluless, but I've been working on this for a while, so it shouldn't take much explaining.



    Thanks in advance!

  2. #2
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    i don't know if this is what your after. it's an equation to convert 3d co-ordinates to 2d.
    http://www.macromedia.com/desdev/art...murai_ch2.html
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  3. #3
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    No, not really...

    Well, that site told me what I already need to know. Basically what I need to do, is use actionscript to plot the points of a line, so that I could make an array of lines for example. But these coordinates must have a z factor because I need to rotate this whole thing sideways so you see the whole thing, and it looks 3d. I've seen this done, I just don't know how. Basically it's plotting lines with actionscript, and then rotating the final image.


    Do ya know what I mean?

  4. #4
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    you could use an array of objects. the co-ordinates you gave would look like this;
    definition;
    Code:
    point = [ { x: 30, y: 40, z: -20 }, { x: 30, y: 40, z: -20 } ];
    and to reference them you would use;
    Code:
    y = point[0].y;
    x = point[0].x;
    z = point[0].z;
    does that help?
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  5. #5
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    Could you expand?

    I can see you know what you're talking about; basically I want to make an object that involves a bunch of lines, and I'm using it in a 3d movie. What I have is this movieclip going in a circle, but a z axis circle, so it looks like it's going from big to little in a circle. If you don't understand that, don't worry. To make this object look like it's rotating around the screen, inside the movieclip, I must have the object spinning on it's axis, and I know that I could use a 3d engine for this. So, if you could, could you tell me how to draw for example, a 2-line object like this- > - in actionscript? One that could be rotated so it looked 3d?

    The explanation you gave helped me a bit, but I just don't understand where it all goes. I'm familiar with actionscript, but not with this coordinate jazz.



    Could you expand on your code?


    The dog has bent to his knee to ask for assistance from the master!

  6. #6
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,978
    dude, you do know that is rather disrespectful, right? sorta like you're rolling your eyes as if you don't care.

    just some clarification.


    now, back to the question.

    what BlinkOK just showed via code was that you you have to define your points in a 3D coordinate system. you could draw lines connecting the dots, and then allow the dots to all move with a transformation of X, Y, and Z... thus rotation when the points that are defined change.

    better yet, why not show your code that you already have?

    [ Hello ] | [ gerbick ] | [ Ω ]

  7. #7
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    REALY SORRY ABOUT THE EYE THING

    First of all, the roll eye thing was not me trying to be disrespectful, I don't look at it that way, in fact, I didn't know that it meant rolling eyes, I meant it as- "i'm looking up to your genius" kind of thing. ANYway. I've gotten my code from a reliable source, but anyway that's not the point. I can't figure out how to make it draw any lines. here's the code-
    Code:
    function drawline(x1, y1, x2, y2, col, object) {
    
    	object.lineStyle(1, col, 100);
    	object.moveTo(x1, y1);
    	object.lineTo(x2, y2);
    }
    Does that help explain? By the way, if that was the code, the one Blink put, where in the timeline should I put it? As in, a movieclip, the first frame, where? Mainly because there's 2 sets of code. I'm not too familiar.

  8. #8
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,978
    I'm almost sure that the code is on the first frame.

    [ Hello ] | [ gerbick ] | [ Ω ]

  9. #9
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    ARRRRRR

    I just tried it! I put all the stuff blink said in the first frame, and nothing happened! What was supposed to happen by the way?


    Could you help?

  10. #10
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    Okay, getting there...

    I think I'm getting close to how to do this. I've figured out how to draw lines with actionscript. I'm now using this code to draw a horizontal line across the stage.
    Code:
    _root.createEmptyMovieClip("line", 1);
    with (_root.line) {
    	lineStyle(20, cccccc, 1000);
    	moveTo(0,100);
    	lineTo(400,100);
    }
    Now, this projects 2 points on the stage obviously. How could I, for example, rotate this line, so it looked like it was spinning around? It would look like a line going from big to small, in the middle of it or something.



    Any help is appreciated!

  11. #11
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    try this;
    Code:
    point = [ { x: 30, y: 40, z: -20 }, { x: 30, y: 40, z: -30 } ];
    //
    function to3d(p) {
     var d = 100 / ( 100 + p.z);
     return({ x: p.x * d, y: p.y * d });
    }
    //
    function drawline(p1, p2) {
     var r;
     lineStyle(2, 0);
     r = to3d(p1);
     trace("["+p1.x+","+p1.y+","+p1.z+"]("+r.x+","+r.y+")"); 
     moveTo(r.x, r.y);
     r = to3d(p2);
     trace("["+p2.x+","+p2.y+","+p2.z+"]("+r.x+","+r.y+")"); 
     lineTo(r.x, r.y);
    }
    //
    l = point.length;
    for(i=0;i<l;i++) {
      n = i + 1;
      if (i == (l-1))
          n = 0;
    trace(i+":"+n);
      drawLine(point[i], point[n]);
    }
    stop();
    place the code in frame 1 on the main timeline of a new movie. this code will join the dots in the point array, when it gets to the last element it will joint to the first element. the trace statements will show what's happening
    hope this helps
    blink
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  12. #12
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    Syntax error

    You've made a syntax error I beleive, it says that the first line of the code, right, the left side has to be a variable or opperand or something. Anyhow, if it makes a difference, I'm using mx.

    P.S. at the same time when you posted, I did Too! Cool huh?

  13. #13
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,978
    do you mean something like this is what you're after?

    [ Hello ] | [ gerbick ] | [ Ω ]

  14. #14
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    if i copy and past the code into mx it works fine.
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  15. #15
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    Oh, well..

    oh, well, it works for me now too. Must have forgotten the first digit or something. anyway, that's a long complicated method, although I can't say it's worse or better than this way-
    Code:
    function drawline(x1, y1, x2, y2, col, object) {
    
    	object.lineStyle(1, col, 100);
    	object.moveTo(x1, y1);
    	object.lineTo(x2, y2);
    }
    
    _root.createEmptyMovieClip("stickman", 1);
    drawline(0, 0, 200, 200, 0x000000, "stickman");
    drawline(200, 200, 500, 500, 0x000000, "stickman");
    That looks to me like it should work, but it dosen't. Can't realy understand the problem, of course I don't work with functions a lot. Could you guys see the problem?

    By the way, THANKS SO MUCH FOR THE CODE, BLINKOK, but how would I rotate an object made with this code? Do you know?

    Anyway, thanks!
    If you can read this, You're to close to your computer screen.

  16. #16
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    i can give you a solution but the camera's rotation will be constrained along the horizontal axis. in other words you won't be able to look up or down. you will be able to move up and down, just not look up or down. is that ok?
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  17. #17
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118

    Yeah...

    Yeah, Yeah man! That would be great! Don't worry, I don't need any horizontal camera angles, all I need is the camera to spin around an object!

    Flash isn't swift, I know.
    If you can read this, You're to close to your computer screen.

  18. #18
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    here is a very short tutorial for a 3d plane;
    http://www.nlc.net.au/~oceana/tutori...erspective.htm
    hope it helps
    blinkok
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  19. #19
    There Were No Good Names Left
    Join Date
    Dec 2002
    Location
    Edge of a building
    Posts
    118
    You...Are...My...GGGGGGGGGGOOOOOOOOOOOOOOODDDDDDDD DD!

    Thank YouSOOOOOOOOOOO Much!

    I haven't even looked at the fla., but you are BRILLIANT!!!!!!!

    I'll just see if it works, and I'll right back like tomorrow. So, you can check it tomorrow sometime if you want
    If you can read this, You're to close to your computer screen.

  20. #20
    Senior Member
    Join Date
    Jan 2003
    Posts
    131
    Originally posted by gerbick
    do you mean something like this is what you're after?
    hi gerbick,

    i reworked the 3d-cube.fla you posted a bit - you can see it here . problem is : i want it to rotate by itself - in such a way that each point gets to eventually take the *spotlight* in the front ...

    i would appreciate if you could point me in the right direction?

    Last edited by bryan.fury; 02-26-2003 at 03:31 PM.

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