void MarionetteZooApp::update()
{
	mFps = getAverageFps();

	CameraPersp cam = mMayaCam.getCamera();
	if ( cam.getFov() != mCameraFov )
	{
		cam.setPerspective( mCameraFov, getWindowAspectRatio(), 0.1f, 1000.0f );
		mMayaCam.setCurrentCam( cam );
	}
	if( mCameraLock )
	{
		if( mCameraEyePoint != cam.getEyePoint() )
		{
			cam.setEyePoint( mCameraEyePoint );
			mMayaCam.setCurrentCam( cam );
		}
		if( mCameraCenterOfInterestPoint != cam.getCenterOfInterestPoint() )
		{
			cam.setCenterOfInterestPoint( mCameraCenterOfInterestPoint );
			mMayaCam.setCurrentCam( cam );
		}
	}
	else
	{
		mCameraEyePoint              = cam.getEyePoint();
		mCameraCenterOfInterestPoint = cam.getCenterOfInterestPoint();
	}

// 	mLight->setDirection( mLightDirection * Vec3f( 1.f, 1.f, -1.f ) );
// 	mLight->update( cam );

	mBulletWorld->update();
	mModelManager->update();
}
Example #2
0
File: cApp.cpp Project: stdmtb/n9
void cApp::keyDown( KeyEvent event ){
    switch (event.getChar()) {
        case '1': camUi.setCurrentCam(cams[0]);     break;
        case '2': camUi.setCurrentCam(cams[1]);     break;
        case '3': camUi.setCurrentCam(cams[2]);     break;
        case '4': camUi.setCurrentCam(cams[3]);     break;
        case '5': camUi.setCurrentCam(cams[4]);     break;
        case 'R': mExp.startRender();               break;
        case 'T': mExp.stopRender();                break;
        case 'f': frame+=100;                       break;
        case '0': frame=0; simDirNum++;             break;
    }
}
Example #3
0
void AssimpApp::setup()
{
	mAssimpLoader = assimp::AssimpLoader( getAssetPath( "astroboy_walk.dae" ) );
	mAssimpLoader.setAnimation( 0 );


	CameraPersp cam;
	cam.setPerspective( 60, getWindowAspectRatio(), 0.1f, 1000.0f );
	cam.setEyePoint( Vec3f( 0, 7, 20 ) );
	cam.setCenterOfInterestPoint( Vec3f( 0, 7, 0 ) );
	mMayaCam.setCurrentCam( cam );

	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 300 ) );
	mEnableWireframe = false;
	mParams.addParam( "Wireframe", &mEnableWireframe );
	mEnableTextures = true;
	mParams.addParam( "Textures", &mEnableTextures );
	mEnableSkinning = true;
	mParams.addParam( "Skinning", &mEnableSkinning );
	mEnableAnimation = false;
	mParams.addParam( "Animation", &mEnableAnimation );
	mDrawBBox = false;
	mParams.addParam( "Bounding box", &mDrawBBox );
	mParams.addSeparator();
	mParams.addParam( "Fps", &mFps, "", true );
}
Example #4
0
void reflection_animationApp::resize( ResizeEvent event )
{
    // reset camera on resize
	CameraPersp cam = m_mayaCam.getCamera();
    cam.setAspectRatio( getWindowAspectRatio() );
    m_mayaCam.setCurrentCam( cam );
}
void FadeCandyClientApp::setup()
{
	bInitialized = false;
	g_Width = 124; // set global width and height to something
	g_Height = 8; // they need to be reset when the receiver connects to a sender
	//point FC to host and port
	effectRunner = FCEffectRunner::create("127.0.0.1",7890);
	//create instance of our custom effect
	e = MyEffect::create(spoutSurf);
	effectRunner->setEffect(boost::dynamic_pointer_cast<FCEffect>( e ));
	effectRunner->setMaxFrameRate(400);
	effectRunner->setVerbose(true);
    effectRunner->setLayout("layouts/grid16x8.json",0);
	//add visualizer to see effect on screen
	FCEffectVisualizerRef viz = FCEffectVisualizer::create();
	effectRunner->setVisualizer(viz);
	
	// set up the camera
	CameraPersp cam;
	cam.setEyePoint( Vec3f(300.0f, 250.f, -500.0f) );
	cam.setCenterOfInterestPoint( Vec3f(300.0f, 200.0f, 0.0f) );
	cam.setPerspective( 60.0f, getWindowAspectRatio(), 1.0f, 1000.0f );
	mMayaCam.setCurrentCam( cam );
	gl::disableVerticalSync();
}
void FadeCandyClientApp::resize()
{
	// adjust aspect ratio
	CameraPersp cam = mMayaCam.getCamera();
	cam.setAspectRatio( getWindowAspectRatio() );
	mMayaCam.setCurrentCam( cam );
}
void TessellationSampleApp::setup()
{
	// setup shader
//	try {
//		mGlsl = gl::GlslProg::create( gl::GlslProg::Format().vertex( loadAsset( "basic.vert" ) )
//									 .fragment( loadAsset( "basic.frag" ) )
//									 .geometry( loadAsset( "basic.geom" ) ) );
//	}
//	catch( gl::GlslProgCompileExc ex ) {
//		cout << ex.what() << endl;
//		shutdown();
//	}
	
	// setup VertBatch with a single point at the origin
//	mBatch = gl::VertBatch::create();
//	mBatch->vertex( Vec2f::zero() );
//	mBatch->color( 1.0f, 0.0f, 0.0f );
	
	vertexArrayObject = gl::Vao::create();
	vertexBufferObject = gl::Vbo::create(GL_ARRAY_BUFFER);
	indexBufferObject = gl::Vbo::create(GL_ELEMENT_ARRAY_BUFFER);
	
	mTessellationInner = mTessellationOuter = 3;
	
	this->loadShader();
	this->createIcosahedron();
	
	CameraPersp cam;
	cam.setEyePoint( Vec3f(5.0f, 10.0f, 10.0f) );
	cam.setCenterOfInterestPoint( Vec3f(0.0f, 2.5f, 0.0f) );
	cam.setPerspective( 60.0f, getWindowAspectRatio(), 1.0f, 1000.0f );
	mMayaCam.setCurrentCam( cam );
}
void TessellationSampleApp::resize()
{
	// adjust aspect ratio
	CameraPersp cam = mMayaCam.getCamera();
	cam.setAspectRatio( getWindowAspectRatio() );
	mMayaCam.setCurrentCam( cam );
}
void wellingtonModelApp::frameCurrentObject()
{
    Sphere boundingSphere = Sphere::calculateBoundingSphere( mMesh.getVertices() );
	
	mMayaCam.setCurrentCam( mMayaCam.getCamera().getFrameSphere( boundingSphere, 100 ) );
    
}
Example #10
0
File: cApp.cpp Project: stdmtb/n9
void cApp::setup(){
    
    int w = win_w*master_scale;
    int h = win_h*master_scale;
    
    setFrameRate( fps );
    setWindowSize( w*0.5, h*0.5 );
    setWindowPos( 0, 0 );
    mExp.setup( w, h, 0, 3000, GL_RGB, mt::getRenderPath(), 0);
    
    CameraPersp cam( w, h, 54.4f, 1, 10000 );
    cam.lookAt( Vec3f(0,0, 1300), Vec3f(0,0,0) );
    cam.setCenterOfInterestPoint( Vec3f(0,0,0) );
    camUi.setCurrentCam( cam );

    assetDir = mt::getAssetPath();
    simDir.push_back( assetDir/"sim"/"red_particle3"/"rpc2");
    
    int nSim = simDir.size();
    vbo.assign( nSim, VboSet() );
    
#ifdef RENDER
    mExp.startRender();
#endif
}
void FastTrailsApp::resize( ResizeEvent event )
{
	// adjust aspect ratio
	CameraPersp cam = mCamera.getCamera();
	cam.setAspectRatio( event.getAspectRatio() );
	mCamera.setCurrentCam( cam );
}
void MarionetteZooApp::setup()
{
	gl::enableDepthRead();
	gl::enableDepthWrite();

	setupParams();

	CameraPersp cam;
	cam.setPerspective( mCameraFov, getWindowAspectRatio(), 0.1f, 1000.0f );
	cam.setEyePoint( mCameraEyePoint );
	cam.setCenterOfInterestPoint( mCameraCenterOfInterestPoint );
	mMayaCam.setCurrentCam( cam );

	{
// 		glEnable( GL_LIGHTING );
// 		glEnable( GL_DEPTH_TEST );
// 		glEnable( GL_RESCALE_NORMAL );
// 
// 		//create light
// 		mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 );
// 		mLight->setAmbient( Color( 1.0f, 1.0f, 1.0f ) );
// 		mLight->setDiffuse( Color( 1.0f, 1.0f, 1.0f ) );
// 		mLight->setSpecular( Color( 1.0f, 1.0f, 1.0f ) );
// 		mLight->setShadowParams( 100.0f, 1.0f, 20.0f );
// //		mLight->update( cam );
// //		mLight->enable();
	}

	mBulletWorld = BulletWorldRef( new BulletWorld() );
	mBulletWorld->setup();

	mModelManager = ModelManagerRef( new ModelManager( mBulletWorld ) );
}
void HexagonMirrorApp::resize( ResizeEvent event )
{
    // adjust the camera aspect ratio
    CameraPersp cam = mCamera.getCamera();
    cam.setAspectRatio( event.getAspectRatio() );
    mCamera.setCurrentCam( cam );
}
void HexagonMirrorApp::resize()
{
	// adjust the camera aspect ratio
	CameraPersp cam = mCamera.getCamera();
	cam.setAspectRatio( getWindowAspectRatio() );
	mCamera.setCurrentCam( cam );
}
void HexagonMirrorApp::setup()
{
    // initialize camera
    CameraPersp	cam;
    cam.setEyePoint( Vec3f(44, 34, 57) );
    cam.setCenterOfInterestPoint( Vec3f(44, 34, 0) );
    cam.setFov( 60.0f );
    mCamera.setCurrentCam( cam );

    // load shader
    try {
        mShaderInstanced = gl::GlslProg( loadAsset("phong_vert.glsl"), loadAsset("phong_frag.glsl") );
    }
    catch( const std::exception &e ) {
        console() << e.what() << std::endl;
    }

    // create a vertex array object, which allows us to efficiently position each instance
    initializeBuffer();

    // load hexagon mesh
    loadMesh();

    // connect to a webcam
    mWebcam = Capture( 160, 120 );
}
void HexagonMirrorApp::setup()
{
	// initialize camera
	CameraPersp	cam;
	cam.setEyePoint( Vec3f(90, 70, 90) );
	cam.setCenterOfInterestPoint( Vec3f(90, 70, 0) );
	cam.setFov( 60.0f );
	mCamera.setCurrentCam( cam );

	// load shader
	try { mShaderInstanced = gl::GlslProg( loadAsset("phong_vert.glsl"), loadAsset("phong_frag.glsl") ); }
	catch( const std::exception &e ) { console() << "Could not load and compile shader: " << e.what() << std::endl; }

	// create a vertex array object, which allows us to efficiently position each instance
	initializeBuffer();

	// load hexagon mesh
	loadMesh();

	// connect to a webcam
	try { 
		mCapture = Capture::create( 160, 120 ); 
		mCapture->start();
	}
	catch( const std::exception &e ) { 
		console() << "Could not connect to webcam: " << e.what() << std::endl;

		try { mCaptureTexture = loadImage( loadAsset("placeholder.png") ); }
		catch( const std::exception &e ) { }
	}
}
void PhysicallyBasedShadingApp::update()
{
	// animate the light
	if( mAnimateLight ){
		mLightPosition = vec3( cos( mTime * 0.5f ) * 8.0f, 8.0f + sin( mTime * 0.25f ) * 3.5f, sin( mTime * 0.5f ) * 8.0f );
		mTime += 0.025f;
	}
	
	// check for camera properties change
	CameraPersp cam = mMayaCam.getCamera();
	float sensorHeight = mSensorSize / getWindowAspectRatio();
	float fov = 180.0f / M_PI * 2.0f * math<float>::atan( 0.5f * sensorHeight / mFocalLength );
	
	if( mFocalLengthPreset != 0 && mFocalLengthPreset != mPrevFocalLengthPreset ){
		mFocalLength = sFocalPresetsValues[ mFocalLengthPreset ];
	}
	if( mSensorSizePreset != 0 && mSensorSizePreset != mPrevSensorSizePreset ){
		mSensorSize = sSensorPresetsValues[ mSensorSizePreset ];
	}
	if( mFStopPreset != 0 && mFStopPreset != mPrevFStopPreset ){
		mFStop = sFStopPresetsValues[ mFStopPreset ];
	}
	mPrevFocalLengthPreset	= mFocalLengthPreset;
	mPrevSensorSizePreset	= mSensorSizePreset;
	mPrevFStopPreset		= mFStopPreset;
	
	// update the fov if necessary
	if( cam.getFov() != fov ){
		cam.setFov( fov );
		mMayaCam.setCurrentCam( cam );
	}
}
Example #18
0
void gpuPSApp::setup()
{
    mStep = true;
    try {
        // Multiple render targets shader updates the positions/velocities
        mParticlesShader = gl::GlslProg( ci::app::loadResource( PASSTHROUGH_VERT ), ci::app::loadResource( PARTICLES_FRAG ));
        // Vertex displacement shader
        mDisplacementShader = gl::GlslProg( ci::app::loadResource( VERTEXDISPLACEMENT_VERT ), ci::app::loadResource( VERTEXDISPLACEMENT_FRAG ));
    }
    catch( ci::gl::GlslProgCompileExc &exc ) {
        std::cout << "Shader compile error: " << endl;
        std::cout << exc.what();
    }
    catch( ... ) {
        std::cout << "Unable to load shader" << endl;
    }
    gl::clear();
    setupPingPongFbo();
    // THE VBO HAS TO BE DRAWN AFTER FBO!
    setupVBO();
    
    CameraPersp cam;
    cam.setEyePoint( Vec3f(5.0f, 10.0f, 10.0f) );
    cam.setCenterOfInterestPoint( Vec3f(0.0f, 0.0f, 0.0f) );
    cam.setPerspective( 60.0f, getWindowAspectRatio(), 1.0f, 1000.0f );
    mMayaCam.setCurrentCam( cam );
//    gl::enableDepthRead();
//    gl::enableAlphaBlending();
}
Example #19
0
void AudioObjApp::setup()
{
    mFeatureGain           = 1.0f;
    mFeatureOffset         = 0.0f;
    mFeatureDamping        = 0.85f;
    
    mFeatureSpread         = 1.0f;
    mFeatureSpreadOffset   = 0.0f;
    
    mObjColor           = ColorA( 0.0f, 1.0f, 1.0f, 1.0f );
    mRenderWireframe    = true;
    
    loadObject( getAssetPath( "cube.obj" ) );
    
    initGui();
    
    mXtract     = ciXtractReceiver::create();
	mFeature    = mXtract->getFeatureData( "XTRACT_SPECTRUM" );
    mFeature->setLog( true );
    
    loadShader();
    
	CameraPersp initialCam;
	initialCam.setPerspective( 45.0f, getWindowAspectRatio(), 0.1, 1000 );
	mMayaCam.setCurrentCam( initialCam );

	mFeatureSurf	= Surface32f( 32, 32, false );	// we can store up to 1024 values(32x32)
	mFeatureTex	= gl::Texture( 32, 32 );
}
Example #20
0
void AudioObjApp::resize()
{
	CameraPersp cam;
    cam.setPerspective( 45.0f, getWindowAspectRatio(), 0.1, 10000 );
	mMayaCam.setCurrentCam( cam );

}
Example #21
0
void rayMarcherApp::setup()
{
    CameraPersp cam;
    mStartEyePoint = Vec3f( 15, 21, 27.5 ) * 0.65f;
    cam.lookAt( mStartEyePoint, Vec3f::zero(), Vec3f::yAxis() );
    cam.setCenterOfInterest( mStartEyePoint.distance( Vec3f::zero() ) );
    mMayaCam.setCurrentCam( cam );
}
void AudioVisualizerApp::mouseDown( MouseEvent event )
{
	// handle mouse down
	mIsMouseDown = true;

	mMayaCam.setCurrentCam(mCamera);
	mMayaCam.mouseDown( event.getPos() );
}
Example #23
0
void _TBOX_PREFIX_App::resize()
{
	console() << getWindowBounds();
	CameraPersp cam = mMayaCam.getCamera();
	cam.setAspectRatio( getWindowAspectRatio() );
	mMayaCam.setCurrentCam( cam );
	gl::enableDepthRead();
}
Example #24
0
void CameraLensShiftTestApp::resize()
{
	mCamera.setAspectRatio( event.getAspectRatio() * 0.5f );

	CameraPersp cam( mOverview.getCamera() );
	cam.setAspectRatio( event.getAspectRatio() * 0.5f );
	mOverview.setCurrentCam( cam );
}
void StereoscopicRenderingApp::resize()
{
	// make sure the camera's aspect ratio remains correct
	mCamera.setAspectRatio( getWindowAspectRatio() );
	mMayaCam.setCurrentCam( mCamera );

	// create/resize the Frame Buffer Object required for some of the render methods
	createFbo();
}
Example #26
0
void GizmoSampleApp::keyDown( KeyEvent event ){
    if( event.getChar() == '1' ) mGizmo->setMode( Gizmo::TRANSLATE );
    else if( event.getChar() == '2' ) mGizmo->setMode( Gizmo::ROTATE );
    else if( event.getChar() == '3' ) mGizmo->setMode( Gizmo::SCALE );
    else if( event.getChar() == 'o' ) {
        CameraPersp centered = mCamUI.getCamera();
        centered.setCenterOfInterestPoint( mGizmo->getTranslate() );
        mCamUI.setCurrentCam( centered );
    }
}
Example #27
0
void rayMarcherApp::resize( int width, int height )
{
    mImageSurface = shared_ptr<Surface8u>( new Surface8u( getWindowWidth(), getWindowHeight(), false ) );
    mImageTexture = gl::Texture( *mImageSurface );
    mCurrentLine = 0;

    CameraPersp cam = mMayaCam.getCamera();
    cam.setPerspective( 45, getWindowWidth() / (float)getWindowHeight(), 0.1f, 100.0f );
    mMayaCam.setCurrentCam( cam );
}
Example #28
0
void GizmoSampleApp::setup()
{
    // Create a reference to our gizmo object 
    mGizmo = Gizmo::create( getWindowSize() );    
    
    // Create the cam interface
    CameraPersp cam;
    cam.setEyePoint( Vec3f( 0.0f, 300.0f, 500.0f ) );
	cam.setPerspective(50, getWindowWidth() / (float) getWindowHeight(), 1, 10000 );
	cam.setCenterOfInterestPoint( Vec3f::zero() );
	mCamUI.setCurrentCam( cam );
}
Example #29
0
void GeometryApp::mouseDown( MouseEvent event )
{
	mRecenterCamera = false;

	mMayaCam.setCurrentCam( mCamera );
	mMayaCam.mouseDown( event.getPos() );

	if( getElapsedSeconds() - mLastMouseDownTime < 0.2f ) {
		mPrimitiveSelected = static_cast<Primitive>( static_cast<int>(mPrimitiveSelected) + 1 );
		createGeometry();
	}

	mLastMouseDownTime = getElapsedSeconds();
}
void StereoscopicRenderingApp::resize( ResizeEvent event )
{
	// make sure the camera's aspect ratio remains correct
	mCamera.setAspectRatio( event.getAspectRatio() );	
	mMayaCam.setCurrentCam( mCamera );

	// create/resize the FBO's required for anaglyph rendering
	gl::Fbo::Format fmt;
	fmt.setMagFilter( GL_LINEAR );
	fmt.setSamples(8);

	mAnaglyphLeft = gl::Fbo( event.getWidth(), event.getHeight(), fmt );
	mAnaglyphRight = gl::Fbo( event.getWidth(), event.getHeight(), fmt );
}