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


C++ Rand::seed方法代码示例

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


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

示例1: NextFile

//*************************************************************************
void BeatDetectorApp::NextFile()
{
	roto = 0;
	if(mTrack && mTrack->isPlaying())
	{
		mTrack->enablePcmBuffering(false);
		mTrack->stop();
	}

#ifdef WIN32
	time_t now;
	time(&now);
	int time_int = (int)now;
#else
	timeval now;
	gettimeofday(&now, NULL);
	int time_int = now.tv_sec;
#endif

	Rand r;
	r.seed(time_int);
	int rand_file = r.nextInt(m_FileList.size());
	path my_path = m_FileList[rand_file].path();
	m_CurrentFile = my_path.string();
	
	if(!write_frames)
	{
		mAudioSource = audio::load(m_CurrentFile);
		mTrack = audio::Output::addTrack(mAudioSource, false);
		mTrack->enablePcmBuffering(true);
		mTrack->play();		
	}
	//rot_inc = r.nextFloat(1.5f, 30.0f);
}
开发者ID:merf,项目名称:VisualiserTestbed,代码行数:35,代码来源:KissFileSampleApp.cpp

示例2: Color

void Example4App::setup()
{
    gl::clear( Color( 1, 1, 1 ) );
    gl::enableAlphaBlending();
    
    generator_.seed(randInt());
    app::setWindowSize(600, 200);
    mean_ = getWindowWidth() / 2;
}
开发者ID:Mohsenvand,项目名称:nature-of-code-cinder,代码行数:9,代码来源:Example4App.cpp

示例3: setup

void CristalWaveApp::setup()
{
	float sizeW = getWindowWidth() * 0.5f;
	float sizeH = getWindowHeight() * 0.5f;
	float	x = 0.0f,
			z = 0.0f,
			y = 0.0f;

	/////////////////////////////////////////////////
	int numRows = PARAM_WAVE_NB_ROWS;
	int gap = PARAM_WAVE_GAP + getWindowWidth() / 2000;
	int numLines = getWindowWidth() / gap + 1;
	/////////////////////////////////////////////////

	mOpacity = 0.0f;
	mOffsetCameratH = 60; // Global amplitude

	// Init BackgroundLayer
	mBackground.setup(getWindowWidth(), getWindowHeight(), mOffsetCameratH);

	// Init Wave Model
	mWave.setup(getWindowWidth(), getWindowHeight(), numRows, numLines, -mOffsetCameratH);

	// set a random offset
	Rand rnd;
	rnd.seed((unsigned long)GetTickCount());
	mOffsetTime = rnd.nextFloat(0.0f, 100.0f);

	// Set the Shader program
	mFresnelShader.load();
	mpWaveShader = &mFresnelShader;
	mWave.setShader(mpWaveShader);

	// --------------------------------------------------------
	// Set Particule manager
	int nbParticule = PARAM_NB_PARTICULES;
	mEmitter.radius = PARAM_EMITTER_RADIUS;

	mParticuleInTheWindManager.attrPosition = Vec3f::zero();
	mParticuleInTheWindManager.attrFactor = PARAM_FORCE_FACTOR;

	ParticuleManager::PARTICULE_LIFE particule_life;
	particule_life.minTTL = 0.5f;
	particule_life.maxTTL = 3.5f;
	particule_life.minTTH = 1.0f;
	particule_life.minTTH = 4.0f;
	mParticuleInTheWindManager.init(nbParticule, particule_life, getWindowWidth());
}
开发者ID:NeKoFu,项目名称:CristalWave,代码行数:48,代码来源:CristalWaveApp.cpp

示例4: mpeReset

void MPEBouncingBallApp::mpeReset()
{
    console() << "RESETTING\n";

    // Set the random seed to a known value so all of the clients are using the same rand values.
    mRand.seed(1);

    // Clear out the previous state
    mServerFramesProcessed = 0;
    mBalls.clear();

    // Add the first ball
    ivec2 sizeMaster = mClient->getMasterSize();
    addBallAtPosition(vec2(mRand.nextFloat(sizeMaster.x), mRand.nextFloat(sizeMaster.y)));
    
    if (mClient->isAsynchronousClient())
    {
        send3DSettings();
    }
}
开发者ID:indefinit,项目名称:Most-Pixels-Ever-Cinder,代码行数:20,代码来源:MPEBouncingBallApp.cpp

示例5: Color

void P_2_1_3_01App::draw()
{
	// clear out the window with black
	gl::clear( Color( 1, 1, 1 ) );
    
    gl::color(0, 0, 0, 0.5f);
    
    mRand.seed(mRandomSeed);
    
    gl::pushMatrices();
    gl::translate(mTileWidth / 2.0f, mTileHeight / 2.0f);
    
    mCircleCount = mMousePos.x / 30.0f + 1.0f;
    
    mEndSize = lmap(float(mMousePos.x), 0.0f, float(getWindowWidth()), mTileWidth / 2.0f, 0.0f);
    mEndOffset = lmap(float(mMousePos.y), 0.0f, float(getWindowHeight()), 0.0f, (mTileWidth - mEndSize)/2.0f);
    
    for (int gridY = 0; gridY <= mTileCountY; gridY++) {
        for (int gridX = 0; gridX <= mTileCountX; gridX++) {
            gl::pushMatrices();
            gl::translate(mTileWidth * gridX, mTileHeight * gridY);
            gl::scale(Vec2f(1.0f, mTileHeight / mTileWidth));
            
            int toggle = mRand.nextInt(4);
            if (toggle == 0) gl::rotate(-90.0f);
            if (toggle == 1) gl::rotate(0.0f);
            if (toggle == 2) gl::rotate(90.0f);
            if (toggle == 3) gl::rotate(180.0f);
            
            for (int i = 0; i < mCircleCount; i++) {
                float diameter = lmap(float(i), 0.0f, mCircleCount - 1.0f, mTileWidth, mEndSize);
                float offset = lmap(float(i), 0.0f, mCircleCount - 1.0f, 0.0f, mEndOffset);
                gl::drawStrokedCircle(Vec2f(offset, 0.0f), diameter / 2.0f);
            }
            
            gl::popMatrices();
        }
    }
    
    gl::popMatrices();
}
开发者ID:sergey-bash,项目名称:GenerativeDesignCinder,代码行数:41,代码来源:P_2_1_3_01App.cpp

示例6:

MyCircle::MyCircle(int x, int y, int radius){
	this->x_ = x;
	this->y_ = y;
	this->child_ = NULL;
	this->anchor_x_ = x;
	this->anchor_y_ = y;
	this->bound_ = 0;
	this->alpha_level_ = 0;

	//make sure the radius isn't too large
	if(radius > 100)
		this->radius_ = 100;
	else
		this->radius_ = radius;

	//make the shape a random color:
	Rand random;
	random.seed(x*y);
	this->color_ = Color8u(random.nextInt(0,256),
		random.nextInt(0,256),random.nextInt(0,256));

	this->work_color_ = color_;
}
开发者ID:bournehw,项目名称:Assignment2,代码行数:23,代码来源:MyCircle.cpp

示例7: render

void StereoscopicRenderingApp::render()
{	
	float seconds = (float) getElapsedSeconds();

	// enable 3D rendering
	gl::enableDepthRead();
	gl::enableDepthWrite();

	// set 3D camera matrices
	gl::pushMatrices();
	gl::setMatrices( mCamera );

	if( mShaderPhong && mMeshTrombone && mMeshNote ) {
		// enable phong shading
		mShaderPhong.bind();	
		
		// draw trombone
		gl::pushModelView();
		{
			gl::color( Color(0.7f, 0.6f, 0.0f) );
			gl::rotate( Vec3f::yAxis() * 10.0f * seconds );
			gl::draw( mMeshTrombone );

			// reflection
			gl::scale( 1.0f, -1.0f, 1.0f );
			gl::draw( mMeshTrombone );
		}
		gl::popModelView();	

		// draw animated notes
		Rand rnd;
		for(int i=-100; i<=100; ++i) {
			rnd.seed(i);

			float t = rnd.nextFloat() * 200.0f + 2.0f * seconds;
			float r = rnd.nextFloat() * 360.0f + 60.0f * seconds;
			float z = fmodf( 5.0f * t, 200.0f ) - 100.0f;		

			gl::pushModelView();
			{
				gl::color( Color( CM_HSV, rnd.nextFloat(), 1.0f, 1.0f ) );

				gl::pushModelView();
				gl::translate( i * 0.5f, 0.15f + 1.0f * math<float>::abs( sinf(3.0f * t) ), -z );
				gl::rotate( Vec3f::yAxis() * r );
				gl::draw( mMeshNote );
				gl::popModelView();
				
				// reflection
				gl::pushModelView();
				gl::scale( 1.0f, -1.0f, 1.0f );
				gl::translate( i * 0.5f, 0.15f + 1.0f * math<float>::abs( sinf(3.0f * t) ), -z );
				gl::rotate( Vec3f::yAxis() * r );
				gl::draw( mMeshNote );
				gl::popModelView();
			}
			gl::popModelView();
		}

		mShaderPhong.unbind();
	}

	// draw grid
	gl::color( Color(0.8f, 0.8f, 0.8f) );
	for(int i=-100; i<=100; ++i) {
		gl::drawLine( Vec3f((float) i, 0, -100), Vec3f((float) i, 0, 100) );
		gl::drawLine( Vec3f(-100, 0, (float) i), Vec3f(100, 0, (float) i) );
	}

	// draw floor
	gl::enableAlphaBlending();
	gl::color( ColorA(1,1,1,0.75f) );
	gl::drawCube( Vec3f(0.0f, -0.5f, 0.0f), Vec3f(200.0f, 1.0f, 200.0f) );
	gl::disableAlphaBlending();

	// restore 2D rendering
	gl::popMatrices();
	gl::disableDepthWrite();
	gl::disableDepthRead();

	// render UI
	if( mDrawUI ) renderUI();
}
开发者ID:AKS2346,项目名称:Cinder,代码行数:83,代码来源:StereoscopicRenderingApp.cpp


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