merging pods

Is there a simple way to combine/merge pods? Thanks in advance.


In short, no.





Some things you can do are:


- Merge two model files in your 3D editor of choice before re-exporting.


- Load two POD files separately and alter your renderer to deal with the multiple POD objects. If you’re using POD to a large extent in a an extensive 3D application this is probably what you’ll need to do anyway.





Obviously you could also combine them programmatically yourself, but I’m not sure if that would class as “simple”.

my perl code to do this:





joinScenes( %amalgatedScene, [%scene, %scene2]);


            # %amalgatedScene = %scene;


         # %amalgatedScene = %scene2;





sub joinScenes($$) {


   my ( $destScene, $sourceScenes) = @;





   my ($srcScene, $key, $entry, $entry2,


      


      );





   foreach $srcScene (@$sourceScenes) {


     


      addLights($destScene, $srcScene);


      addCameras($destScene, $srcScene);          


      addTextures($destScene, $srcScene); # dependent order tex, mat, mesh


      addMaterials($destScene, $srcScene);


      addMeshes($destScene, $srcScene);





      %meshIdxMap = ();


      %cameraIdxMap = ();


      %lightIdxMap = ();


      %textureIdxMap = ();


      %materialIdxMap = ();


              


        # we don’t add nodes, they are manipulated via the above add functions


        # nNumNode nNumMeshNode pNode





      $entry2 = $$destScene{nNumFrame};


      $entry = $$srcScene{nNumFrame};





      if( $entry > $entry2) {


        $$destScene{nNumFrame} = $entry; # max frame count


      }


      foreach $key (‘pfColourBackground’, ‘pfColourAmbient’, ‘nFlags’, ) {


            


      $entry = $$srcScene{$key};


        $entry2 = $$destScene{$key};


        if( not defined $entry2 ) {


             # overrides first source is it


           


            if( defined $entry ) {


            if( ref($entry) eq ‘ARRAY’) {


           $$destScene{$key} = [deepArrayCopy($entry)];


               }


               else {


           $$destScene{$key} = $entry;


               }


            }     


        }


      }


   }


}





   # returns ($meshNodes, $lightNodes, $cameraNodes, $otherNodes)


   #          empty arrays if there are no nodes


   #


   # this assumes there are nodes of lights and cameras


   # no way of knowing if there are subsets of light or camera nodes


   # any remaining nodes taked as other


   #


sub nodesParts($) {


   my ($scene) = @
;





   my ($meshNodes, $lightNodes, $cameraNodes, $otherNodes,


       $numMeshNodes, $numLights, $numCameras, $nodeCount,


       $nodes, $node, $endIndex, $count, );





   # if( not isScene($scene) ) { confess “not a scenen”;} # can be empty





   $numMeshNodes = $$scene{nNumMeshNode};


   $numLights    = $$scene{nNumLight};


   $numCameras   = $$scene{nNumCamera};


   $nodeCount    = $$scene{nNumNode};


   $nodes        = $$scene{pNode};





   if( not defined $nodes or scalar(@$nodes) == 0) {


      return ([], [], [], []);


   }





   if( $numMeshNodes > $nodeCount) {


      confess “nNumMeshNode greater than nNumNode. n”;


   }


   $count = scalar(@$nodes);


   if( $nodeCount != $count ) {


      confess “node count ($nodeCount) not equal to number of nodes ($count). n”;


   }


   $meshNodes = [@$nodes[0…$numMeshNodes-1]];





     # assuming no node subsets in between


     


   if( $nodeCount - ($numMeshNodes + $numLights) >= 0) {


      $endIndex = $numMeshNodes + $numLights -1;


      $lightNodes = [@$nodes[$numMeshNodes…$endIndex]];





      if( $nodeCount - ($numMeshNodes + $numLights + $numCameras) > 0) {


        $endIndex = $numMeshNodes + $numLights + $numCameras -1;


        $cameraNodes = [@$nodes[$numMeshNodes + $numLights…$endIndex]];


        $otherNodes = [@$nodes[$numMeshNodes + $numLights + $numCameras…$nodeCount-1]];


      }


      else {


        $endIndex = $nodeCount-1;


        $cameraNodes = [@$nodes[$numMeshNodes + $numLights…$endIndex]];


        $otherNodes = [];


      }     


   }


   else {


      $endIndex = $nodeCount-1;


      $lightNodes = [@$nodes[$numMeshNodes…$endIndex]];


      $cameraNodes = [];


      $otherNodes = [];


   }


   


   return ($meshNodes, $lightNodes, $cameraNodes, $otherNodes);





}





sub addCameras($$) {


   my ($destScene, $srcScene) = @;





   addThings($destScene, $srcScene,‘nNumCamera’, ‘pCamera’, &areCamerasEqual, %cameraIdxMap, 0);


}





sub addLights($$) {


   my ($destScene, $srcScene) = @
;





   addThings($destScene, $srcScene,‘nNumLight’, ‘pLight’, &areLightsEqual, %lightIdxMap, 0);


}





sub addMeshes($$) {


   my ($destScene, $srcScene) = @;





   addThings($destScene, $srcScene,‘nNumMesh’, ‘pMesh’, &areMeshesEqual, %meshIdxMap, 0);


}





sub addMaterials($$) {


   my ($destScene, $srcScene) = @
;





   addThings($destScene, $srcScene,‘nNumMaterial’, ‘pMaterial’, &areMaterialsEqual, %materialIdxMap, 0);


}





sub addTextures($$) {


   my ($destScene, $srcScene) = @;





   addThings($destScene, $srcScene,‘nNumTexture’, ‘pTexture’, &areTexturesEqual, %textureIdxMap, 0);


}


   # add function join the entities together and modify the nodes


   # $skip is skip equality test, just put it in


   #


sub addThings($$$$$$$) {


   my ($destScene, $srcScene, $numThing, $things, $equalityFunc, $idxMap, $skip,) = @
;





   my ($destMeshNodes, $destLightNodes, $destCameraNodes, $destOtherNodes,


       $srcMeshNodes, $srcLightNodes, $srcCameraNodes, $srcOtherNodes,


       $countDest, $countSrc, @srcThings, @destThings, @things2add, $thing1, $thing2,


       %thingsEqual, $thingNodes, $count, $idx, $idxParent, $idxMat,


       $node, $node2, @nodes, $i, $thingNodesSrc, $thingNodesDest, $destOffset,


      );





# if( not isScene($destScene) ) { confess “dest not a scenen”;} # can start empty


   if( not isScene($srcScene) ) { confess “source not a scenen”;}





   $countSrc = $$srcScene{$numThing};


   $countDest = $$destScene{$numThing};





   if( not defined $countSrc or $countSrc == 0) {


      return;


   }


   @srcThings = @{$$srcScene{$things}};


   if( defined $$destScene{$things}) {


      @destThings = @{$$destScene{$things}};


   }


   else {


      @destThings = ();


   }


   $destOffset = scalar(@destThings);





   $count = scalar(@srcThings);


   if( $countSrc != $count) { confess “source scene $numThing ($countSrc) not equal to counted $things ($count).n”;}





   $count = scalar(@destThings);


   if( $countDest != $count) { confess “dest scene $numThing ($countDest) not equal to counted $things ($count).n”;}








   ($destMeshNodes, $destLightNodes, $destCameraNodes, $destOtherNodes) = nodesParts($destScene);


   ($srcMeshNodes, $srcLightNodes, $srcCameraNodes, $srcOtherNodes) = nodesParts($srcScene);





   if( not $skip) {





      foreach $thing1 (@destThings) {


        foreach $thing2 (@srcThings) {


            if( &$equalityFunc($thing1, $thing2) == 1) {


            $thingsEqual{$thing2} = 1;


         }


        }


      }


      $i = 0;


      foreach $thing2 (@srcThings) {


      if( exists $thingsEqual{$thing2}) {


         $i++;


         next;


      }


        push @things2add, copyThing($thing2);


        $$idxMap{$i} = $destOffset + $i;


      $i++;


      }


   }


   else {


      @things2add = map {copyThing($_) } @srcThings;


      for $i (0…$count-1) {


        $$idxMap{$i} = $destOffset + $i;


      }


   }





   push @{$$destScene{$things}}, @things2add;


   $$destScene{$numThing} = $countDest + scalar(@things2add);





     # rejig the nodes


     


   if( $things eq ‘pMaterial’) {


        # no nodes for materials


        # but nIdxTexDiffuse needs rejig


      foreach $node (@things2add) {


      $idx = $$node{nIdxTexDiffuse};


        if( exists $textureIdxMap{$idx}) {


         $$node{nIdxTexDiffuse} = $textureIdxMap{$idx};


        }


      }


   }


   elsif( $things eq ‘pTexture’) {


     # no nodes for textures


   }


   elsif( $things eq ‘pCamera’) {


      foreach $node (@$srcCameraNodes) {


        $idx = $$node{nIdx};


        if( exists $$idxMap{$idx}) {


         $node2 = copyThing($node);


            $$node2{nIdx} = $$idxMap{$idx};


            push @$destCameraNodes, $node2;


        }


      }


   }


   elsif( $things eq ‘pLight’) {


      foreach $node (@$srcLightNodes) {


        $idx = $$node{nIdx};


        if( exists $$idxMap{$idx}) {


         $node2 = copyThing($node);


            $$node2{nIdx} = $$idxMap{$idx};


            push @$destLightNodes, $node2;


        }


      }


   }


   elsif( $things eq ‘pMesh’) {


      foreach $node (@$srcMeshNodes) {


      $idx = $$node{nIdx};


        if( exists $$idxMap{$idx}) {


         $node2 = copyThing($node);


            $$node2{nIdx} = $$idxMap{$idx};


            if( defined $$node2{nIdxParent} and


               $$node2{nIdxParent} != -1) {


            $idxParent = $$node2{nIdxParent};


               if( exists $$idxMap{$idxParent}) {


                  $$node2{nIdxParent} = $$idxMap{$idxParent};


               }


               else {


           $$node2{nIdxParent} = -1;


               }


            }


            


            if( defined $$node2{nIdxMaterial} and


               $$node2{nIdxMaterial} != -1) {


            $idxMat = $$node2{nIdxMaterial};


               if( exists $materialIdxMap{$idxMat}) {


                  $$node2{nIdxMaterial} = $materialIdxMap{$idxMat};


               }


               else {


                  $$node2{nIdxMaterial} = -1;


               }


            }


            push @$destMeshNodes, $node2;


        }


      }


   }


   @nodes = (@$destMeshNodes, @$destLightNodes, @$destCameraNodes, @$destOtherNodes);


   $$destScene{pNode} = [@nodes];


   $$destScene{nNumNode} = scalar(@nodes);


   $$destScene{nNumMeshNode} = scalar(@$destMeshNodes);








}


    





quite important functionality missing in c++ sdk.





Anyway is there any further work being applied to this current sdk?

nice, thanks. i’ll give this a shot and report back.