original_docstring: Converts a VoxShape into a UsdGeom.PointInstancer
  
          Creates prototypes for different variant point shapes based on PointShapeVariantSetNames.
  
          Args:
              stage (Usd.Stage): The payload stage to operate on.
              xform_node (VoxTransform): The transform data for this shape.
              shape_node (VoxShape): The node containing the source data to convert.
              parent_prim: The parent prim for the mesh.
          
docstring: Converts a VoxShape into a UsdGeom.PointInstancer
  Creates prototypes for different variant point shapes based on PointShapeVariantSetNames.
docstring_tokens: Converts a VoxShape into a UsdGeom . PointInstancer Creates prototypes for different variant point shapes based on PointShapeVariantSetNames .
code: def _voxels2point_instances(self, stage, xform_node, shape_node, parent_prim):
          """Converts a VoxShape into a UsdGeom.PointInstancer
  
          Creates prototypes for different variant point shapes based on PointShapeVariantSetNames.
  
          Args:
              stage (Usd.Stage): The payload stage to operate on.
              xform_node (VoxTransform): The transform data for this shape.
              shape_node (VoxShape): The node containing the source data to convert.
              parent_prim: The parent prim for the mesh.
          """
          instancer = UsdGeom.PointInstancer.Define(stage, parent_prim.GetPath().AppendPath(
              "VoxelModel_{}".format(shape_node.node_id)))
          instancer.AddTransformOp().Set(Gf.Matrix4d(*xform_node.transform))
          # self._set_pivot(shape_node.model, instancer)
          instancer.CreatePrototypesRel()
          proto_container = stage.OverridePrim(instancer.GetPath().AppendPath("Prototypes"))
          mtl2proto_id = {}
          default_prim = stage.GetPseudoRoot().GetChildren()[0]
          if not default_prim.HasVariantSets():
              pt_shape_varset = default_prim.GetVariantSets().AddVariantSet("PointShape")
              for variant_name in PointShapeVariantSetNames.values():
                  pt_shape_varset.AddVariant(variant_name)
          else:
              pt_shape_varset = default_prim.GetVariantSet("PointShape")
  
          ids = []
          positions = []
          for voxel in shape_node.model.voxels:
              mtl_id = voxel[3]
              if mtl_id not in mtl2proto_id:
                  mtl2proto_id[mtl_id] = len(proto_container.GetChildren())
                  pt_shape_varset.SetVariantSelection(PointShapeVariantSetNames.CUBES)
                  with pt_shape_varset.GetVariantEditContext():
                      self._create_cube_geom(stage, instancer, proto_container, mtl_id)
                  pt_shape_varset.SetVariantSelection(PointShapeVariantSetNames.SPHERES)
                  with pt_shape_varset.GetVariantEditContext():
                      self._create_sphere_geom(stage, instancer, proto_container, mtl_id)
                  pt_shape_varset.SetVariantSelection(PointShapeVariantSetNames.STUDS)
                  with pt_shape_varset.GetVariantEditContext():
                      self._create_stud_geom(stage, instancer, proto_container, mtl_id)
  
              ids.append(mtl2proto_id[mtl_id])
              position = [float(coord) * self.voxel_size for coord in voxel[:3]]
              # XY center the local origin on the model
              position = [position[0] - int(shape_node.model.size[0] / 2.0),
                          position[1] - int(shape_node.model.size[1] / 2.0),
                          position[2] - int(shape_node.model.size[2] / 2.0)]
              positions.append(position)
          instancer.CreateProtoIndicesAttr()
          instancer.CreatePositionsAttr()
          instancer.GetProtoIndicesAttr().Set(ids)
          instancer.GetPositionsAttr().Set(positions)
code_tokens: def _voxels2point_instances ( self , stage , xform_node , shape_node , parent_prim ) : instancer = UsdGeom . PointInstancer . Define ( stage , parent_prim . GetPath ( ) . AppendPath ( "VoxelModel_{}" . format ( shape_node . node_id ) ) ) instancer . AddTransformOp ( ) . Set ( Gf . Matrix4d ( * xform_node . transform ) ) instancer . CreatePrototypesRel ( ) proto_container = stage . OverridePrim ( instancer . GetPath ( ) . AppendPath ( "Prototypes" ) ) mtl2proto_id = { } default_prim = stage . GetPseudoRoot ( ) . GetChildren ( ) [ 0 ] if not default_prim . HasVariantSets ( ) : pt_shape_varset = default_prim . GetVariantSets ( ) . AddVariantSet ( "PointShape" ) for variant_name in PointShapeVariantSetNames . values ( ) : pt_shape_varset . AddVariant ( variant_name ) else : pt_shape_varset = default_prim . GetVariantSet ( "PointShape" ) ids = [ ] positions = [ ] for voxel in shape_node . model . voxels : mtl_id = voxel [ 3 ] if mtl_id not in mtl2proto_id : mtl2proto_id [ mtl_id ] = len ( proto_container . GetChildren ( ) ) pt_shape_varset . SetVariantSelection ( PointShapeVariantSetNames . CUBES ) with pt_shape_varset . GetVariantEditContext ( ) : self . _create_cube_geom ( stage , instancer , proto_container , mtl_id ) pt_shape_varset . SetVariantSelection ( PointShapeVariantSetNames . SPHERES ) with pt_shape_varset . GetVariantEditContext ( ) : self . _create_sphere_geom ( stage , instancer , proto_container , mtl_id ) pt_shape_varset . SetVariantSelection ( PointShapeVariantSetNames . STUDS ) with pt_shape_varset . GetVariantEditContext ( ) : self . _create_stud_geom ( stage , instancer , proto_container , mtl_id ) ids . append ( mtl2proto_id [ mtl_id ] ) position = [ float ( coord ) * self . voxel_size for coord in voxel [ : 3 ] ] position = [ position [ 0 ] - int ( shape_node . model . size [ 0 ] / 2.0 ) , position [ 1 ] - int ( shape_node . model . size [ 1 ] / 2.0 ) , position [ 2 ] - int ( shape_node . model . size [ 2 ] / 2.0 ) ] positions . append ( position ) instancer . CreateProtoIndicesAttr ( ) instancer . CreatePositionsAttr ( ) instancer . GetProtoIndicesAttr ( ) . Set ( ids ) instancer . GetPositionsAttr ( ) . Set ( positions )
short_docstring: Converts a VoxShape into a UsdGeom.PointInstancer
  Creates prototypes for different variant point shapes based on PointShapeVariantSetNames.
short_docstring_tokens: Converts a VoxShape into a UsdGeom . PointInstancer Creates prototypes for different variant point shapes based on PointShapeVariantSetNames .
comment: """Converts a VoxShape into a UsdGeom.PointInstancer
  
          Creates prototypes for different variant point shapes based on PointShapeVariantSetNames.
  
          Args:
              stage (Usd.Stage): The payload stage to operate on.
              xform_node (VoxTransform): The transform data for this shape.
              shape_node (VoxShape): The node containing the source data to convert.
              parent_prim: The parent prim for the mesh.
          """$SEP$# self._set_pivot(shape_node.model, instancer)
  $SEP$# XY center the local origin on the model
  