当前位置: 首页>>代码示例>>C++>>正文


C++ Perlin::setSeed方法代码示例

本文整理汇总了C++中Perlin::setSeed方法的典型用法代码示例。如果您正苦于以下问题:C++ Perlin::setSeed方法的具体用法?C++ Perlin::setSeed怎么用?C++ Perlin::setSeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Perlin的用法示例。


在下文中一共展示了Perlin::setSeed方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: scopeStencil

void Day59App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.1, 0.1, 0.1 ) );
    gl::color(Color(0.,0.,0.));
    gl::clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
    mCam.setEyePoint(vec3(0.,0.,fabs(cos(omega) * 50.f)));
  mPerlin.setSeed(getElapsedFrames());
    
    // enable stencil test to be able to give the stencil buffers values.
    gl::ScopedState scopeStencil( GL_STENCIL_TEST, true );
  //  gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
    for (int i =0; i <NUM_OBJS; i++)
    {
        
        vec3 noise = mPerlin.dfBm(mRandomPositions[i]);
    
        gl::ScopedMatrices scpMtx;
        gl::translate(mRandomPositions[i]);
        
    
        {
            gl::ScopedMatrices push;
            gl::rotate(angleAxis(theta + mOffsets[i], vec3(1.0, 0., 0.)));
            gl::translate(mRandomPositions[i]);
            gl::scale(mScales[i]);
            
            //DRAW THE MAIN OBJECT (1ST RENDER PASS) AS NORMAL, FILL THE STENCIL BUFFER
            gl::stencilFunc(GL_ALWAYS, 1, 0xFF); //ALL FRAGMENTS MUST UPDATE THE STENCIL BUFFER
            gl::stencilMask(0xFF); //ENABLE WRITING TO THE STENCIL BUFFER
            mObject->draw();
        }
        
        //IF THE STENCIL TEST FAILS, KEEP THE FRAGMENT
        //IF STENCIL PASSES AND DEPTH FAILS, KEEP THE FRAGMENT
        //IF THE DEPTH TEST AND STENCIL TEST PASS, REPLACE THE FRAGMENT
        glStencilOp(GL_KEEP  , GL_KEEP, GL_REPLACE);
        
        //2ND RENDER PASS - DRAW OBJECT SLIGHTLY BIGGER, BUT DISABLE STENCIL WRITING.  BECAUSE THE STENCIL BUFFER IS FILLED WITH 1s (PARTICULARLY IN THE AREA OF THE ORIGINAL OBJECT), THE ONLY THING THAT WILL BE DRAWN IS THE AREA OF THE 2ND OBJECT, IE. THE SIZE DIFFERENCE
        
        gl::stencilFunc(GL_NOTEQUAL, 1, 0xFF); //don't update the stencil buffer
        gl::stencilMask(0x00);
        gl::disable(GL_DEPTH_TEST);
        {
            gl::ScopedMatrices push;
            gl::rotate(angleAxis(theta + mOffsets[i], vec3(1.0, 0., 0.)));
            gl::translate(mRandomPositions[i]);
            
            gl::scale(vec3(mScales[i] + vec3(0.1) ));
            
            mBorderObject->draw();
        }
    
    }
    
    gl::stencilMask(0xFF);
    gl::enable(GL_DEPTH_TEST);
  //  saveGif();
    
}
开发者ID:Craigson,项目名称:100days,代码行数:60,代码来源:Day59App.cpp

示例2: setup

void LookAroundYouApp::setup()
{
	Rand::randomize();
	
    mVolume = 1.0;
    
    // Setup GUI
	getWindow()->setTitle("MPCDigital App");
	mParams = params::InterfaceGl( "Settings", Vec2i( 300, 200 ) );
	mParams.addParam( "Framerate", &mFrameRate, "", true );
    mParams.addSeparator();
    mParams.addParam("Speed", &Boid::speedMultiplier, "min=0.5 max=5.0 step=0.01");
    mParams.addParam("Radius", &Boid::radiusMultiplier, "min=0.5 max=5.0 step=0.01");
    mParams.addParam("Range", &Boid::range, "min=10.0 max=100 step=0.1");
    mParams.addSeparator();
    mParams.addParam("Master Volume", &mVolume, "min=0 max=1.0 step=0.01");
    
    
    // Setup Audio
    AudioDevice::printDeviceMap();
    mAudioDevice = make_shared<AudioDevice>();
    mAudioDevice->setup(0);
    mAudioDevice->setAmbientReverb(FMOD_PRESET_UNDERWATER);
    console() << "Channels Available: " << mAudioDevice->getNumRemainingChannels() << endl;
    
    DataSourceRef data = loadAsset("music/Music For Airports - 1 1.mp3");
    string musicName = mAudioDevice->registerSound(data, true, false, true);
    music = mAudioDevice->getSoundInstance(musicName, 1.0);
    music->pause();
    
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/blue.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/fliup.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/green.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/howl.wav"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/orange.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/red.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/white.aif"), true, true));
    fxnames.push_back(mAudioDevice->registerSound(loadAsset("fx/yellow.aif"), true, true));
    
    // Setup noise generator to drive Boid motion
    mPerlin = new Perlin();
    mPerlin->setSeed(clock());
	mPerlin->setOctaves(1);
    
    // Construct Boids
    for(int i=0; i<10; i++) {
        int n = Rand::randInt(0, fxnames.size());
        SoundInstanceRef fx = mAudioDevice->getSoundInstance(fxnames[n], 1.0);
        BoidRef boid = make_shared<Boid>(mPerlin, fx);
        mBoids.push_back(boid);
    }
    
	
	// enable the depth buffer (for 3D)
	gl::enableDepthRead();
	gl::enableDepthWrite();
    gl::enableAlphaBlending();
}
开发者ID:KitchenTableCoders,项目名称:3daudio,代码行数:58,代码来源:LookAroundYouApp.cpp

示例3: setup

void cApp::setup(){
    mExp.setup(1920, 1080, 0, 100-1, GL_RGB, mt::getRenderPath(), 0, "test" );
    setWindowSize( 1920, 1080 );
    setWindowPos(0, 0);
    
    mPln.setSeed( 345 );
    mPln.setOctaves( 4 );
    
    cam = CameraPersp(1920, 1080, 55, 0.1, 100000);
    eye = vec3(0,0,1000);
    cam.lookAt(eye, vec3(0,0,0));
    camui.setCamera(&cam);
}
开发者ID:stdmtb,项目名称:uf_0.9.0,代码行数:13,代码来源:cApp.cpp

示例4: setup

void BasicParticleApp::setup()
{
	mPerlin.setSeed( clock() );

	mAnimationCounter = 0;
	for( int s = 0; s < NUM_INITIAL_PARTICLES; ++s )
		mParticles.push_back( Particle( Vec2f( Rand::randFloat( getWindowWidth() ), Rand::randFloat( getWindowHeight() ) ) ) );

	CONSERVATION_OF_VELOCITY = 0.9f;
	SPEED = 5.0f;

	// Turn on additive blending
	gl::enableAlphaBlending();
}
开发者ID:AaronMeyers,项目名称:Cinder,代码行数:14,代码来源:BasicParticleApp.cpp

示例5: setup

void cApp::setup(){
    
    setWindowPos( 0, 0 );
    setWindowSize( mW*0.5, mH*0.5 );
    mExp.setup( mW*mScale, mH*mScale,0, 2999, GL_RGB, mt::getRenderPath() );
    
    mPln.setOctaves(4);
    mPln.setSeed(1332);

    randSeed( mt::getSeed() );
    
    int count = 0;
    for( int i=0; i<100; i++){
        StrangeAgent sa;
        sa.setRandom();
        mSAs.push_back( sa );

        for(int j=0; j<sa.points.size(); j++){
            mPlnPts.push_back( Vec3f(count*scale,0,0) );
            count++;
        }
    }
    
    total = count;
    
    if( 1 ){
        CameraPersp cam;
        cam.setNearClip(0.1);
        cam.setFarClip(1000000);
        cam.setFov(60);
        cam.setEyePoint( Vec3f(0,0,-30 ) );
        cam.setCenterOfInterestPoint( Vec3f(0,0,0) );
        cam.setAspectRatio( (float)mW/mH );
        mCamUi.setCurrentCam(cam);
    }else{
        ortho.setNearClip(0.1);
        ortho.setFarClip(1000000);
        ortho.setEyePoint( Vec3f(0,0,-7 ) );
        ortho.setCenterOfInterestPoint( Vec3f(0,0,0) );
        ortho.setAspectRatio( (float)mW/mH );
    }
    
#ifdef RENDER
    mExp.startRender();
#endif
}
开发者ID:stdmtb,项目名称:n9,代码行数:46,代码来源:cApp.cpp

示例6: setup

void cApp::setup(){
    setFrameRate( 25 );
    setWindowPos( 0, 0 );
    setWindowSize( mW*mScale, mH*mScale );
    mExp.setup( mW*mScale, mH*mScale, 0, 2999, GL_RGB, mt::getRenderPath() );
    
    mPln.setOctaves( 3 );
    mPln.setSeed( 551 );
    
    mt::loadColorSample("img/Mx80_2_org_B.jpg", mColorSample1 );
    mt::loadColorSample("img/Mx80_2_org_B.jpg", mColorSample2 );

    
    {
        // Audio Setup
        auto ctx = audio::Context::master();
        audio::DeviceRef device = audio::Device::getDefaultOutput();
        audio::Device::Format format;
        format.sampleRate( 192000 );
        format.framesPerBlock( mFpb );
        device->updateFormat( format );
        
        cout << "--- Audio Setting --- " << endl;
        cout << "device name      : " << device->getName() << endl;
        cout << "Sample Rate      : " << ctx->getSampleRate() << endl;
        cout << "frames per Block : " << ctx->getFramesPerBlock() << endl;

        mWaves.assign( 7, Wave() );
        
        for( int i=0; i<mWaves.size(); i++ ){
            mWaves[i].create( "snd/test/3s1e_192k_" + toString(i+1)+ ".wav" );
        }

        ctx->enable();
    }
    
    
#ifdef RENDER
    mExp.startRender();
#endif

}
开发者ID:stdmtb,项目名称:n9,代码行数:42,代码来源:cApp.cpp

示例7: setup

void cApp::setup(){
    
    setWindowPos( 0, 0 );
    setWindowSize( 1080*3*0.5, 1920*0.5 );
    mExp.setup( 1080*3, 1920, 3000, GL_RGB, mt::getRenderPath(), 0);
    
    CameraPersp cam(1080*3, 1920, 54.4f, 0.1, 10000 );
    cam.lookAt( Vec3f(0,0, 1600), Vec3f(0,0,0) );
    cam.setCenterOfInterestPoint( Vec3f(0,0,0) );
    camUi.setCurrentCam( cam );
    
    mPln.setSeed(123);
    mPln.setOctaves(4);
    
    fs::path assetPath = mt::getAssetPath();
    
    {
        // make VectorMap
        Surface32f sAspect( loadImage(assetPath/("img/00/halpha3000_aspect_32bit.tif")) );
        Surface32f sSlope( loadImage(assetPath/("img/00/halpha3000_slope1.tif")) );

        int w = sAspect.getWidth();
        int h = sAspect.getHeight();
        
        mVecMap.assign(w, vector<Vec2f>(h) );

        for( int i=0; i<sAspect.getWidth(); i++) {
            for( int j=0; j<sAspect.getHeight(); j++ ) {
                
                Vec2i pos(i, j);
                float aspect = *sAspect.getDataRed( pos );
                float slope = *sSlope.getDataRed( pos );
                if( slope!=0 && aspect!=-9999 ){

                    Vec2f vel( 0, slope*10.0 );
                    vel.rotate( toRadians(aspect) );
                    mVecMap[i][j] = vel;
                }else{
                    mVecMap[i][j] = Vec2f::zero();
                }
                
                mVelocity.push_back( Vec3f(mVecMap[i][j].x, mVecMap[i][j].y, 0) );
            }
        }
    }
    
    {
        // make point from intensity
        Surface32f sIntensity( loadImage(assetPath/("img/00/halpha3000-skv3264879915580.tiff")) );
        intensityW = sIntensity.getWidth();
        intensityH = sIntensity.getHeight();
        
        Surface32f::Iter itr = sIntensity.getIter();
        float threashold = 0.15;
        float extrusion = 300;
        while ( itr.line() ) {
            while( itr.pixel() ){
                float gray = itr.r();
                if( threashold < gray ){
                    Vec2i pos = itr.getPos();
                    Vec3f v(pos.x, pos.y, gray*extrusion );
                    Vec3f noise = mPln.dfBm( Vec3f(pos.x, pos.y, gray) ) * 2.0;
                    ps.push_back( v + noise );
                    float c = gray + 0.2f;
                    float a = lmap(c, 0.0f, 1.0f, 0.3f, 0.7f);
                    cs.push_back( ColorAf(c, c, c, a) );
                }
            }
        }
        
        
        mPoints = gl::VboMesh( ps.size(), 0, mt::getVboLayout(), GL_POINTS );
        gl::VboMesh::VertexIter vitr( mPoints );
        for(int i=0; i<ps.size(); i++ ){
            vitr.setPosition( ps[i] );
            vitr.setColorRGBA( cs[i] );

            ++vitr;
        }
    }
    
    
    mExp.startRender();
    bStart = true;
    
}
开发者ID:stdmtb,项目名称:uf_0.8.6,代码行数:86,代码来源:cApp.cpp


注:本文中的Perlin::setSeed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。