A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: getting the ground position in 3D

  1. #1
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139

    getting the ground position in 3D

    using the basic 3D scaling formula:

    var scaleRatio = focalLength/(focalLength+z);

    how can i get the ground position of and object in 3D space and then convert that to Stage coordinates. simply grabbing the y coordinate in 3D space wont work because if the z depth is say 2000 the y coordinate wil still be the same if the z depth is 10.

    Basically, i'm trying to make shadows, i need to know the height from the ground the current object is based on its z depth.

    Not sure what i need to do to calculate this though.

    Any help?
    lather yourself up with soap - soap arcade

  2. #2
    #
    Join Date
    Apr 2002
    Location
    berlin - germany
    Posts
    107
    Set z=0 than you get:

    scaleRatio = focalAngle / focalLength

    Rearrange:

    x3d = focalLength / focalAngle * x2d
    y3d = focalLength / focalAngle * y2d

    untested...

  3. #3
    #
    Join Date
    Apr 2002
    Location
    berlin - germany
    Posts
    107
    I think I missed the target

    But you can simply take the Y-coordinate. If Y=0 is the ground, than the Y-coordinates of any object is its height.

  4. #4
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    thanks andre, but i found the solution by simply converting the the negative y position of the 3D camera to 3D space then adding the camera's (stage or 2D coordinates)

    var scaleRatio = focalLength/(focalLength+z);
    //calculate ground
    var ground = -(camera.y*scaleRatio)+camera.stageY

    thanks anyway though.
    lather yourself up with soap - soap arcade

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