Home   Help Search Login Register  

Author Topic: Positioning Issue  (Read 2437 times)

0 Members and 1 Guest are viewing this topic.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Positioning Issue
« on: 16 Mar 2009, 14:50:42 »
Pardon me if I'm missing something obvious here, but I can't seem to work it out (have searched, etc.).  I'm attempting to build (in a script), a bridge between an island and mainland, for use in a mission by human players .  I took a starting co-ordinate from a manually-placed bridge piece, and have positioned the bridge pieces by script thereafter (the script, listed below, is a little hacky, just for the sake of this example).  The bridge heads due north, so directions are not the problem, and I'm setting heights with setPosASL, to ensure they're equal (at least, I presume it achieves that... the Biki seems to imply it).

However, the pieces of the bridge that go over land that is above sea level are offset in all three dimensions, and I can't really figure out the best way to get around it.  The first piece, as you can see on the left side of the screenshot, is created at the exact location I specified, but the next piece seems to not follow on directly from it (though all subsequent pieces are fine, until meeting land above sea level on the other side).

Any help would be greatly appreciated (as would an easier/better way to create a bridge and import the actual objects into the mission, so it need not be scripted... without me having to manually copy down co-ordinates for each piece).

Mock-up script:
Code: [Select]
_bridgeName = "AAST070";
_bridgeStartX = 9298.54;
_bridgeStartY = 3616.73;
_bridgeSectorLength = 20;
_bridgeHeight = -26;
_bridgeVectorDir = [0,0,0];
_bridgeVectorUp = [0,0,0];

_bridgeSectors = 55;

hint "Preparing to build bridge...";
sleep 2;

// Create objects
for "_x" from 0 to _bridgeSectors step 1 do {
_tmpY = _bridgeStartY + (_x*_bridgeSectorLength);

_tmp = _bridgeName createVehicle [_bridgeStartX,_tmpY,_bridgeHeight];

_tmp setPosASL [_bridgeStartX, _tmpY, _bridgeHeight];
_tmp setVectorDir _bridgeVectorDir;
_tmp setVectorUp _bridgeVectorUp;
_tmp setDir 0;

hint format["Sector %1 of %2 done.", _x, _bridgeSectors];
sleep .5;
};

sleep 5;
hint "Done."

Screenshot attached.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Positioning Issue
« Reply #1 on: 16 Mar 2009, 15:17:08 »
Generally, placing bridge pieces in the editor is a very tricky process and really needs to be done on a piece by piece basis especially for those bits that meet land after a crossing of water, and vica versa.

Having a whole construction laid via script is not really going to work as the script cannot view the result and decide that THAT piece needs to be nudged 50cm left or THOSE pieces could do with a drop of 10 more centimetres.

To be fair, bridges were never intended to be available in the editor for mission construction, they are classed under CfgNonAIVehicles the same as StreetLamps. They were intended to be used for placing in .wrp files when constructing islands, even here they have to be placed carefully and have their position checked and adjusted before moving onto the next piece.

I remember, in OFP especially, that even when you had your bridge placed so it looked very good in the editor and your mission ran well, if someone loaded your mission and was using a different 'Terrain Detail' level than the one used when placing the bridge during mission construction, then the bridge pieces no longer formed a usable bridge, until the person switched to the same detail level that was used when laying the bridge.



Planck
I know a little about a lot, and a lot about a little.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Positioning Issue
« Reply #2 on: 16 Mar 2009, 15:25:06 »
Ahh... right  :(  Just what I didn't want to hear.  But, thanks anyway.  I suppose it's better than me spending hours on trying to get it right.

Is there any other sort of faux-solution that could be implemented, such as laying some object above the water, with fences on the sides, or is that going to be the same problem again?  I'd really like to connect this particular island to the mainland via some form of road link if at all possible.

Quote
if someone loaded your mission and was using a different 'Terrain Detail' level than the one used when placing the bridge during mission construction, then the bridge pieces no longer formed a usable bridge, until the person switched to the same detail level that was used when laying the bridge.
Is that still true when positioning absolutely with setPosASL?  I can understand if you were setPos'ing relative to the world, but surely using setPosASL removes that difficulty?
« Last Edit: 16 Mar 2009, 15:35:51 by JamesF1 »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Positioning Issue
« Reply #3 on: 16 Mar 2009, 15:36:15 »
You can lay a bridge across the water, no problem, but I think you will have to do it piece by piece, checking each piece is in the correct position and adjusting as necessary till you have it laid.  Time and patience.

However be prepared for others to complain if they are using a different terrain detail level which may or may not screw the positioning.

Laying road sections across the water will not work at all, even supposing you had them available in the editor.


Planck
I know a little about a lot, and a lot about a little.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Positioning Issue
« Reply #4 on: 16 Mar 2009, 15:39:14 »
However be prepared for others to complain if they are using a different terrain detail level which may or may not screw the positioning.
As I said above (in an edit), would the positioning still screw up using setPosASL in a script?

Quote
Laying road sections across the water will not work at all, even supposing you had them available in the editor.
I thought about that just after I'd typed it and edited above :)

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Positioning Issue
« Reply #5 on: 16 Mar 2009, 15:51:53 »
Now, this is where you can experiment.....

Most of what went previous was pertinent for OFP and only by guessing is pertinent to ArmA too.
Judging by your experience so far it is broadly similar to OFP.

The thing with setPosASL is, you aren't always laying a bridge piece above sea-level.
the pieces out in the water are being set far below the sea-level and I have no idea how setPosASL works under water.

Similar, but different, strangeness can be expected if the bridge piece is being placed under the surface when on land.


Planck
I know a little about a lot, and a lot about a little.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Positioning Issue
« Reply #6 on: 16 Mar 2009, 15:53:23 »
Time to go togglin' the detail level!  I'll have an experiment and 'report back' for everyone else's benefit.

Thanks again  :good:

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Positioning Issue
« Reply #7 on: 16 Mar 2009, 15:56:19 »
Place them in the RTEditor and export to sqf file. Then, run that sqf when you want to place the objects. Pretty sure that i0n0s copes with all sorts of positional problems like this for you. Bit overkill, but...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Positioning Issue
« Reply #8 on: 16 Mar 2009, 16:13:40 »

Am doing the end pieces like that, but I don't exactly relish placing the entire 63 bridge pieces manually, especially with the peculiar way to handle pitch/roll in RTE :(  Oh well...



No need to quote entire previous post - Planck
« Last Edit: 16 Mar 2009, 18:40:48 by Planck »

Offline i0n0s

  • Former Staff
  • ****
Re: Positioning Issue
« Reply #9 on: 16 Mar 2009, 16:46:08 »
Since he tries to place buildings he should better use the 3DE.

Code: [Select]
_bridgeVectorDir = [0,0,0];
_bridgeVectorUp = [0,0,0];
At least VectorUp should be non-zero since a zero value doesn't change it.

And I overheard the part with pitch/roll in RTE, since you can modify pitch and roll easily.

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Positioning Issue
« Reply #10 on: 16 Mar 2009, 18:21:48 »
At least VectorUp should be non-zero since a zero value doesn't change it.
Yeah, sorry, that's a typo on my part  :whistle:

Quote
And I overheard the part with pitch/roll in RTE, since you can modify pitch and roll easily.
True enough, but it's really quite fiddly to get into an exact position, unless I'm missing something (again)?

Offline i0n0s

  • Former Staff
  • ****
Re: Positioning Issue
« Reply #11 on: 17 Mar 2009, 00:30:18 »
Didn't setVectorUp [0,0,1] solve the problem?
If not: Use setPos on the first segment.

About the pitch-bank:
As long as I don't get any feedback about this, it will stay as it are. But for bigger discussions about this: -> RTE thread.

Offline Sparticus76

  • Members
  • *
Re: Positioning Issue
« Reply #12 on: 17 Mar 2009, 08:43:04 »
I know you dont want to create it manually, but if you do, you can use hints to get each pieces exact position and direction, then delete the bridge and use the info to create the bridge with a script could you not?

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: Positioning Issue
« Reply #13 on: 17 Mar 2009, 11:56:00 »

 edit the sqm  its about the easiest way to do things like this . once you have established how far one sections needs to be in front of another you simply adjust the POS accordingly , remebering that in the sqm it is XZY not xyz .




  alternatively use modeltoworld  in your script .  createvehicle bridge and  use incremental changes where necessary. 
bridgepart_x setpos (startingbridgepart  modelToWorld [0,0,0]); <<  here you need to decide which direction you want to add the new distance and add 0+_x and of course _x= _x + length of bridge part every time you place a new one.



I love ofp

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: Positioning Issue
« Reply #14 on: 17 Mar 2009, 12:48:59 »
I'll take a look at using modelToWorld, and see what happens.  I can always generate all the sections that work fine by script, and then manually place the problematic sections in RTE, or whatever, I guess.  Will do some experiments :)

Thanks, guys  :good: