Re: New model utilities
Posted: Mon Jul 16, 2012 8:44 pm
Thanks for investigating, i'll see if i can coax the lighting functions from the default oolite shaders into this oxp
For information and discussion about Oolite.
https://bb.oolite.space/
--preserve-material-names
. When used, the material names used in the OBJ file are retained, instead of replacing them with diffuse map names. This is more convenient and legible when using materials
or shaders
dictionaries for all materials.I think when that happens, you need to fall back to Dat2Obj.py instead of Dat2ObjTex.py.submersible wrote:Dat2ObjTex.py tells me that multiple textures are not supported. Before I go diving into the code - can anyone enlighten me, is that a fundamental problem with the conversion from Obj2DatTex ? I would really like to be able to round trip some models.
It's just a limitation of Dat2ObjTex. For most cases, simply writing a new “usemtl” command each time the texture name changes in the DAT would probably be sufficient. In theory, this could lead to multiple non-contiguous “usemtl” commands for the same material, which might confuse some OBJ tools, but I don’t think any of our converters would generated DATs with that issue unless they got an OBJ like that in the first place.submersible wrote:Dat2ObjTex.py tells me that multiple textures are not supported. Before I go diving into the code - can anyone enlighten me, is that a fundamental problem with the conversion from Obj2DatTex ? I would really like to be able to round trip some models.
Obj2DatTexNorm.py
with --preserve-material-names
(or -m
) - I find it simpler to use in the shipdata.plist/usr/local/bin
- no problems so far.No, so here is an informal one.Tricky wrote:Is there a formal specification for the .DAT file?
<smooth-group> <ignored1> <ignored2> <nx> <ny> <nz> 3 <idx1> <idx2> <idx3>
nx, ny, nz
form a face normal. This is ignored of NORMALS is present. If NORMALS is not present and smooth
is set in the shipdata entry, smooth-group
is used to group faces together in smoothing to provide a mix of smooth and sharp edges. The two ignored values (which should be integers) are historical artefacts.<name> <uscale> <vscale> <u1> <v1> <u2> <v2> <u3> <v3>
name
specifies the material to use. If it’s an integer and there’s a NAMES section, it’s treated specially.<nameCount>
) on the same line, and is followed by nameCount
lines. Each line is a material name.name
is an integer, the name
is used as a zero-based index into the name list. This allows names with spaces (but no commas), but it’s mainly there to save a little disk bandwidth for large models.smooth
key are ignored. This is generally a Good Thing.What warning is this?Tricky wrote:Also, why the warning about having the python files in the same directory as the objects? I have them located in/usr/local/bin
- no problems so far.
----8<---- (Snip)JensAyton wrote:No, so here is an informal one.Tricky wrote:Is there a formal specification for the .DAT file?
Sorry, it was an instruction that I read last year from the wiki... OXP howto model :: Export the modelJensAyton wrote:What warning is this?Tricky wrote:Also, why the warning about having the python files in the same directory as the objects? I have them located in/usr/local/bin
- no problems so far.
/usr/bin/2to3
, allows the utils to work with python v3, again, somewhere on the forum it says that you can't use the utils with v3.As I read it, that’s not so much a “warning” as one way to do it.Tricky wrote:Sorry, it was an instruction that I read last year from the wiki... OXP howto model :: Export the model
Code: Select all
# oolite_plugin.rb
# copyright 2013 by Maik Schulz
# licensed CC-BY-SA 3.0
# version 0.1 (April 10th, 2013)
require 'sketchup.rb'
UI.menu("PlugIns").add_item("Load Oolite DAT file") {
load_dat_file
}
def load_dat_file
chosen_dat_file = UI.openpanel "Open Oolite DAT file"
file = File.open(chosen_dat_file, "r")
mode = 0 #expect NVERTS
file.each {|line|
line = line.split("#").at(0).rstrip #remove comments and trailing white space
if mode == 0 && line[0, 6] == "NVERTS" then
@nverts = line[7, line.length - 2].to_i
@verts = Array.new
mode = 1
elsif mode == 1 && line[0, 6] == "NFACES" then
@nfaces = line [7, line.length - 2].to_i
@faces = Array.new
mode = 2
elsif mode == 2 && line[0, 6] == "VERTEX" then
mode = 3 #expect vertex lines
elsif mode == 3 && line.split(/[,\t ]+/).size == 3 then
vertex_line = line.split(/[,\t ]+/)
@verts.push(Array[vertex_line[0].to_f, vertex_line[1].to_f, vertex_line[2].to_f])
elsif mode == 3 && line [0, 5] == "FACES" then
mode = 4 #expect face lines
elsif mode == 4 && line.split(/[,\t ]+/).size == 10 then
face_line = line.split(/[,\t ]+/)
@faces.push(Array[face_line[7].to_i, face_line[8].to_i, face_line[9].to_i])
end
}
file.close
puts "loaded " + @verts.size.to_s + " vertices, " + @faces.size.to_s + " faces from " + chosen_dat_file
model = Sketchup.active_model
entities = model.entities
for n in [email protected] - 1 do
entities.add_face @verts.at(@faces.at(n).at(0)), @verts.at(@faces.at(n).at(1)), @verts.at(@faces.at(n).at(2))
end
end
Sorry Maik, I personally use Wings3d for everything so can't test it out. If, however, you get bored and want to write one for Wings.. I would be all over it. };]maik wrote:Does anyone see a benefit in this? Other than me learning a little bit of Ruby and SketchUp plugin programming and brushing up on geometric math?