Page 2 of 6
Posted: Fri Jun 11, 2010 10:53 am
by Commander McLane
Let me quote Killer Wolf, a couple of posts up here:
Killer Wolf wrote:the only thing to consider, is if it's in scale in Oolite, going by the comic illo there, it's gonna by tiny.
So yes, congratulations for creating the first ship that will fit smoothly into a cargo pod!
(No, really!, the cargopod has size 9 x 6 x 5.8, which is bigger in (almost) all dimensions than your model.
)
If you want to re-scale, I suggest you don't even consider a factor smaller than ten, and even that would be small.
And IIRC, limits on faces have been lifted in recent versions of Oolite, so no problem there.
Posted: Fri Jun 11, 2010 10:54 am
by Killer Wolf
i said that in my first mail :-/
i don't think the poly limit is owt to worry about, i asked about this and the opinion seemed to be massive textures were more of a performance issue. besides, if it's very rare to see, it's not like you'll be coming across a squadron of them that would choke up the game.
as for scale i'd assume you're modeller can easily scale it up.
edit : lol, ninja'd by McLane!
Posted: Fri Jun 11, 2010 11:05 am
by DaddyHoggy
I knew it was small, but jeez - cargo pod small - whoops!
Will be interesting to see if AC3D also scales the UV map too - otherwise I'm going to have to realign all my textures again too!
Thanks all - might get there yet!!
Posted: Fri Jun 11, 2010 11:21 am
by JensAyton
Kaks wrote:Or alternatively, use the 'right' texture .png to begin with!
If you use 'texturefilenameusedinsideoolite.png' inside your 3d progam, you don't need the extra steps mentioned by KW & Zieman. :)
Or even more alternatively, use a materials entry:
Code: Select all
materials =
{
"cube2_auv.tga" =
{
diffuse_map = "mytexturename*.png";
};
}
Well… you
could.
Commander McLane wrote:And IIRC, limits on faces have been lifted in recent versions of Oolite, so no problem there
Well, sort of. Due to inefficiencies in Oolite, the cost of loading a mesh scales badly (it’s proportional to the product of the face count and the vertex count). This will probably be fixed for 1.75.
1352 shouldn’t be a problem, though.
DaddyHoggy wrote:Will be interesting to see if AC3D also scales the UV map too - otherwise I'm going to have to realign all my textures again too!
Since the UV map is in texture coordinate space, you want it to
not scale it.
Posted: Fri Jun 11, 2010 11:25 am
by JensAyton
DaddyHoggy wrote:My .mtl file looks like this:
Code: Select all
newmtl acmat_0
Kd 1 1 1
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
newmtl acmat_1
Kd 1 1 0
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
newmtl acmat_2
Kd 1 0 0
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
newmtl acmat_3
Kd 0.533333 0.533333 0.533333
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
newmtl acmat_4
Kd 0 0 1
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
What you have here is five different materials with the same texture map but different base colours. If you want to modulate the texture map by these colours, you’ll need to use five different texture names in the MTL file to get different material names in Oolite. I’m guessing you don’t, though. (You could potentially save texture space by using untextured materials except for the “8” decal, but that’s a bit esoteric.)
Posted: Fri Jun 11, 2010 11:33 am
by Griff
DaddyHoggy wrote:Will be interesting to see if AC3D also scales the UV map too - otherwise I'm going to have to realign all my textures again too!
as long as you uniformly scale up the complete model in all 3 axis DH you won't have to worry about your UV map, you'll only get problems if the scaling stretches or twists any individual polygons, you'll have to re-UV those polygons then as the texture will go all stretchy and distorted accross them since their new shape no longer matches their UV shape, you can use a texture of a checkerboard pattern applied to your model to easily spot distorted UVs
Lovely work though DH, it looks an awful lot like the original drawing, if you're still tweaking the model then maybe bring the point at the nose back a bit so it's not so sharp, the drawing seems to have a blunter nose.
I wonder if Oolite will do cel-shading? I'm sure there's lots of examples on the web of shader code we might be able to pinch
Posted: Fri Jun 11, 2010 11:47 am
by Killer Wolf
"I knew it was small, but jeez - cargo pod small - whoops! "
make it a trading item! the first Oolite action figure. 25 tons of model ships to Lave...
Posted: Fri Jun 11, 2010 12:35 pm
by DaddyHoggy
Griff wrote:DaddyHoggy wrote:Will be interesting to see if AC3D also scales the UV map too - otherwise I'm going to have to realign all my textures again too!
as long as you uniformly scale up the complete model in all 3 axis DH you won't have to worry about your UV map, you'll only get problems if the scaling stretches or twists any individual polygons, you'll have to re-UV those polygons then as the texture will go all stretchy and distorted accross them since their new shape no longer matches their UV shape, you can use a texture of a checkerboard pattern applied to your model to easily spot distorted UVs
Lovely work though DH, it looks an awful lot like the original drawing, if you're still tweaking the model then maybe bring the point at the nose back a bit so it's not so sharp, the drawing seems to have a blunter nose.
I wonder if Oolite will do cel-shading? I'm sure there's lots of examples on the web of shader code we might be able to pinch
Re: Nose - I did try - but my early attempts were somewhat disastrous - I think I would need to introduce additional vertex/surfaces on the cone down to the nose tip to shape it better - I might have a little go at this when I'm braver!
Posted: Fri Jun 11, 2010 12:38 pm
by DaddyHoggy
Ahruman wrote:DaddyHoggy wrote:My .mtl file looks like this:
Code: Select all
newmtl acmat_0
Kd 1 1 1
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
newmtl acmat_1
Kd 1 1 0
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
newmtl acmat_2
Kd 1 0 0
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
newmtl acmat_3
Kd 0.533333 0.533333 0.533333
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
newmtl acmat_4
Kd 0 0 1
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd tycho8.png
What you have here is five different materials with the same texture map but different base colours. If you want to modulate the texture map by these colours, you’ll need to use five different texture names in the MTL file to get different material names in Oolite. I’m guessing you don’t, though. (You could potentially save texture space by using untextured materials except for the “8” decal, but that’s a bit esoteric.)
When I first built the model and before I added any textures I used AC3Ds colour palette to colour the main hull red, the wings yellow, the engine grey, the nacelle intakes blue and the cockpit dome grey-blue, after I applied the textures I made the underlying colour for the whole model white (the default) - but I guess the original colourings somehow remain?
Posted: Fri Jun 11, 2010 12:42 pm
by DaddyHoggy
Griff wrote:DaddyHoggy wrote:Will be interesting to see if AC3D also scales the UV map too - otherwise I'm going to have to realign all my textures again too!
as long as you uniformly scale up the complete model in all 3 axis DH you won't have to worry about your UV map, you'll only get problems if the scaling stretches or twists any individual polygons, you'll have to re-UV those polygons then as the texture will go all stretchy and distorted accross them since their new shape no longer matches their UV shape, you can use a texture of a checkerboard pattern applied to your model to easily spot distorted UVs
Lovely work though DH, it looks an awful lot like the original drawing, if you're still tweaking the model then maybe bring the point at the nose back a bit so it's not so sharp, the drawing seems to have a blunter nose.
I wonder if Oolite will do cel-shading? I'm sure there's lots of examples on the web of shader code we might be able to pinch
The one thing I don't like about AC3D is that it doesn't seem to be able to do a flat projection of the shapes - so for example to get the yellow shape around the wings and front nacelles I had to match the side on projection of the whole main hull to my texture - it wouldn't (doesn't allow?) unwrapping of the shape to overlay it on to the texture map - so I've had to be quite creative matching texture pattern to the shape of the ship...
Posted: Fri Jun 11, 2010 2:44 pm
by DaddyHoggy
OK, I've rescaled and fiddled with the shape slightly as suggested by others.
Given the wiki is down and some of the links in the cached version Kaks gave me don't work - what is the absolute minimum I need to do from the creation of an OXP point of view to have it:
1) Appear at the start of the game along with the rest of the ships (before the Start game thing)
2) Spawned in the game (for example as I launch from a station) so I can look at it and judge its size - all the ship oxps I have seem to be rather complicated - I just want to see it and then build up to the clever stuff as I go after that.
TIA
DH
Posted: Fri Jun 11, 2010 2:50 pm
by Griff
I just had a quick skim through the AC3D manual pdf on their website, Page 52, the "Texture Coordinate Editor" seems to be the place for reprojecting the UV's, i'm puzzled though, it shows a cylindrical map right there on that page, but in the interface picture abve it there are only reproject buttons for top, side and spherical, ideally you'd want to do the main body of the rocket as a cylindrical unwrap down its Z axis, and then reselect the polygon cones at both ends (nose and inside the engine) and do a front projection on those so they come out as a nice and easy to paint circles on the UV map.
With the 4 wings on the rocket DH, a quick time saving tip is to just UV 1 of them and then clone those polygons for the other 3, since it's already UV'd all the clones will be UV'd too, and you can just move their UV's into a new space on the map if you want them to have a unique bit of texturing or leave them all on top of each other to have them share the same texture (handy if space on the map is tight)
edit:
to get the ship ingame, you'll need at least a folder with a name ending in .oxp in your oolite AddOns folder
Inside that you'll need a Config folder with a shipdata.plist and a demoships.plist file
for the shipdata.plist, this will probably be enough for testing
Code: Select all
{
"DH_Rocket" =
{
like_ship = "asteroid";
model = "dh_rocket.dat";
roles = "dh_test";
};
}
for the demoships.plist, use this:
Next, you'll need a Models folder with a dat file of your obj in called dh_rocket.dat (see the model = line in the shipdata.plist, what's written there has to match your dat file)
and finally a Textures folder with your ships texture in, in .png format
this will get your ship onto the demo screen parade, for the spawning it outside the station i use a script.js file also place in the oxps config folder, it contains just the instruction to place the ship outside teh station when i launce, i can't get to that script file for the moment, but i can certainly post it up when i get home
Posted: Fri Jun 11, 2010 3:07 pm
by DaddyHoggy
Griff wrote:I just had a quick skim through the AC3D manual pdf on their website, Page 52, the "Texture Coordinate Editor" seems to be the place for reprojecting the UV's, i'm puzzled though, it shows a cylindrical map right there on that page, but in the interface picture abve it there are only reproject buttons for top, side and spherical, ideally you'd want to do the main body of the rocket as a cylindrical unwrap down its Z axis, and then reselect the polygon cones at both ends (nose and inside the engine) and do a front projection on those so they come out as a nice and easy to paint circles on the UV map.
With the 4 wings on the rocket DH, a quick time saving tip is to just UV 1 of them and then clone those polygons for the other 3, since it's already UV'd all the clones will be UV'd too, and you can just move their UV's into a new space on the map if you want them to have a unique bit of texturing or leave them all on top of each other to have them share the same texture (handy if space on the map is tight)
edit:
to get the ship ingame, you'll need at least a folder with a name ending in .oxp in your oolite AddOns folder
Inside that you'll need a Config folder with a shipdata.plist and a demoships.plist file
for the shipdata.plist, this will probably be enough fo testing
Code: Select all
{
"DH_Rocket" =
{
like_ship = "asteroid";
model = "dh_rocket.dat";
roles = "dh_test";
};
}
for the demoships.plist, use this:
Next, you'll need a Models folder with a dat file of your obj in called dh_rocket.dat (see the model = line in the shipdata.plist, what's written there has to match your dat file
and finally a Textures folder with your ships texture in, in .png format
A cylinder does unwrap in the texture coordinate editor BUT it would seem more complicated shapes - such as the main hull or the nacelles which started as cylinders but then had extra vertices added and then were extruded and scaled - won't unwrap - so you have to work it all out by picking individual surfaces or get lucky with one of the limited projections (as I did).
[and I did what you suggested with the eight surfaces of the four wings]
EDIT: Partial ninja! You edited while I was replying!
Posted: Fri Jun 11, 2010 3:08 pm
by Griff
here the obj2dattex.py script you'll need to convert your obj to dat, save the following code as Obj2DatTex.py
Code: Select all
#!/usr/bin/python
# EXTENSIONS : "obj" "OBJ" # Accepted file extentions
# OSTYPES : "****" # Accepted file types
# ROLE : Editor # Role (Editor, Viewer, None)
# SERVICEMENU : Obj2DatTex/Convert to .dat # Name of Service menu item
"""
This script takes a Wavefront .obj file
and exports a .dat file containing the same trimesh.
Colour for the faces is set to flat grey (127,127,127)
and surface normals calculated for each triangle.
"""
import sys, string, math
def vertex_reference(n, nv):
if (n < 0):
return n + nv
return n - 1
inputfilenames = sys.argv[1:]
print "converting..."
print inputfilenames
for inputfilename in inputfilenames:
outputfilename = inputfilename.lower().replace(".obj", ".dat")
if (outputfilename == inputfilename):
outputfilename = outputfilename,append(".1")
print inputfilename+"->"+outputfilename
inputfile = open( inputfilename, "r")
lines = inputfile.read().splitlines(0)
outputfile = open( outputfilename, "w")
mode = 'SKIP'
vertex_lines_out = ['VERTEX\n']
faces_lines_out = ['FACES\n']
n_verts = 0
n_faces = 0
skips = 0
vertex=[]
uv=[]
face=[]
texture=[]
uvForVertex=[]
uvsForTexture={}
textureForFace=[]
uvsForFace=[]
textureCounter = 0
interpretTexture = 0
materials = {}
max_v = [0.0, 0.0, 0.0]
min_v = [0.0, 0.0, 0.0]
# find materials from mtllib
for line in lines:
tokens = string.split(line)
#print "line :"
#print line
#print "tokens :"
#print tokens
if (tokens != []):
if (tokens[0] == 'mtllib'):
path = string.split(inputfilename, '/')
path[-1] = tokens[1]
materialfilename = string.join(path,'/')
print "going to open material library file: %s" % materialfilename
infile = open( materialfilename, "r")
mlines = infile.read().splitlines(0)
newMaterial = 0
for mline in mlines:
tokens1 = string.split(mline)
if (tokens1 != []):
if (tokens1[0] == 'newmtl'):
newMaterialName = tokens1[1]
newMaterial = 1
if (tokens1[0] == 'map_Kd'):
if (newMaterial):
materials[newMaterialName] = tokens1[1]
print "Material %s -> %s" % (newMaterialName, tokens1[1])
newMaterial = 0
#print "materials :"
#print materials
# find geometry vertices first
for line in lines:
tokens = string.split(line)
if (tokens != []):
if (tokens[0] == 'v'):
n_verts = n_verts + 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) )
vertex_lines_out.append('%.5f, %.5f, %.5f\n' % ( x, y, z))
if (x > max_v[0]):
max_v[0] = x
if (y > max_v[1]):
max_v[1] = y
if (z > max_v[2]):
max_v[2] = z
if (x < min_v[0]):
min_v[0] = x
if (y < min_v[1]):
min_v[1] = y
if (z < min_v[2]):
min_v[2] = z
#print "vertex:"
#print vertex, len(vertex), n_verts
#print "\n"
# find texture coordinates next
for line in lines:
tokens = string.split(line)
if (tokens != []):
if (tokens[0] == 'vt'):
uv.append( ( float(tokens[1]), 1.0 - float(tokens[2])) )
#print "uv:"
#print uv, len(uv), n_verts
#print "\n"
# find faces next
# use red colour to show smoothing groups
smoothing_group = 1
group_token = 0;
for line in lines:
tokens = string.split(line)
if (tokens != []):
if (tokens[0] == 's'):
# we check the group number if it's zero this is a non-smoothed group
group_token = tokens[1]
if (group_token == 'off'):
group_token = 0
else:
group_token = int(group_token)
if group_token > 0:
smoothing_group = group_token
else:
smoothing_group = 0
if (tokens[0] == 'usemtl'):
textureName = tokens[1]
if (materials.has_key(textureName)):
textureName = materials[textureName]
interpretTexture = 1
texture.append(textureName)
uvsForTexture[textureName] = n_verts * [[]]
if (tokens[0] == 'f'):
#print "line: %s" % line
while (len(tokens) >=4):
bits = string.split(tokens[1], '/')
v1 = vertex_reference(int(bits[0]), n_verts)
if (bits[1] > ''):
vt1 = vertex_reference(int(bits[1]), n_verts)
bits = string.split(tokens[2], '/')
v2 = vertex_reference(int(bits[0]), n_verts)
if (bits[1] > ''):
vt2 = vertex_reference(int(bits[1]), n_verts)
bits = string.split(tokens[3], '/')
v3 = vertex_reference(int(bits[0]), n_verts)
if (bits[1] > ''):
vt3 = vertex_reference(int(bits[1]), n_verts)
else:
interpretTexture = 0
#print "face (geometry): %d %d %d" % (v1, v2, v3)
#print "face (textures): %d %d %d\n" % (vt1, vt2, vt3)
d0 = (vertex[v2][0]-vertex[v1][0], vertex[v2][1]-vertex[v1][1], vertex[v2][2]-vertex[v1][2])
d1 = (vertex[v3][0]-vertex[v2][0], vertex[v3][1]-vertex[v2][1], vertex[v3][2]-vertex[v2][2])
xp = (d0[1]*d1[2]-d0[2]*d1[1], d0[2]*d1[0]-d0[0]*d1[2], d0[0]*d1[1]-d0[1]*d1[0])
det = math.sqrt(xp[0]*xp[0] + xp[1]*xp[1] + xp[2]*xp[2])
if (det > 0):
n_faces = n_faces + 1
# norm = (xp[0]/det, xp[1]/det, xp[2]/det)
# negate the normal to allow correct texturing...
norm = ( -xp[0]/det, -xp[1]/det, -xp[2]/det)
face.append((v1,v2,v3))
faces_lines_out.append('%d,0,0,\t%.5f,%.5f,%.5f,\t3,\t%d,%d,%d\n' % (smoothing_group,norm[0],norm[1],norm[2],v1,v2,v3))
#
# check if we're in a non-smoothed group - if so keep incrementing the 'red' smoothing_group value...
#
if (group_token == 0):
smoothing_group = smoothing_group + 1
if (smoothing_group > 255):
smoothing_group = 0
if (interpretTexture):
textureForFace.append(textureName)
uvsForTexture[textureName][v1] = uv[vt1]
uvsForTexture[textureName][v2] = uv[vt2]
uvsForTexture[textureName][v3] = uv[vt3]
uvsForFace.append([ uv[vt1], uv[vt2], uv[vt3]])
tokens = tokens[:2]+tokens[3:]
# begin final output...
outputfile.write('// output from Obj2DatTex.py Wavefront text file conversion script\n')
outputfile.write('// (c) 2005 By Giles Williams\n')
outputfile.write('// \n')
outputfile.write('// original file: "%s"\n' % inputfilename)
outputfile.write('// \n')
outputfile.write('// model size: %.3f x %.3f x %.3f\n' % ( max_v[0]-min_v[0], max_v[1]-min_v[1], max_v[2]-min_v[2]))
outputfile.write('// \n')
outputfile.write('// textures used: %s\n' % uvsForTexture.keys())
outputfile.write('// \n')
outputfile.write('NVERTS %d\n' % n_verts)
outputfile.write('NFACES %d\n' % n_faces)
outputfile.write('\n')
outputfile.writelines(vertex_lines_out)
outputfile.write('\n')
outputfile.writelines(faces_lines_out)
outputfile.write('\n')
# check that we have textures for every vertex...
okayToWriteTexture = 1
#print "uvsForTexture :"
#print uvsForTexture
#print "uvsForFace :"
#print uvsForFace
if (len(textureForFace) != len(face)):
okayToWriteTexture = 0
if (len(uvsForFace) != len(face)):
okayToWriteTexture = 0
for texture in textureForFace:
if (texture == ''):
okayToWriteTexture = 0
# if we're all clear then write out the texture uv coordinates
if (okayToWriteTexture):
outputfile.write('TEXTURES\n')
for i in range(0, len(face)):
facet = face[i]
texture = textureForFace[i]
uvForVertex = uvsForTexture[texture]
outputfile.write('%s\t1.0 1.0\t%.5f %.5f\t%.5f %.5f\t%.5f %.5f\n' % (texture, uvsForFace[i][0][0], uvsForFace[i][0][1], uvsForFace[i][1][0], uvsForFace[i][1][1], uvsForFace[i][2][0], uvsForFace[i][2][1]))
outputfile.write('\n')
outputfile.write('END\n')
outputfile.close();
print "done"
print ""
#
# end
#
There's quite a comprehensive guide on how to use this script somewhere with lots of screenshots and stuff on the boards, can't find it at the moment though, will keep looking
Posted: Fri Jun 11, 2010 3:12 pm
by DaddyHoggy
Griff wrote:this will get your ship onto the demo screen parade, for the spawning it outside the station i use a script.js file also place in the oxps config folder, it contains just the instruction to place the ship outside teh station when i launce, i can't get to that script file for the moment, but i can certainly post it up when i get home
I think your shader thargoid contains (accidentally) said script.js - I'll have a look later.
Thanks for the py script - that bit I've got (that link did work from Kak's cache) - and my ship is in .dat format - that's how "we" knew it would fit inside a cargo pod when I first converted it
it's 10x bigger now.