Exemplo n.º 1
0
void kinectSkelApp::setup()
{
	console() << "There are " << Kinect::getNumDevices() << " Kinects connected." << std::endl;

	mKinect = Kinect( Kinect::Device() ); // the default Device implies the first Kinect connected
	
	mParams = params::InterfaceGl( "KinectSkel", Vec2i( 200, 180 ) );
	mParams.addParam( "Kinect Tilt", &mKinectTilt, "min=-31 max=31 keyIncr=T keyDecr=t" );
	mParams.addParam( "lo thresh", &mLo, "min=.0 max=1.0 step=.025 keyIncr=L keyDecr=l" );
	mParams.addParam( "hi thresh", &mHi, "min=.0 max=1.0 step=.025 keyIncr=H keyDecr=h" );
	mParams.addParam( "dilate size", &mDilateSize, "min=3 max=20 step=1 keyIncr=D keyDecr=d" );
	mParams.addParam( "dilate iter", &mDilateIter, "min=1 max=10 step=1 keyIncr=F keyDecr=f" );
	mParams.addParam( "skel thresh", &mSkelThresh, "min=0 max=255 step=1 keyIncr=S keyDecr=s" );
	mLo = 0.5;
	mHi = 1.0;
	mDilateSize = 8;
	mDilateIter = 1;
	mKinectTilt = .0f;
	mSkelThresh = 0;
	mFboThresh = gl::Fbo(640, 480);
	mShader	= gl::GlslProg( loadResource( RES_VERT_ID ), loadResource( RES_FRAG_ID ) );
	mDepthTexture	= gl::Texture( 640, 480 );
	mColorTexture	= gl::Texture( 640, 480 );
	depthSurf = Surface8u(640, 480, true);
	
	kern00 = cv::Mat(5, 5, CV_32FC1, L0);
	kern45 = cv::Mat(5, 5, CV_32FC1, L45);
	kern90 = cv::Mat(5, 5, CV_32FC1, L90);
	kern135 = cv::Mat(5, 5, CV_32FC1, L135);
}
Exemplo n.º 2
0
void BasicApp::setup()
{
	setWindowSize(800, 600);

	configFilename = "config.xml"; 
	bgColor = Color::black();

	showRect = true;
	rectRot = 0.f;
	rectColor = ColorA::gray(0.5f);
	rectPosition = Vec3f::zero();

	showCircle = true;
	circleRadius = 70.f;
	circleColor = ColorA::gray(0.7f);
	circlePosition = Vec3f::zero();

	text = "Config Block for Cinder";

	doubleParam = 0.0; intParam = 0; quatfParam = Quatf();
	
	enumNames.push_back( "Orange" );
	enumNames.push_back( "Apple" );
	enumNames.push_back( "Banana" );
	enumValue = 0;

	//-----------------------------------------------------------------------------

    mParams = params::InterfaceGl( "Settings", Vec2i( 400, 550 ) );
    mConfig = new config::Config(&mParams);
    
    mParams.addParam("Configuration file name", &configFilename);
    mParams.addButton("Save config", bind(&BasicApp::saveConfig, this));
    mParams.addButton("Load config", bind(&BasicApp::loadConfig, this));
    mParams.addSeparator();
	
    mConfig->addParam("Background color", &bgColor);
    mConfig->addParam("Text", &text);
    mParams.addSeparator();

	mConfig->newNode("Rectangle");
    mConfig->addParam("Show rectangle", &showRect);
    mConfig->addParam("Rectangle rotation", &rectRot);
    mConfig->addParam("Rectangle color", &rectColor);
	mConfig->addParam("Rectangle position", &rectPosition);
    mParams.addSeparator();

	mConfig->newNode("Circle");
	mConfig->addParam("Show circle", &showCircle);
    mConfig->addParam("Circle radius", &circleRadius);
    mConfig->addParam("Circle color", &circleColor);
	mConfig->addParam("Circle position", &circlePosition);

	mConfig->newNode("Other");
	mConfig->addParam("Double type parameter", &doubleParam);
	mConfig->addParam("Int type parameter", &intParam);
	mConfig->addParam("Quatf type parameter", &quatfParam);
	mConfig->addParam("Enum type parameter", enumNames, &enumValue);

}
void kinectPointCloudApp::setup()
{	
	// SETUP PARAMS
	mParams = params::InterfaceGl( "KinectPointCloud", Vec2i( 200, 180 ) );
	mParams.addParam( "Scene Rotation", &mSceneRotation, "opened=1" );
	mParams.addParam( "Cam Distance", &mCameraDistance, "min=100.0 max=5000.0 step=100.0 keyIncr=s keyDecr=w" );
	mParams.addParam( "Kinect Tilt", &mKinectTilt, "min=-31 max=31 keyIncr=T keyDecr=t" );
	
	// SETUP CAMERA
	mCameraDistance = 1000.0f;
	mEye			= Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCenter			= Vec3f::zero();
	mUp				= Vec3f::yAxis();
	mCam.setPerspective( 75.0f, getWindowAspectRatio(), 1.0f, 8000.0f );
	
	// SETUP KINECT AND TEXTURES
	console() << "There are " << Kinect::getNumDevices() << " Kinects connected." << std::endl;
	mKinect			= Kinect( Kinect::Device() ); // use the default Kinect
	mDepthTexture	= gl::Texture( 640, 480 );
	
	// SETUP VBO AND SHADER	
	createVbo();
	mShader	= gl::GlslProg( loadResource( RES_VERT_ID ), loadResource( RES_FRAG_ID ) );
	
	// SETUP GL
	gl::enableDepthWrite();
	gl::enableDepthRead();
}
Exemplo n.º 4
0
 KinectDepthSource(params::InterfaceGl& params)
 : mTilt(0)
 , mEnableIR(false)
 {
   params.addParam( "Tilt", &mTilt, "min=-31 max=32");
   params.addParam( "Toggle IR", &mEnableIR);
 }
void FractalStudyApp::setup()
{
    // SETUP CAMERA
	mCameraDistance = 1200.0f;
	mEye			= Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCenter			= Vec3f( 0.0f, 0.0f, 0.0f );
	mUp				= Vec3f::yAxis();
	mCam.setPerspective( 75.0f, getWindowAspectRatio(), 5.0f, 2000.0f );
    
    
    //PARAMS
    mParams = params::InterfaceGl( "Control Panel", Vec2i( 200, 160 ) );
    mParams.addParam( "Scene Rotation", &mSceneRotation );
    mParams.addParam( "Eye Distance", &mCameraDistance, "min=50.0 max=1500.0 step=50.0 keyIncr=s keyDecr=w" );
    
    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
	
	gl::enableDepthWrite();
	gl::enableDepthRead();
	gl::enableAlphaBlending();
    
    glDisable( GL_TEXTURE_2D );
    
    mDirectional = 1.0f;
    
    camAngle = 0;
    
    mSaveFrame = false;
}
Exemplo n.º 6
0
void ColorTilesApp::setup()
{
    app::setWindowSize(1200, 800);
    gl::enableAlphaBlending();

    // Set up the camera.
    cameraDistance_ = 1000.0f;
    eye_ = Vec3f(0.0f, 0.0f, cameraDistance_);
    center_ = Vec3f::zero();
    up_ = Vec3f::yAxis();
    camera_.setPerspective(75.0f, getWindowAspectRatio(), 5.0f, 2000.0f);

    // Set up camera control.
    params_ = params::InterfaceGl("Color Tiles", Vec2i(225, 200));
    params_.addParam("Scene Rotation", &sceneRotation_);
    params_.addParam("Eye Distance", &cameraDistance_, "min=0.0 max=2000.0 step=50.0 keyIncr=s keyDecr=w");
    
    // Set up the initial set of tiles.
    for (int x = -HALF_WIDTH; x <= HALF_WIDTH; ++x) {
        for (int y = -HALF_WIDTH; y <= HALF_WIDTH; ++y) {
            for (int z = -HALF_WIDTH; z <= HALF_WIDTH; ++z) {
                int xpos = x * TILE_WIDTH;
                int ypos = y * TILE_HEIGHT;
                int zpos = z * TILE_WIDTH;
                
                Tile* tile = new Tile(xpos, ypos, zpos,
                                      TILE_WIDTH, TILE_HEIGHT, TILE_DEPTH);
                tiles_.push_back(tile);
            }
        }
    }
}
Exemplo n.º 7
0
void NIUserMaskApp::setup()
{
	try
	{
		mNI = ni::OpenNI( ni::OpenNI::Device() );
	}
	catch ( ... )
	{
		console() << "Could not open Kinect" << endl;
		quit();
	}

	mNIUserTracker = mNI.getUserTracker();

	mNI.setMirrored();
	mNI.start();

	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 100 ) );
	mBlurAmt = 15.0;
	mParams.addParam( "blur", &mBlurAmt, "min=1 max=15 step=.5" );
	mErodeAmt = 3.0;
	mParams.addParam( "erode", &mErodeAmt, "min=1 max=15 step=.5" );
	mDilateAmt = 7.0;
	mParams.addParam( "dilate", &mDilateAmt, "min=1 max=15 step=.5" );
	mThres = 128;
	mParams.addParam( "threshold", &mThres, "min=1 max=255" );
}
void SierpinskiTriangleChaos3DApp::setup()
{
    
    // SETUP CAMERA
	mCameraDistance = 1000.0f;
	mEye			= Vec3f( 0.0f, 300.0f, mCameraDistance );
	mCenter			= Vec3f( 0.0f, 300.0f, 0.0f );
	mUp				= Vec3f::yAxis();
	mCam.setPerspective( 75.0f, getWindowAspectRatio(), 5.0f, 3000.0f );
    
    
    //PARAMS
    mParams = params::InterfaceGl( "Control Panel", Vec2i( 200, 160 ) );
    mParams.addParam( "Scene Rotation", &mSceneRotation );
    mParams.addParam( "Eye Distance", &mCameraDistance, "min=50.0 max=1300.0 step=20.0 keyIncr=s keyDecr=w" );
    
    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
	
	gl::enableDepthWrite();
	gl::enableDepthRead();
	gl::enableAlphaBlending();
    
    glDisable( GL_TEXTURE_2D );
    
    mDirectional = 1.0f;
    
    marker1.set( 0.0f, 0.0f, 400.0f);
    marker2.set( -346.5f, 0.0f, -200.0f);
    marker3.set( 346.5f, 0.0f, -200.0f);
    marker4.set( 0.0f, 600.0f, 0.0f);
    
    thePoint.set( Rand::randFloat(-100.0f, 100.0f), Rand::randFloat(-100.0f, 100.0f), Rand::randFloat(-100.0f, 100.0f) );
    
    mSaveFrame = true;
}
Exemplo n.º 9
0
void f6_structure::setup()
{
	// SET WINDOW
	setWindowSize(1920, 1080);
	setFrameRate(30.f);
	gl::color(Color::black());

	// SETUP PARTICLE SYSTEMS
	ParticleSystem ps1;
	ps1.setup();
	pss.push_back(ps1);

	// SETUP LISTENER
	Listener& listener = Listener::getInstance();
	listener.setup();

	// SETUP TRACKER
	//t.setup();

	// SETUP PARAMS
	mParams = params::InterfaceGl("Parameters", Vec2i(200, 150));
	mParams.addParam("Particle ID", &pf.d_particleToCreate, "keyIncr=+ keyDecr=-");
	mParams.addSeparator();
	mParams.addParam("Total particles", &mTotalParticles, "readonly=1");
	mParams.addParam("Volume", &mVolume, "readonly=1");
	mParams.addParam("Scale", &listener.mScale, "min=0.1 max=40.0 step=0.1");
	
}
void ___PACKAGENAMEASIDENTIFIER___App::setup()
{
	try {
		mCapture = Capture( kCaptureWidth, kCaptureHeight );
		mCapture.start();
	} catch ( ... ) {
		console() << "Error with capture device." << std::endl;
		exit(1);
	}

	try {
		mShader = gl::GlslProg( loadResource( RES_SHADER_PASSTHRU ), loadResource( RES_SHADER_FRAGMENT ) );
	} catch ( gl::GlslProgCompileExc &exc ) {
		console() << "Cannot compile shader: " << exc.what() << std::endl;
		exit(1);
	}catch ( Exception &exc ){
		console() << "Cannot load shader: " << exc.what() << std::endl;
		exit(1);
	}
	
	mFbo = gl::Fbo( kWindowWidth, kWindowHeight );

	mMixColorRed = 0.0f;
	mMixColorGreen = 0.0f;
	mMixColorBlue = 0.0f;

	mParams = params::InterfaceGl( "Parameters", Vec2i( kParamsWidth, kParamsHeight ) );
	mParams.addParam( "Mix Red", &mMixColorRed, "min=-1.0 max=1.0 step=0.01 keyIncr=r keyDecr=R" );
	mParams.addParam( "Mix Green", &mMixColorGreen, "min=-1.0 max=1.0 step=0.01 keyIncr=g keyDecr=G" );
	mParams.addParam( "Mix Blue", &mMixColorBlue, "min=-1.0 max=1.0 step=0.01 keyIncr=b keyDecr=B" );


}
Exemplo n.º 11
0
void RDiffusionApp::setup()
{
	mReactionU = 0.25f;
	mReactionV = 0.04f;
	mReactionK = 0.047f;
	mReactionF = 0.1f;

	mMousePressed = false;
	
	// Setup the parameters
	mParams = params::InterfaceGl( "Parameters", Vec2i( 175, 100 ) );
	mParams.addParam( "Reaction u", &mReactionU, "min=0.0 max=0.4 step=0.01 keyIncr=u keyDecr=U" );
	mParams.addParam( "Reaction v", &mReactionV, "min=0.0 max=0.4 step=0.01 keyIncr=v keyDecr=V" );
	mParams.addParam( "Reaction k", &mReactionK, "min=0.0 max=1.0 step=0.001 keyIncr=k keyDecr=K" );	
	mParams.addParam( "Reaction f", &mReactionF, "min=0.0 max=1.0 step=0.001 keyIncr=f keyDecr=F" );
	
	gl::Fbo::Format format;
	format.enableDepthBuffer( false );
	
	mCurrentFBO = 0;
	mOtherFBO = 1;
	mFBOs[0] = gl::Fbo( FBO_WIDTH, FBO_HEIGHT, format );
	mFBOs[1] = gl::Fbo( FBO_WIDTH, FBO_HEIGHT, format );
	
	mShader = gl::GlslProg( loadResource( RES_PASS_THRU_VERT ), loadResource( RES_GSRD_FRAG ) );
	mTexture = gl::Texture( loadImage( loadResource( RES_STARTER_IMAGE ) ) );
	mTexture.setWrap( GL_REPEAT, GL_REPEAT );
	mTexture.setMinFilter( GL_LINEAR );
	mTexture.setMagFilter( GL_LINEAR );
	mTexture.bind( 1 );
	
	resetFBOs();
}
Exemplo n.º 12
0
void _TBOX_PREFIX_App::keyUp( KeyEvent event )
{
	if( event.getChar() == 'f' ) {
		app::setFullScreen( !app::isFullScreen() );
	} else if(event.getChar()==KeyEvent::KEY_SPACE) {
		mParams.maximize( !mParams.isMaximized() );
	}
}
Exemplo n.º 13
0
void SpriteSheetGeneratorApp::setup()
{
  mParams = params::InterfaceGl( "SpriteSheet Generator", Vec2i( 200, 200 ) );
  mParams.setOptions( "", "position='50 450'" );
  mParams.addParam( "Preview scaling", &mWindowScaling, "min=0.1 max=2.0 step=0.05");
  mParams.addParam( "Preview offset", &mPreviewOffset.y );
  mParams.addParam( "Output name", &mFilename );
  mParams.addButton( "Save sheet", [this](){ saveSpriteSheet(); } );
}
Exemplo n.º 14
0
    void setup() { // вызавется при запуске приложения
        objectPosition =  Vec3f::zero();
        cameraDistance = 500; // выставим значение по умолчанию от камеры до цели
        camera.setPerspective( 60.0f, getWindowAspectRatio(), 5.0f, 3000.0f ); // настроим преспективу камеры

        cameraParams = params::InterfaceGl( "Camera Settings", Vec2i( 225, 200 ) ); // создадим окно интерфейса (название, размер)
        cameraParams.addParam( "Scene Rotation", &sceneRotation ); // окно может управлять вращением сцены
        cameraParams.addParam( "Eye Distance", &cameraDistance, "min=50.0 max=1000.0 step=50.0 keyIncr=s keyDecr=w" ); // окно может управлять расстоянием от того гда камера до того куда она смотрит (подробнее о параметрах http://anttweakbar.sourceforge.net/doc/tools%3aanttweakbar%3avarparamsyntax)
    }
void ForelleVisualAppApp::showClusterBar()
{
    bShowClusterBar = !bShowClusterBar;
    clusterBar.isVisible(bShowClusterBar);
    if(bShowClusterBar)
        menueBar.setOptions("Show ClusterBar" , "label='Hide ClusterBar'");
    else
        menueBar.setOptions("Show ClusterBar" , "label='Show ClusterBar'");

}
Exemplo n.º 16
0
void ContoursApp::setup()
{	
	mKinect = Kinect( Kinect::Device() );
	mKinectReady = false;
	mKinectIR = false;
	
	silhouetteDetector = new SilhouetteDetector(640,480);
	contours = new vector<vector<cv::Point> >();
	
	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 100 ) );
	mParams.addParam( "Near Threshold", &silhouetteDetector->mNearThreshold, "min=0 max=255 step=1.0 keyIncr=z keyDecr=Z" );
	mParams.addParam( "Far Threshold", &silhouetteDetector->mFarThreshold, "min=0 max=255 step=1.0 keyIncr=x keyDecr=X" );
	mParams.addParam( "Blur Amount", &silhouetteDetector->mBlurAmt, "min=0 max=20 step=1.0 keyIncr=b keyDecr=B" );
}
Exemplo n.º 17
0
void PolygonBooleanApp::setup()
{
	mParams = params::InterfaceGl( "App parameters", ivec2( 180, 100 ) );
	mParams.addButton( "Union", std::bind( &PolygonBooleanApp::doUnion, this ) );
	mParams.addButton( "Intersection", std::bind( &PolygonBooleanApp::doIntersection, this ) );
	mParams.addButton( "XOR", std::bind( &PolygonBooleanApp::doXor, this ) );
	mParams.addButton( "Difference", std::bind( &PolygonBooleanApp::doDifference, this ) );

	mPolyA = makePolyWithHole();
	mPolyAMesh = makeMesh( mPolyA );

	mPolyB = makeLetterA();	//makeStar();
	mPolyBMesh = makeMesh( mPolyB );
}
void ForelleVisualAppApp::keyDown( KeyEvent event )
{
   


    if( event.isAccelDown() &&  event.getCode()== app::KeyEvent::KEY_n  ) {
        
        if(menueBar.isVisible())
            menueBar.show(false);
        else
            menueBar.show(true);

    }
	else if( event.getCode() == app::KeyEvent::KEY_UP && !clusters.empty() ) {
		(*selectedCluster)->moveUp(1);
	}
	else if( event.getCode() == app::KeyEvent::KEY_DOWN && !clusters.empty()) {
            (*selectedCluster)->moveDown(1);
	}
    else if( event.getCode() == app::KeyEvent::KEY_LEFT && !clusters.empty() ) {
              (*selectedCluster)->moveLeft(1);
    }
    else if( event.getCode() == app::KeyEvent::KEY_RIGHT && !clusters.empty()) {
        (*selectedCluster)->moveRight(1);
    }
    else if( event.getCode() == app::KeyEvent::KEY_TAB ) {
        controller.changeSelectedCluster(clusters, selectedCluster);
    }    
    else  
    if(event.getCode() == app::KeyEvent::KEY_ESCAPE)
        setFullScreen(false);
	if(event.getCode() == 'f')
        setFullScreen(true);
    if(event.getCode() == '8')
        pos.y -=10;
    if(event.getCode() == '5')
        pos.y +=10;
    if(event.getCode() == '4')
        pos.x -=10;
    if(event.getCode() == '6')
        pos.x +=10;
    if(event.getCode() == app::KeyEvent::KEY_p){
        scale++;
    }
    if(event.getCode() == app::KeyEvent::KEY_m){
        scale--;
    }


}
void PaintingBeingsApp::draw()
{
	gl::clear(ColorAf::gray(0.6f));

	gl::setViewport(getWindowBounds());
	gl::setMatrices(_camera);

	glMultMatrixf(_arcball.getQuat());

	if (_showWireFrame)
		gl::enableWireframe();
	else
		gl::disableWireframe();

	if (_launchAlgoGen)
	{
		if (!_showImageBeing)
		{
			_image.getTexture().enableAndBind();
			gl::draw(_image.getTexture(), _rectangleTextutre);
			_image.getTexture().unbind();

			gl::Texture textureAlgoGen = _algoGen.getBestImage();
			textureAlgoGen.enableAndBind();
			gl::draw(textureAlgoGen, _rectangleAlgoGen);
			textureAlgoGen.unbind();
		}
		else
		{
			_imageBeing.draw(_algoGen.getBestImage());
		}
	}	

	_params.draw();
}
Exemplo n.º 20
0
void ocvWarpApp::setup()
{
    mInputImage = ci::Surface8u( loadImage( loadAsset( "aus.jpg" ) ) );

    mRotationCenter = vec2( mInputImage.getSize() ) * 0.5f;
    mRotationAngle = 31.2f;
    mScale = 0.77f;

    mParams = params::InterfaceGl( "Parameters", ivec2( 200, 400 ) );
    mParams.addParam( "Rotation Center X", &mRotationCenter.x );
    mParams.addParam( "Rotation Center Y", &mRotationCenter.y );
    mParams.addParam( "Rotation Angle", &mRotationAngle );
    mParams.addParam( "Scale", &mScale, "step=0.01" );

    updateImage();
}
Exemplo n.º 21
0
void ArmyDemoApp::draw()
{
	gl::clear( Color::black() );
	gl::setMatrices( mCamera );
	gl::translate( 0, -5.0f, 0.0f );
	gl::scale( vec3( 0.1f ) );
	
	if ( mEnableWireframe )
		gl::enableWireframe();
	
	for(int i=0; i < ROW_LEN; ++i) {
		for(int j=0; j < ROW_LEN; ++j ) {
			gl::pushModelMatrix();
			gl::translate(SPACING * (i - 0.5f * ROW_LEN), 0, SPACING * (j - 0.5f * ROW_LEN));
			mSkeletalMesh->setPose( mTime + 2.0f*( i * j )/NUM_MONSTERS );
			if( mDrawMesh ) {
				model::Renderer::draw( mSkeletalMesh );
			}
			if( mDrawSkeleton) {
				model::Renderer::draw( mSkeletalMesh->getSkeleton() );
			}
			gl::popModelMatrix();
		}
	}
	
	if ( mEnableWireframe )
		gl::disableWireframe();
	
	mParams.draw();
	
}
Exemplo n.º 22
0
void LookAroundYouApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) );
	
	// set up the camera
	gl::pushMatrices();
	gl::setMatrices( mMayaCam.getCamera() );
	
    
    for(int i=0; i<mBoids.size(); i++) {
        mBoids[i]->draw();
    }

    gl::drawCoordinateFrame( 6.0f );
    
	gl::popMatrices();
	
	// Draw the interface
	mParams.draw();
    
    float pos = music->getPlayheadNorm();
    Rectf bar(0, 0, app::getWindowWidth()*pos, 10);
    gl::drawSolidRect(bar);
}
Exemplo n.º 23
0
void ocvWarpApp::setup()
{		
	mInputImage = ci::Surface8u( loadImage( loadResource( RES_IMAGE ) ) );

	mRotationCenter = mInputImage.getSize() * 0.5f;
	mRotationAngle = 31.2f;
	mScale = 0.77f;
	
	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 400 ) );
	mParams.addParam( "Rotation Center X", &mRotationCenter.x );
	mParams.addParam( "Rotation Center Y", &mRotationCenter.y );
	mParams.addParam( "Rotation Angle", &mRotationAngle );
	mParams.addParam( "Scale", &mScale, "step=0.1" );

	updateImage();
}
void AnotherSandboxProjectApp::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    
    glUseProgram(_drawingProgram);
    glBindVertexArray(_drawingVAO);
    glBindBuffer(GL_ARRAY_BUFFER, _drawingVBO);
    
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_BUFFER, _gridTex);
    glBindSampler(0, 0);
    
    glProgramUniform2f(_drawingProgram, _drawingScreenSizeLoc, (GLfloat)getWindowWidth(), (GLfloat)getWindowHeight());
    
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
    glUseProgram(0);
    
    vec2 cellRectSize = vec2((float)getWindowWidth() / (float)_DSPController->getGridSize().x, (float)getWindowHeight() / (float)_DSPController->getGridSize().x);
    ivec2 mouseCell = (ivec2)((vec2)getMousePos() / cellRectSize);
    vec2 mouseCellPoint = (vec2)mouseCell * cellRectSize;
    
    gl::color(1.0, 0.0, 0.0);
    gl::drawSolidRect(Rectf(mouseCellPoint, mouseCellPoint + cellRectSize));
    
    _params.draw();
}
Exemplo n.º 25
0
void TweakBarApp::setup()
{
	mObjSize = 4;
	mLightDirection = Vec3f( 0, 0, -1 );
	mColor = ColorA( 0.25f, 0.5f, 1.0f, 1.0f );

	// setup our default camera, looking down the z-axis
	mCam.lookAt( Vec3f( -20, 0, 0 ), Vec3f::zero() );

	// Setup the parameters
	mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 400 ) );
	mParams.addParam( "Cube Size", &mObjSize, "min=0.1 max=20.5 step=0.5 keyIncr=z keyDecr=Z" );
	mParams.addParam( "Cube Rotation", &mObjOrientation );
	mParams.addParam( "Cube Color", &mColor, "" );	
	mParams.addSeparator();	
	mParams.addParam( "Light Direction", &mLightDirection, "" );
}
Exemplo n.º 26
0
void MatrixStudyApp::setup()
{
    // SETUP CAMERA
	mCameraDistance = 1200.0f;
	mEye			= Vec3f( 0.0f, 0.0f, mCameraDistance );
	mCenter			= Vec3f( 0.0f, 0.0f, 0.0f );
	mUp				= Vec3f::yAxis();
	mCam.setPerspective( 75.0f, getWindowAspectRatio(), 5.0f, 3000.0f );
    
    // CAMERA ROTATION
    xAngle = 0.0f;
    yAngle = 0.0f;
    zAngle = 0.0f;
    
    //PARAMS
    mParams = params::InterfaceGl( "Control Panel", Vec2i( 200, 160 ) );
    mParams.addParam( "Scene Rotation", &mSceneRotation );
    mParams.addParam( "Eye Distance", &mCameraDistance, "min=50.0 max=1500.0 step=50.0 keyIncr=s keyDecr=w" );
    mParams.addParam( "X Angle", &xAngle, "min=0.0 max=360.0 step=5.0 keyIncr=r keyDecr=f" );
    mParams.addParam( "Y Angle", &yAngle, "min=0.0 max=360.0 step=5.0 keyIncr=t keyDecr=g" );
    mParams.addParam( "Z Angle", &zAngle, "min=0.0 max=360.0 step=5.0 keyIncr=y keyDecr=h" );

    
    mDirectional = 1.0f;
    
    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
	
	gl::enableDepthWrite();
	gl::enableDepthRead();
	gl::enableAlphaBlending();
    
    glDisable( GL_TEXTURE_2D );
    
    
    // Set up coordinates
    
    mLocalStartPosition.set(100.0f, 100.0f, 0.0f);
    mLocalBasisRotation.set(20.0f, 30.0f, 45.0f);
    mLocalObjectRotation.set(0.0f, 30.0f, 60.0f);
    mLocalEndPosition.set( 0.0f, 300.0f, 0.0f); //I know what the local end position is because I'm drawing a cylinder of length 300. 
    
    mWorldEndPosition = getWorldEndPosition( mLocalStartPosition, mLocalBasisRotation, mLocalObjectRotation, mLocalEndPosition );
  
    mShowCube = true;
    
}
Exemplo n.º 27
0
void screenSaverTestApp::setup()
{
  Rand::randomize();
  gl::enableAlphaBlending();
  gl::clear( Color( 1.0, 1.0, 1.0) );
  glEnable(GL_LINE_SMOOTH);
  mReset = 0;
  mTime = getElapsedSeconds();
  mLastDraw = mTime;

  mStartingWidth = 11.0;
  mMaxDepth = 12;
  mSegmentLengthMin = 4;
  mSegmentLengthMax = 14;
  mBranchRotationMin = -13.0f;
  mBranchRotationMax = 11.0f;
  mProbBranch = 0.7f;
  mScaleReduction = 0.7f;
  mBranchRotationMin2 = 10.0f;
  mBranchRotationMax2 = 20.0f;

  // Setup the parameters
  mParams = params::InterfaceGl( "Parameters", Vec2i( 200, 400 ) );
  mParams.addParam( "Starting Width", &mStartingWidth, "min=1 max=20 step=1" );
  mParams.addParam( "Max Depth", &mMaxDepth, "min=1 max=20 step=1" );
  mParams.addParam( "Seg Length (min)", &mSegmentLengthMin, "min=1 max=30 step=1" );
  mParams.addParam( "Seg Length (max)", &mSegmentLengthMax, "min=1 max=30 step=1" );
  mParams.addParam( "Branch Rotation (min)", &mBranchRotationMin, "min=-360 max=360 step=1" );
  mParams.addParam( "Branch Rotation (max)", &mBranchRotationMax, "min=-360 max=360 step=1" );
  mParams.addParam( "Prob Branch", &mProbBranch, "min=0.0 max=1.0 step=0.05" );
  mParams.addParam( "Scale Reduction", &mScaleReduction, "min=0.0 max=1.0 step=0.05" );
  mParams.addParam( "Branch Rotation 2 (min)", &mBranchRotationMin2, "min=-360 max=360 step=1" );
  mParams.addParam( "Branch Rotation 2 (max)", &mBranchRotationMax2, "min=-360 max=360 step=1" );
}
Exemplo n.º 28
0
void DepthProcessor::setup(params::InterfaceGl& params)
{
	mStepFrom = 1;
	mAreaThreshold = 2000.0f;
  mDrawTex = dtDepth;

  std::vector<std::string> enumSource;
  enumSource.push_back("None");
  enumSource.push_back("Kinect");
  enumSource.push_back("Fake");
  enumSource.push_back("Recorded");
  params.addParam( "Depth Source", enumSource, (int*) &mDepthType);
	params.addParam( "Init frame amount", &mInitFrames, "min=0 max=300" );
	params.addParam( "Step from", &mStepFrom, "min=1 max=255" );
  params.addParam( "Depth LowPass filter", &mDepthLowPass, "min=0 max=255");
	params.addParam( "CV area threshold", &mAreaThreshold, "min=1");
  std::vector<std::string> enumDraw;
  enumDraw.push_back("Depth");
  enumDraw.push_back("Color");
  enumDraw.push_back("Contour");
  enumDraw.push_back("Background");
  params.addParam( "Texture", enumDraw, &mDrawTex);
  params.addParam( "Record Depth Data", &mRecordRequested);

  mKinectDepthSource = std::make_shared<KinectDepthSource>(params);
  mDepthSource = mKinectDepthSource;
  mFakeDepthSource = std::make_shared<FakeDepthSource>();
  mVideoDepthSource = std::make_shared<VideoDepthSource>();
  
  mProcessingThread = std::thread(std::bind(&DepthProcessor::threadFunc, this));
}
Exemplo n.º 29
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 );
}
Exemplo n.º 30
0
void HandTrackingApp::setup()
{
 
    mThreshold = 70.0f;
    mBlobMin = 20.0f;
    mBlobMax = 80.0f;
 
    mParams = params::InterfaceGl( "Hand Tracking", Vec2i( 10, 10 ) );
    mParams.addParam( "Threshold", &mThreshold, "min=0.0 max=255.0 step=1.0 keyIncr=s keyDecr=w" );
    mParams.addParam( "Blob Minimum Radius", &mBlobMin, "min=1.0 max=200.0 step=1.0 keyIncr=e keyDecr=d" );
    mParams.addParam( "Blob Maximum Radius", &mBlobMax, "min=1.0 max=200.0 step=1.0 keyIncr=r keyDecr=f" );
    mParams.addParam( "Kinect Tilt", &mKinectTilt, "min=-31 max=31 keyIncr=T keyDecr=t" );
 
    mKinect = Kinect( Kinect::Device() );
 
    mTargetPosition = Vec3f::zero();
 
}