예제 #1
0
파일: cApp.cpp 프로젝트: stdmtb/uf_0.9.0
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);
}
예제 #2
0
파일: cApp.cpp 프로젝트: stdmtb/uf_0.9.0
void cApp::setup(){
    setWindowPos( 0, 0 );

    float w = 1920;
    float h = 1080;
    
    setWindowSize( w, h );
    
    cam = CameraPersp(w, h, 55.0f, 1, 10000 );
    cam.lookAt( vec3(0,0,1200), vec3(0,0,0) );
    cam.setLensShift( 0,0 );
    camUi.setCamera( &cam );
    
    fftCheck();
//    dftCheck();
}
예제 #3
0
void BouncingBalls3dApp::setup()
{
    for (int i = 0; i < NUM_BALLS; i++) {
        mBalls.push_back( BouncingBall::create( randVec3() * 3.f) );
    }
    
    mBox = AxisAlignedBox( vec3(-25), vec3(25) );
    
    mCamera.setPerspective(60, getWindowAspectRatio(), .1, 10000);
    mCamera.lookAt(vec3(0,0,30), vec3(0));
    
    mUI.connect(getWindow());
    mUI.setCamera(&mCamera);
    
    gl::enableDepthRead();
    gl::enableDepthWrite();
    
}
예제 #4
0
파일: cApp.cpp 프로젝트: stdmtb/uf_0.9.0
void cApp::setup(){
    setWindowPos( 0, 0 );
    
    float w = 1920;
    float h = 1080*3;
    
    setWindowSize( w*0.2, h*0.2 );
    mExp.setup( w, h, 0, 550-1, GL_RGB, mt::getRenderPath(), 0);
    
    cam = CameraPersp(w, h, 55.0f, 0.1, 1000000 );
    
    if(0){
        cam.lookAt( vec3(0,0,800), vec3(0,0,0) );
        cam.setLensShift( 0,0 );
    }else{
        cam.setNearClip(0.100000);
        cam.setFarClip(1000000.000000);
        cam.setAspectRatio(0.592593);
        cam.setFov(55.000000);
        cam.setEyePoint(vec3(326.924622,-381.081604,259.431519));
        cam.setWorldUp(vec3(0.000000,1.000000,0.000000));
        cam.setLensShift(vec2(0.000000,0.000000));
        cam.setViewDirection(vec3(-0.578462,0.674288,-0.459040));
        cam.lookAt(vec3(326.924622,-381.081604,259.431519)+vec3(-0.578462,0.674288,-0.459040));
    }
    
    camUi.setCamera( &cam );
    
    mPln.setSeed(123);
    mPln.setOctaves(4);
    
    for( int i=0; i<6; i++){
        Ramses r(eSimType,i);
        rms.push_back( r );
    }

    makeGui();
    
#ifdef RENDER
    mExp.startRender();
#endif
    
}
예제 #5
0
파일: cApp.cpp 프로젝트: stdmtb/uf_0.9.0
void cApp::setup(){
    
    mPln.setSeed( 345 );
    mPln.setOctaves( 4 );
    
    openDir();
    
    fs::path path = dir/("f_00000.png");
    sur = Surface8u( loadImage( path) );
    int w = sur.getWidth();
    int h = sur.getHeight();
    
    pcam = CameraPersp(w, h, 50, 1, 10000);
    camUi.setCamera( &pcam );
    mExp.setup( w, h, 0, 3000-1, GL_RGB, mt::getRenderPath(), 0 );
    setWindowSize( w*0.5, h*0.5 );
    setWindowPos(0, 0);
    
    
#ifdef RENDER
    mExp.startRender();
#endif
}
예제 #6
0
void AudioVisualizerApp::setup()
{
	// initialize signals
	signalChannelEnd = false;

	// make a list of valid audio file extensions and initialize audio variables
	const char* extensions[] = { "mp3", "wav", "ogg" };
	mAudioExtensions = vector<string>( extensions, extensions + 2 );
	mAudioPath = getAssetPath( "" );
	mIsAudioPlaying = false;

	// setup camera
	mCamera.setPerspective( 50.0f, 1.0f, 1.0f, 10000.0f );
	mCamera.lookAt( vec3( -kWidth / 4, kHeight / 2, -kWidth / 8 ), vec3( kWidth / 4, -kHeight / 8, kWidth / 4 ) );

	mCameraUi.setCamera( &mCamera );

	// create channels from which we can construct our textures
	mChannelLeft = Channel32f( kBands, kHistory );
	mChannelRight = Channel32f( kBands, kHistory );
	memset( mChannelLeft.getData(), 0, mChannelLeft.getRowBytes() * kHistory );
	memset( mChannelRight.getData(), 0, mChannelRight.getRowBytes() * kHistory );

	// create texture format (wrap the y-axis, clamp the x-axis)
	mTextureFormat.setWrapS( GL_CLAMP_TO_BORDER );
	mTextureFormat.setWrapT( GL_REPEAT );
	mTextureFormat.setMinFilter( GL_LINEAR );
	mTextureFormat.setMagFilter( GL_LINEAR );
	mTextureFormat.loadTopDown( true );

	// compile shader
	try {
		mShader = gl::GlslProg::create( loadAsset( "shaders/spectrum.vert" ), loadAsset( "shaders/spectrum.frag" ) );
	}
	catch( const std::exception& e ) {
		console() << e.what() << std::endl;
		quit();
		return;
	}

	// create static mesh (all animation is done in the vertex shader)
	std::vector<vec3>		positions;
	std::vector<Colorf>		colors;
	std::vector<vec2>		coords;
	std::vector<uint32_t>	indices;

	for( size_t h = 0; h < kHeight; ++h ) {
		for( size_t w = 0; w < kWidth; ++w ) {
			// add polygon indices
			if( h < kHeight - 1 && w < kWidth - 1 ) {
				size_t offset = positions.size();

				indices.emplace_back( offset );
				indices.emplace_back( offset + kWidth );
				indices.emplace_back( offset + kWidth + 1 );
				indices.emplace_back( offset );
				indices.emplace_back( offset + kWidth + 1 );
				indices.emplace_back( offset + 1 );
			}

			// add vertex
			positions.emplace_back( vec3( float( w ), 0, float( h ) ) );

			// add texture coordinates
			// note: we only want to draw the lower part of the frequency bands,
			//  so we scale the coordinates a bit
			const float part = 0.5f;
			float s = w / float( kWidth - 1 );
			float t = h / float( kHeight - 1 );
			coords.emplace_back( vec2( part - part * s, t ) );

			// add vertex colors
			colors.emplace_back( Color( CM_HSV, s, 0.5f, 0.75f ) );
		}
	}

	gl::VboMesh::Layout layout;
	layout.usage( GL_STATIC_DRAW );
	layout.attrib( geom::Attrib::POSITION, 3 );
	layout.attrib( geom::Attrib::COLOR, 3 );
	layout.attrib( geom::Attrib::TEX_COORD_0, 2 );

	mMesh = gl::VboMesh::create( positions.size(), GL_TRIANGLES, { layout }, indices.size(), GL_UNSIGNED_INT );
	mMesh->bufferAttrib( geom::POSITION, positions.size() * sizeof( vec3 ), positions.data() );
	mMesh->bufferAttrib( geom::COLOR, colors.size() * sizeof( vec3 ), colors.data() );
	mMesh->bufferAttrib( geom::TEX_COORD_0, coords.size() * sizeof( vec2 ), coords.data() );
	mMesh->bufferIndices( indices.size() * sizeof( uint32_t ), indices.data() );

	// play audio using the Cinder FMOD block
	FMOD::System_Create( &mFMODSystem );
	mFMODSystem->init( 32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, NULL );
	mFMODSound = nullptr;
	mFMODChannel = nullptr;

	playAudio( findAudio( mAudioPath ) );

	mIsMouseDown = false;
	mMouseUpDelay = 30.0;
	mMouseUpTime = getElapsedSeconds() - mMouseUpDelay;

	// the texture offset has two purposes:
	//  1) it tells us where to upload the next spectrum data
	//  2) we use it to offset the texture coordinates in the shader for the scrolling effect
	mOffset = 0;
}
예제 #7
0
파일: cApp.cpp 프로젝트: stdmtb/uf_0.9.0
void cApp::resize(){
    CameraPersp & cam = const_cast<CameraPersp&>(camUi.getCamera());
    cam.setAspectRatio( getWindowAspectRatio() );
    camUi.setCamera( &cam );
}
void ViewportArrayApp::mouseWheel( MouseEvent event )
{
	int viewport = getViewportAt( mViewports, event.getPos() );
	if( viewport != -1 ) mCameraUi.setCamera( &mCameras[viewport] );
	mCameraUi.mouseWheel( event );
}
void ViewportArrayApp::mouseUp( MouseEvent event )
{
	if( currentViewport != -1 ) mCameraUi.setCamera( &mCameras[currentViewport] );
	mCameraUi.mouseUp( event );
}