• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

NURBS plugin version 0.1

Scheduled Pinned Locked Moved Developers' Forum
28 Posts 7 Posters 2.9k Views 7 Watching
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.
  • M Offline
    Mr.K.1
    last edited by Mr.K.1 25 Jul 2011, 13:57

    I can't seem to find one, not even a bad one so I guess I'll take a shot at it.

    Now uploaded version 0.1:
    Took way longer then expected but the data flow was all sorts of messed up, so now I have a very crude working version, missing all UI and is set up very specifically / badly.
    But I wanted to share the first draft so maybe someone can be inspired to pitch in with ideas for the interface.

    Files included:

    • Nurbs.dll (calculates NURBS)
    • Nurbs.cpp (course code if someone wants an overview or perhaps improve it)
    • NurbsPlugin.rb (manages the data flow)
    • car_nurbs.skp (a simple model set up with control points)

    Use:

    • extract Nurbs_plugin.zip into Sketchup/Plugins folder
    • open car_nurbs.skp
    • right-click either of the car layouts and select NURBS (you will need to do it twice on startup due to remaining DLL issues)
    • a control input box will pop-up so you can control how the surface is created
    • click OK and it will draw a surface

    EDIT: Removed the files as they are not prime time ready, and I don't want people to end up with shoddy plugins.
    If anyone wants the code I'll send you what I have.

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 25 Jul 2011, 15:36

      Info.. formulae, and further links:

      Link Preview Image
      Non-uniform rational B-spline - Wikipedia

      favicon

      (en.wikipedia.org)

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • D Offline
        Dan Rathbun
        last edited by 25 Jul 2011, 15:45

        There seems to already be a Ruby interface written for openGL (with NURBS)

        gem: http://rubygems.org/gems/ruby-opengl

        doc: http://rubydoc.info/gems/ruby-opengl/0.60.1/frames

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • M Offline
          Mr.K.1
          last edited by 28 Jul 2011, 15:15

          Thank you for the links.
          So the first version is up and now I need to see if it works for anyone.

          Main issues:

          • lack of UI (currently the control and grid creation are very limited)

          • needs a grid builder, vertices of existing models cannot be sorted into a usable grid so they need to be sampled (hope raycast isn't the only solution)

          • needs prebuilt grids, for a quick start on new projects

          • control grid presentation, not yet sure how the vertices should be presented (actual geometry is easy to control but adds unnecessary data, and virtual data requires writing new tools (move, rotate, scale))

          • DLL can calculate the surface very quick, but Sketchup needs a long time to draw it, is there a direct optimized way of doing this?
            Not drawing faces until the final edit may be a good choice.

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 28 Jul 2011, 17:57

            Other issues:

            • I use the word "knurbs" because it's by Mr.K (yes.. reminds me of Linux KDE apps.)
            1. Files should be in a "author/knurbs" subfolder below the Plugins folder, not in the Plugins folder itself.

            2. Needs a "knurbs_ext.rb" registration script in the Plugins folder, to allow users to activate / deactivate it from the Preferences > Extensions dialog.

            3. The require() statement for the DLL dependancy needs to go at the top of the rb file, within a begin ... rescue .. end block, so that the rest of the ruby code only loads if the DLL/DYLIB file is found. Block needs a rescue LoadError clause to inform user that the DLL cannot be found.

            4. The plugin code needs to be wrapped in an Author::KNURBS namespace!!

            • Currently the methods are being defined within Object, and are propagating into ALL Ruby objects. This is a NO-NO.* The global vars need to be converted to either local, instance, or class vars, within the plugin's namespace. (Globals should only be used if they are to be shared with ALL plugins.)
            1. The plugin is currently Windows only as it uses a DLL, and the Win32API class to call the C++ side functions.
            • Needs the C++ side functions wrapped to expose them to Ruby (within the plugin's Ruby-side namespace.) Win32API will no longer be needed, as require() can load DLL and DYLIB files.
            • Needs an edition compiled with Xcode on Mac, as a DYLIB file.

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 28 Jul 2011, 18:04

              The UI will need to be a Tool class (or several of them.)

              Within a Tool the draw() method can draw temporary geometry (that is not added to the model.)

              Note the Sketchup OpenGL constants that can be used with View.draw()

              GL_LINES GL_LINE_LOOP GL_LINE_STRIP GL_POINTS GL_POLYGON GL_QUADS GL_QUAD_STRIP GL_TRIANGLES GL_TRIANGLE_FAN GL_TRIANGLE_STRIP

              Also, take note of the other View class draw methods. These must be used within a Tools instance.

              See Fredo6's BezierSpline Plugin plugin for examples.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • R Online
                Rich O Brien Moderator
                last edited by 28 Jul 2011, 19:20

                Error Loading File NurbsPlugin.rb
                127; The specified procedure could not be found.   - Init_Nurbs
                C;/PROGRA~2/Google/GOOGLE~1/Plugins/Nurbs.dll
                

                Nurbs.dll is in my plugins folder. Is this v7 only?

                Download the free D'oh Book for SketchUp πŸ“–

                1 Reply Last reply Reply Quote 0
                • M Offline
                  Mr.K.1
                  last edited by 28 Jul 2011, 19:37

                  @unknownuser said:

                  Error Loading File NurbsPlugin.rb
                  > 127; The specified procedure could not be found.   - Init_Nurbs
                  > C;/PROGRA~2/Google/GOOGLE~1/Plugins/Nurbs.dll
                  

                  Nurbs.dll is in my plugins folder. Is this v7 only?

                  That is only Ruby trying to call an initialization command in DLL which doesn't exist, I tried adding some empty ones to get around the error message but nothing fixed it sofar.

                  This is only the first crack at the plugin, and I see I got alot of corners to trim.

                  1 Reply Last reply Reply Quote 0
                  • soloS Offline
                    solo
                    last edited by 28 Jul 2011, 19:38

                    Whooho!!

                    Cannot help you with code, but mate I'm here with encouragement.

                    http://www.solos-art.com

                    If you see a toilet in your dreams do not use it.

                    1 Reply Last reply Reply Quote 0
                    • R Online
                      Rich O Brien Moderator
                      last edited by 28 Jul 2011, 19:43

                      I played with the car model and so far it's pretty good. Have you seen n-gon's Bezier Patch plugin?

                      Download the free D'oh Book for SketchUp πŸ“–

                      1 Reply Last reply Reply Quote 0
                      • M Offline
                        Mr.K.1
                        last edited by 28 Jul 2011, 20:00

                        Nope did not spot that, and I started work on this because I couldn't find any Sketchup surface builders anywhere.
                        Thanks for the heads up, guess I'm off the hook then πŸ˜„

                        I'm just gonna wrap this one up into a slightly more wholesome package and direct people to the other version.

                        1 Reply Last reply Reply Quote 0
                        • D Offline
                          Dan Rathbun
                          last edited by 28 Jul 2011, 20:44

                          @unknownuser said:

                          @unknownuser said:

                          Error Loading File NurbsPlugin.rb
                          > > 127; The specified procedure could not be found.   - Init_Nurbs
                          > > C;/PROGRA~2/Google/GOOGLE~1/Plugins/Nurbs.dll
                          

                          Nurbs.dll is in my plugins folder. Is this v7 only?

                          That is only Ruby trying to call an initialization command in DLL which doesn't exist, I tried adding some empty ones to get around the error message but nothing fixed it sofar.

                          This is only the first crack at the plugin, and I see I got alot of corners to trim.

                          Actually the DLL is NOT a Ruby C extension, so cannot be loaded with require() (at this time.)
                          As it's accessed via the Win32API class... for now just comment out the line
                          require 'Nurbs.dll'
                          as it doesn't do anything anyway.

                          I'm not here much anymore.

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            Dan Rathbun
                            last edited by 28 Jul 2011, 20:46

                            Looking thru the CPP file, I dont see anything that couldn't just be written in pure Ruby. (might be slower of course.)

                            I'm not here much anymore.

                            1 Reply Last reply Reply Quote 0
                            • M Offline
                              Mr.K.1
                              last edited by 28 Jul 2011, 21:14

                              But if I remove require() Win32API doesn't find the file at all... and I'm guessing using a full path would actually fix that.

                              Yes the C++ code is fairly simple, I thought interfacing a working example with Ruby would be simple to make and compute faster, but as it turns out it needs alot of array transformations(which were nibbling away at my sanity) plus the added time cost of those it is very questionable if a direct Ruby compute would be any slower.
                              And since drawing is the real time hog it doesn't really matter.

                              How is thomthom doing the Bezier Surface? Ruby only?

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                Dan Rathbun
                                last edited by 28 Jul 2011, 21:41

                                @unknownuser said:

                                But if I remove require() Win32API doesn't find the file at all... and I'm guessing using a full path would actually fix that.

                                Yes... normally the DLLs used are system files like user32.dll etc. so the OS knows where to find them.

                                The default working dir when Ruby starts is the HOME dir... ENV['USERPROFILE'] but you can save it, change it, use it and restore it.

                                Your also creating a new Win32API instance each time that method is called.
                                It would be simplier to create a reference to the call outside the method:
                                olddir = Dir.getwd Dir.chdir(File.expand_path(File.dirname(__FILE__))) @nurbs = Win32API.new('Nurbs','nurbs', ["p","p","p"],"L") Dir.chdir(olddir)

                                then within the method
                                @nurbs.call(@a,@b,@c)

                                I'm not here much anymore.

                                1 Reply Last reply Reply Quote 0
                                • D Offline
                                  Dan Rathbun
                                  last edited by 28 Jul 2011, 21:46

                                  @unknownuser said:

                                  How is thomthom doing the Bezier Surface? Ruby only?

                                  dunno.. he's on vacation.

                                  I'm not here much anymore.

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    Dan Rathbun
                                    last edited by 29 Jul 2011, 16:30

                                    @dan rathbun said:

                                    See Fredo6's BezierSpline Plugin plugin for examples.

                                    SO.. was Fredo's utility what you wanted, but could not find it because he didn't use the word "NURBS" ??

                                    I'm not here much anymore.

                                    1 Reply Last reply Reply Quote 0
                                    • M Offline
                                      Mr.K.1
                                      last edited by 29 Jul 2011, 20:02

                                      I was looking for a surface builder, don't know if I'm missing something but Fredo's BezierSpline just does 2D curves.

                                      But if there already is any sort of SU surface builder in existance I would love to know about it.

                                      1 Reply Last reply Reply Quote 0
                                      • D Offline
                                        Dan Rathbun
                                        last edited by 29 Jul 2011, 20:50

                                        @unknownuser said:

                                        I was looking for a surface builder, don't know if I'm missing something but Fredo's BezierSpline just does 2D curves.

                                        But if there already is any sort of SU surface builder in existance I would love to know about it.

                                        Fredo's (Beta) CurviLoft

                                        Now once a surface mesh is created, the built in tools lack power. If ThomThom is working on a mesh editor tool, then you just KNOW it will be a good one!

                                        Add:

                                        SoapSkin Bubble

                                        SurfaceGen

                                        I'm not here much anymore.

                                        1 Reply Last reply Reply Quote 0
                                        • M Offline
                                          Mr.K.1
                                          last edited by 29 Jul 2011, 21:02

                                          YES! Curviloft is exactly what I wanted, thank you.

                                          Now I can move on to other projects, and it makes this thread/topic obsolete, could someone please remove it?

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 1 / 2
                                          1 / 2
                                          • First post
                                            1/28
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement