1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Ride into the sunset with the 32nd Modeling Contest. The contest is optionally paired. Best of luck, people!
    Dismiss Notice
  4. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  5. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[System] GetCamOffset

Discussion in 'JASS Resources' started by N-a-z-g-u-l, Jun 12, 2009.

  1. Na_Dann_Ma_GoGo

    Na_Dann_Ma_GoGo

    Joined:
    Apr 5, 2008
    Messages:
    367
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Hmm seems fine for me without the negative thingy. Whatever, I hope the camera stuff will be THAT much better in SC2 :O
    I mean it works just fine now but eats a lot of performance for smooth vision.
     
  2. N-a-z-g-u-l

    N-a-z-g-u-l

    Joined:
    May 26, 2005
    Messages:
    197
    Resources:
    9
    Maps:
    8
    JASS:
    1
    Resources:
    9
    I tried toadcops method in my map, and it really does about the same job...
    But theres a difference: His method is not smooth. Sometimes the camera is at the wrong position, its not much, however, enough to be annoying in my case.

    To provide a similiar method:

    Code (Text):

    function SetCameraXYZ takes real x, real y, real z returns nothing
            call SetCameraField(CAMERA_FIELD_ZOFFSET,z-GetCamOffset(x,y),0)
            call PanCameraToTimed(x,y,0)
    endfunction
     
     
  3. LordLyra

    LordLyra

    Joined:
    Aug 27, 2008
    Messages:
    58
    Resources:
    0
    Resources:
    0
    Then is there a way to get the Z of a Unit?
    I tested the GetUnitZ, it didnt work...
    Its like units dont have a Z hight, is it so or can someone show me how to get the Z of an unit, not of his location?
     
  4. N-a-z-g-u-l

    N-a-z-g-u-l

    Joined:
    May 26, 2005
    Messages:
    197
    Resources:
    9
    Maps:
    8
    JASS:
    1
    Resources:
    9
    Nope, there's unfortunately no way to get the precise unitZ. It is common to use GetLocationZ + GetUnitFlyHeight, however this returns wrong values for flying units near cliffs and walking/hovering units in water (rare case).
    I already found out that theres also some sort of grid for flying units, not very different from that used for camera smoothing, however, the calculation of the grid values is different. besides that it would be very annoying work to find the true grid calculation, because there is no way to get the true unitZ even with some tricky, time-consuming stuff. you would have to compare the fly heights of hovering vs flying units...

    and still: ground units (walk + hover) walk on the terrain below water, while amphibious or swimming units walk on the water surface. flying units also use the water surface as a reference point (which is good, because this is what GetLocationZ returns)

    however, all in all the difference between GetLocationZ+GetUnitFlyHeight compared to true value is never too big. I also use this approximation for my Supreme Commander map, it sometimes looks a bit weird near cliffs but is not very noticable in general.

    EDIT: I forgot one important thing to mention - you can set a value for destructables for flying units to fly over them and not through them. the only (easy) way to fix this, is removing these values from all of your destructable. you could also save them all in some variables, calculate something like that grid i mentioned before, and then try to figure out their influence... however, not very clean nor fast nor necessary

    and... let me guess, you are german?

    EDIT2: Started to look into it again, but its even more annoying than what ive thought - flying units do not simply read one point from that grid, but about 4 and then choose the highest one (probably), this makes them fly on the same height for a short time on top of a hill

    EDIT3: I am no longer sure about EDIT2, however, it is quite obvious that the grid cells have a size of 256x256 instead of 512x512 (what ive expected before)...
    that means 4 times the values to be saved... this is quite a lot of data
     
    Last edited: Apr 23, 2010
  5. LordLyra

    LordLyra

    Joined:
    Aug 27, 2008
    Messages:
    58
    Resources:
    0
    Resources:
    0
    Lol you wrote and edited it 4 times on like on hour.
    Thanks.

    and... let me answer, I'm from Sweden. xD
     
  6. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,162
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    This needs some better privatization and definitely needs a longer description for what it does, and how to use it.
     
  7. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,162
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Graveyarded.

    Better naming convention would have also helped.
     
  8. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,709
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    Pulled out from the graveyard by user request.

    Based on the comments this seems to be a working snippet
    with lacking documentation and privatization. I didn't check and tried the content myself.
    Currently this resource remains not approve-able due to know issues ( read comments )
    I also doubt that the N-a-z-g-u-l will update his snippet.
    You might want to improve the code and re-submit it in the JASS section.
     
  9. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,832
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Why? Just edit the TO and add the private keywords. The system itself can hardly be optimized further.
     
  10. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,162
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Here is OP with privatization and relevant lib name:
    I can edit the op to match if others want it.
     
  11. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,162
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Re-graveyarding.
     
  12. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,428
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Didn't see that last post. I'd say go ahead and update it + ship it.
     
  13. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,162
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Re-ungraveyarded.
     
  14. Kanaru

    Kanaru

    Joined:
    Apr 26, 2006
    Messages:
    160
    Resources:
    0
    Resources:
    0
    I am so confused, how do you make this function in a map?

    I tried downloading OP's map to just see how it worked there but it gives errors so it doesn't launch.

    I'm able to get the library and launch my map but I don't really understand JASS well and I don't think there's anything calling this to function... But my experiments aren't doing anything either, and I'm not really sure where to go from here.
     
    Last edited: Feb 4, 2020