void HttpClientApp::setup()
{
	gl::enable( GL_TEXTURE_2D );
	
	mBytesRead		= 0;
	mContentLength	= 0;
	mFont			= Font( "Georgia", 24 );
	mFrameRate		= 0.0f;
	mFullScreen		= false;
	mHost			= "127.0.0.1";
	mIndex			= 0;
	
	mHttpRequest = HttpRequest( "GET", "/", HttpVersion::HTTP_1_1 );
	mHttpRequest.setHeader( "Host",			mHost );
	mHttpRequest.setHeader( "Accept",		"*/*" );

	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 150 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,			"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addParam( "Image index",	&mIndex,				"min=0 max=3 step=1 keyDecr=i keyIncr=I" );
	mParams->addParam( "Host",			&mHost );
	mParams->addButton( "Write",		[ & ]() { write(); },	"key=w" );
	mParams->addButton( "Quit",			[ & ]() { quit(); },	"key=q" );
	
	mClient = TcpClient::create( io_service() );
	mClient->connectConnectEventHandler( &HttpClientApp::onConnect, this );
	mClient->connectErrorEventHandler( &HttpClientApp::onError, this );
	mClient->connectResolveEventHandler( &HttpClientApp::onResolve, this );
}
Exemplo n.º 2
0
void ServerApp::setup()
{
	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mMessage	= "Hello, client!";
	
	gl::enable( GL_TEXTURE_2D );
	mFont		= Font( "Georgia", 80 );
	mSize		= Vec2f( getWindowSize() );
	mText		= "Listening...";
	mTextPrev	= "";

	mServer.addConnectCallback( &ServerApp::onConnect, this );
	mServer.addDisconnectCallback( &ServerApp::onDisconnect, this );
	mServer.addErrorCallback( &ServerApp::onError, this );
	mServer.addInterruptCallback( &ServerApp::onInterrupt, this );
	mServer.addPingCallback( &ServerApp::onPing, this );
	mServer.addReadCallback( &ServerApp::onRead, this );

	mParams = params::InterfaceGl::create( "SERVER", Vec2i( 200, 100 ) );
	mParams->addParam( "Frame rate", &mFrameRate, "", true );
	mParams->addParam( "Fullscreen", &mFullScreen, "key=f" );
	mParams->addParam( "Message", &mMessage );
	mParams->addButton( "Write", bind( &ServerApp::write, this ), "key=w" );
	mParams->addButton( "Quit", bind( &ServerApp::quit, this ), "key=q" );

	mServer.listen( 9002 );
}
Exemplo n.º 3
0
void WebClientApp::setup()
{
	gl::enable( GL_TEXTURE_2D );
	
	mFont			= Font( "Georgia", 24 );
	mFrameRate		= 0.0f;
	mFullScreen		= false;
	mHost			= "libcinder.org";
	mPort			= 80;
	
	mHttpRequest = HttpRequest( "GET", "/", HttpVersion::HTTP_1_0 );
	mHttpRequest.setHeader( "Host", mHost );
	mHttpRequest.setHeader( "Accept", "*/*" );
	mHttpRequest.setHeader( "Connection", "close" );

	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 150 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,					"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addParam( "Host",			&mHost );
	mParams->addParam( "Port",			&mPort,							"min=0 max=65535 step=1 keyDecr=p keyIncr=P" );
	mParams->addButton( "Write", bind(	&WebClientApp::write, this ),	"key=w" );
	mParams->addButton( "Quit", bind(	&WebClientApp::quit, this ),	"key=q" );
	
	mClient = TcpClient::create( io_service() );
	mClient->connectConnectEventHandler( &WebClientApp::onConnect, this );
	mClient->connectErrorEventHandler( &WebClientApp::onError, this );
	mClient->connectResolveEventHandler( &WebClientApp::onResolve, this );
}
Exemplo n.º 4
0
void BasicApp::setup()
{	
	gl::enable( GL_TEXTURE_2D );
	
	mFrameRate	= 0.0f;
	mFullScreen	= false;

	mDevice = Kinect2::Device::create();
	mDevice->start();
	mDevice->connectBodyIndexEventHandler( [ & ]( const Kinect2::BodyIndexFrame& frame )
	{
		mChannelBodyIndex = frame.getChannel();
	} );
	mDevice->connectColorEventHandler( [ & ]( const Kinect2::ColorFrame& frame )
	{
		mSurfaceColor = frame.getSurface();
	} );
	mDevice->connectDepthEventHandler( [ & ]( const Kinect2::DepthFrame& frame )
	{
		mChannelDepth = frame.getChannel();
	} );
	mDevice->connectInfraredEventHandler( [ & ]( const Kinect2::InfraredFrame& frame )
	{
		mChannelInfrared = frame.getChannel();
	} );
	
	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 100 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,			"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addButton( "Quit",			[ & ]() { quit(); } ,	"key=q" );
}
void MultiUdpClientApp::setup()
{
	gl::enableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	
	mFont		= Font( "Georgia", 24 );
	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mHost		= "127.0.0.1";
	mPortLocal	= 0;
	mPortRemote	= 2000;
	mRequest	= "Hello, server!";
		
	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 150 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,					"", true );
	mParams->addParam( "Full screen",	&mFullScreen,					"key=f" );
	mParams->addParam( "Host",			&mHost );
	mParams->addParam( "Port",			&mPortRemote,
					  "min=0 max=65535 step=1 keyDecr=p keyIncr=P" );
	mParams->addParam( "Request",		&mRequest );
	mParams->addButton( "Write", bind(	&MultiUdpClientApp::write, this ),	"key=w" );
	mParams->addButton( "Quit", bind(	&MultiUdpClientApp::quit, this ),	"key=q" );

	mClient = UdpClient::create( io_service() );
	mServer = UdpServer::create( io_service() );

	mClient->connectConnectEventHandler( &MultiUdpClientApp::onConnect, this );
	mClient->connectErrorEventHandler( &MultiUdpClientApp::onError, this );
	mClient->connectResolveEventHandler( &MultiUdpClientApp::onResolve, this );

	mServer->connectAcceptEventHandler( &MultiUdpClientApp::onAccept, this );
	mServer->connectErrorEventHandler( &MultiUdpClientApp::onError, this );
}
Exemplo n.º 6
0
void FaceApp::setup()
{	
	gl::enableAlphaBlending();
	
	mEnabledFace2d	= true;
	mEnabledFace3d	= true;
	mFrameRate		= 0.0f;
	mFullScreen		= false;

	mDevice = Kinect2::Device::create();
	mDevice->start();
	mDevice->enableFaceMesh();
	mDevice->connectBodyEventHandler( [ & ]( const Kinect2::BodyFrame frame )
	{
	} );
	mDevice->connectColorEventHandler( [ & ]( const Kinect2::ColorFrame frame )
	{
		mSurface = frame.getSurface();
	} );
		
	mParams = params::InterfaceGl::create( "Params", Vec2i( 230, 130 ) );
	mParams->addParam( "Frame rate",		&mFrameRate,			"", true );
	mParams->addParam( "Full screen",		&mFullScreen ).key( "f" );
	mParams->addParam( "2d face tracking",	&mEnabledFace2d ).key( "2" );
	mParams->addParam( "3d face tracking",	&mEnabledFace3d ).key( "3" );
	mParams->addButton( "Quit",				[ & ]() { quit(); } ,	"key=q" );
}
Exemplo n.º 7
0
void ClientApp::setup()
{
	gl::enable( GL_TEXTURE_2D );
	mFont		= Font( "Georgia", 80 );
	mSize		= Vec2f( getWindowSize() );
	mText		= "";
	mTextPrev	= mText;

	mClient.addConnectCallback( &ClientApp::onConnect, this );
	mClient.addDisconnectCallback( &ClientApp::onDisconnect, this );
	mClient.addErrorCallback( &ClientApp::onError, this );
	mClient.addInterruptCallback( &ClientApp::onInterrupt, this );
	mClient.addPingCallback( &ClientApp::onPing, this );
	mClient.addReadCallback( &ClientApp::onRead, this );

	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mMessage	= "Hello, server!";
	mPing		= false;
	mPingTime	= getElapsedSeconds();

	mParams = params::InterfaceGl::create( "CLIENT", Vec2i( 200, 160 ) );
	mParams->addParam( "Frame rate", &mFrameRate, "", true );
	mParams->addParam( "Fullscreen", &mFullScreen, "key=f" );
	mParams->addParam( "Ping enabled", &mPing, "key=p" );
	mParams->addParam( "Message", &mMessage );
	mParams->addButton( "Connect", bind( &ClientApp::connect, this ), "key=c" );
	mParams->addButton( "Disconnect", bind( &ClientApp::disconnect, this ), "key=d" );
	mParams->addButton( "Write", bind( &ClientApp::write, this ), "key=w" );
	mParams->addButton( "Quit", bind( &ClientApp::quit, this ), "key=q" );

	connect();
}
Exemplo n.º 8
0
void UdpServerApp::setup()
{
	gl::enableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );

	mFont		= Font( "Georgia", 24 );
	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mPort		= 2000;
	mPortPrev	= mPort;
	
	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 110 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,					"", true );
	mParams->addParam( "Full screen",	&mFullScreen,					"key=f" );
	mParams->addParam( "Port",			&mPort,
					  "min=0 max=65535 step=1 keyDecr=p keyIncr=P" );
	mParams->addButton( "Quit", bind(	&UdpServerApp::quit, this ),	"key=q" );
	
	// Initialize a server by passing a boost::asio::io_service to it.
	// ci::App already has one that it polls on update, so we'll use that.
	// You can use your own io_service, but you will have to manage it 
	// manually (i.e., call poll(), poll_one(), run(), etc).
	mServer = UdpServer::create( io_service() );

	// Add callbacks to work with the server asynchronously.
	mServer->connectAcceptEventHandler( &UdpServerApp::onAccept, this );
	mServer->connectErrorEventHandler( &UdpServerApp::onError, this );
	
	// Start listening.
	accept();
}
void CameraComponent::loadGUI(const ci::params::InterfaceGlRef &gui)
{
    gui->addSeparator();
    gui->addText( mContext->getName() +" : "+ getName());
    auto updateFn = std::bind(&CameraComponent::updateCameraParams, this);
    gui->addParam( mContext->getName() +" : FOV", &mFov).updateFn(updateFn);
    gui->addParam( mContext->getName() +" : Far", &mFar).updateFn(updateFn);
    gui->addParam( mContext->getName() +" : Near", &mNear).updateFn(updateFn);
    gui->addParam( mContext->getName() +" : Interest Point", &mInterestPoint);

}
Exemplo n.º 10
0
void FtpClientApp::setup()
{
	gl::enable( GL_TEXTURE_2D );
	
	mFont			= Font( "Georgia", 24 );
	mFrameRate		= 0.0f;
	mFullScreen		= false;
	
	mParams = params::InterfaceGl::create( "Params", ivec2( 200, 120 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,			"", true );
    mParams->addParam( "Full screen",	&mFullScreen,           "key=f" );
    mParams->addButton( "Quit",			[ & ]() { quit(); },	"key=q" );
	
	mConnectionControl = TcpClientConnection::create( io_service() );

	mConnectionControl->connect( "www.bantherewind.com", 21 );
}
Exemplo n.º 11
0
void LeapApp::setup()
{
    gl::enable( GL_LINE_SMOOTH );
    glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
    gl::enable( GL_POLYGON_SMOOTH );
    glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );

    mCamera = CameraPersp( getWindowWidth(), getWindowHeight(), 60.0f, 1.0f, 1000.0f );
    mCamera.lookAt( Vec3f( 0.0f, 250.0f, 500.0f ), Vec3f( 0.0f, 250.0f, 0.0f ) );

    mDevice = Device::create();
    mDevice->connectEventHandler( &LeapApp::onFrame, this );

    mFrameRate	= 0.0f;
    mFullScreen	= false;
    mParams = params::InterfaceGl::create( "Params", Vec2i( 200, 105 ) );
    mParams->addParam( "Frame rate",	&mFrameRate,						"", true );
    mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
    mParams->addButton( "Screen shot",	bind( &LeapApp::screenShot, this ),	"key=space" );
    mParams->addButton( "Quit",			bind( &LeapApp::quit, this ),		"key=q" );
}
Exemplo n.º 12
0
void TcpClientApp::setup()
{	
	gl::enableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	
	mFont		= Font( "Georgia", 24 );
	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mHost		= "localhost";
	mPort		= 2000;
	mRequest	= "echo";
		
	mParams = params::InterfaceGl::create( "Params", Vec2i( 200, 150 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,					"", true );
	mParams->addParam( "Full screen",	&mFullScreen,					"key=f" );
	mParams->addParam( "Host",			&mHost );
	mParams->addParam( "Port",			&mPort,
					  "min=0 max=65535 step=1 keyDecr=p keyIncr=P" );
	mParams->addParam( "Request",		&mRequest );
	mParams->addButton( "Write", bind(	&TcpClientApp::write, this ),	"key=w" );
	mParams->addButton( "Quit", bind(	&TcpClientApp::quit, this ),	"key=q" );
	
	// Initialize a client by passing a boost::asio::io_service to it.
	// ci::App already has one that it polls on update, so we'll use that.
	// You can use your own io_service, but you will have to manage it 
	// manually (i.e., call poll(), poll_one(), run(), etc).
	mClient = TcpClient::create( io_service() );

	// Add callbacks to work with the client asynchronously.
	// Note that you can use lambdas.
	mClient->connectConnectEventHandler( &TcpClientApp::onConnect, this );
	mClient->connectErrorEventHandler( &TcpClientApp::onError, this );
	mClient->connectResolveEventHandler( [ & ]()
	{
		mText.push_back( "Endpoint resolved" );
	} );
}
Exemplo n.º 13
0
void ImageApp::setup()
{
	gl::enable( GL_TEXTURE_2D );
	
	mDevice = Device::create();
	mDevice->connectEventHandler( [ & ]( Leap::Frame frame )
	{
		mFrame = frame;
	} );

	mFrameRate	= 0.0f;
	mFullScreen	= false;
	mParams = params::InterfaceGl::create( "Params", Vec2i( 200, 105 ) );
	mParams->addParam( "Frame rate",	&mFrameRate,				"", true );
	mParams->addParam( "Full screen",	&mFullScreen ).key( "f" );
	mParams->addButton( "Screen shot",	[ & ]() { screenShot(); },	"key=space" );
	mParams->addButton( "Quit",			[ & ]() { quit(); },		"key=q" );
}
Exemplo n.º 14
0
void ImageFileBasicApp::setup()
{
	m_params = params::InterfaceGl::create("Params", ivec2(210, 210));
	m_params->addParam<bool>("Full Screen", [&](bool b)->void { setFullScreen(b); }, [&]()->bool { return isFullScreen(); }).key("g");	// Fails

	m_params->addParam("full screen", &m_bFullscreen).updateFn([this] 
	{	setFullScreen(m_bFullscreen);	CI_LOG_I("m_bFullscreen: " << m_bFullscreen); }).key("h");

	try {
		fs::path path = getOpenFilePath( "", ImageIo::getLoadExtensions() );
		if( ! path.empty() ) {
			mTexture = gl::Texture::create( loadImage( path ) );
		}
	}
	catch( Exception &exc ) {
		CI_LOG_EXCEPTION( "failed to load image.", exc );
	}
}
void OSCComponent::loadGUI(const ci::params::InterfaceGlRef &gui)
{
    gui->addSeparator();
    gui->addText( mContext->getName() +" : "+ getName());
    auto updateFn = [&]{ mListener.setup(mListenPort); };
    gui->addParam("listen port", &mListenPort).updateFn(updateFn);
    
    ///TODO:: change osc sender gui update
    
//    auto loadFn = [&]{
//        auto tree = ec::ConfigManager::get()->retreiveComponent(ec::Controller::get()->scene().lock()->getName(), mContext->getName(), getName() );
//        auto ip = tree["send_ip"].getValue();
//        auto port = tree["send_port"].getValue<int>();
//        mSendPort = port;
//        mSendIp = ip;
//        mSender.setup(mSendIp, mSendPort);
//    };
//    gui->addButton("reload osc sender", loadFn );

}
Exemplo n.º 16
0
void SegmentationApp::initInterface()
{
    interface->clear();
    
    if (guiMode == GUI_MODE::LOAD_IMAGE) {
        interface->addButton( "Open Image", std::bind( &SegmentationApp::openImage, this ) );        
    }
    else if (guiMode == GUI_MODE::LOAD_GROUNDTRUTH) {
        interface->addButton( "Open Ground Truth", std::bind( &SegmentationApp::openGroundTruth, this ) );
        //interface->addButton( "Open Doctor Image", std::bind( &SegmentationApp::openDoctorImage, this ) );
        interface->addSeparator();
        interface->addParam("filter radius", &filterRadius).min(0).max(10).step(1);
        interface->addButton( "Mean Filter", std::bind( &SegmentationApp::meanFilter, this ) );
        interface->addButton( "Median Filter", std::bind( &SegmentationApp::medianFilter, this ) );
        interface->addButton( "Min Filter", std::bind( &SegmentationApp::minFilter, this ) );
        interface->addButton( "Max Filter", std::bind( &SegmentationApp::maxFilter, this ) );
        interface->addSeparator();
        interface->addButton( "Get Hue", std::bind( &SegmentationApp::getHue, this ) );
        interface->addSeparator();
        interface->addParam("hue threshold", &hueThreshold).min(0).max(PI).step(.005).updateFn([this] () {
            thresholdHue(); });;
        interface->addParam("angle", &hueAngle).min(-PI).max(PI).step(.005).updateFn([this] () {
            thresholdHue(); });;
        interface->addButton( "threshold hue", std::bind( &SegmentationApp::thresholdHue, this ) );
        interface->addSeparator();
        interface->addParam("green weight", &greenWeight).min(0).max(5).step(.01).updateFn([this] () {
            experimentalColorDistance(); });;
        interface->addParam("blue weight", &blueWeight).min(0).max(5).step(.01).updateFn([this] () {
            experimentalColorDistance(); });;
        interface->addButton( "experimental threshold", std::bind( &SegmentationApp::experimentalColorDistance, this ) );
        interface->addSeparator();
        interface->addParam("otsus Iterations", &otsusIterations).min(1).max(5).step(1);

        interface->addButton( "otsus red", std::bind( &SegmentationApp::redOtsusThreshold, this ) );
        interface->addButton( "otsus green", std::bind( &SegmentationApp::greenOtsusThreshold, this ) );
        interface->addButton( "otsus blue", std::bind( &SegmentationApp::blueOtsusThreshold, this ) );
        interface->addButton( "otsus gray", std::bind( &SegmentationApp::grayOtsusThreshold, this ) );
        interface->addButton( "otsus best", std::bind( &SegmentationApp::multiImageOtsusThreshold, this ) );
        
        //interface->addButton( "otsus binary mask", std::bind( &SegmentationApp::otsusBinaryMask, this ) );
        //interface->addButton( "otsus color union", std::bind( &SegmentationApp::otsusColorUnion, this ) );
        interface->addSeparator();
        interface->addButton( "erode", std::bind( &SegmentationApp::erode, this ) );
        interface->addButton( "dilate", std::bind( &SegmentationApp::dilate, this ) );
        interface->addSeparator();
        interface->addButton( "get largest component", std::bind( &SegmentationApp::getLargestComponents, this ) );
        interface->addButton( "fill holes", std::bind( &SegmentationApp::fillHoles, this ) );
        interface->addSeparator();
        interface->addButton( "show result", std::bind( &SegmentationApp::showResult, this ) );

        //interface->addButton( "otsus edge intersection", std::bind( &SegmentationApp::otsusEdgeIntersection, this ) );
        //interface->addSeparator();
        //interface->addButton( "color gradient", std::bind( &SegmentationApp::getColorGradient, this ) );
        //interface->addButton( "thin edges", std::bind( &SegmentationApp::edgeThinColorGradient, this ) );
        interface->addSeparator();
        
        interface->addButton( "autoSegment", std::bind( &SegmentationApp::autoSegment, this ) );
        
        interface->addText( "Dice Coeddicient : " + std::to_string(diceCoefficientResult) );
        interface->addSeparator();
        interface->addButton( "Reset", std::bind( &SegmentationApp::reset, this ) );
        interface->addSeparator();
        interface->addButton( "Save Input", std::bind( &SegmentationApp::saveInputImage, this ) );
        interface->addButton( "Save Segmentation", std::bind( &SegmentationApp::saveSegmentedImage, this ) );
        interface->addButton( "Save Result", std::bind( &SegmentationApp::saveResultImage, this ) );
        
    }
    else if (guiMode == GUI_MODE::DO_TRAINING) {
        interface->addParam("filter radius", &filterRadius).min(0).max(10).step(1);
        interface->addButton( "Mean Filter", std::bind( &SegmentationApp::meanFilter, this ) );
        interface->addButton( "Median Filter", std::bind( &SegmentationApp::medianFilter, this ) );
        interface->addButton( "Min Filter", std::bind( &SegmentationApp::minFilter, this ) );
        interface->addButton( "Max Filter", std::bind( &SegmentationApp::maxFilter, this ) );
        interface->addSeparator();
        interface->addButton( "Open Doctor Image", std::bind( &SegmentationApp::openDoctorImage, this ) );
        interface->addSeparator();
        interface->addButton( "Train", std::bind( &SegmentationApp::trainImage, this ) );
    }
    else if (guiMode == GUI_MODE::DO_DOCTOR_TRAINING) {
        
        
        interface->addParam("filter radius", &filterRadius).min(0).max(10).step(1);
        interface->addButton( "Mean Filter", std::bind( &SegmentationApp::meanFilter, this ) );
        interface->addButton( "Median Filter", std::bind( &SegmentationApp::medianFilter, this ) );
        interface->addSeparator();
        interface->addButton( "Doctor Training", std::bind( &SegmentationApp::trainDoctorImage, this ) );
    }
    else if (guiMode == GUI_MODE::THRESHOLD) {
        interface->addButton( "Show Mean Distance", std::bind( &SegmentationApp::getColorDistance, this ) );
        interface->addButton( "Threshold Color", std::bind( &SegmentationApp::thresholdColor, this ) );
        interface->addParam("color distance", &colorThreshold).min(0.f).max(255.f).step(1).updateFn([this] () {
            thresholdColor(); });
        interface->addSeparator();
        interface->addButton( "Threshold Mahalonobis", std::bind( &SegmentationApp::thresholdMahalonobis, this ) );
        interface->addParam("mahalonobis distance", &mahalonobisThreshold).min(0.f).max(255.f).step(1);
    }
    interface->addSeparator();
    
}
Exemplo n.º 17
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" );
}
Exemplo n.º 18
0
void SpherePrimitive::AddParams(ci::params::InterfaceGlRef _params) {
	Primitive::AddParams(_params);
	_params->addParam(GetName() + "::Center", &mCenter, "group=" + GetName() + " label='Center'");
	_params->addParam(GetName() + "::Radius", &mRadius, "group=" + GetName() + " label='Radius'");
}