Example #1
0
void MemExploreApp::update()
{
  Vec2f center = getWindowCenter();

  mCameraArcball.resetQuat();
  mCameraArcball.mouseDown(center);
  mCameraArcball.mouseDrag(getWindowSize() - mMousePos);
  mCamera.setOrientation(mCameraArcball.getQuat() * mCamera.getOrientation());

  // Reset mouse position to center of screen
  if(mIsFullscreen) {
    Vec2f center = getWindowCenter();
    CGSetLocalEventsSuppressionInterval(0.0);
    CGWarpMouseCursorPosition(CGPointMake(center.x, center.y));
    mMousePos = center;
  }

  float speed = 0.01f;
  Vec3f camX = mCamera.getOrientation() * Vec3f::xAxis() * speed;
  Vec3f camY = mCamera.getOrientation() * Vec3f::yAxis() * speed;
  Vec3f camZ = mCamera.getOrientation() * Vec3f::zAxis() * speed;
  
  if(mKeysDown.count('w')) mCameraAcc -= camZ;
  if(mKeysDown.count('a')) mCameraAcc -= camX;
  if(mKeysDown.count('s')) mCameraAcc += camZ;
  if(mKeysDown.count('d')) mCameraAcc += camX;
  if(mKeysDown.count('q')) mCameraAcc += camY;
  if(mKeysDown.count('e')) mCameraAcc -= camY;

  mCameraVel += mCameraAcc;
  mCamera.setEyePoint(mCamera.getEyePoint() + mCameraVel);
  mCameraVel *= 0.975f;
  mCameraAcc *= 0.8f;
}
Example #2
0
void fsExperiments::draw()
{
	gl::clear( mBackground );

	CameraPersp cam( getWindowWidth(), getWindowHeight(), 60.0f );
	cam.setPerspective( 60, getWindowAspectRatio(), 1, 5000 );
	cam.lookAt( Vec3f( 0, 0, mEyeDistance ), Vec3f::zero(), Vec3f( 0, -1, 0 ) );
	gl::setMatrices( cam );

	gl::setViewport( getWindowBounds() );

	gl::enableDepthRead();
	gl::enableDepthWrite();

	GlobalData& data = GlobalData::get();

	gl::pushModelView();
	gl::rotate( mArcball.getQuat() );
	gl::rotate( data.mHeadRotation );

	mEffects[ mCurrentEffect ]->draw();

	gl::popModelView();

	params::PInterfaceGl::draw();
}
void BasicShaderIIApp::draw()
{
	gl::clear( Color::black() ); 
	// Draw FPS
	gl::color( Color::white() );
	mTextureFont->drawString( toString( floor(getAverageFps()) ) + " FPS", Vec2f( 100, getWindowHeight() - mTextureFont->getDescent() ) );
    
    gl::pushMatrices();
	gl::setMatrices( mCam );
    gl::enableAlphaBlending();
    
	// draw interface
	params::InterfaceGl::draw();
	
	if( mDoSave )
	{	// save non-conflicting image
		// includes interface to record parameters
		saveFrame();
		mDoSave = false;
	}
    
    mShader.bind();
    mShader.uniform("lightDir", mLightDir );   
    
    gl::pushMatrices();
    gl::rotate( mArcball.getQuat() );
    gl::draw( mVBO );
    gl::popMatrices();
    mShader.unbind();     
    
    gl::popMatrices();
}
void ImageHFApp::draw()
{
    gl::clear();

    gl::pushModelView();
		gl::translate( vec3( 0.0f, 0.0f, mHeight / 2.0f ) );
		gl::rotate( mArcball.getQuat() );
		if( mVboMesh )
			gl::draw( mVboMesh );
    gl::popModelView();
}
Example #5
0
void ObjLoaderApp::draw()
{
    gl::enableDepthWrite();
    gl::enableDepthRead();

    gl::clear( Color( 0.0f, 0.1f, 0.2f ) );

    gl::setMatrices( mCam );

    gl::pushMatrices();
    gl::rotate( mArcball.getQuat() );
    mBatch->draw();
    gl::popMatrices();
}
Example #6
0
void BasicApp::draw()
{
	dx::clear( Color( 0, 0, 0 ), true );

	dx::pushModelView();
	dx::translate( vec3( 800.0f, 500.0f, mHeight / 2.0f ) );
	dx::rotate( mArcball.getQuat() );
	if ( mVboMesh )
		dx::draw( mVboMesh );
	dx::popModelView();

	std::stringstream s;
	s << "Framerate:" << getAverageFps();
	dx::drawString(s.str(),vec2(10.0f,10.0f),Color::white(),mFont);
}
Example #7
0
// this draws with the sphere and axes to help undertand how arcball works
void ArcballDemoApp::drawVerbose()
{
	// draw the cube
	gl::pushModelView();
		gl::translate( getWindowCenter() );
		gl::scale( Vec3f( 200.0f, 200.0f, 200.0f ) );	
		gl::rotate( mArcball.getQuat() );
		gl::drawColorCube( Vec3f::zero(), Vec3f( 1, 1, 1 ) );
	gl::popModelView();

	// draw the back faces of the sphere
	gl::pushModelView();
		glColor4f( 0.0, 0.0, 0.0, 0.3f );
		gl::disableDepthWrite();
		gl::translate( getWindowCenter() );
		glCullFace( GL_FRONT );
		gl::drawSphere( Vec3f::zero(), mArcball.getRadius(), 50 );
	gl::popModelView();

	gl::enableDepthWrite();
	glCullFace( GL_BACK );

	// draw the axes
	gl::pushModelView();
		gl::translate( getWindowCenter() );
		
		// start
		glColor4f( 1.0, 1.0, 0.0f, 1.0f );
		gl::drawVector( Vec3f::zero(), mArcball.mouseOnSphere( mInitialMouseDown ) * mArcball.getRadius(), 10, 5 );
		
		// end
		glColor4f( 0.0, 1.0, 0.0f, 1.0f );
		gl::drawVector( Vec3f::zero(), mArcball.mouseOnSphere( mCurrentMouseDown ) * mArcball.getRadius(), 10, 5 );
		
		// constraint
		if( mUseConstraintAxis ) {
			glColor4f( 0.0, 0.7f, 1.0f, 1.0f );
			gl::drawVector( mConstraintAxis * -mArcball.getRadius() * 1.5, mConstraintAxis * mArcball.getRadius() * 1.5, 10, 5 );		
		}
	gl::popModelView();

	// draw the front faces of the sphere
	gl::pushModelView();
		glColor4f( 0.0, 0.0, 0.0, 0.3f );
		gl::translate( getWindowCenter() );
		gl::drawSphere( Vec3f::zero(), mArcball.getRadius(), 50 );
	gl::popModelView();	
}
Example #8
0
void ArcballTestApp::draw()
{
	CameraPersp &cam = ( mUsingCameraUi ) ? mDebugCam : mCam;
	gl::clear( Color( 0, 0.0f, 0.15f ) );
	gl::setMatrices( cam );

	// draw the earth
	gl::enableDepthRead();
	gl::enableDepthWrite();
	gl::translate( mEarthSphere.getCenter() );
	gl::rotate( mArcball.getQuat() );
	mEarthTex->bind();
	mEarth->draw();

	// draw constraint axis
	if( mArcball.isUsingConstraint() ) {
		gl::setMatrices( cam );
		gl::color( 1, 1, 0 );
		gl::translate( mEarthSphere.getCenter() );
		gl::rotate( glm::rotation( vec3( 0, 1, 0 ), mArcball.getConstraintAxis() ) );
		mConstraintAxis->draw();
	}

	gl::disableDepthRead();

	// draw from vector marker
	gl::setMatrices( cam );
	gl::color( 0, 1, 0.25f );
	gl::translate( mEarthSphere.getCenter() + mArcball.getFromVector() * mEarthSphere.getRadius() );
	mMarker->draw();

	// draw to vector marker
	gl::setMatrices( cam );
	gl::color( 1, 0.5f, 0.25f );
	gl::translate( mEarthSphere.getCenter() + mArcball.getToVector() * mEarthSphere.getRadius() );
	mMarker->draw();

	// draw the elliptical axes
	gl::setMatricesWindow( getWindowSize() );
	gl::color( 1, 0, 0 );
	vec2 center, axisA, axisB;
	mCam.calcScreenProjection( mEarthSphere, getWindowSize(), &center, &axisA, &axisB );
	gl::drawLine( center - axisA, center + axisA );
	gl::drawLine( center - axisB, center + axisB );
}
Example #9
0
void camerasApp::draw()
{
	gl::clear( Color( 0, 0.1f, 0.2f ) );
    
    // draw the cube
	gl::pushMatrices();
    gl::translate( getWindowCenter() );
    gl::rotate( mArcball.getQuat() );
    if(mTexture) {
        mTexture->enableAndBind();
        gl::drawCube(Vec3f::zero(), Vec3f(320,320,320));
        mTexture->unbind();
    }
	gl::popMatrices();
    


}
Example #10
0
void ArcballDemoApp::draw()
{
	gl::clear( Color( 0, 0.1f, 0.2f ) );

	if( mDrawVerbose )
		drawVerbose();
	else {
		// the order of operations is important here - we don't want the rotation applied to the scale
		// and likewise, we don't want the translation applied to the scale 
		// So the code below:
		// 1) rotates the cube by the quaternion that arcball has provided
		// 2) scales the cube to be 200 pixels big
		// 3) moves the cube to the center of the window
		gl::pushModelView();
			glCullFace( GL_BACK );
			gl::translate( getWindowSize() / 2.0f );
			gl::scale( Vec3f( 200.0f, 200.0f, 200.0f ) );	
			gl::rotate( mArcball.getQuat() );
			gl::drawColorCube( Vec3f::zero(), Vec3f( 1, 1, 1 ) );
		gl::popModelView();		
	}
}
Example #11
0
void gpuPSApp::draw()
{
	gl::setMatrices( mCam );
	gl::setViewport( getWindowBounds() );
	gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 1.0f ) );
	
	mFBO[mCurrentFBO].bindTexture(0,0);
	mDisplShader.bind();
	mDisplShader.uniform("displacementMap", 0 );
	gl::pushModelView();
	gl::translate( Vec3f( 0.0f, 0.0f, getWindowHeight() / 2.0f ) );
	gl::rotate( mArcball.getQuat() );
	gl::draw( mVboMesh );
    gl::popModelView();
	
	mDisplShader.unbind();
	mFBO[mCurrentFBO].unbindTexture();
	
	gl::setMatricesWindow(getWindowSize());
	gl::drawString( toString( SIDE*SIDE ) + " vertices", Vec2f(32.0f, 32.0f));
	gl::drawString( toString((int) getAverageFps()) + " fps", Vec2f(32.0f, 52.0f));
}
void wellingtonModelApp::draw()
{
    
    gl::enableDepthRead();
    gl::enableDepthWrite();
    gl::enableAlphaBlending();
    
    // clear out the window with black
	gl::clear( Color( 0, 0, 0 ) );
    
    /*
     if(mWaterModule != NULL){
     gl::pushMatrices();
     mWaterModule->draw();
     gl::popMatrices();
     }
     */
    
    
//    /*
    gl::setMatrices( mMayaCam.getCamera());
    
    gl::pushMatrices();
    myImage.enableAndBind();
    gl::rotate( mArcball.getQuat() );
    gl::scale(Vec3f(0.035,0.035,0.035));
    glLineWidth(0.3f);
    gl::enableWireframe();
    gl::rotate(Vec3f(50.0, -20.0, 0.0));
    gl::draw(mVbo);
    myImage.unbind();
    gl::popMatrices();
     
//     */
    
 
    
}
Example #13
0
void ObjLoaderApp::draw()
{
	gl::enableDepthWrite();
	gl::enableDepthRead();
	
	gl::clear( Color( 0.0f, 0.1f, 0.2f ) );
	glDisable( GL_CULL_FACE );

	gl::setMatrices( mMayaCam.getCamera() );

/*	Sphere boundingSphere = Sphere::calculateBoundingSphere( mMesh.getVertices() );
	glColor3f( 1.0f, 1.0f, 1.0f );
	gl::disableDepthWrite();
	mTexture->disable();
	mShader.unbind();
	gl::draw( boundingSphere, 30 );
	gl::enableDepthWrite();
*/
	mShader.bind();
	gl::pushMatrices();
		gl::rotate( mArcball.getQuat() );
		gl::draw( mVBO );
	gl::popMatrices();
}
void CinderProjectionTestApp::draw()
{
	
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ), true );
	
	
	gl::enableDepthRead();
	gl::enableDepthWrite();
	
	//gl::enableAlphaBlending();
	
	
	if ( mActiveCam == CAM_LOOK )
	{
		gl::setMatrices( mLookCam );
		gl::rotate( mArcball.getQuat() );
	}
	else if ( mActiveCam == CAM_SWEET )
		gl::setMatrices( mSweetCam );
	else if ( mActiveCam == CAM_PROJ )
		gl::setMatrices( mProjCam );
	
	// Green = Cam from 'sweet spot'
	gl::color( Color( 0, 1, 0 ) );
	gl::drawFrustum( mSweetCam );
	
	// Cyan = Cam from projector
	gl::color( Color( 0, 1, 1 ) );
	gl::drawFrustum( mProjCam );
	
	// Draw a grid in the yz plane
	gl::color( Color( 0.2f, 0.2f, 0.2f ) );
	gl::pushMatrices();
	gl::scale(Vec3f::one() /5 );
	for (int i=0; i<=20; ++i)
	{
		gl::drawLine(Vec3f(-100.0f+(i*10.0f), 0.0f, -100.0f),Vec3f(-100.0f+(i*10.0f), 0.0f, 100.0f));
		gl::drawLine(Vec3f(-100.0f, 0.0f, -100.0f+(i*10.0f)),Vec3f(100.0f, 0.0f, -100.0f+(i*10.0f)));
	}
	gl::popMatrices();
	
	gl::color( Color::white() );
	
	//glEnable( GL_LIGHTING );
	//glEnable( GL_LIGHT0 );
	//GLfloat light_position[] = { mMousePos.x, mMousePos.y, 75.0f, 1.0f };
	//glLightfv( GL_LIGHT0, GL_POSITION, light_position );
	
	
	// Bind texture, so it will be avaible to the fragment shader.
	mTexture.bind();
    // Bind the texture projection shader, let the magic happen!
    mProjShader.bind();
    
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    mProjShader.uniform("projMap", 0);
    mProjShader.uniform("TexGenMat", mSweetCam.getProjectionMatrix() );
    mProjShader.uniform("InvViewMat", mProjCam.getInverseModelViewMatrix() );
	mProjShader.uniform("texScaling", mTextureScaling );
	//mProjShader.uniform("alpha", 0.6f );
    //mProjShader.uniform("scaling", 10.0f );
	
	gl::pushModelView();
	//gl::rotate( Vec3f( 0.0f, 45.0f, 0.0f ) );
	gl::rotate( mCubeRotation );
	gl::translate( Vec3f(0.0f, 0.5f * mCubeSize, 0.0f) );
	gl::drawColorCube( Vec3f::zero(), Vec3f::one() * mCubeSize );
	gl::popModelView();
	
	
    
    mProjShader.unbind();
	mTexture.unbind();
	
	glDisable( GL_LIGHTING );
	
	gl::color( Color::white() );
	
	
	// Draw the interface
	params::InterfaceGl::draw();
}