示例#1
0
//**********************************************************************************************************************
vector<string> SffMultipleCommand::setParameters(){	
	try {		
		CommandParameter pfile("file", "InputTypes", "", "", "none", "none", "none","fasta-name",false,true,true); parameters.push_back(pfile);
        
        //sffinfo
		CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(ptrim);
        
        //trim.flows
 		CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "","",false,false); parameters.push_back(pmaxhomop);
		CommandParameter pmaxflows("maxflows", "Number", "", "450", "", "", "","",false,false); parameters.push_back(pmaxflows);
		CommandParameter pminflows("minflows", "Number", "", "450", "", "", "","",false,false); parameters.push_back(pminflows);
		CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(ppdiffs);
		CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "","",false,false,true); parameters.push_back(pbdiffs);
        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pldiffs);
		CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(psdiffs);
        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "","",false,false); parameters.push_back(ptdiffs);
		CommandParameter psignal("signal", "Number", "", "0.50", "", "", "","",false,false); parameters.push_back(psignal);
		CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "","",false,false); parameters.push_back(pnoise);
		CommandParameter porder("order", "Multiple", "A-B-I", "A", "", "", "","",false,false, true); parameters.push_back(porder);
        //shhh.flows
        CommandParameter plookup("lookup", "InputTypes", "", "", "none", "none", "none","",false,false,true); parameters.push_back(plookup);
		CommandParameter pcutoff("cutoff", "Number", "", "0.01", "", "", "","",false,false); parameters.push_back(pcutoff);
		CommandParameter pmaxiter("maxiter", "Number", "", "1000", "", "", "","",false,false); parameters.push_back(pmaxiter);
        CommandParameter plarge("large", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(plarge);
		CommandParameter psigma("sigma", "Number", "", "60", "", "", "","",false,false); parameters.push_back(psigma);
		CommandParameter pmindelta("mindelta", "Number", "", "0.000001", "", "", "","",false,false); parameters.push_back(pmindelta);
        
        //trim.seqs parameters
        CommandParameter pallfiles("allfiles", "Boolean", "", "t", "", "", "","",false,false); parameters.push_back(pallfiles);
        CommandParameter pflip("flip", "Boolean", "", "F", "", "", "","",false,false,true); parameters.push_back(pflip);
		CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "","",false,false); parameters.push_back(pmaxambig);
		CommandParameter pminlength("minlength", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pminlength);
		CommandParameter pmaxlength("maxlength", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pmaxlength);
		CommandParameter pkeepforward("keepforward", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pkeepforward);
        CommandParameter pkeepfirst("keepfirst", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pkeepfirst);
		CommandParameter premovelast("removelast", "Number", "", "0", "", "", "","",false,false); parameters.push_back(premovelast);

        
        CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
		CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
		CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
		
		vector<string> myArray;
		for (int i = 0; i < parameters.size(); i++) {	myArray.push_back(parameters[i].name);		}
		return myArray;
	}
	catch(exception& e) {
		m->errorOut(e, "SffMultipleCommand", "setParameters");
		exit(1);
	}
}
示例#2
0
// Debugging function for noise
void WriteNoiseRawFile()
{
	static unsigned char data[65536];
	int x, y;

	for(y = 0; y < 256; y++)
	{
		for(x = 0; x < 256; x++)
		{
			float n = 0.5f * pnoise((float)x / 16.0f, (float)y, 0) + 0.5f;
			data[y * 256 + x] = (unsigned char)(n * 255.0f);
		}
	}

	FILE* fp = fopen("noise.raw", "wb");
	fwrite(data, 65536, sizeof(unsigned char), fp);
	fclose(fp);
}
示例#3
0
void DoNoiseTexture()
{
	static unsigned char s_data[65536];
	int x, y;

	// Generate the noise data
	for(y = 0; y < 64; y++)
	{
		for(x = 0; x < 64; x++)
		{
			float n = 0.5f * pnoise((float)x / 16.0f, (float)y / 16.0f, fNoiseTime) + 0.5f;
			s_data[y * 64 + x] = (unsigned char)(n * 255.0f);
		}
	}

	glBindTexture(GL_TEXTURE_2D, g_nNoiseTexture);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 64, 64, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, s_data);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
示例#4
0
void Chunk::CustomLandscape(float offset, int numChunks, int x, int y, int z)
{
	int numVoxels = 0;
	float caves, center_falloff, plateau_falloff, density;

	//heightMapBuilder.SetBounds (2.0 + mPosition.x, 6.0, 1.0+ mPosition.y, 5.0);
	heightMapBuilder.SetBounds (0.5 + offset + x * 0.5, 1.0 + offset + x * 0.5, 0.5 + z * 0.5 , 1.0 + z * 0.5);
	heightMapBuilder.Build ();
	
	for(int i = 0; i < CHUNK_SIZE; i++)
	{
		for (int j = 0; j < CHUNK_SIZE; j++)
		{
			for(int k = 0; k < CHUNK_SIZE; k++)
			{
				float xf = float(i + (x*CHUNK_SIZE))/(CHUNK_SIZE*numChunks);
				float yf = float(j + (y*CHUNK_SIZE))/(CHUNK_SIZE*numChunks);
				float zf = float(k + (z*CHUNK_SIZE))/(CHUNK_SIZE*numChunks);
				float value = simplex_noise(1, xf*3, yf*3, zf*3);

				if(yf <= 0.8)
				{
					plateau_falloff = 1.0;
				}
				else if(0.8 < yf && yf < 0.9)
				{
					plateau_falloff = 1.0-(yf-0.8)*10.0;
				}
				else
				{
					plateau_falloff = 0.0;
				}

				center_falloff = 0.1/(
										pow((xf-0.5)*1.5, 2) +
										pow((yf-1.0)*0.8, 2) +
										pow((zf-0.5)*1.5, 2) );
				caves = pow(simplex_noise(1, xf*5, yf*5, zf*5), 3);
				density = (
					simplex_noise(5, xf, yf*0.5, zf) *
					center_falloff *
					plateau_falloff );
				density *= pow(
					pnoise((xf+1)*3.0, (yf+1)*3.0, (zf+1)*3.0)+0.4, 1.8
				);
				if(caves < 0.5)
				{
					density = 0;
				}
				
				if(density > 3.1)
				{
					m_pBlocks[i][j][k].Type = distribution(e);
					shouldRender = true;
				}
				else
					m_pBlocks[i][j][k].Type = 0; 
			}
		}
	}
	
	for(int i = 0; i < CHUNK_SIZE; i++)
	{
		for (int j = 0; j < CHUNK_SIZE; j++)
		{
			for(int k = 0; k < CHUNK_SIZE; k++)
			{
				/*if(j + 1 > numChunks*CHUNK_SIZE || (j + 1 < CHUNK_SIZE) && m_pBlocks[i][j+1][k].Type == 0)
				{
					m_pBlocks[i][j][k].Type = 1;
				}*/

				if(m_pBlocks[i][j][k].Type == 2)
				{
					m_pBlocks[i][j][k].Type = 1;
				}

				if( j + 1 > numChunks*CHUNK_SIZE || ((j + 1 < CHUNK_SIZE) && m_pBlocks[i][j+1][k].Type == 0) && m_pBlocks[i][j][k].Type == 1)
				{
					m_pBlocks[i][j][k].Type = 2;
				}
			}
		}
	}
}
void Bonsai::synthesize( size_t ndx, float ii, float jj )
{	 
	// Results
	PVRTVec3 C(0.0, 0.0, 0.0); // result color
	float H=0.0; // result height

	// intermediate heights
	float Hs = 0.0; // structural height
	float Hf = 0.0; // fine height (detail)

	// Radius val .. make taller in middle
	//float rval = (1.0 - (sqrt( ii*ii + jj*jj ) / 2.0));
	float rval = ((sqrt( ii*ii + jj*jj ) / 2.0));

	// ==========================================
	// Layer -- Base Height
	// ==========================================	
	if (m_params.base == BASE_ROLLING_HILLS)
	{
		// "Rolling hills" -- base height

		// domain distortion
		float distDir = pnoise( ii * m_params.base_scale, 
			10.0 + m_params.offs, 
			jj *  
			m_params.base_scale );

		float ii2 = ii + distDir * m_params.base_distAmt;
		float jj2 = jj + distDir * m_params.base_distAmt;

		// structural height
		Hs = pnoise( ii2 * 2, 0.0, jj2 * 2 );				
		Hs = rval + (Hs * 0.3);	
	}
	else if (m_params.base == BASE_JAGGY)
	{
		// "Jagged mountians" -- base height		

		// structural height
		Hs = 5.0 * fabs(pturb( ii * m_params.base_scale, 
				m_params.offs - 5, 
				jj * m_params.base_scale, 6, true ));
		
		Hs = (rval + Hs) / 2.0;	
	}

	// ==========================================
	// Layer -- Base Veg
	// ==========================================	
	// Base veg
	if (m_params.baseVeg == BASEVEG_TURBY)
	{
		// color with turbulence
		float val = pturb( ii * 4, m_params.offs, jj * 4, 8, false );

		// add some height detail
		Hf = val * 0.05;
	
		// set color
		float v2 = clamp(val);
		C = mix( m_pally.m_colorOrganic1, m_pally.m_colorOrganic2, v2 );
	}
	else if (m_params.baseVeg == BASEVEG_HITE)
	{
		// Use height to drive color
		float t = Hs * m_params.baseVeg_hite_repeats;
		t = t - floor( t );

		C = mix( m_pally.m_colorOrganic2, m_pally.m_colorOrganic1, t );
	}

	// ==========================================
	// Layer -- Patch Veg
	// ==========================================	
	if (m_params.patchVeg == PATCHVEG_PATCHY)
	{
		float val = pturb( ii * m_params.patchVeg_scale, 
							m_params.offs, 
							jj * m_params.patchVeg_scale, 3, false );

		if (val > m_params.patchVeg_thresh)
		{			
			float v = pnoise( ii * m_params.patchVeg_nscale, m_params.offs, 
							jj * m_params.patchVeg_nscale );
			v = fabs(v);

			// FIXME: using accent color for this because there's no
			// accents yet
			if (m_params.patchMixMineral)
			{
				C = mix( m_pally.m_colorMineral1, m_pally.m_colorAccent, v );
			}
			else
			{
				C = mix( m_pally.m_colorOrganic2, m_pally.m_colorAccent, v );
			}

			// Add a little bit of height
			Hf += fstep( m_params.patchVeg_thresh, m_params.patchVeg_thresh + 0.05, val ) * 0.01;
		}
	}

	// ==========================================
	// Layer -- Decoration
	// ==========================================	
	if (m_params.deco == DECORATION_LAVATUBES)
	{
		float v = pnoise( ii * m_params.decoLavaScale, 0.0, 
							jj * m_params.decoLavaScale );
		float v2 = 1.0 - fstep( 0.0, m_params.decoLavaWidth, fabs(v) );

		//C = PVRTVec3( clamp( -v, 0, 1),v2, clamp( v, 0, 1));
		if (v2 > 0.01)
		{
			// replace color with tube
			C = mix( m_pally.m_colorMineral2, m_pally.m_colorMineral1, v2 );
			
			// Replace Hf
			Hf = v2 * m_params.decoLavaWidth * 0.5;
		}

	}


	// ====================================================

	// final height	
	H = Hs + Hf;

	// final color
	m_terrainColor[ndx * 3 + 0] = C.x * 255.0;
	m_terrainColor[ndx * 3 + 1] = C.y * 255.0;
	m_terrainColor[ndx * 3 + 2] = C.z * 255.0;


	// apply height
	m_hiteData[ndx] = H;
		
}
示例#6
0
float snoise(float x,float y){
    return pnoise(x,y,0);
}