JSCAD User Group
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Union on multi-color imported obj file lose colors

    Scheduled Pinned Locked Moved Development Discussions
    7 Posts 2 Posters 1.2k Views 1 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.
    • gilboonetG Offline
      gilboonet
      last edited by gilboonet

      Hello, I'm trying to work with a multi-color obj file. It has 7 parts for a total of 312 triangles, and when I join them (with union), there are only 258 triangles which is explained by the fact that if the 7 parts had only 3 vertices polygons, the joined version had both 3 and 4 vertices polygons. This is not a big deal, but apparently as soon as a 4 vertices polygons appear, colors are lost for all remaining polygons. Is it a bug ? For the moment I can use a specific union function.
      Capture d’écran de 2022-01-21 20-40-10.png

      1 Reply Last reply Reply Quote 0
      • gilboonetG Offline
        gilboonet
        last edited by

        It only took :

        let vf = require('./' + fileName)
        var vf2 = vf[0]
        if (vf.length > 1) {
        	for (var i = 1; i < vf.length; i++){
        		vf[i].polygons.forEach(function(p){ vf2.polygons.push(p) })
        	}
        }
        var V = toPolyhedron(vf2)
        

        But now as my script handles multi-color obj files and can unfold them as separate pieces, is there a way to render (in 2d) those pieces in color (if possible the same that is used on the 3d model) ? For the moment it's not easy to see which unfolded piece correspond a 3d piece.
        capture DEPLIEUR COULEURS.png

        z3devZ 1 Reply Last reply Reply Quote 0
        • z3devZ Offline
          z3dev
          last edited by

          The Boolean functions always return a new solid, without colors. This makes the results easy to understand.

          For designs that want to use colors, the colors should be applied as the last step of a design. This allows designs to control the colors when exporting, e.g. exporting to OBJ with colors.

          1 Reply Last reply Reply Quote 0
          • z3devZ Offline
            z3dev @gilboonet
            last edited by

            I’m not sure as the ability to track the original polygon colors will depend on the unfolding algorithm. Maybe the algorithm can keep a map to the original polygon, and use the original color when creating the 2D paths

            gilboonetG 1 Reply Last reply Reply Quote 0
            • gilboonetG Offline
              gilboonet @z3dev
              last edited by

              @z3dev As you said, I'm keeping track of the colors from the original polygons and the unfolding works fine among those colors, but now my problem is that I didn't find a way to render the unfolded pieces with this color (imagine one of the colored 3d polygon on the volume unfolded with its color).

              z3devZ 1 Reply Last reply Reply Quote 0
              • z3devZ Offline
                z3dev @gilboonet
                last edited by

                @gilboonet is it possible to add color to each of the unfolded pieces, i.e. add color to the lines?

                gilboonetG 1 Reply Last reply Reply Quote 0
                • gilboonetG Offline
                  gilboonet @z3dev
                  last edited by gilboonet

                  @z3dev Sadly, lines already have a color (red for cuts, maroon for mountain fold and green for valley fold).
                  Capture d’écran de 2022-01-23 10-07-15.png

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • First post
                    Last post
                  Powered by NodeBB | Contributors