A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: MODEL world coordinate system in Flax MX

  1. #1
    Junior Member
    Join Date
    Dec 2004
    Posts
    5

    MODEL world coordinate system in Flax MX

    How can I MODEL world coordinate system in flash?

    I have got a AutoCAD siteplan map in dxf format (which is in real-world coordinate system). I have also stored x, y coordinate of some stations (boreholes) on this map in a database which are again in real-world coordinate (like x=50000, y=-120000). I would like to be able to plot these stations into the map (that I import into flash) on the fly by reading the x and y coordinates. But the coordinate needs to be change/transformed/translated so that it matches up with the screen coordinate and therefore appears on the map AT THE RIGHT SPOT. In SVG, I was able to specify a viewbox...can can I do this in flash? Let's say I know the orgin x and y of the map is x= -959742 and y=-3518979 ...therefore the x and y of the stations are in this range......I just want to know how I can convert the x and y of my stations to X, Y screen coordinates to match it up with the imported autoCAD drawing map.

  2. #2
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    I have not looked up what flash's size limitation is, but I think the _x and _y coordinates you mention are larger that what flash allows, not sure how to reduce them without a demo of what your trying to do. One thing I can think of off the top of my head is using an array based coordinate system that takes into account a z depth and places the objects on a map according to an array and limits the view of the map.
    code:

    MapEntities = 20;
    MapType = ["object1", "object2", "object3", "object4", "object5", "object6", "object7"];
    MapObj = [1,7, 1, 1, 1, 3, 3, 3, 3, 3, 3, 6, 6, 6, 6, 3, 2, 5, 5, 5];
    MapX = [0,0, 516, 814, -1500, -255, -433, -600, -711, -745, -734, 400, 717, 1717, 3000, -1810, -317, -271, -359, -410];
    MapY = [0,0, 3480, 3520, 2500, -538, -475, -356, -204, -7, 189, -120, -86, -1286, 3000, 4000, -21, 56, 53, -16];



    then something like this to actually move the 'world coordinates' according to the perspective view...
    code:

    if (_root.hit == true) {
    //uses mouse position to determine world position. This could be
    //coded to buttons or whatever
    angle = angle+(_root._xmouse-_root.world._width/2)/6000;
    if (Math.abs(angle)>Math.PI) {
    angle = -angle;
    }
    step = (_root._ymouse-_root.world._height/2)/20;
    y = y+Math.cos(angle)*step;
    x = x+Math.sin(angle)*step;
    }
    MovieClip.prototype.moveworld = function() {
    with (this) {
    y1 = y-_root.y;
    x1 = x-_root.x;
    if (Math.abs(y1)>hide_dist or Math.abs(x1)>hide_dist) {
    _visible = false;
    } else {
    alpha = Math.atan(x1/y1)-((y1>0) ? Math.PI : 0);
    beta = _root.angle-alpha;
    beta = (beta>Math.PI) ? (beta-pi2) : ((beta<-Math.PI) ? (beta+pi2) : beta);
    if (Math.abs(beta)>hide_area) {
    _visible = false;
    } else {
    a = Math.sqrt(x1*x1+y1*y1)*Math.cos(beta);
    if (a>hide_dist) {
    _visible = false;
    } else {
    _visible = true;
    _x = _root.world._width/2-_root.world._width*Math.sin(beta);
    ratio = _root.world._width/a;
    _y = _root.world._height/2-ratio*(z-_root.z)-100;
    _yscale = ratio*100;
    _xscale = _yscale;
    swapDepths(hide_dist-a+1000);

    }
    }
    }
    }
    }



    This pseudo code uses a maximum world size of 6000. You can create a move system by simply declareing "hit=true". This will place the objects at the coordinates in the array and limit the view until you are within a certain distance. This may not be what your after at all, but the 'world' idea is what brought this to mind. I have a demo somewhere of a simulated 3D world in flash that I played around with for some time trying to learn how it was done.The MovieClip.prototype.moveworld is straight out of it, but I pasted it to a textfile to test some things and I can't seem to find the fla at the moment.

    Hope it helps
    NTD

  3. #3
    Junior Member
    Join Date
    Dec 2004
    Posts
    5

    autoCAD map coordinate to flash Cartesian coordinates

    Thank you. My question is:
    "How can I convert autoCAD map (global coordinate system) to flash Cartesian coordinates".

    I have got some points (stations) for which I have stored the Global Position X and Y in a database. In SVG, I was able to read those X, Y and import it into the map and plot it in the right spot (by specifying SVG viewbox for the map). How can I do this in Flash??
    Last edited by ladan; 01-04-2005 at 03:27 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