original_docstring: Sets mesh prim attributes
  
          All defines geom subsets if the shape_node utilizes more than one material.
  
          Args:
              shape_node (VoxShape): Contains the source data to populate the mesh prim.
              mesh: The mesh prim to populate.
          
docstring: Sets mesh prim attributes
  All defines geom subsets if the shape_node utilizes more than one material.
docstring_tokens: Sets mesh prim attributes All defines geom subsets if the shape_node utilizes more than one material .
code: def _set_mesh_attrs(self, shape_node, mesh):
          """Sets mesh prim attributes
  
          All defines geom subsets if the shape_node utilizes more than one material.
  
          Args:
              shape_node (VoxShape): Contains the source data to populate the mesh prim.
              mesh: The mesh prim to populate.
          """
          vertices = []
          total_face_count = 0
          display_colors = []
          opacity = []
          subsets = []
          for mtl_id, mesh_verts in shape_node.model.meshes.items():
              start_idx = len(vertices)
              vertices.extend(mesh_verts)
              end_idx = len(vertices)
              start_face_idx = int(start_idx / 4)
              end_face_idx = int(end_idx / 4)
              face_count = int(len(mesh_verts) / 4.0)
              total_face_count += face_count
              vox_mtl = VoxBaseMaterial.get(mtl_id)
              display_colors.extend([Gf.Vec3f(vox_mtl.color[0:3])] * face_count)
              if isinstance(vox_mtl, VoxGlassMaterial):
                  opacity.extend([vox_mtl.get_opacity()] * face_count)
              else:
                  opacity.extend([1.0] * face_count)
              subsets.append({"mtl_id": mtl_id, "start_face_idx": start_face_idx, "end_face_idx": end_face_idx})
  
          mesh.CreatePointsAttr(vertices)
          mesh.CreateFaceVertexCountsAttr([4] * total_face_count)
          mesh.CreateFaceVertexIndicesAttr(list(range(len(vertices))))
          mesh.CreateDisplayColorPrimvar(UsdGeom.Tokens.uniform).Set(display_colors)
          mesh.CreateDisplayOpacityPrimvar(UsdGeom.Tokens.uniform).Set(opacity)
  
          if len(subsets) > 1:
              # Create geom subsets if the mesh uses more than one material.
              mesh_binding_api = UsdShade.MaterialBindingAPI(mesh.GetPrim())
              for item in subsets:
                  subset = mesh_binding_api.CreateMaterialBindSubset("VoxelPart_{}".format(item["mtl_id"]),
                                                                     Vt.IntArray(list(range(item["start_face_idx"],
                                                                                            item["end_face_idx"]))))
                  self._add_binding_target(item["mtl_id"], subset.GetPath(), GeometryVariantSetNames.MERGED_MESHES)
          else:
              # This mesh uses only one material, so no need to create geom subsets.
              self._add_binding_target(subsets[0]["mtl_id"], mesh.GetPath(), GeometryVariantSetNames.MERGED_MESHES)
  
          self.total_triangles += total_face_count * 2
code_tokens: def _set_mesh_attrs ( self , shape_node , mesh ) : vertices = [ ] total_face_count = 0 display_colors = [ ] opacity = [ ] subsets = [ ] for mtl_id , mesh_verts in shape_node . model . meshes . items ( ) : start_idx = len ( vertices ) vertices . extend ( mesh_verts ) end_idx = len ( vertices ) start_face_idx = int ( start_idx / 4 ) end_face_idx = int ( end_idx / 4 ) face_count = int ( len ( mesh_verts ) / 4.0 ) total_face_count += face_count vox_mtl = VoxBaseMaterial . get ( mtl_id ) display_colors . extend ( [ Gf . Vec3f ( vox_mtl . color [ 0 : 3 ] ) ] * face_count ) if isinstance ( vox_mtl , VoxGlassMaterial ) : opacity . extend ( [ vox_mtl . get_opacity ( ) ] * face_count ) else : opacity . extend ( [ 1.0 ] * face_count ) subsets . append ( { "mtl_id" : mtl_id , "start_face_idx" : start_face_idx , "end_face_idx" : end_face_idx } ) mesh . CreatePointsAttr ( vertices ) mesh . CreateFaceVertexCountsAttr ( [ 4 ] * total_face_count ) mesh . CreateFaceVertexIndicesAttr ( list ( range ( len ( vertices ) ) ) ) mesh . CreateDisplayColorPrimvar ( UsdGeom . Tokens . uniform ) . Set ( display_colors ) mesh . CreateDisplayOpacityPrimvar ( UsdGeom . Tokens . uniform ) . Set ( opacity ) if len ( subsets ) > 1 : mesh_binding_api = UsdShade . MaterialBindingAPI ( mesh . GetPrim ( ) ) for item in subsets : subset = mesh_binding_api . CreateMaterialBindSubset ( "VoxelPart_{}" . format ( item [ "mtl_id" ] ) , Vt . IntArray ( list ( range ( item [ "start_face_idx" ] , item [ "end_face_idx" ] ) ) ) ) self . _add_binding_target ( item [ "mtl_id" ] , subset . GetPath ( ) , GeometryVariantSetNames . MERGED_MESHES ) else : self . _add_binding_target ( subsets [ 0 ] [ "mtl_id" ] , mesh . GetPath ( ) , GeometryVariantSetNames . MERGED_MESHES ) self . total_triangles += total_face_count * 2
short_docstring: Sets mesh prim attributes
  All defines geom subsets if the shape_node utilizes more than one material.
short_docstring_tokens: Sets mesh prim attributes All defines geom subsets if the shape_node utilizes more than one material .
comment: """Sets mesh prim attributes
  
          All defines geom subsets if the shape_node utilizes more than one material.
  
          Args:
              shape_node (VoxShape): Contains the source data to populate the mesh prim.
              mesh: The mesh prim to populate.
          """$SEP$# Create geom subsets if the mesh uses more than one material.
  $SEP$# This mesh uses only one material, so no need to create geom subsets.
  