[Outdated] Obj file to strategic map converter

Users who are viewing this thread

I formatted map.txt in a spreadsheet for different purposes, but will help here too. Import as space-delimited, export same. Also speeds up loading of finished map a bit, when you shave off 3-4 digits from that unnecessary accuracy
 
I've tested it with more complicated maps and my little script seems to be working fine without any issues. So if anyone else has the same issue as I had, here is a python script which reads a badly formatted "map.txt" and outputs "map2.txt" as a formatted version:

Code:
import os
import re


linematcher = re.compile("^(?P<n>111\.00)|((?P<f>.+)E\+(?P<e>.+))")

def format(string,righthand):
	match = re.match(linematcher,string)
	
	if match.group("n"):
		string = "0.0001110"
	else:
		floatpart = float(match.group("f"))
		exppart = int(match.group("e"))
		
		if righthand:
			exppart = (exppart/10)
		
		exppart = exppart - 8
		
		exppart = 10 ** exppart
		
		string = str(floatpart*exppart)
		
	return string

f = open("map.txt")
lines = f.readlines()
f.close()

formatted = []
	
for line in lines:
	
	linesplit = line.split(" ")
	splitlength = len(linesplit)
	if splitlength == 3: # If one of the badly formatted lines.
		linesplit[0] = format(linesplit[0],True)
		linesplit[1] = format(linesplit[1],True)
		linesplit[2] = format(linesplit[2],False) # False, no need to remove a trailing 0 from exponential part
		line = (" ".join(linesplit))+"\n"
		
	formatted.append(line)


f = open("map2.txt",'w')
fullstring = "".join(formatted)
f.write(fullstring)
f.close()

Also I created a quick batch script which runs the program, followed by my script, and then copies "map2.txt" to "../map.txt" (the folder below)

Code:
@echo off
"./obj to MB map converter.exe"
echo Fixing badly formed map file
python formatter.py
echo Replacing module map file
rm "../map.txt"
cp map2.txt ../map.txt
echo Map Compiled to "../map.txt"
echo Press any key to exit. . .
pause>nul
 
Ive created a map with wings3d exported it as obj but wen i try to change it with your program i get this...
Reading faces and materials....
Object must be quadriangulated!!
Process aborted..
Dunno what that meens so il waith for an response to see what i must change at my map.
The map is the map of europe and its huge.

This is a picture of the map i created
MapofEurope.jpg
this is my first map ever so it may look bad to more experienced ppl
 
There is a little box to the right of the export option. Click this and it'll bring up the export options.

This is a fairly advanced tool though, you might want to check out Thorgrim's map editor or something else instead.
 
I had a problem similar to Yoshiboy's, but the correction script wasn't working for me in every case.  So I made a Java version of the same utility.  It works slightly different but shouldn't have that exponentials issue (looks similar to floating point calculation errors?).  The downside (possibly a big one if your map is huge) to my version is that it doesn't (yet) triangulate for you, so when you export from Wings3D you have to pick triangulation instead of quadrangulation.  Otherwise it seems to work well.

Would anyone be interested in that?  (I guess in case of problems like Yoshiboy and I had.)  I requested upload access to M&B Repository just in case but I wouldn't mind packaging it alongside Tul's version either if that makes more sense, since this version isn't that helpful in comparison...
 
Okay, here it is: http://www.mbrepository.com/file.php?id=1839

Let me know if there's any issues (entirely possible).  Also I'm not sure if it'll work with non-Wings exported obj files but I guess it's worth a shot.


Hopefully Tul doesn't mind this, and again this is only a backup version.  If both work for you, use Tul's because of his faster triangulation code (also it's obviously more tested at this point in time).

Huge thanks to Tul for providing this for me to work off of (it saved me considerable time) and for the idea itself!  Let me know if I should make a different thread for this version, I'm not sure what the etiquette is for this sort of thing.  Thanks,
 
Sounds good - my script was working fine on my laptop but I had to change it again to get it working on my desktop computer. It's working atm but I'm sure the java program would be useful in the future :smile:
 
That's interesting.. well hopefully the backup version works. :smile: I'd be interested in hearing whether anyone had any success with it.
 
man ive tested and retested the first version and no succes no map made will work i hope your version is more good
il post here fedback after i play a bit with it
 
at least the first makes you a map
my main proble is that thorgrim map editor makes the maps to small in my opinion and i wanted to try this to see if i can create a biger map
but this seems to not worck
if i put my map, made in 3ds max converted with thorgrim map editor,in game the game works with no problem
if i converted with this program....game craches
 
Clau24 said:
at least the first makes you a map
my main proble is that thorgrim map editor makes the maps to small in my opinion and i wanted to try this to see if i can create a biger map
but this seems to not worck
if i put my map, made in 3ds max converted with thorgrim map editor,in game the game works with no problem
if i converted with this program....game craches

With which version (original or java)?  Neither one works?  Can you upload an example obj file for download somewhere that we could look at?  You could also try importing the obj from 3ds into Wings3D and then exporting it using the Wings export.  The obj file format specification isn't as strict as it probably could have been, so there might be some differences that need to be accounted for.
 
ok so here is my map
http://rapidshare.com/files/381978240/map.obj
some information about it
i created it in diferent plane and diferent size than your map
but adjusted the size and coordinates to fit with size and coord of your map
the map is fully triangulated
and im usind just 2 of the materials (deap_ocean and plain) the rest i just deleted
this map is imported in wings 3d and reexported as obj
hope you can help me
tested and retested with bouth obj converter none works
also the map is the first version next version i put more materials like forest and mountain
but if you can make this to work then the other version must work aswell
Note: as this map to work in game i load it in thorgrim map editor and put some plain and water over the default texture and is ready to put ingame
 
oh damn i put a rong version of the map
this is the right version
http://rapidshare.com/files/382004918/Europe_with_terain_and_right_size2.obj
sorry but just ignore the link in the uper post
you have to change the name to map yourself(my head is messed up :grin:)
 
Okay, I took some time to look at your obj file and do some testing.

Good news, bad news, and moot news.

Moot: I made some changes to get the map.txt file to be created, but because of the more complex way 3ds is writing it's obj files it'd take a lot more work than I had hoped (I'd have to do some research) to get it working.  (Crashes M&B)

Bad news: So, I wasn't able to produce an update to the utility to fix this... but--

Good news: I was able to get your map to work by importing the obj file into Wings3D and exporting it using the procedure I gave on the M&B repo page.  Wings3D IS free (and not that hard to learn IMO), so that's good.  Might be a bit of a hassle but at least you can use your map like that.  It was pretty fast, at least (I guess faster than doing the map completely in Wings since the triangulation was already done by 3ds).

http://www.wings3d.com/

Another thing - you still may have some chance finding an alternate obj export plugin for 3ds, or getting 3ds to export a properly formatted obj file using what you currently have.  The problem appears to be related to exporting of extra data my utility doesn't process (and I assume Tul's doesn't either):
Texture coordinates (doubt it's a problem)
Normals (probably the issue)
Smooth Groups (can't remember if I saw this)

It looks like your textures fine and you have triangular faces, so those probably aren't the issue.  I don't know what the 3ds export dialog looks like, but maybe you can alter some of the settings to get it to output a compatible file?  If there are any settings that say something like "vertex normal" or "normal vector" altering those settings (turn them off) might be worth a shot.  If you can find some settings that work in 3ds I'm sure someone would appreciate you posting them somewhere in the thread for reference.

Hope that helps,
 
Clau24 said:
this map is imported in wings 3d and reexported as obj

Wait I just noticed this - are you sure you're using the settings in the screenshot I included with the download?  It worked for me, looked like a big Europe!

Here's the map.txt file I ended up with:

http://rapidshare.com/files/382086193/map.txt.html
 
ok now  program is chnaging the obj to txt but another proble apeared..
i put the map txt into the game and the game crached
now.. look what the thorgrim map editor sees wen i load my map
Native-1.jpg
is like the map is rotated with 90degres
 
Back
Top Bottom