• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

[Plugin] Import OBJ with Materials v2.1 20131118

Scheduled Pinned Locked Moved Plugins
279 Posts 87 Posters 378.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    notareal
    last edited by 26 Aug 2010, 13:33

    Here is a model that seems to fail http://www.fileden.com/files/2009/5/30/2461193//dragon_scene_OBJ.rar (From CGTalk Frosted Glass Challenge). Maybe it's a bit large... but simlab obj importer seems to handle it.

    Welcome to try [Thea Render](http://www.thearender.com/), Thea support | [kerkythea.net](http://www.kerkythea.net/) -team member

    1 Reply Last reply Reply Quote 0
    • H Offline
      honoluludesktop
      last edited by 22 Sept 2010, 23:59

      TIG, Wow, nice piece of code. Lots stuff I have to learn, like next, case, when, def file.run(par1, par2), etc. Makes the code look more compact and easy to read. Oh well, if I looked here before starting what I am working on, I may not have understood:-)

      Some of the stuff that's driving me nuts when writing importers, is that different exporters do not format the data exactly. SU's DxfIn treats "10", and " 10" equally, and many exporters ignore the convention that is " 10". I don't know if I should go back and fix my code to read "10" or not. It's no problem for my use, and would like to "share", but am concerned about posting something that may not work for some.

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 23 Sept 2010, 12:11

        honoluludesktop
        A DXF has alternating lines for 'code' and 'value'.
        So if it's an odd-numbered line then it's always 'code' and if it's an even-numbered line it's always the previous line's code's 'value'...
        It's a DXF convention to indent the 'code' number, BUT it's not necessary and any importer should strip off leading spaces anyway...

          0
        SECTION
          2
        HEADER
          9
        etc
        

        is the same as

        0
        SECTION
        2
        HEADER
        9
        etc
        

        To see a DXF 'parser' look at my DXF Text Importer http://forums.sketchucation.com/viewtopic.php?p=194488#p194488
        πŸ€“

        TIG

        1 Reply Last reply Reply Quote 0
        • H Offline
          honoluludesktop
          last edited by 23 Sept 2010, 12:55

          OK, thanks, I will look at it. I may have to wait for a complete rewrite to parse the 'code'. Isn't some of that done in the Obj translator? I couldn't tell since I am not at all familiar with Obj.

          When I think about it, any translator can be a modular app., just as you did with the text importer as a supplement to SUs DxfIn. My own interest has been limited to very basic geometry, and dealing with the anomalies of my Cad's DxfIn/Out. It suits me since I use SU exclusively for visualization and modeling, and Cad for functional diagramming and production drawings. Accordingly, I only require the basic geometry to pass between SU and Cad.

          1 Reply Last reply Reply Quote 0
          • O Offline
            onesimo
            last edited by 25 Sept 2010, 18:37

            hi tig! thanks for the importer. its working perfectly for me on my archmodels.
            i should have tried it when i first saw the post. thanks so much and i really appreciate your work.

            1 Reply Last reply Reply Quote 0
            • O Offline
              onesimo
              last edited by 15 Oct 2010, 05:24

              hi tig! im using 3ds max design 2011. when i open/obj import my exported file the textures are not showing.. it seems my .mtl file is different from the one posted (the one with the building). thanks!


              my exported file from 3ds max

              1 Reply Last reply Reply Quote 0
              • K Offline
                Krisidious
                last edited by 15 Oct 2010, 05:43

                I imported an Obj file and the uvw map came in perfectly.

                objimporter02.jpg

                but some geometry was lost... any ideas on why?

                objimporter01.jpg

                By: Kristoff Rand
                Home DesignerUnique House Plans

                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 15 Oct 2010, 08:58

                  @onesimo said:

                  hi tig! im using 3ds max design 2011. when i open/obj import my exported file the textures are not showing.. it seems my .mtl file is different from the one posted (the one with the building). thanks!

                  The MTL file has the lines

                  Ka 0.0000 0.0000 0.0000
                  Kd 0.0000 0.0000 0.0000
                  Ks 0.3500 0.3500 0.3500
                  

                  they should read

                  Ka 0.0000 0.0000 0.0000
                  Kd 0.3500 0.3500 0.3500
                  Ks 0.0000 0.0000 0.0000
                  

                  The Kd value sets the material's RGB color in the original MTL file it is [0,0,0] = 'black'
                  If you swap the Kd and Ks values and it renders 'gray' as expected...
                  Only the 'Kd' value is read by the SUp importer - the other twp 'K' values involve reflectivity and spectral info that SUp can't use and are superfluous...
                  Also if an MTL material has an image_file defined at the end of its text_block that will be used as its 'texture', overriding any RGB 'color' - but this material does not have a texture.
                  When you make an OBJ file check that its MTL file's 'Kd' is set to RGB otherwise it will be 'black'.

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 15 Oct 2010, 09:03

                    @krisidious said:

                    I imported an Obj file and the uvw map came in perfectly.
                    but some geometry was lost... any ideas on why?

                    The OBJ importer should import all available geometry described in the file - sometimes with very convoluted meshes it can fail, but it rarely 'misses' stuff out - in fact it's more likely to try and tie vertices together that don't join in the original with extra geometry!
                    If you import the same file into another app - like Blender? - is it still missing parts?
                    If so perhaps the export didn't pick up parts in the first place πŸ˜•
                    What app made the OBJ file originally?

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • K Offline
                      Krisidious
                      last edited by 15 Oct 2010, 09:07

                      @tig said:

                      @krisidious said:

                      I imported an Obj file and the uvw map came in perfectly.
                      but some geometry was lost... any ideas on why?

                      The OBJ importer should import all available geometry described in the file - sometimes with very convoluted meshes it can fail, but it rarely 'misses' stuff out - in fact it's more likely to try and tie vertices together that don't join in the original with extra geometry!
                      If you import the same file into another app - like Blender? - is it still missing parts?
                      If so perhaps the export didn't pick up parts in the first place πŸ˜•
                      What app made the OBJ file originally?

                      it came from AC3D, I tried the file in 3Dmax and it's all there. it's no biggy, I don't need to do it. I was just trying it out.

                      By: Kristoff Rand
                      Home DesignerUnique House Plans

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        TIG Moderator
                        last edited by 15 Oct 2010, 09:11

                        Kristoff

                        Can you PM me the OBJ/MTL etc [zipped].
                        I'd like to see if I can find out the cause anyway... πŸ€“

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • T Offline
                          TIG Moderator
                          last edited by 15 Oct 2010, 09:29

                          Kristoff

                          I got the 'Ford' OBJ file by PM.
                          It imported fine for me... IF I set the units to 'meters' - it also then comes in at the correct 'size'!
                          If you use 'mm' it is tries to make some edges that are 1000 times too small 0 as you might have seen in other threads that guarantees that geometry fails to be made. SUp / OpenGL doesn't like anything smaller than about 0.1mm...
                          The importer reads the OBJ file's 'header' and if it has 'units=' in it then that is given as the default displayed in the dialog as it starts, otherwise it defaults to 'inches'.
                          In the case of this 'Ford' OBJ there's no header info at all, so you need to take a guess - trying larger scale units should always make geometry as the 0.1mm is never likely but of course the imported object might then be the wrong 'size'.
                          Meters are a common unit in non-US made OBJs...
                          So, panic over - try it in 'meters' and it should work fine... πŸ€“

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • K Offline
                            Krisidious
                            last edited by 15 Oct 2010, 09:35

                            damn counting with 10's burned me again... (hits self in head meter not millimeter!)

                            awesome plugin. I also love the groupstoobj.rb ...

                            By: Kristoff Rand
                            Home DesignerUnique House Plans

                            1 Reply Last reply Reply Quote 0
                            • E Offline
                              eloiraiol
                              last edited by 26 Oct 2010, 16:31

                              Because the images do not appear in the trial, only show the textures in SketchUp itself. Where is a picture is blank!

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                TIG Moderator
                                last edited by 26 Oct 2010, 21:33

                                @eloiraiol said:

                                Because the images do not appear in the trial, only show the textures in SketchUp itself. Where is a picture is blank!

                                Please explain your problem another way... I don't understand πŸ˜•

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • W Offline
                                  wyatt
                                  last edited by 27 Oct 2010, 14:25

                                  I'm stepping into an area that I don't fully understand, so hopefully this question makes sense. I would like to import an obj with vertex colors turned on. I have a tcs file that I believe contains the vertex color data, but the obj and mtl don't appear to reference that file at all. I haven't found much searching Google for the tcs file format. Is it possible to import vertex colors into SU?

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    TIG Moderator
                                    last edited by 27 Oct 2010, 15:15

                                    @unknownuser said:

                                    I'm stepping into an area that I don't fully understand, so hopefully this question makes sense. I would like to import an obj with vertex colors turned on. I have a tcs file that I believe contains the vertex color data, but the obj and mtl don't appear to reference that file at all. I haven't found much searching Google for the tcs file format. Is it possible to import vertex colors into SU?

                                    Not with this tool - it only imports 'faces' with their colors/textures - not even raw 'edges'...

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by 27 Oct 2010, 15:17

                                      Vertex colours, the connected face should have a surface that blends the colour from each vertex?

                                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • W Offline
                                        wyatt
                                        last edited by 27 Oct 2010, 15:46

                                        Yes, that's the idea.

                                        1 Reply Last reply Reply Quote 0
                                        • majidM Offline
                                          majid
                                          last edited by 3 Nov 2010, 19:42

                                          thanx again TIG πŸ‘ now I can play with sculptris + SU

                                          My inspiring A, B, Sketches book: https://sketchucation.com/shop/books/intermediate/2612-alphabet-inspired-sketches--inspiring-drills-for-architects--3d-artists-and-designers-

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 3
                                          • 4
                                          • 5
                                          • 6
                                          • 7
                                          • 8
                                          • 13
                                          • 14
                                          • 6 / 14
                                          • First post
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement