int CV_BilateralFilterTest::prepare_test_case(int /* test_case_index */) { const static int types[] = { CV_32FC1, CV_32FC3, CV_8UC1, CV_8UC3 }; RNG& rng = ts->get_rng(); Size size(getRandInt(rng, MIN_WIDTH, MAX_WIDTH), getRandInt(rng, MIN_HEIGHT, MAX_HEIGHT)); int type = types[rng(sizeof(types) / sizeof(types[0]))]; _d = rng.uniform(0., 1.) > 0.5 ? 5 : 3; _src.create(size, type); rng.fill(_src, RNG::UNIFORM, 0, 256); _sigma_color = _sigma_space = 1.; return 1; }
//********************************************************************* // FUNCTION: fillRandomArray() // DESCRIPTION: fills variable size array with random values // INPUT: // Parameters: newArray - pointer to array that needs to be filled with random values // arraySize - length of array // IMPLEMENTED BY: Neil Townsend //********************************************************************** void fillRandomArray(int *newArray, int arraySize) { for(int randomCounter = 0; randomCounter < arraySize; randomCounter++) { newArray[randomCounter] = getRandInt(); } //*********DEBUG**************** // cout << "Filled array with " << arraySize << " random values" << endl; //****************************** }
void Tree::generate(uint8_t limit) { uint8_t darkness=1; srand((uint32_t)time(NULL)); uint8_t m_trunkHeight = getRandInt(MIN_TRUNK,limit); bool smalltree=false; //in this implementation we generate the trunk and as we do we call branching and canopy if(m_trunkHeight<BRANCHING_HEIGHT) { smalltree=true; darkness=0; } uint8_t th=m_trunkHeight-1; uint8_t i; for(i = 0; i < th; i++) { if(smalltree) { Trunk* v = new Trunk(_x,_y+i,_z,darkness); if(i>=MIN_TRUNK-1){ m_Branch[n_branches]= v; n_branches++; } else { delete v; } } else { Trunk* v = new Trunk(_x,_y+i,_z,darkness); if(i>BRANCHING_HEIGHT-1) { generateBranches(v); } else { delete v; } } } Trunk* v = new Trunk(_x,_y+i,_z,darkness); m_Branch[n_branches]= v; n_branches++; generateBranches(v); generateCanopy(); }
void Tree::generateCanopy(){ uint8_t blocktype; uint8_t meta; uint8_t canopySize; vec loc; uint8_t canopy_darkness = 0; //Not much point making less code with a while/for loop //since compiled this is alot faster if(rand() % 15 ==0){ canopy_darkness++; } if(rand() % 15 ==0){ canopy_darkness++; } if(rand() % 15 ==0){ canopy_darkness++; } //I'm Not Proud of this looping. for(uint8_t i=0;i<n_branches;i++){ canopySize = getRandInt(MIN_CANOPY,MAX_CANOPY); loc = m_Branch[i]->location(); delete m_Branch[i]; int32_t posx = loc.x(); uint8_t posy = loc.y(); int32_t posz = loc.z(); for(int8_t xi=(-canopySize);xi<=canopySize;xi++){ for(int8_t yi=(-canopySize);yi<=canopySize;yi++){ for(int8_t zi=(-canopySize);zi<=canopySize;zi++){ if(sqrt(xi^2+yi^2+zi^2) <= canopySize){ int32_t temp_posx = posx+xi; uint8_t temp_posy = posy+yi; int32_t temp_posz = posz+zi; Mineserver::get()->map()->getBlock(temp_posx,temp_posy,temp_posz,&blocktype,&meta); if(blocktype== BLOCK_AIR){ Canopy u(temp_posx,temp_posy,temp_posz,canopy_darkness); } } } } } } }