Jump to content
Sign in to follow this  
Homer Johnston

Road Painter tool (development thread)

Recommended Posts

DON'T USE it create "stairs" as shown above !

Here is the script :

Just make a backup of HOMJ_RoadPainter_Export.sqf

in the scripts folder of Homer's editor's mission RoadPainter.(yourmapname)

and use this one.

Result :

arma2roadpaintvisitor2.th.jpg

BUT IN BULDOZER = GAPS & STAIRS

arma2roadpaintvisitor3.jpg

// HOMJ_RoadPainter_Export.sqf
// From Homer Johnston

// Heavily Modified by GueB 01/05/2011 
// Please make backup of the original file somewhere to revert back to Visitor Road tool use !

// This script now :
// optimizes straight parts with different algo and exports to windows clipboard as specific format:
// ^ca\roads2\asf3_25^;3813.84;3578.2;0;180;µ
// to be converted to : "ca\roads2\asf3_25";3813.84;3578.2;0;180;\n(= carrier return)
// (using notepad++ since it has nice macro function for char. replacement)
// If someone has the ability to make another EXE which does the job as Homer's original one...



// Get currently selected section name:
private ["_exportSection", "_dims", "_exportThis"];

_h = 0;
{
call compile format ["_exportSection = + %1", _x];
//call compile format ["ctrlSetText [10101, str(%1)]", lbData [19873, lbCurSel 19873]];
// Process road section into exportable data:		["|", "ca\roads2\asf1_",  [0, 6.25], "", [[x, y], dir], [[x, y], dir], _road];


_i = 0;
_str = 0;
_prefix = "";
_suffix = "";
_locx = 0;
_locy = 0;
_locstx = 0;
_locsty = 0;
_loclnx = 0;
_loclny = 0;
_anglestr = 0 ;

// First, go through the entire exported section and evaluate it once for multiple straight pieces (convert 6+6 to 12)

while {_i < (count _exportSection)} do {
	_road = _exportSection select _i;	
	if (((_road select 0) == "|") AND ((_road select 1 == _prefix) OR (_str == 0))) then {
		if (_str == 0) then {
			_prefix = _road select 1;
			_suffix = _road select 3;
			_locstx = (((_road select 4) select 0) select 0);
			_locsty = (((_road select 4) select 0) select 1);
			_anglestr = ((_road select 4) select 1);
		};

		_str = _str + 1; 

		if (_str == 2) then {
				_newRoad = ["|", _prefix, [0, 12.5], _suffix, [[_locstx, _locsty], _anglestr], [[(((_road select 5) select 0) select 0), (((_road select 5) select 0) select 1)], _anglestr]];
				_exportSection set [_i - 1, _newRoad]; // replace the first straight piece with a 12m section
				_exportSection set [_i , "DELETE"]; // delete the last straight piece
		};

	}else {
		_str = 0 ;
		};
	_i = _i + 1;
};

// Second, AGAIN go through the previous optimized exported section and evaluate it for multiple straight pieces (convert 12+12 to 25)

_exportSection = _exportSection - ["DELETE"];	
_i = 0;
_str = 0;
_prefix = "";
_suffix = "";
_locx = 0;
_locy = 0;
_locstx = 0;
_locsty = 0;
_anglestr = 0 ;

while {_i < (count _exportSection)} do {
	_road = _exportSection select _i;	
	if ((_road select 0) == "|" )  then {
		if (_str == 0) then {
			_prefix = _road select 1;
			_suffix = _road select 3;
			_locstx = (((_road select 4) select 0) select 0);
			_locsty = (((_road select 4) select 0) select 1);
			_anglestr = ((_road select 4) select 1);
		};

		_str = _str + 1; 

		if (_str == 2) then {
				_newRoad = ["|", _prefix, [0, 25], _suffix, [[_locstx, _locsty], _anglestr], [[(((_road select 5) select 0) select 0), (((_road select 5) select 0) select 1)], _anglestr]];
				_exportSection set [_i - 1, _newRoad]; // replace the first straight piece with a 25m section
				_exportSection set [_i , "DELETE"]; // delete the last straight piece
				_str = 0;
		};

	}else {
		_str = 0 ;
		};
	_i = _i + 1;
};	


_exportSection = _exportSection - ["DELETE"];

// Now prepare a data export string
_exportData = "";
for "_i" from 0 to (count _exportSection - 1) do {
	_x = _exportSection select _i;

	if ((_x select 0) == "|") then {
		_dims = str(floor ((_x select 2) select 1));
		// calculate center of objects for import to visitor
		_locx = ((((_x select 4) select 0) select 0) + (((_x select 5) select 0) select 0)) / 2 ;
		_locy = ((((_x select 4) select 0) select 1) + (((_x select 5) select 0) select 1)) / 2 ;
		// create string to format : ^ca\roads2\asf3_25^;3813.84;3578.2;0;180;µ
		// to be converted using notepad++ for example to : "ca\roads2\asf3_25";3813.84;3578.2;0;180;\n(= carrier return)
		_exportData = _exportData + "^" + (_x select 1) + _dims + '^' + ";" + str(_locx) + ";"  + str(_locy) +  ";"  + "0" + ";" + str(floor ((_x select 4) select 1)) + ";" + 'µ' ;


	} else {
		_dims = str(floor ((_x select 2) select 0)) + " " + str(floor ((_x select 2) select 1));
		// calculate center of objects for import to visitor
		_locx = ((((_x select 4) select 0) select 0) + (((_x select 5) select 0) select 0)) / 2 ;
		_locy = ((((_x select 4) select 0) select 1) + (((_x select 5) select 0) select 1)) / 2 ;
		// create string to format : ^ca\roads2\asf3_25^;3813.84;3578.2;0;180;µ
		// to be converted using notepad++ for example to : "ca\roads2\asf3_25";3813.84;3578.2;0;180;\n(= carrier return)
		_exportData = _exportData + "^" + (_x select 1) + _dims + '^' + ";" + str(_locx) + ";"  + str(_locy) +  ";"  + "0" + ";" + str(floor ((_x select 4) select 1)) + ";" + 'µ' ;
		};
	};

// Homer's EXEC disabled
//_fileName = toArray (_this select _h);
//for "_i" from 0 to 9 do {_fileName set [_i, "DELETE"];};
//_fileName = toString(_fileName - ["DELETE"]);
//_pathName = ctrlText 19871;
//_export = (format ['HOMJ_PAINTER^WRITE^%1%2.txt^', _pathName, _fileName]) + _exportData;
_export = _exportData;
// HERE is the copy to Windows Clipboard
copyToClipboard _export;
//waitUntil {sleep 0.01;copyFromClipboard == "HOMJ_ENDWRITE"};
_h = _h + 1;
} forEach _this;

"Message" hintC format ["EXPORT DONE TO CLIPBOARD - Don't forget to paste it in a text editor"];

["EXPORT DONE!"] execVM "scripts\HOMJ_RoadPainter_ThrowMessage.sqf";
sleep 3;
[""] execVM "scripts\HOMJ_RoadPainter_ThrowMessage.sqf";

Some additionnal Character replacement is required just before import to Visitor since ArmA2 scripts can't manage " and carrier returns (explanations in script's first comments).

Further development could be to integrate full management of crossroads, terminators... since they are just simple objects after binarization...

Edited by wattgaz
SQF not working as expected

Share this post


Link to post
Share on other sites

hey there - believe it or not I am still alive... I haven't touched my ArmA projects in ages, sadly!

I saw in your SQF comments about modifying the exe program. If you can describe what different functionality you need from it, then I should be able to edit and recompile it for you without much trouble. If it'd help or if you have any questions, just let me know.

Share this post


Link to post
Share on other sites

Hi !

In fact my SQF DOENST WORK as expected !

Placement of road sections (location point) DIFFERS from editor/arma2 and Visitor3.

It create "stairs", as shown in previous post.

DON'T USE IT !!!

I had to fall back to your original script, I am modifying it just to export coords and angle of 1st keypoint , to avoid hassle in coord. manual entering/guessing in Visitor3 (For VERY LONG roads, half a meter of misplacement of starting point, it means BIG gap at the end )

I tried to mess a little with a convertion algo. script for full import as objects (lots of cos and sin around, lot of cases to include all angle changes regarding the angle measurements and road straight/angle sequences)

I managed to do something but not universal so I gave up.

Share this post


Link to post
Share on other sites

cheers Bushlurker.

hmm, it's very unusual that it would develop those "stairs" (I couldn't see them previously; was at work earlier)... since it's intended to work by importing a txt file, and thus Visitor builds the roads exactly the same as if you were to place them piece-by-piece (with Visitor). has anyone else been using the tool and experiencing the same issue?

Share this post


Link to post
Share on other sites

I tried many times with several full reinstall of BITools here is the difference :

- Visitor road tools has internal computations regarding angle, directions management, and fine positioning between parts

- If you add them "by hand" as objects (I dit it for airport roads on my map) then when there is a turn, you have to add a coord change to make roads edges aligned in buldozer. ( Did it visually)

So I discovered that object (center?) in Arma2 is not the same placing point in Visitor and found EXACT coord transformation:

example : angle 0 straigth 6m asf1 = X 0 Y 0

then turning part has to be= angle 0 turn 10 25 = X 0.145 Y 5.819

for edges to align perfectly in buldozer.

An export of the same section from ArmA2 and your tool : angle of turning part is still 0 but X and Y coords differs .

So the combination your tool + visitor road tool is OK

but combination your tool + export all parts coords + import as objects to visitor doesn't work properly

Edited by wattgaz

Share this post


Link to post
Share on other sites

Hi mate, can be made ​​compatible with the roads of arrowhead?

Share this post


Link to post
Share on other sites

yes i want to know exactly the same thing.

if i imported the file, it somehow only makes a straight road for me.

till now ive manualy layed all the road sections and im not happy with the outcome

hope for a breaktrough of this insane tool..

Share this post


Link to post
Share on other sites

Hey folks, well after something like 2 years of absence I've finally decided to tackle roads again. I've started work on a new version from scratch. Road painter V2 (assuming it all works and gets finished) will work a bit differently than the old one. I plan to use roads as artificial objects (like wattgaz appears to be trying to do), as I got tired of the terrible limitations of visitor road networks. The tool will also be designed to only work by drawing singular paths starting and ending with terminators (faders). No crossroads. The tool will make use of all available turn pieces, instead of just the 10-degree ones. I think this will satisfy 95% of road usages. It will generate an import file which you can use to dump roads into visitor. This is going to have some new problems, such as how to smooth the terrain, but those will be tackled when I get there. I should have a rough test version out within a couple weeks, then we can start discussing features a bit more. I'm eventually hoping to implement spline-based drawing rather than piece-based, but that'll probably take me quite a while to figure out.

Edited by Homer Johnston

Share this post


Link to post
Share on other sites

Looks like the fine-adjustment provided by the finer angles will make it more enjoyable to fit the road to curves, less fighting over which angle works best... :)

(no actual placement functionality or GUI yet, just math!)

q03xcf_psEY

Share this post


Link to post
Share on other sites

Found a couple more hours to work on this tonight; I'll occasionally post updates as I deem worthy, if people have suggestions regarding what they see I'd encourage commenting your thoughts, otherwise I'm pretty happy just rambling on to myself.

I'm making this one more modular, so that in theory new roads could be "plugged in" easier. It also supports any combination of turn/straight pieces you give it, so it'll work e.g. with ArmA1 roads as well. I can't even remember what they looked like. Anyways - made a basic "pick road type" dialog thing which loads all the types (as defined in a text file). The new curves seem to work great; it's incredibly fast to just click around and place road where you need it.

alpha_startRoad.jpg

new_road_curves.jpg

At this rate, I'll probably have another more impressive pictures-update on the weekend, and then *hopefully* something up for beta-use by the weekend after.

Share this post


Link to post
Share on other sites

Wow this is looking really nice, even more so if you can "plug in" custom road-packs. Can't wait to try this out on my current project. I was not looking forward to manually place miles of road piece by piece on top of the dykes.

Share this post


Link to post
Share on other sites

That´s really awesome...

i believe there´s many islandmaker´s eyes following this thread.

:)

Share this post


Link to post
Share on other sites
... I'd encourage commenting your thoughts, otherwise I'm pretty happy just rambling on to myself.

* We watch, we drool ! *

Share this post


Link to post
Share on other sites

I am in the islands "business" because of you Mr. Johnston, cause Minimalaco didn't know how to use your excellent tool

If it would be possible, when exporting it would be nice to ticket an option to export position (x,y,z,) of any individual part of road...

Just asking if it's possible, but thank you very much indeed for all your effort...

Share this post


Link to post
Share on other sites
If it would be possible, when exporting it would be nice to ticket an option to export position (x,y,z,) of any individual part of road...

You may be in luck; that's essentially how the new version will work. I'm going to use the tool to produce an "import objects" file. Users will have to define road objects as "artificial objects" within visitor and then run the import script.

If you have a very specific purpose in mind or formatting you need in an exported file, feel free to let me know; it's probably very easy to accommodate for...

Share this post


Link to post
Share on other sites

That's great !!! Wish you luck with all that heavy stuff!!! XD

EDIT: I don't understand well how configs and code work, but certainly is good to know where exactly is installed some object, since it allows to introduce sharp modifications and amendments in some manual and, even better, semi-automated way... which is always a great advance to avoid tedious tasks... just like adjust surrounding objects or expand roads after changing some part of terrain, i.e., after placing some water pond or adjusting some near river, etc...

Edited by Robster

Share this post


Link to post
Share on other sites
Amazing, we expect an update for roads OA?

That is actually a difficult question, since all we have is binarized ODOLs in a new format. I tried placing one in Visitor and it caused buldozer to crash stating an incorrect P3D format. I may be able to try some "clever hacks" but they wouldn't be very fun to use.

After the tool is improved to a usable state, I'm hopeful that we could try to produce a few community-made roads and release them for public use...

Edited by Homer Johnston

Share this post


Link to post
Share on other sites

I have to make a couple of custom road-surfaces for my 1940 era map as well. Would be great I the tool could be made to work with them.

Share this post


Link to post
Share on other sites

Hi Homer! Welcome back!!!

all we have is binarized ODOLs in a new format

The Latest BIS Tools release includes MLOD road parts for OA and PMC - problem with them being, all the "usual" curves are missing... that may not be a problem with your new approach to things... :)

Great to see you back and working on this again!!!

B

Share this post


Link to post
Share on other sites
The Latest BIS Tools release includes MLOD road parts for OA and PMC

Oh, perfect - I'm just horribly out of date then :p ... the tool should be capable of handling just about any combination of turn pieces, so ArmA1, ArmA2, OA, PMC, and user-made road families should all work just fine. User-made roads will require you to have them spawnable in the editor via createVehicle, plus spend 2 minutes defining the family in a text file. Obviously the more pieces you give it, the easier it will be to shape the roads. I'll be able to post more details later.

The two massive drawbacks this tool currently faces are:

1) If you need to delete a road from your WRP, you'll have to delete the road piece-by-piece in Visitor

2) The default "smooth roads" script will not be usable

I'm hoping the first issue simply won't be that big of a deal; make sure your roads are correct before you import them, please! :p Actually I could probably write some scripts to automate this a bit, but it's time I'd rather spend on other features first.

The 2nd issue will require some real work - right now I'm planning to make my own smoother algorithm which exports a file, which can in turn be imported by a new visitor script to shift terrain vertices. With a little luck and time, I should be able to make something that is at least equal to the smooth roads script, and hopefully without any of the issues that seem to plague it...

Edited by Homer Johnston

Share this post


Link to post
Share on other sites

Excellent, the current tool is very fast and easy to use, and have not had any problems.

the second point, I think there would be no problem, I create the way objects using OA roads, and then pass the old version to flatten the road.

Finally, it would be faster than them hand in hand.

Thanks !

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×