Oolite Bulletins

For information and discussion about Oolite.
It is currently Fri Mar 22, 2019 6:49 am

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Apr 28, 2007 7:55 am 
Offline
---- E L I T E ----
---- E L I T E ----
User avatar

Joined: Fri Mar 30, 2007 8:32 am
Posts: 1474
Location: Witchspace
i recently created my first model for oolite..

I created my model in 3d max 7.0 and exported it to wavefront object. mymodel.obj

i struck upon a problem when i tried to convert it using the python script

i have installed python 2.5 on windows XP enterprise (updated all across the line)

when the script obj2dattex.py was executed..

"it said, error in line 73 empty float"
x = -float(tokens[1])

i looked at the script and the object file..

The section of the script in Question looks like this
Code:
	for line in lines:
		tokens = string.split(line, ' ')
		if (tokens[0] == 'v'):
			n_verts = n_verts + 1
	#		x = float(tokens[1])
	# negate x value for vertex to allow correct texturing...
			x = -float(tokens[1])
			y = float(tokens[2])
			z = float(tokens[3])
			vertex.append( ( x, y, z) )
What happens here is ofcourse it looks for for the Character 'V'
after which it puts the next Character into X, and makes it negative

The obj file i was using lookes like this at the first line where it has 'v'
Code:
v  -0.01808810 6.54705524 -7.28214598

Notice that following immiditately after the 'v' is 2 spaces

this means that as far as i can understand that now during the scripts
first loop here that

token[0]='v '
token[1]=' ' <--- notice it holds a space a white space
token[2]='-0.01808810 '
token[3]='6.54705524 '

i have no idea how string.split(line, ' ') works but can understand how it is supposed to work..

i figured it had that empty slot in

token[1], and therefore

token[2] would hold the X value
token[3] would hold the Y value
token[4] would hold the Z value

so, i alterd the script accordingly to
Code:
			x = -float(tokens[2])
			y = float(tokens[3])
			z = float(tokens[4])
and viola it works, and proof of it is that my model/s is ingame... :-D
i have no clue who to report this to but i figured someone here prolly has something todo with it..

Cheers

Frame


Top
   
 Post subject:
PostPosted: Sat Apr 28, 2007 10:18 am 
Offline
Grand Admiral Emeritus
Grand Admiral Emeritus
User avatar

Joined: Sat Apr 02, 2005 2:43 pm
Posts: 6657
Location: Sweden
Hmm. The script is by Giles, who’s mostly not here any more. The problem seems to be that it’s expecting tokens to be separated specifically by spaces, but should be allowing arbitrary whitespace. I don’t know how to do this in Python, though. Anyone?

Edit: actually, it seems that all that’s needed is to remove the explicit separator, i.e. change string.split(line, ' ') to string.split(line).

_________________
E-mail: jens@oolite.org


Top
   
 Post subject:
PostPosted: Fri Oct 09, 2009 1:14 am 
Offline
---- E L I T E ----
---- E L I T E ----

Joined: Mon Jul 06, 2009 11:12 pm
Posts: 322
Location: Uncharted backwaters of the unfashionable end of the western spiral arm
I don't know python 2.6, but I do know Cobra Mk III. (Sorry, couldn't resist.)

There appears to be the stub of a tutorial which does not seem related to Giles's "Flying Brick" job - looks like Draco Caeles ('im again :-) ) started it. I wonder if Draco would object to creating a bastard child that was slightly less good than either of these tutorials but contained all the info from both, plus the two threads on the go here?

http://wiki.alioth.net/index.php?title= ... _your_Mind


Top
   
 Post subject:
PostPosted: Fri Oct 09, 2009 7:46 am 
Offline
Thargoid
Thargoid
User avatar

Joined: Thu Jun 12, 2008 6:55 pm
Posts: 5510
If I remember rightly some of these oddities can be overcome by installing Wings3D, and rather than using it to actually do the modelling just use it to import and then re-export the .obj file.

The output of Wings seems to play quite well with the scripts (better than the output of other packages) so you end up using it as an .obj --> .obj convertor.

_________________
My OXPs via Boxspace or from my Wiki pages :D.

Thargoid TV
Dropbox Referral Link


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited