[Plugin] Import OBJ with Materials v2.1 20131118
-
I've only looked at one downloadable model.
The most recently added OBJ [bazze...] is poorly set up.
There is no units 'clue' in its header.
There is no call to an MTL file inside the OBJ.
There is no MTL file - which would be used to define Materials.
The two images are not referenced, as there is no MTL file to call them - also they typically go inside a subfolder with the OBJ and MTL files...So using that you will never get materials included.
If you guess the units to be 'meters' then all of the geometry might get made...
With smaller units, any tiny edges will not get created, and any reliant faces will also no make it through... -
Thanks TIG, I am guessing that as the modeller is European that metres is the correct scale, especially as the subject is reasonably large. I have SOME of the models translated with Turbocad but the older aircraft tend to be more complex and that is where the problems lie.
-
It worked after a few attempts, very slow but that is understandable with all the detail. I will have to work out how to wrap the textures next. Thanks againTIG, I appreciate your quick response.
-
Hi TIG,
I've been using this wonderful plugin for quite a long time, apparently it wouldn't work nicely in 2016 Make (I haven't tested in 2016 Pro) but it's working like a charm in 2015 Pro. So is there a plan to make it work under 2016 Make?
When I say it wouldn't work it's not bringing all the geometry, just some random faces from the whole model.
Cheers
erkan -
I'm unsure why you are having issues with v2016...
It should be compatible, even though its RBZ hasn't yet been signed to run in all v2016's security-policies...
I haven't tested it though !
So, is the exact same OBJ working differently in v2015 and v2016 ?
Can you ZIP the OBJ etc, and PM it to me, so I can test it here... -
Hi TIG!
Thank you so much for the plugin.
I finally installed old frecle Tree[D] that I had downloaded when still available... I think it's great and easy to use to generate 3d trees, so your plugin is perfect to be able to import OBJ + Material into my sketchup 2016.
Tree[D] is still a MUST HAVE in 2016 or there´s new stuff? vs 3D Tree Maker? Free is better... -
I purchased a model in .obj format from Turbosquid. Within the OBJ folder are .obj files and .mtl files. In addition to the OBJ folder there is a TEXTURES folder containing .tif files.
I've tried several ways to import the model into SU. The only time anything was actually imported was when I used "Import as Mesh", but some of the model was missing (size=feet) and there were no textures or materials.
The Cortaderia_variant1.obj file contains identification of the .mtl file:
==========================================================================
Wavefront OBJ format exported by Red-i Productions' "Riptide Pro"
(a commercial plugin for Cinema 4D PC & Mac, R9.6 or later)
Red-i Productions
http://skinprops.com
==========================================================================
mtllib Cortaderia_variant1.mtl
o si3d_0031_leaf01
v -0.00283137 0.010224 0.114454
v -0.000566467 0.00851267 0.116015
v 0.00263311 0.00845039 0.116518
v -0.0110162 0.0498717 0.168671
v -0.00835776 0.0478127 0.170411
v -0.00461871 0.0477404 0.171001
v -0.0204793 0.0850494.....................The mtllib Cortaderia_variant1.mtl file contains:
==========================================================================
Wavefront Material file
Exported by Red-i Productions' "Riptide Pro"
(a commercial plugin for Cinema 4D PC & Mac, R9.6 or later)
Red-i Productions
http://skinprops.com
==========================================================================
newmtl default_Mat
illum 2
Kd 0.800000 0.800000 0.800000newmtl si3d_0031_leaf01
Ns 50.781250
illum 2
Kd 0.800000 0.800000 0.800000
map_Kd si3d_0031_leaf01.tif
bump si3d_0031_leaf01_rel.tif
map_d si3d_0031_leaf01_a.tifnewmtl si3d_0031_leaf02
Ns 50.781250
illum 2
Kd 0.800000 0.800000 0.800000
map_Kd si3d_0031_leaf02.tif
bump si3d_0031_leaf01_rel.tif
map_d si3d_0031_leaf01_a.tifetc,
.
.
.
.
.The textures folder contains:
-
Have you also tried the [faster] Fluid OBJ Importer ?
I suspect the OBJ's units are meters ?
The vertex spacings seem very small otherwise.Any Ruby Console error messages when importing it ?
In my version the mesh option ignores textures - so that's expected.
At first glance the MTL materials seem to be defined OK, although the bumps images etc will be ignored.
However, themap_Kd si3d_0031_leaf01.tif
does NOT include the actual path to the 'textures
' folder.
I suggest you copy that folders' image files into the main folder with the OBJ and MTL files...
Then retry, using meters as the units...Have you tried importing the OBJ into Blender and then exporting it as a DAE.
That DAE might then import into a SKP... -
See this which discusses what I did with your suggestions/comments in mind:
-
Sorry @Bob I can't access that forum.
Can you précis it ?Did it work ?
-
I got another question about this importer. If im correct it would show vertices or some sort of count in the bottom left corner. It doesnt no more for me on mac, but im not sure if it was with this script
Ive used this script before and always sort of worked. Now i got this model which is in Meters. WHen i import it in Meters nothing happens, at least on mac SU becomes non responding. But thats normal i believe for this script. When i use Inch, it does work only a lot of the mesh is cut off and not showing.
Im using SU8 on osx 10.11.2
EDIT
after checking on using inches again. It does show some progress in the bottom left. It seems with meters some errors apear.Ive zipped the part with the textures, perhaps you can check or see. If you like
https://www.dropbox.com/s/ihpnays8veufcpm/plant%20part.zip?dl=0EDIT2
When i use inch it also goed much faster. I did let it go now for 20min orso and than it did the meters. Not sure why the difference in time??? Also centimeters go much faster than meter. -
In the bottom left of the status-bar it shows a count of the lines of text it has processed in the OBJ file - in your case:
Processing line 1234 of 139564
About a third of that relate to vertices, the remainder are normal maps, face creation etc.It took my PC 23 mins to import it in meters [which I believe to be the correct units, though the OBJ file's header does no define any units at all!].
The faces are triangulated and reversed [see screenshot], making the application of materials somewhat pointless... The blue faces are reversed.
It is an enormous file for a small plant - this kind of geometry is not very suited to use in SketchUp - a single plant that is bigger in Mb than many users' entire building projects seems excessive...
It's ~20Mb !
It had three errors that were fixed using statistics - coincident edge vertices - here were no errors in processing reported in the Ruby Console as it was processing...
-
Thanks for looking into it. My problem is that i got that timer showing with other models, but with this particular model it doesnt show. BLender doesnt seem to add it metric number, it was indeed meters.
PS why is using inch much faster than meters?
Could i use your tree_fix.rb to get the back material on the mesh?
This is not my model, i would use this as a proxy and use a 2d of this model
-
I read somewhere back that someone was testing a updated loading info. Ive tried using his code but got some errors.
How can i change the update response, set it lower, so su is perhaps more responsive?
The normals etc are correct iin this model, they point upwards. Do you think if the dimensions/measurements are added in the OBJ file it would go faster?
-
You could try the 'fix' rb - no promises...
Inches is probably quicker since the read number is taken as inches, otherwise it has to be converted to another unit-system.
Every vertex has x/y/z and there are lots of them so 100k processes add up time-wise !There is the Fluid OBJ Importer, which is faster as it's written in C, but it is $$$...
-
yes i know, but i always try the crapp out of free before im pushed for the payed.
But you dont have any idea why the count doesnt show up.
Im wondering though how i can get the model inside SU in inches than???
PS OBJ doesnt have a unit or dimension header, did some checkup about that. It only uses 1 1 1 but no measurement system. Thats whats causing all the fuzz about people importing huge models exported from different modelers
-
Maybe it's a MAC thing ?
The status bar updating is known to slow down MAC processing compared to PC, so perhaps it's skipping it ??An OBJ file has coordinate values set up for the vertices, in the form:
x y z
Although usually the OBJ's y & z axes are flipped when compared to a SKP - hence the plugin's final prompt to change them around.
The x/y/z values are set off from an 'origin' - just like in a SKP, so:
0 0 0
and
1 0 0
are ONE unit apart in the x direction.
A good OBJ has a line in its header, saying something like:
units = "meters"
My plugin looks for this and uses it as the default units.
If it's missing then it defaults to "inches" [the correct default for non-headed OBJs].
The ONE unit is then taken as the assumed distance - e.g. 1m or 1"
If you know it's a "meter" OBJ, then you should use meters and it then imports at the correct size.
If you assumed it's "inches" then it'll be far too small.The problem in using a smaller sized unit that the coordinates specify can fall foul of the SketchUp tolerance issue. If two points are within 1/1000" then they are assumed coincident, and so the related edges/face is not made. So if it's a "meter" OBJ and two vertices are 0.001m apart, and you chose "meters", they will get processed and a small facet is created - since 1mm is considerably more than 1/1000" [actually ~39/1000"]. However, if you mistakenly chose "mm", then the calculations assume they are now 0.001mm apart and since this is considerably less than 1/1000" [], they are not processed.
The units used in the OBJ are converted into the correct size in the SKP, so if it's a "meter" OBJ and you are importing it into a SKP set up for "inches" it doesn't matter - the 1m tall object specified in the OBJ, is made 39.37..." tall in the SKP.
If you are uncertain of the dimensions used in an OBJ then I recommend using say "meters", since even if you are wrong, its over-sized geometry will get created, and you can always scale the imported geometry down to the correct size [using the Tapemeasure tool method]. But if you choose a tiny unit like mm when it is set up in m you will almost certainly get missing faces, not to mention that it will be 1000x too small ! -
@tig said:
Sorry @Bob I can't access that forum.
Can you précis it ?Did it work ?
My post from Thea forum:
Today I bought FluidImporter Pro and used it on a model from TurboSquid. As TIG suggested, once I put all of the files in one folder (obj, mtl and tif), FluidImporter did a very fast job of importing the model into SU. I'm in the process of rendering each variation of the model in Presto AO. Then I'll convert them to Thea models and make SU proxies to use with Skatter.
The TurboSquid model also came in fbx so I gave that a try: MUCH faster import with FluidImporter Pro.However, I've not been able to successfully import XFrog files in obj: just doesn't work. A real frustration since I have so many XFrog plant and tree models.
Of course the best of all worlds, IMO, would be an easy, efficient way to import fbx models directly into Thea and make proxies for SU. I don't think XFrog provides fbx (I may be wrong) but they're not the only makers of good plants and trees.
-
@tig said:
Maybe it's a MAC thing ?
The status bar updating is known to slow down MAC processing compared to PC, so perhaps it's skipping it ??An OBJ file has coordinate values set up for the vertices, in the form:
x y z
Although usually the OBJ's y & z axes are flipped when compared to a SKP - hence the plugin's final prompt to change them around.
The x/y/z values are set off from an 'origin' - just like in a SKP, so:
0 0 0
and
1 0 0
are ONE unit apart in the x direction.
A good OBJ has a line in its header, saying something like:
units = "meters"
My plugin looks for this and uses it as the default units.
If it's missing then it defaults to "inches" [the correct default for non-headed OBJs].
The ONE unit is then taken as the assumed distance - e.g. 1m or 1"
If you know it's a "meter" OBJ, then you should use meters and it then imports at the correct size.
If you assumed it's "inches" then it'll be far too small.The problem in using a smaller sized unit that the coordinates specify can fall foul of the SketchUp tolerance issue. If two points are within 1/1000" then they are assumed coincident, and so the related edges/face is not made. So if it's a "meter" OBJ and two vertices are 0.001m apart, and you chose "meters", they will get processed and a small facet is created - since 1mm is considerably more than 1/1000" [actually ~39/1000"]. However, if you mistakenly chose "mm", then the calculations assume they are now 0.001mm apart and since this is considerably less than 1/1000" [], they are not processed.
The units used in the OBJ are converted into the correct size in the SKP, so if it's a "meter" OBJ and you are importing it into a SKP set up for "inches" it doesn't matter - the 1m tall object specified in the OBJ, is made 39.37..." tall in the SKP.
If you are uncertain of the dimensions used in an OBJ then I recommend using say "meters", since even if you are wrong, its over-sized geometry will get created, and you can always scale the imported geometry down to the correct size [using the Tapemeasure tool method]. But if you choose a tiny unit like mm when it is set up in m you will almost certainly get missing faces, not to mention that it will be 1000x too small !Is there a way/method i can take that status update from the code? It used to work but now somehow never appears no more.
Im testing a different model know. 9k vertices and is still slow, ive done a lot of models and never was experiencing this... dont understand what happened.
PS where did you see that about a header in OBJ, it says nothing on wiki about this??? or some others i checked about explination on OBJ. I thought i check some background info on OBJ perhaps it could help me as well.
I do noticed when you run the impoter a second time it is somehow much slow than the first time? Is there some cache problem
PS
Bob you need to make sure that OBJ imports in other app correct. I remember a version of Xfrog has bad exported OBJ files which dont contain the correct textures assigned in the MTL file -
If you export an OBJ from SUp the header says this:
` # Alias OBJ Model File
Exported from SketchUp, (c) 2000-2012 Trimble Navigation Limited
# File units = millimeters
mtllib Untitled.mtl
g Mesh1 G_2016_1 Model
usemtl Mirror_01
v 223.781 841.405 0
vt -1.99553 9.71584
vn 0 0 -1
v 195.802 797.206 0
vt -0.893997 7.97573
v 195.802 831.592 0
vt -0.893997 9.3295
f 1/1/1 2/2/1 3/3/1
...`So it is possible to indicate the units used in the OBJ in its header - in this case '
mm
' ...
https://en.wikipedia.org/wiki/Wavefront_.obj_file
It is just good manners to the OBJ's user...
If you want to remove the status_bar updates, edit the RB file in a plain text editor - like Notepad++ [PC] or TextWrangler [MAC] and find the line #228 saying:
Sketchup.set_status_text("Processing line #{line_cnt} of #{lines.length}")
Type a#
at the start of the line to stop it loading...
To optimize the calculations you can also skip the counter by adding a#
before the previous line #227 which saysline_cnt += 1
which will save a few milliseconds on the now unneeded increment...
Save the file and restart SketchUp to see the change...
OBJs define geometry, they are supplied with a linked MTL file defining the materials: this almost always resides in the same folder as the OBJ [the name of the MTL file is given near the start of the OBJ's text].
That makes each material - where it is textured it indicates a reference to an image-file.
Good OBJ exporters will usually write these texture-files into a folder, which is shipped with the OBJ/MTL files.
Good OBJ exporters will also include the relative path to that folder when specifying the texture-file, e.g.
newmtl Mirror_01 Ka 0.000000 0.000000 0.000000 Kd 0.725490 0.725490 0.725490 Ks 0.330000 0.330000 0.330000 map_Kd **Untitled/**Mirror_01.jpg
However, with some poorly set up OBJ exports the image files are put in a subfolder, BUT only the file-name is included in the MTL e.g.map_Kd Mirror_01.jpg
In which case the texture-file in the folder is not found and the material is just made plain-colored.
The way to fix this is either to edit the MTL to include thefolder_name/
before each file-name - or probably easier, either move the OBJ/MTL into the image-files' folder, OR move the image-files into the same folder as the OBJ/MTL - either way the required image-files are then found and used...
Advertisement