mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 14:50:36 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into blendface
This commit is contained in:
commit
c0c542f1c3
1 changed files with 188 additions and 79 deletions
|
@ -55,19 +55,8 @@ void voxelTutorial(VoxelTree * tree) {
|
|||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
qInstallMessageHandler(sharedMessageHandler);
|
||||
|
||||
// Handles taking and SVO and splitting it into multiple SVOs based on
|
||||
// jurisdiction details
|
||||
const char* SPLIT_SVO = "--splitSVO";
|
||||
const char* splitSVOFile = getCmdOption(argc, argv, SPLIT_SVO);
|
||||
const char* SPLIT_JURISDICTION_ROOT = "--splitJurisdictionRoot";
|
||||
const char* SPLIT_JURISDICTION_ENDNODES = "--splitJurisdictionEndNodes";
|
||||
const char* splitJurisdictionRoot = getCmdOption(argc, argv, SPLIT_JURISDICTION_ROOT);
|
||||
const char* splitJurisdictionEndNodes = getCmdOption(argc, argv, SPLIT_JURISDICTION_ENDNODES);
|
||||
if (splitSVOFile && splitJurisdictionRoot && splitJurisdictionEndNodes) {
|
||||
void processSplitSVOFile(const char* splitSVOFile,const char* splitJurisdictionRoot,const char* splitJurisdictionEndNodes) {
|
||||
char outputFileName[512];
|
||||
|
||||
printf("splitSVOFile: %s Jurisdictions Root: %s EndNodes: %s\n",
|
||||
|
@ -147,6 +136,126 @@ int main(int argc, const char * argv[])
|
|||
rootSVO.writeToSVOFile(outputFileName);
|
||||
|
||||
printf("exiting now\n");
|
||||
}
|
||||
|
||||
class copyAndFillArgs {
|
||||
public:
|
||||
VoxelTree* destinationTree;
|
||||
unsigned long outCount;
|
||||
unsigned long inCount;
|
||||
unsigned long originalCount;
|
||||
|
||||
};
|
||||
|
||||
bool copyAndFillOperation(VoxelNode* node, void* extraData) {
|
||||
copyAndFillArgs* args = (copyAndFillArgs*)extraData;
|
||||
char outputMessage[128];
|
||||
|
||||
args->inCount++;
|
||||
int percentDone = (100*args->inCount/args->originalCount);
|
||||
|
||||
// For each leaf node...
|
||||
if (node->isLeaf()) {
|
||||
// create a copy of the leaf in the copy destination
|
||||
float x = node->getCorner().x;
|
||||
float y = node->getCorner().y;
|
||||
float z = node->getCorner().z;
|
||||
float s = node->getScale();
|
||||
unsigned char red = node->getTrueColor()[RED_INDEX];
|
||||
unsigned char green = node->getTrueColor()[GREEN_INDEX];
|
||||
unsigned char blue = node->getTrueColor()[BLUE_INDEX];
|
||||
bool destructive = true;
|
||||
|
||||
args->destinationTree->createVoxel(x, y, z, s, red, green, blue, destructive);
|
||||
args->outCount++;
|
||||
|
||||
sprintf(outputMessage,"Completed: %d%% (%lu of %lu) - Creating voxel %lu at [%f,%f,%f,%f]",
|
||||
percentDone,args->inCount,args->originalCount,args->outCount,x,y,z,s);
|
||||
printf("%s",outputMessage);
|
||||
for (int b = 0; b < strlen(outputMessage); b++) {
|
||||
printf("\b");
|
||||
}
|
||||
|
||||
// and create same sized leafs from this leaf voxel down to zero in the destination tree
|
||||
for (float yFill = y-s; yFill >= 0.0f; yFill -= s) {
|
||||
args->destinationTree->createVoxel(x, yFill, z, s, red, green, blue, destructive);
|
||||
|
||||
args->outCount++;
|
||||
|
||||
sprintf(outputMessage,"Completed: %d%% (%lu of %lu) - Creating fill voxel %lu at [%f,%f,%f,%f]",
|
||||
percentDone,args->inCount,args->originalCount,args->outCount,x,y,z,s);
|
||||
printf("%s",outputMessage);
|
||||
for (int b = 0; b < strlen(outputMessage); b++) {
|
||||
printf("\b");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void processFillSVOFile(const char* fillSVOFile) {
|
||||
char outputFileName[512];
|
||||
|
||||
printf("fillSVOFile: %s\n", fillSVOFile);
|
||||
|
||||
VoxelTree originalSVO(true); // reaveraging
|
||||
VoxelTree filledSVO(true); // reaveraging
|
||||
|
||||
originalSVO.readFromSVOFile(fillSVOFile);
|
||||
qDebug("Nodes after loading %lu nodes\n", originalSVO.getVoxelCount());
|
||||
originalSVO.reaverageVoxelColors(originalSVO.rootNode);
|
||||
qDebug("Original Voxels reAveraged\n");
|
||||
qDebug("Nodes after reaveraging %lu nodes\n", originalSVO.getVoxelCount());
|
||||
|
||||
copyAndFillArgs args;
|
||||
args.destinationTree = &filledSVO;
|
||||
args.inCount = 0;
|
||||
args.outCount = 0;
|
||||
args.originalCount = originalSVO.getVoxelCount();
|
||||
|
||||
printf("Begin processing...\n");
|
||||
originalSVO.recurseTreeWithOperation(copyAndFillOperation, &args);
|
||||
printf("DONE processing...\n");
|
||||
|
||||
qDebug("Original input nodes used for filling %lu nodes\n", args.originalCount);
|
||||
qDebug("Input nodes traversed during filling %lu nodes\n", args.inCount);
|
||||
qDebug("Nodes created during filling %lu nodes\n", args.outCount);
|
||||
qDebug("Nodes after filling %lu nodes\n", filledSVO.getVoxelCount());
|
||||
|
||||
filledSVO.reaverageVoxelColors(filledSVO.rootNode);
|
||||
qDebug("Nodes after reaveraging %lu nodes\n", filledSVO.getVoxelCount());
|
||||
|
||||
sprintf(outputFileName, "filled%s", fillSVOFile);
|
||||
printf("outputFile: %s\n", outputFileName);
|
||||
filledSVO.writeToSVOFile(outputFileName);
|
||||
|
||||
printf("exiting now\n");
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
qInstallMessageHandler(sharedMessageHandler);
|
||||
|
||||
// Handles taking and SVO and splitting it into multiple SVOs based on
|
||||
// jurisdiction details
|
||||
const char* SPLIT_SVO = "--splitSVO";
|
||||
const char* splitSVOFile = getCmdOption(argc, argv, SPLIT_SVO);
|
||||
const char* SPLIT_JURISDICTION_ROOT = "--splitJurisdictionRoot";
|
||||
const char* SPLIT_JURISDICTION_ENDNODES = "--splitJurisdictionEndNodes";
|
||||
const char* splitJurisdictionRoot = getCmdOption(argc, argv, SPLIT_JURISDICTION_ROOT);
|
||||
const char* splitJurisdictionEndNodes = getCmdOption(argc, argv, SPLIT_JURISDICTION_ENDNODES);
|
||||
if (splitSVOFile && splitJurisdictionRoot && splitJurisdictionEndNodes) {
|
||||
processSplitSVOFile(splitSVOFile, splitJurisdictionRoot, splitJurisdictionEndNodes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Handles taking an SVO and filling in the empty space below the voxels to make it solid.
|
||||
const char* FILL_SVO = "--fillSVO";
|
||||
const char* fillSVOFile = getCmdOption(argc, argv, FILL_SVO);
|
||||
if (fillSVOFile) {
|
||||
processFillSVOFile(fillSVOFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue