1. #1
    Member Follow User Gallery
    Join Date
    Nov 2004
    Posts
    53

    Default Object to Canvas Coords?

    Not sure how to phrase it in ZB but I am looking for a way to convert "global" to "local" coordinates and vice versa. I guess in ZB it would be "object" coordinates (as in preview window) to "canvas" coordinates (as on canvas). Has anyone figured out how to do this?

    Also, any way to control the rotation axis with more precision?

    Thanks for any input

  2. #2
    Senior Member Follow User Gallery
    Join Date
    Apr 2001
    Location
    In the Ozone
    Posts
    2,280

    Default

    Hi Bism

    I think I can help you in regards to placing zspheres based upon canvas coordinates. My zsphere scripts are based on this

    rough algorithm off the top of my head since I don't have code with me at work.

    in zscript code
    1. create root zsphere at center of canvas x = 320 y = 240
    2. Size the Zsphere to 100x100x100 using transformset (object cords are based upon unity factor of 1)
    [Transformset,320,240,0,100,100,100,0,0,0]

    3. Root global loc: gx=320 gy=240 gz=0
    4. Object cords of root are always ox=0 oy=0 oz=0
    5. example, you wish to connect a new Zsphere node to the root at canvas cordinates of gx1=420 gy1=340 gz1=0
    6. the xyz location of the zsphere should be

    to get the offset from the root sphere do this

    nx = (gx1-gx)*.01 for example (420-320)*.01
    ny = (gy1-gy)*.01 for example (340-240)*.01
    nz = (gz1-gz) *.01 for example (0-0) *.01

    7. use zsphereadd to add the new node using nx, ny, and nz. With the zsphere mesh sized to 100 the new node should be placed at the canvas cordinates of 420x340x0

    Hope this helps and I have explained it in a legible manner
    Last edited by Digits; 10-18-05 at 11:07 AM.

  3. #3
    Member Follow User Gallery
    Join Date
    Nov 2004
    Posts
    53

    Default

    Digits,
    Great!...The "aha" moment came with using transformset. My way was a little... goofy in comparison. Thanks.

    Now, what the heck is going on with rotation? Seems I flip over when getting towards 90 or 180. Is this true? Have I been staying up too late? What is happening?

    Anyway, thanks again. Hopefully scripts with a purpose will be coming soon...

  4. #4
    Senior Member Follow User Gallery
    Join Date
    Apr 2001
    Location
    In the Ozone
    Posts
    2,280

    Default

    What you have discovered is Gimbal Lock, here is a thread where this has been discussed

    Rotation Problem

    I've tried a number of ways to overcome this but my brain ain't big enough

  5. #5
    Member Follow User Gallery
    Join Date
    Nov 2004
    Posts
    53

    Default

    Thanks for the link. Looks like Euler angles and quaternions are on todays reading menu...

Posting Permissions

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