コード例 #1
0
ファイル: NOISE.CPP プロジェクト: ApocalypseDesign/ad_public
void noise3D::do_efx2D(double pos)
{
  int x, y, ip, pixel, ofs;
  // int ip2, s;
  float p;
  float step, step_x, step_y, fx, fy;

  step=(float)(pos*2.0);
  step_x=(float)(1.0/80.0);
  step_y=(float)(1.0/60.0);

  ofs=0;
  fy=0;
  for (y=0; y<image->height; y++)
  {
	fx=step;
    for (x=0; x<image->width; x++)
	{
	   p=Perlin(fx, fy, step, 0.45f, 6);
//	   s=(int)(128.0*sinf(6.28f*x/image->width))+128;
	   ip=myfist(p+SHINESS);
	   if (ip<0) ip=0;
	   if (ip>255) ip=255;
//       s=s+ip;
//	   if (s>255) s=255;
	   pixel=palette[ip];
//	   image->uint32ptr[ofs++]=pixel;
	   image->uint32ptr[ofs++]=ip | (ip<<8) | (ip<<16);
	   fx+=step_x;
	}
    fy+=step_y;
  }
}
コード例 #2
0
ファイル: PerlinNoise.cpp プロジェクト: vHanda/Survival
void PerlinNoise::operator()(SDL_Surface * s)
{
    SDL_FillRect(s, NULL, 0);

    int r = rand() % 256;
    int g = rand() % 256;
    int b = rand() % 256;
    for(int x=0; x<s->w; x++)
        for(int y=0; y<s->h; y++)
        {
            float t = Perlin( (int)x, (int)y );
            int value = 128 + 128*t;
            clamp(0, value, 255);
            //std::cout << value << std::endl;

            Color c;
            c.r = r;
            c.g = g;
            c.b = b;
            c.a = value;

            set_pixel(s, x, y, c);
        }

}
コード例 #3
0
ファイル: SeaFloor.cpp プロジェクト: amputek/CELL
SeaFloor :: SeaFloor(){
    
    vec2 loc = vec2(0,0);
    
    for(float i = 1.0f; i >= 0.05f; i*=0.86f){
        rows.push_back( new GameObject(loc, i));
        paths.push_back( *new vector<vec2>() );
    }
    reverse( rows.begin(), rows.end() );
    
    perlin = Perlin(2); //create new perlin noise generator

}
コード例 #4
0
ファイル: SeaSurface.cpp プロジェクト: amputek/CELL
SeaSurface :: SeaSurface(){
    
    vec2 loc = vec2(0,-7000);
    
    for(float i = 2.0f; i >= 0.05f; i*=0.82f){
        rows.push_back( new GameObject(loc, i));
        paths.push_back( *new vector<vec2>() );
    }
    reverse( rows.begin(), rows.end() );
    
    perlin = Perlin(2); //create new perlin noise generator
    counter = 0;        //initialise sinewave counter
}
コード例 #5
0
ファイル: LSystem.cpp プロジェクト: dotdat/The-Lattice-Eaters
LSystem::LSystem( Vec2f _loc ) {
	mPerlin = Perlin();
	mLoc = _loc;
	mSteps = 0;
	mSomeStep = 0.1f;
	mXOff = 0.01f;
	mAxiom = "F";
	mRule = "|[+F]|[-F]F";
	mStartLength = 0.2f;
	mTheta = 90.0f;
	mInitNum = 3;
	mProduction = mAxiom;
	mDrawLength = mStartLength;
	mGenerations = 0;
	simulate ( mInitNum );
	updateList();
}
コード例 #6
0
ファイル: LSystem.cpp プロジェクト: dotdat/The-Lattice-Eaters
void LSystem::updateList() {
	mPerlin = Perlin( 8, Rand::randInt( 0, 100000 ) );
	mSteps = mProduction.length();
	if( mSteps > mProduction.length() ) {
		mSteps = mProduction.length();
	}
	gl::pushModelView();
	gl::translate( mLoc );
	gl::pushModelView();
	int countFood = 0;
	for( int i = 0; i < mSteps; i++ ) {
		char step = mProduction.at(i);

		if( step == 'F' || step == '|' ) {
			Vec2f current_loc = (gl::getModelView() * Vec4f( 0.0f, 0.0f, 0.0f, 1.0f )).xy();
			current_loc -= mStartLength;
			current_loc += mLoc;
			boost::shared_ptr<Food> add_food( new Food( current_loc, ColorA( ColorA::black() ) ) );
			mFood.push_back( add_food );
			if( countFood > 0 ) {
				boost::weak_ptr<Food> weakFood(add_food);
				mFood[countFood-1]->setNext( weakFood );
			}
			countFood++;
			gl::translate( 0, -mDrawLength + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*20000.0f );
		}
		else if( step == '+' ) {
			gl::rotate( mTheta + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*(2000.0f * i/30.0f));
		}
		else if( step == '-' ) {
			gl::rotate( -1*(mTheta + mPerlin.fBm( app::getElapsedFrames()*1.0f, i, 0.001f )*(2000.0f * i/30.0f)));
		}
		else if( step == '[' ) {
			gl::pushModelView();
		}
		else if( step == ']' ) {
			gl::popModelView();
		}
	}
	gl::popModelView();
	gl::popModelView();
}
コード例 #7
0
ファイル: NOISE.CPP プロジェクト: ApocalypseDesign/ad_public
void noise2D::do_efx2D(double pos)
{
  int x, y, ip, pixel;
  float p;
  float step, step_x, step_y, fx, fy;
/*
  _asm
  {
	 push eax
	 fstcw word ptr [cwrd]
	 mov [cwrd], ax
	 or ah, 0Ch
	 mov ax, [cwrd]
	 fldcw word ptr [cwrd]
	 pop eax
  }
*/

  step=(float)(pos*2.0);
  step_x=(float)(1.0/80.0);
  step_y=(float)(1.0/60.0);

  fy=0;
  for (y=0; y<image->height; y++)
  {
	fx=step;
    for (x=0; x<image->width; x++)
	{
	   p=Perlin(fx, fy, 0.45f, 6);
	   ip=myfist(p+SHINESS);
	   if (ip<0) ip=0;
	   if (ip>255) ip=255;

	   pixel=ip | (ip<<8) | (ip<<16);
	   image->uint32ptr[image->muly[y]+x]=pixel;
	   fx+=step_x;
	}
    fy+=step_y;
  }
  return;
}
コード例 #8
0
SphereModule::SphereModule(int dataSize, gl::GlslProg sphereShader)
{
	dataSiz = dataSize;
	shader = sphereShader;
	perl = Perlin(3);
}
コード例 #9
0
 Oscillator::Oscillator(){
     mPerlin = Perlin(OSCILLATOR_PERLIN_NUM_OCTAVES, OSCILLATOR_PERLIN_SEED);
 }