Tankbuster 1744 Posted January 1, 2016 As part of my quest to make dynamic missions more.. erm... dynamic, I've been looking into working with road pieces. They don't have classnames so there's a limit to what we can do with them. I started with getting their size and seeing what, if anything could be gained from knowing this. I assumed that the library of road pieces would be quite small, not unlike a slot car set and that the road network would be made of perhaps a couple of dozen different pieces, but my tests seem to show otherwise. I was expecting to see, for example a long straight piece of road with a given area be used over and over again, but that's not what this code shows. Perhaps it's quirk of the method I use to determine the area of each individual piece, I'm not sure. To be honest, the results are so random, I'm beginning to suspect my method. There is one thing we can take to the bank, and that's the fact that runway pieces are counted as road and are ALWAYS 400m² area, presumably they are 20 x 20. The airport aprons and taxiways are the same size, though perhaps not the same piece. Look at the perimeter road to the southeast. It's a dead straight stretch of road and I thought the same road piece would be in use over and over again, but it isn't. The area comes back as more or less 725m². Further north on the main supply route, the bigger roads come back as about 800, but a small number of them are bigger than 1000. See below. Over in Pyrgos, there's a mix of main roads and smaller, in town roads. The area of urban road pieces appears to be smaller, but with a wide variation. See how the MSR road peices out to the east are smaller than those in the north east. Pic below. So after spending a day on creating this data, it seems there's nothing concrete (pardon the pun) about road piece area or indeed, useful. Specifically, my aim was to in script (automatically and dynamically) find the main roads that entered and left a town and was going to place enemy AI roadblocks there. It looks like this method isn't going to help. Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 1, 2016 Here's the code that generates the above results. [COLOR="FF8040"][COLOR="#191970"][B]private[/B][/COLOR] [COLOR="#8B3E2F"][B][[/B][/COLOR][COLOR="#7A7A7A"]"_myroads"[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR][COLOR="#7A7A7A"]"_d0"[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR][COLOR="#7A7A7A"]"_br0"[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR][COLOR="#7A7A7A"]"_br1"[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR][COLOR="#7A7A7A"]"_myarea"[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR][COLOR="#7A7A7A"]"_mkrname"[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR] [COLOR="#7A7A7A"]"_mname1"[/COLOR][COLOR="#8B3E2F"][B]][/B][/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_myroads[/COLOR] [COLOR="#8B3E2F"][B]=[/B][/COLOR] dude [COLOR="#191970"][B]nearRoads[/B][/COLOR] [COLOR="#FF0000"]10000[/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#8B3E2F"][B]{[/B][/COLOR] [COLOR="#1874CD"]_br0[/COLOR] [COLOR="#8B3E2F"][B]=[/B][/COLOR] [COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#191970"][B]boundingBoxReal[/B][/COLOR] [COLOR="#000000"]_x[/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR] [COLOR="#191970"][B]select[/B][/COLOR] [COLOR="#FF0000"]0[/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR][COLOR="#006400"][I]// get its lower left near extreme pos[/I][/COLOR] [COLOR="#1874CD"]_br1[/COLOR] [COLOR="#8B3E2F"][B]=[/B][/COLOR] [COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#191970"][B]boundingBoxReal[/B][/COLOR] [COLOR="#000000"]_x[/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR] [COLOR="#191970"][B]select[/B][/COLOR] [COLOR="#FF0000"]1[/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR][COLOR="#006400"][I]// get its top right far exreme pos[/I][/COLOR] [COLOR="#1874CD"]_maxwidth[/COLOR] [COLOR="#8B3E2F"][B]=[/B][/COLOR] [COLOR="#191970"][B]abs[/B][/COLOR] [COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#1874CD"]_br1[/COLOR] [COLOR="#191970"][B]select[/B][/COLOR] [COLOR="#FF0000"]0[/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR] [COLOR="#8B3E2F"][B]-[/B][/COLOR] [COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#1874CD"]_br0[/COLOR] [COLOR="#191970"][B]select[/B][/COLOR] [COLOR="#FF0000"]0[/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_maxlength[/COLOR] [COLOR="#8B3E2F"][B]=[/B][/COLOR] [COLOR="#191970"][B]abs[/B][/COLOR] [COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#1874CD"]_br1[/COLOR] [COLOR="#191970"][B]select[/B][/COLOR] [COLOR="#FF0000"]1[/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR] [COLOR="#8B3E2F"][B]-[/B][/COLOR] [COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#1874CD"]_br0[/COLOR] [COLOR="#191970"][B]select[/B][/COLOR] [COLOR="#FF0000"]1[/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_myarea[/COLOR] [COLOR="#8B3E2F"][B]=[/B][/COLOR] [COLOR="#191970"][B]floor[/B][/COLOR] [COLOR="#8B3E2F"][B]([/B][/COLOR][COLOR="#1874CD"]_maxwidth[/COLOR] [COLOR="#8B3E2F"][B]*[/B][/COLOR] [COLOR="#1874CD"]_maxlength[/COLOR][COLOR="#8B3E2F"][B])[/B][/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_mname[/COLOR] [COLOR="#8B3E2F"][B]=[/B][/COLOR] [COLOR="#191970"][B]format[/B][/COLOR] [COLOR="#8B3E2F"][B][[/B][/COLOR][COLOR="#7A7A7A"]"m%1%2"[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR] [COLOR="#000000"]_forEachIndex[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR] [COLOR="#000000"]_x[/COLOR][COLOR="#8B3E2F"][B]][/B][/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_mkr[/COLOR] [COLOR="#8B3E2F"][B]=[/B][/COLOR] [COLOR="#191970"][B]createMarker[/B][/COLOR] [COLOR="#8B3E2F"][B][[/B][/COLOR][COLOR="#1874CD"]_mname[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR] [COLOR="#000000"]_x[/COLOR][COLOR="#8B3E2F"][B]][/B][/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_mkr[/COLOR] [COLOR="#191970"][B]setMarkerShape[/B][/COLOR] [COLOR="#7A7A7A"]"ICON"[/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_mkr[/COLOR] [COLOR="#191970"][B]setMarkerType[/B][/COLOR] [COLOR="#7A7A7A"]"hd_dot"[/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_mkr[/COLOR] [COLOR="#191970"][B]setMarkerSize[/B][/COLOR] [COLOR="#8B3E2F"][B][[/B][/COLOR][COLOR="#FF0000"]0.1[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR][COLOR="#FF0000"]0.1[/COLOR][COLOR="#8B3E2F"][B]][/B][/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#1874CD"]_mkr[/COLOR] [COLOR="#191970"][B]setMarkerText[/B][/COLOR] [COLOR="#191970"][B]format[/B][/COLOR] [COLOR="#8B3E2F"][B][[/B][/COLOR][COLOR="#7A7A7A"]"%1"[/COLOR][COLOR="#8B3E2F"][B],[/B][/COLOR] [COLOR="#1874CD"]_myarea[/COLOR][COLOR="#8B3E2F"][B]][/B][/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR] [COLOR="#8B3E2F"][B]}[/B][/COLOR][COLOR="#191970"][B]forEach[/B][/COLOR] [COLOR="#1874CD"]_myroads[/COLOR][COLOR="#8B3E2F"][B];[/B][/COLOR][/COLOR][URL="http://killzonekid.com/sqf-to-bbcode-converter/"][SIZE=1]Made with KK's SQF to BBCode Converter[/SIZE][/URL] Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 1, 2016 Ugh. What's happened to the output from killzonekid's excellent converter? Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 1, 2016 private ["_myroads","_d0","_br0","_br1","_myarea","_mkrname", "_mname1"]; _myroads = dude nearroads 10000; { _br0 = (boundingboxreal _x) select 0;// get its lower left near extreme pos _br1 = (boundingBoxReal _x) select 1;// get its top right far exreme pos _maxwidth = abs ((_br1 select 0) - (_br0 select 0)); _maxlength = abs ((_br1 select 1) - (_br0 select 1)); _myarea = floor (_maxwidth * _maxlength); _mname = format ["m%1%2", _foreachindex, _x]; _mkr = createMarker [_mname, _x]; _mkr setMarkerShape "ICON"; _mkr setMarkerType "hd_dot"; _mkr setMarkerSize [0.1,0.1]; _mkr setmarkertext format ["%1", _myarea]; }foreach _myroads; Until I can work out what's gone tits up in the first post of the code, this will have to do 1 Share this post Link to post Share on other sites
killzone_kid 1330 Posted January 1, 2016 Ugh. What's happened to the output from killzonekid's excellent converter? Nothing. Better question is what happened to the forums not supporting BB Code any more ;) Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 1, 2016 Better question is what happened to the forums not supporting BB Code any more ;) *dislike* Share this post Link to post Share on other sites
Heeeere's johnny! 51 Posted January 1, 2016 The forum is still supporting BBCode, just not in code blocks as it seems, because they have their own coloration. private ["_myroads","_d0","_br0","_br1","_myarea","_mkrname", "_mname1"];_myroads = dude nearRoads 10000;{_br0 = (boundingBoxReal _x) select 0;// get its lower left near extreme pos_br1 = (boundingBoxReal _x) select 1;// get its top right far exreme pos_maxwidth = abs ((_br1 select 0) - (_br0 select 0));_maxlength = abs ((_br1 select 1) - (_br0 select 1));_myarea = floor (_maxwidth * _maxlength);_mname = format ["m%1%2", _forEachIndex, _x];_mkr = createMarker [_mname, _x];_mkr setMarkerShape "ICON";_mkr setMarkerType "hd_dot";_mkr setMarkerSize [0.1,0.1];_mkr setMarkerText format ["%1", _myarea];}forEach _myroads;Made with KK's SQF to BBCode Converter I know, indentations are gone - not my fault. Share this post Link to post Share on other sites
Larrow 2820 Posted January 2, 2016 I believe road nodes are just that nodes in a spline that define a roads shape.Easiest place to see this is on Stratis, goto the corner just before the petrol station on the road from the airport to Agia Marina.Get up on the rocks, notice the little white dots along the road. Two close to each other, one either side of the road centre.Go down to the road, find a white dot, face the nearest road side and go upto the edge, note how you are in a large crumbled section of edge and the next crumbled section to your left has a little square notch in it.Go up to any of the white dots and follow the same procedure. They are all the same. So textures are (at least here) symmetrical across the roads center.Now Bring up the debug console and run.. { createVehicle["sign_arrow_F",getpos _x,[],0,"CAN_COLLIDE"]; }forEach (player nearroads 100); Get back up on the rocks and note the node positions have no correlation between the white dots. Go upto the bridge in Agia Marina and look at the tight bend as the road meets the bridge, you can clearly see here how some of textures have their UV squashed on the inside of the corner and others a large and not so well defined on the outside of the corner.Im guessing its just a row of quads either side of road center with A/set of repeating textures whos UV is always 0-1 in each quad something like.. Where each blue dot here is a road node for example. Not much help i know just an observation i made messing around with roads a few weeks back.Maybe someone who has done some map editing has a better understanding of a roads composition. Share this post Link to post Share on other sites
Stormridge 3 Posted January 2, 2016 I think the spline theory is correct for texturing, though the road 'models' do overlap each other, and the model bounding box vertices are dependent on the direction/angle of the road. For example, if you run the following script on a road running North/South or East/West, you'll see the bounding box corners of each road segment. However, if you run it on a sharp curve (Altis = [6805.27,16380.9,0]) you can see the road's model orientation switch (and the underlying model rotates itself). Someone can probably calculate the angle in which that occurs, based on the angle between connected road centers. (Yes, this all fits in the debug console :) allPoints=[]; { removeAllMissionEventHandlers "DRAW3D"; _br0 = (boundingBoxReal _x) select 0; _br1 = (boundingBoxReal _x) select 1; _modelCenter = boundingCenter _x; _mapPosCenter = getpos _x; _br0Fixed = [_br0 select 0, _br0 select 1, .1]; _br1Fixed = [_br1 select 0, _br1 select 1, .1]; _c1 = _mapPosCenter vectorAdd _br0Fixed; _c2 = _mapPosCenter vectorAdd _br1Fixed; _c3 = _mapPosCenter vectorAdd [_br0 select 0, _br1 select 1, .1]; _c4 = _mapPosCenter vectorAdd [_br1 select 0, _br0 select 1, .1]; createVehicle["sign_arrow_F",_mapPosCenter,[],0,"CAN_COLLIDE"]; createVehicle["Sign_Sphere25cm_F",_c1,[],0,"CAN_COLLIDE"]; createVehicle["Sign_Sphere25cm_F",_c2,[],0,"CAN_COLLIDE"]; createVehicle["Sign_Sphere10cm_F",_c3,[],0,"CAN_COLLIDE"]; createVehicle["Sign_Sphere10cm_F",_c4,[],0,"CAN_COLLIDE"]; allPoints pushback [_mapPosCenter, _c1, _c2, _c3, _c4]; } forEach (player nearroads 100); addMissionEventHandler ["Draw3D",{{drawLine3D[_x select 1,_x select 3,[0,0,1,1]];drawLine3D[_x select 3,_x select 2,[0,0,1,1]];drawLine3D[_x select 2,_x select 4,[0,0,1,1]];drawLine3D[_x select 4,_x select 1,[0,0,1,1]];} foreach allPoints;}]; Side note, The bounding box images look familiar to me, and probably the result of the pathing algorithm that forces a certain width of bounding box based on the direction of the curve... Notice the box overlaps ensure a certain road width. Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 2, 2016 I was getting the idea that the difference in road piece areas meant it wasn't quite as simple as my slot car track assembly analogy. :) Thanks everyone. Road segments don't have classnames, nor have I managed to get their model name so all we have to play with is nearroads, roadsconnectedto and BIS_fnc_dirTo. I was hoping to get something useful out of this that mission makes could use. For example, I hoped that the MSR road pieces might be a certain size and the urban roads might be another. In practice, all that turned up is that airport runways, aprons and taxiways are 400 meters square. It's true that the roads in town TEND to be smaller, but it's not, I think, differentiable enough to be usable. Share this post Link to post Share on other sites
Larrow 2820 Posted January 2, 2016 and the model bounding box vertices are dependent on the direction/angle of the road. For example, if you run the following script on a road running North/South or East/West, you'll see the bounding box corners of each road segment. However, if you run it on a sharp curve (Altis = [6805.27,16380.9,0]) you can see the road's model orientation switch (and the underlying model rotates itself). Thats not the model orienting itself, thats just the bounding box growing to incorporate the mesh it covers. The bounding boxes do not rotate, look again you will see they are all pointing north, the default direction. Dont forget TB that you have isOnRoad aswell. Do the direction from node to node and measure a distance perpendicular until the position is !isOnRoad. e.g _node = ( player nearRoads 50 ) select 0; _nextNode = ( roadsConnectedTo _node ) select 0; _dir = [ getPos _node, getPos _nextNode ] call BIS_fnc_dirTo; _dir = _dir + 90; for "_step" from 2 to 20 step 0.1 do { if !( isOnRoad ( [ _node, _step, _dir ] call BIS_fnc_relPos ) ) exitWith { hint format[ "The road is approx. %1m wide", _step * 2 ]; }; }; Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 2, 2016 Oh yes, isOnRoad is a corker. It was the core behind my roadsidebomb thingy back in A2, doing exactly the step until !isOnRoad. Share this post Link to post Share on other sites
Stormridge 3 Posted January 2, 2016 Thats not the model orienting itself, thats just the bounding box growing to incorporate the mesh it covers. The bounding boxes do not rotate, look again you will see they are all pointing north, the default direction. You are right! I must have had a bug in my script when I ran it near that squiggly section of road. It definitely didn't produce what's there now. 1 Share this post Link to post Share on other sites
code34 248 Posted January 8, 2016 Specifically, my aim was to in script (automatically and dynamically) find the main roads that entered and left a town and was going to place enemy AI roadblocks there. It looks like this method isn't going to help. Hello Tankbuster, i think i have an other code that can help you to achieve this :) i will release it in few hours. Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 8, 2016 Hello Tankbuster, i think i have an other code that can help you to achieve this :) i will release it in few hours. I've already done it, but I'd be interested to see how others tackled it. https://forums.bistudio.com/topic/179598-random-road-block/#entry2959082 Share this post Link to post Share on other sites
code34 248 Posted January 18, 2016 hi tankbuster :) have a look at this place: https://forums.bistudio.com/topic/187346-oo-pathfinding-shortest-route-between-two-positions/ Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 18, 2016 hi tankbuster :) have a look at this place: https://forums.bistudio.com/topic/187346-oo-pathfinding-shortest-route-between-two-positions/ I've seen it and am always impressed at the reception your work gets, but I'll be honest, it scared me off a bit because I understood almost none of it. If you think it might help, though, I will have another read. Share this post Link to post Share on other sites
code34 248 Posted January 18, 2016 I've seen it and am always impressed at the reception your work gets, but I'll be honest, it scared me off a bit because I understood almost none of it. If you think it might help, though, I will have another read. dont be worried about that, it s more simple than you think. You can for example check a virtual route between point A and point B easily and from this information define where to put your road blocks. I copy paste your code in the weight function example, to retrieve the route :) // Weight function example to evaluate each sector _weightfunction = { private ["_position", "_size", "_average", "_cost"]; _position = _this select 0; _size = _this select 1; _average = 0; _cost = 0; _list = _position nearRoads _size; if(count _list > 0) then { _bbr = boundingBoxReal (_list select 0); _br0 = _bbr select 0; _br1 = _bbr select 1; _maxwidth = abs ((_br1 select 0) - (_br0 select 0)); _maxlength = abs ((_br1 select 1) - (_br0 select 1)); _average = floor (_maxwidth * _maxlength); if(_average > 200) then { _cost = 1; } else { _cost = 2; }; }; _cost; }; Share this post Link to post Share on other sites
Tankbuster 1744 Posted January 18, 2016 Oh, I see, it's for the roadblocks. :) They were quite easy to place in the end. I found a location on the toiwn radius, got the nearest road piece that had 2 roads connected to it, then spawned the roadblock assets there. But what you are doing might well be used for something else, so I am going to have another read. Share this post Link to post Share on other sites