Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Stacked objects

  1. #1
    Here's something which stumped me for hours in my current scripts.

    Issue: Stacked objects cause GetPos and GetPosASL to only return the relative height (select 2) above the current object (which can be positive or negative), not above ground or sea level, as I expected.
    (If this is true, it needs to be added to BIKI getPos.)

    The scenario: Now you wouldn't normally encounter this unless you double stack. I wanted to have my radio towers on top of buildings and then to have a danger sign on top of or near the towers, relative to the tower's position. I can't get the relative position.

    Problem: Now it's very clever that GetPos does this, but for GetPosASL to do it is plain wrong. This causes problems because I still need a true height position of the object so I can vertically position objects relative to other objects. So if anyone knows of a command or way to do this, let me know.


    -- EDIT: -- WORK-AROUND SOLUTION --
    deanosbeano's solution works great:
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Offset = &#91;_x,_y,_z&#93;;
    _worldPos = _RelObj modelToWorld _Offset;
    _obj setPos _worldPos;[/QUOTE]
    Note added to getPos - warning.
    Note added to modelToWorld - usage.

    -- END EDIT --



    Screenshot of test scenario (with debug info in Hint)

    InitTower.sqf - test script
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Tower = _this select 0; // radio tower
    _HgtOffset = _this select 1; // height pos adjustment of tower &#40;above ground level&#41;


    //---- Position the tower on top of a building rooftop

    // if the following line is used, then the 2nd setPos call somehow trieds to repos the object in the x & y directions onto a clear space on the ground
    //_Tower setPos &#91; &#40;getPos _Tower select 0&#41;, &#40;getPos _Tower select 1&#41;, 0 &#93;; // don&#39;t want to use this, but try with or without this line for testing


    // Towers placed on top of buildings require a height pos adjustment
    _TowerHgtASL_Before = getPosASL _Tower select 2; // debug
    _TowerHgtBefore = getPos _Tower select 2; // debug

    _Tower setPos &#91; getPos _Tower select 0, getPos _Tower select 1, _HgtOffset &#93;; // try with or without this line for tests to see placement

    // these 2 &#34;After&#34; values returned unexpected results, where z is now relative to top of building
    _TowerHgtASL_After = getPosASL _Tower select 2; // debug
    _TowerHgtAfter = getPos _Tower select 2; // debug


    //---- Place a sign on top of tower - relative to the tower&#39;s current height

    _sign = &#34;Danger&#34; createVehicle &#40;position _Tower&#41;;
    // x & y are roughly centre of tower, z hgt of 26.8 should be on top of tower
    _x = &#40;getPos _Tower select 0&#41; + 0.1;
    _y = &#40;getPos _Tower select 1&#41; + 1.9;
    //_z = _TowerHgtAfter + 26.8 +_HgtOffset -12;
    _z = _TowerHgtAfter + 26.9; // &#60;- The idea here is that we don&#39;t know the original building height, so we want it relative to the tower&#39;s z height pos.
    _sign setPos &#91; _x, _y, _z&#93;;

    // this value returned unexpected result, where z is now relative to top of tower
    _SignHgtAfter = getPos _sign select 2; // debug


    //---- output stats of last Initialiazation

    Hint Format&#91;&#34;TowerName=%1 &#92;n&#92;nTowerHgtASL_Before=%2 &#92;nTowerHgtASL_After=%3 &#92;n&#92;nTowerHgtBefore=%4 &#92;nTowerHgtAfter=%5 &#92;n&#92;nSignHgtAfter=%6 &#92;n_HgtOffset=%7&#34;,
    VehicleVarName _Tower, _TowerHgtASL_Before, _TowerHgtASL_After, _TowerHgtBefore, _TowerHgtAfter, _SignHgtAfter, _HgtOffset &#93;;
    [/QUOTE]

    mission.sqm - extract of 4 towers with their initialization
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class Vehicles
    {
    items=4;
    class Item0
    {
    position&#91;&#93;={10288.456055,146.113144,9210.3 29102};
    id=2;
    side=&#34;EMPTY&#34;;
    vehicle=&#34;Land_vysilac_FM2&#34;;
    skill=0.600000;
    health=0.245674;
    text=&#34;Tower2&#34;;
    init=&#34;fn=compile preprocessFile &#34;&#34;InitTower.sqf&#34;&#34;; &#91;this, 18.12&#93; call fn&#34;;
    };
    class Item1
    {
    position&#91;&#93;={10278.255859,142.778168,9210.3 06641};
    id=3;
    side=&#34;EMPTY&#34;;
    vehicle=&#34;Land_vysilac_FM2&#34;;
    skill=0.600000;
    health=0.245674;
    text=&#34;Tower3&#34;;
    init=&#34;fn=compile preprocessFile &#34;&#34;InitTower.sqf&#34;&#34;; &#91;this, 12.5&#93; call fn&#34;;
    };
    class Item2
    {
    position&#91;&#93;={10278.365234,127.979996,9198.4 22852};
    id=4;
    side=&#34;EMPTY&#34;;
    vehicle=&#34;Land_vysilac_FM2&#34;;
    skill=0.600000;
    health=0.245674;
    text=&#34;Tower4&#34;;
    init=&#34;fn=compile preprocessFile &#34;&#34;InitTower.sqf&#34;&#34;; &#91;this, 0&#93; call fn&#34;;
    };
    class Item3
    {
    position&#91;&#93;={10267.467773,142.778168,9210.2 45117};
    id=1;
    side=&#34;EMPTY&#34;;
    vehicle=&#34;Land_vysilac_FM2&#34;;
    skill=0.600000;
    health=0.245674;
    text=&#34;Tower1&#34;;
    init=&#34;fn=compile preprocessFile &#34;&#34;InitTower.sqf&#34;&#34;; &#91;this, 12.12&#93; call fn&#34;;
    };
    };
    [/QUOTE]

    Can someone confirm this? I definitely didn&#39;t expect GetPosASL to do this.
    If this is all true, how does one get around it?




  2. #2
    i personally use the worldtomodel or modeltoworld
    the second of which will give you a better result.

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    _relPos = &#91;_cm,0,_ht&#93;
    _worldPos = _founder modelToWorld _relPos
    _brk setpos _worldPos[/QUOTE]

    _cm and _ht are variables i use ,you can simply alter them with a number that you would like your sign offset from your tower.

    appologies to the person who originallywrote this on biki i cant remember there name, but i addapted it and it helped me save 60 lines of code checkinng disatances.

    like yousaid the original getpos is broke when it encounters a roof or any pathway because that wil return a _z of 0 wherever it is.

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    _relPos = &#91;1,0,0&#93;
    _worldPos = _tower modelToWorld _relPos
    _sign setpos _worldPos[/QUOTE]

    try the above and play with numbers , also use it for your tower to (object ####) and radio tower

    hope it helps

    ps before the use of this neat command , the trick was to set the objects in editor and hint format the distance between the two, when everything was ok. then you would run a check of the distance after the objects where setpos`d , so if the distance should be hmm 10 , then you would ask ? distance sign < 9.8 then setpos x,y,_dist . where _dist would equal 10 in this case .
    sory to confuse if i did.




  3. #3
    Gunnery Sergeant Dr_Eyeball's Avatar
    Join Date
    Dec 17 2005
    Location
    Australia
    Posts
    584
    Author of the Thread
    Thanks for confirming the issue with those commands.
    The workaround looks good. I will try that.
    Also, your final tip looks too sensible. What&#39;s wrong with previewing 10 times and incrementing by 1.0, 0.1 and 0.01 each time, until it&#39;s right?
    Cheers.

  4. #4
    Quote Originally Posted by [b
    Quote[/b] ]What&#39;s wrong with previewing 10 times and incrementing by 1.0, 0.1 and 0.01 each time, until it&#39;s right?
    lol i sense the irony somewhere :0.
    the prob is that when you get it in the actual mission it will be sat on the ground again lol . thats why a 3 stage check ws always required

    cause it was a barstard.
    and dont even get me started on arma buildings with stair case lol
    there just as abs every step seems to reset _z to 0 .
    lol

  5. #5
    Quote Originally Posted by [b
    Quote[/b] ]Stacked objects cause GetPos and GetPosASL to only return the relative height (select 2) above the current object (which can be positive or negative), not above ground or sea level, as I expected.
    Thats actualy a problem with roadway LOD&#39;s. They were a real pain in the a%^e with OFP to. It&#39;s a shame the above seal level version doesn&#39;t ignore them, I think someones already requested such a command that does, on the wiki?

    Quote Originally Posted by [b
    Quote[/b] ]i personally use the worldtomodel or modeltoworld the second of which will give you a better result.
    Will that ignore or compensate for roadway LOD&#39;s? You still have to use setpos, after all. Would be handy if it did.

  6. #6
    yup it does .
    unless i have been exremely lucky. have not had a fail yet.
    and if it does i would just use the old distance check and change the third value of _relpos to the _dist.
    i will try and find the original thread on this .
    i was hoping maybe now your involved unn you might do two little pargagraphs

    on worldtomodel and modeltoworld ??

    maybe huh ??
    my own brief thinking is it kakes the exact postion as it would be in the mission sqsm and converts that to a normal z,y,z as we would use in editor ,if that make sense




  7. #7
    Quote Originally Posted by [b
    Quote[/b] ] was hoping maybe now your involved unn you might do two little pargagraphs

    on worldtomodel and modeltoworld ??
    I can&#39;t really test anything ATM. But I will certainly give it a try over the weekend. I can see where your comming from, it would help with tide height problems too.

  8. #8
    If you still need a workaround for ASL and height above ground that defeats roadway LODs, here&#39;s what I used in my grenade pack scripts:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_detector = &#34;EmptyDetector&#34; camcreate &#91;0,0,0&#93;
    _pos = &#40;getpos _obj&#41;
    _detector setpos &#91;_pos select 0,_pos select 1&#93;
    _asl = &#40;_obj distance _detector&#41;
    _h = &#40;_obj distance _detector&#41;-&#40;abs&#40;getpos _detector select 2&#41;&#41;[/QUOTE]

    It should still work, if EmptyDetector still exists in ArmA. You could probably even turn them into functions:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private&#91;&#34;_obj&#34;,&#34;_d&#34;, &#34;_pos&#34;,&#34;_z&#34;,&#34;_asl&#34;&#93; ;
    _obj = _this;
    _d = &#34;EmptyDetector&#34; camcreate &#91;0,0,0&#93;;
    _pos = &#40;getpos _obj&#41;;
    _d setpos &#91;_pos select 0,_pos select 1&#93;;
    _z = &#40;_obj distance _d&#41;;
    _asl = &#91;_pos select 0,_pos select 1,_z&#93;;
    deletevehicle _d;
    _asl[/QUOTE]

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private&#91;&#34;_obj&#34;,&#34;_d&#34;, &#34;_pos&#34;,&#34;_z&#34;,&#34;_agl&#34;&#93; ;
    _obj = _this;
    _d = &#34;EmptyDetector&#34; camcreate &#91;0,0,0&#93;;
    _pos = &#40;getpos _obj&#41;;
    _d setpos &#91;_pos select 0,_pos select 1&#93;;
    _z = &#40;_obj distance _d&#41;-&#40;abs&#40;getpos _d select 2&#41;&#41;;
    _agl = &#91;_pos select 0,_pos select 1,_z&#93;;
    deletevehicle _d;
    _agl[/QUOTE]



    VBS2 Designer

    Quote Originally Posted by Armored_Sheep View Post
    I like to call Arma a sandbox game that works pretty much like LEGO - you buy it not just because you want to have a nice car from the main picture on its box, do you?

  9. #9
    Quote Originally Posted by [b
    Quote[/b] ]If you still need a workaround for ASL and height above ground that defeats roadway LODs, here&#39;s what I used in my grenade pack scripts:
    deanosbeano suggestion means we don&#39;t have to worry about using detectors or logics anymore. Using modelToWorld you can now get the position with just one command:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Player ModelToWorld &#91;0,0,0&#93;[/QUOTE]

    I did a quick test, that will now return the correct height when stood on a elevated roadway. But it still appards to be effect by the height of the tide, if your over water when you call the command.

    To identify when an object is over an elevated roadway, you could probably use this:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">&#40;&#40;Player ModelToWorld &#91;0,0,0&#93;&#41; Select 2&#41;&#33;=&#40;&#40;GetPos Player&#41; Select 2&#41;[/QUOTE]

    There are still other issues with roadways, but it at least cuts out some of the lengthy work arounds.

    @Dr_Eyeball

    Another possible solution, if your doing this for a SP mission. Is to use camCreate. In OFP cam created objects were not influenced by roadways, as far as I can remember. So you should be able to stack your objects using multipliers of thier height. Assuming it works the same way in Arma.

  10. #10
    Hmmm
    ok i ask in all sincerity ,is it not the case that you cannot camcreate any objects anymore ?
    or is it specific objects ?
    if you can still camcreate then i have dropped some major bollocks in the last week or so lol.

Page 1 of 2 12 LastLast

Posting Permissions

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