JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Union on multi-color imported obj file lose colors

    Development Discussions
    2
    7
    515
    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.
    • gilboonet
      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
      • gilboonet
        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
        • z3dev
          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?

          gilboonet 1 Reply Last reply Reply Quote 0
          • gilboonet
            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).

            z3dev 1 Reply Last reply Reply Quote 0
            • z3dev
              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

              gilboonet 1 Reply Last reply Reply Quote 0
              • z3dev
                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
                • gilboonet
                  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

                  z3dev 1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB | Contributors