void PaintingBeingsApp::resetCamera()
{
	float eyeZ = static_cast<float>(_rectangleTextutre.getWidth()) * 2.5f;

	if (_showImageBeing)
		eyeZ = static_cast<float>(_image.getMiniatureSize()) * 2.5f;

	float radiusArcBall = static_cast<float>(getWindowHeight() * 0.5f);

	float fieldOfView = 75.0f;
	float nearCamera = 0.1f;
	float farCamera = 1000000.0f;
	_camera = CameraPersp(getWindowWidth(), getWindowHeight(), fieldOfView, nearCamera, farCamera);

	_camera.lookAt(Vec3f(0.0f, 0.0f, eyeZ), Vec3f::zero());
	_arcball = Arcball(getWindowSize());
	_arcball.setRadius(radiusArcBall);
}
void PaintingBeingsApp::setup()
{	
	setStop();

	// Setup des paramètres de OpenGL
	glShadeModel(GL_SMOOTH);
	gl::enable(GL_POLYGON_SMOOTH);
	glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
	gl::enableAlphaBlending();
	gl::enableDepthRead();
	gl::enableDepthWrite();

	// Setup Capture webcam
	_capture = Capture(640, 480);
	_capture.start();

	// Setup camera
	float fieldOfView = 75.0f;
	float nearCamera = 0.1f;
	float farCamera = 1000000.0f;
	_camera = CameraPersp(getWindowWidth(), getWindowHeight(), fieldOfView, nearCamera, farCamera);
	_camera.lookAt(Vec3f(0.0f, 0.0f, 50.0f), Vec3f::zero());

	// Setup arcball (camera rotation)
	float radiusArcBall = static_cast<float>(getWindowHeight() * 0.5f);
	_arcball = Arcball(getWindowSize());
	_arcball.setRadius(radiusArcBall);


	// Génération de la population d'ImageBeing
	_imageBeing = ImageBeing();

	_rectangleAlgoGen.set(-75.0f, 25.0f, -25.0f, -25.0f);
	_rectangleTextutre.set(25.0f, 25.0f, 75.0f, -25.0f);


	// Setup de l'interface
	_params = params::InterfaceGl("Options", Vec2i(200, 400));
	updateInterface(false);
}
예제 #3
0
void GpGpuApp::setup()
{
	// Load shaders
	try {
		mGlslProgDraw = gl::GlslProg::create( loadResource( RES_GLSL_DRAW_VERT ), loadResource( RES_GLSL_DRAW_FRAG ) );
	} catch ( gl::GlslProgCompileExc ex ) {
		console() << ex.what() << "\n";
		quit();
	}
	
	try {
		mGlslProgGpGpu0 = gl::GlslProg::create( loadResource( RES_GLSL_GPGPU_VERT ), loadResource( RES_GLSL_GPGPU0_FRAG ) );
	} catch ( gl::GlslProgCompileExc ex ) {
		console() << ex.what() << "\n";
		quit();
	}
	
	try {
		mGlslProgGpGpu1 = gl::GlslProg::create( loadResource( RES_GLSL_GPGPU_VERT ), loadResource( RES_GLSL_GPGPU1_FRAG ) );
	} catch ( gl::GlslProgCompileExc ex ) {
		console() << ex.what() << "\n";
		quit();
	}
	
	// Define all properties
	mArcball					= Arcball( getWindowSize() );
	mBrushSize					= 0.1f;
	mCamera						= CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 1.0f, 100000.0f );
	mEyePoint					= Vec3f( 0.0f, 20.0f, 256.0f );
	mFullScreen					= isFullScreen();
	mFullScreenPrev				= mFullScreen;
	mLightAmbient				= ColorAf::gray( 0.1f );
	mLightAttenuationConstant	= 0.1f;
	mLightAttenuationLinear		= 0.01f;
	mLightAttenuationQuadratic	= 0.001f;
	mLightDiffuse				= ColorAf( 0.9f, 0.3f, 0.667f );
	mLightPosition				= Vec3f( 11.38f, -1.39f, 59.74f );
	mLightSpecular				= ColorAf::white();
	mLightShine					= 1.0f;
	mMaterialAmbient			= 1.0f;
	mMaterialDiffuse			= 1.0f;
	mMaterialEmissive			= 0.0f;
	mMaterialSpecular			= 1.0f;
	mMesh						= gl::VboMesh::create( MeshHelper::createCube() );
	mMouseDown					= false;
	mMouse						= Vec2f::zero();
	mMouseVelocity				= Vec2f::zero();
	mParams						= params::InterfaceGl::create( "Params", Vec2i( 250, 400 ) );
	mSize						= Vec2i( 512, 512 );
	mSizePrev					= Vec2i::zero();
	mTextureBrush				= gl::Texture::create( loadImage( loadResource( RES_PNG_BRUSH ) ) );
	
	// Set up arcball
	mArcball.setRadius( (float)getWindowHeight() * 0.5f );
	
	// Set up parameters
	mParams->addParam( "Frame rate",		&mFrameRate,					"", true );
	mParams->addParam( "Full screen",		&mFullScreen,					"key=f" );
	mParams->addButton( "Quit",				bind( &GpGpuApp::quit, this ),	"key=q" );
	
	mParams->addSeparator( "" );
	mParams->addParam( "Brush size",		&mBrushSize,					"min=0.0 max=1.0 step=0.001" );
	mParams->addParam( "Size X",			&mSize.x,						"min=1 max=1024 step=1" );
	mParams->addParam( "Size Y",			&mSize.y,						"min=1 max=1024 step=1" );
	
	mParams->addSeparator( "" );
	mParams->addParam( "Light ambient",		&mLightAmbient );
	mParams->addParam( "Light att const",	&mLightAttenuationConstant,		"min=0.0 max=1.0 step=0.001" );
	mParams->addParam( "Light att line",	&mLightAttenuationLinear,		"min=0.0 max=1.0 step=0.0001" );
	mParams->addParam( "Light att quad",	&mLightAttenuationQuadratic,	"min=0.0 max=1.0 step=0.00001" );
	mParams->addParam( "Light diffuse",		&mLightDiffuse );
	mParams->addParam( "Light position",	&mLightPosition );
	mParams->addParam( "Light specular",	&mLightSpecular );
	mParams->addParam( "Light shine",		&mLightShine,					"min=0.0 max=100000.0 step=1.0" );
	
	mParams->addSeparator( "" );
	mParams->addParam( "Material ambient",	&mMaterialAmbient,				"min=0.0 max=1.0 step=0.001" );
	mParams->addParam( "Material diffuse",	&mMaterialDiffuse,				"min=0.0 max=1.0 step=0.001" );
	mParams->addParam( "Material emissive",	&mMaterialEmissive,				"min=0.0 max=1.0 step=0.001" );
	mParams->addParam( "Material specular",	&mMaterialSpecular,				"min=0.0 max=1.0 step=0.001" );
}
void VboMeshSampleApp::setup()
{
	// Setting an unrealistically high frame rate effectively
	// disables frame rate limiting
	setFrameRate( 10000.0f );
	setWindowSize( 800, 600 );

	// Set up OpenGL to work with default lighting
	glShadeModel( GL_SMOOTH );
	gl::enable( GL_POLYGON_SMOOTH );
	glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
	gl::enable( GL_NORMALIZE );
	gl::enableAlphaBlending();
	gl::enableDepthRead();
	gl::enableDepthWrite();

	// Load the texture map
	mTexture = gl::Texture( loadImage( loadResource( RES_TEXTURE ) ) );

	// Define properties
	mFrameRate			= 0.0f;
	mFullScreen			= false;
	mLightEnabled		= true;
	mMeshIndex			= 0;
	mNumSegments		= 48;
	mNumSegmentsPrev	= mNumSegments;
	mScale				= Vec3f::one();
	mTextureEnabled		= true;
	mWireframe			= false;
	
	// Set up the arcball
	mArcball = Arcball( getWindowSize() );
	mArcball.setRadius( (float)getWindowHeight() * 0.5f );
	
	// Set up the camera
	mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 0.0001f, 10.0f );
	mCamera.lookAt( Vec3f( 0.0f, 0.0f, -5.0f ), Vec3f::zero() );

	// Set up the light
	mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 );
	mLight->setAmbient( ColorAf::white() );
	mLight->setDiffuse( ColorAf::white() );
	mLight->setDirection( Vec3f::one() );
	mLight->setPosition( Vec3f::one() * -1.0f );
	mLight->setSpecular( ColorAf::white() );
	mLight->enable();

	// Define the mesh titles for the params GUI
	mMeshTitles.push_back( "Cube" );
	mMeshTitles.push_back( "Sphere" );
	mMeshTitles.push_back( "Cylinder" );
	mMeshTitles.push_back( "Cone" );
	mMeshTitles.push_back( "Circle" );
	mMeshTitles.push_back( "Square" );
	mMeshTitles.push_back( "Ring" );
	mMeshTitles.push_back( "Custom" );

	// Set up the params GUI
	mParams = params::InterfaceGl( "Params", Vec2i( 200, 320 ) );
	mParams.addParam( "Frame rate",		&mFrameRate,									"", true									);
	mParams.addSeparator();
	mParams.addParam( "Enable light",	&mLightEnabled,									"key=l"										);
	mParams.addParam( "Enable texture",	&mTextureEnabled,								"key=t"										);
	mParams.addParam( "Mesh type",		mMeshTitles, &mMeshIndex,						"keyDecr=m keyIncr=M"						);
	mParams.addParam( "Scale",			&mScale																						);
	mParams.addParam( "Segments",		&mNumSegments,									"keyDecr=s keyIncr=S min=3 max=1024 step=1"	);
	mParams.addParam( "Wireframe",		&mWireframe,									"key=w"										);
	mParams.addSeparator();
	mParams.addParam( "Full screen",	&mFullScreen,									"key=f"										);
	mParams.addButton( "Screen shot",	bind( &VboMeshSampleApp::screenShot, this ),	"key=space"									);
	mParams.addButton( "Quit",			bind( &VboMeshSampleApp::quit, this ),			"key=q"										);

	// Generate meshes
	createMeshes();
}