Exemplo n.º 1
0
void QuickTimeSampleApp::loadMovieFile( const fs::path &moviePath )
{
	try {
		// load up the movie, set it to loop, and begin playing
		mMovie = qtime::MovieGl::create( moviePath );
		mMovie->setLoop();
		mMovie->play();
		
		// create a texture for showing some info about the movie
		TextLayout infoText;
		infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
		infoText.setColor( Color::white() );
		infoText.addCenteredLine( moviePath.filename().string() );
		infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
		infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
		infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
		infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
		infoText.setBorder( 4, 2 );
		mInfoTexture = gl::Texture::create( infoText.render( true ) );
	}
	catch( ci::Exception &exc ) {
		console() << "Exception caught trying to load the movie from path: " << moviePath << ", what: " << exc.what() << std::endl;
		mMovie.reset();
		mInfoTexture.reset();
	}

	mFrameTexture.reset();
}
Exemplo n.º 2
0
void QuickTimeSampleApp::loadMovieFile( const fs::path& moviePath )
{
	try {
		// load up the movie, set it to loop, and begin playing
		mMovie = qtime::MovieGl( moviePath );
		mMovie.setLoop();
		mMovie.play();
		
		// create a texture for showing some info about the movie
		TextLayout infoText;
		infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
		infoText.setColor( Color::white() );
		infoText.addCenteredLine( getPathFileName( moviePath.string() ) );
		infoText.addLine( toString( mMovie.getWidth() ) + " x " + toString( mMovie.getHeight() ) + " pixels" );
		infoText.addLine( toString( mMovie.getDuration() ) + " seconds" );
		infoText.addLine( toString( mMovie.getNumFrames() ) + " frames" );
		infoText.addLine( toString( mMovie.getFramerate() ) + " fps" );
		infoText.setBorder( 4, 2 );
		mInfoTexture = gl::Texture( infoText.render( true ) );
	}
	catch( ... ) {
		console() << "Unable to load the movie." << std::endl;
		mMovie.reset();
		mInfoTexture.reset();
	}

	mFrameTexture.reset();
}
Exemplo n.º 3
0
AccordionItem::AccordionItem( Timeline &timeline, float x, float y, float height, float contractedWidth, float expandedWidth, gl::Texture image, string title, string subtitle ) 
	: mTimeline(timeline), mX(x), mY(y), mWidth(contractedWidth), mHeight(height), mExpandedWidth(expandedWidth), mImage(image), mTitle(title), mSubtitle(subtitle)
{
#if defined( CINDER_COCOA )
	std::string normalFont( "Arial" );
	std::string boldFont( "Arial-BoldMT" );
#else
	std::string normalFont( "Arial" );
	std::string boldFont( "ArialBold" );
#endif
	
	mAnimEase = EaseOutAtan(25);
	mAnimDuration = 0.7f;
	
	mTextAlpha = 0.0f;
	
	TextLayout layout;
	layout.clear( ColorA( 0.6f, 0.6f, 0.6f, 0.0f ) );
	layout.setFont( Font( boldFont, 26 ) );
	layout.setColor( Color( 1, 1, 1 ) );
	layout.addLine( mTitle );
	layout.setFont( Font( normalFont, 16 ) );
	layout.addLine( mSubtitle );
	layout.setBorder(11, 6);
	mText = gl::Texture( layout.render( true ) );
	
	update();
}
Exemplo n.º 4
0
void ciApp::draw()
{
	gl::clear();

	gl::ScopedColor white(Color::white());

	auto get_center_rect = [&](Area area) ->Rectf { return Rectf(area).getCenteredFit(getWindowBounds(), true); };

	{	
		//auto tex = filter->getTexture();
		auto tex = vector_blur.getTexture();
		gl::draw(tex, get_center_rect(tex->getBounds()));
	}
	
	{
		gl::ScopedMatrices scpMatrix;
		gl::scale(0.2f, 0.2f);
		gl::draw(mTexture);
	}

	vector_blur.drawDebug(vec2(0, 0), 0.2f);

	mParams->draw();

	{
		TextLayout infoFps;
		infoFps.clear(ColorA(0.2f, 0.2f, 0.2f, 0.5f));
		infoFps.setColor(Color::white());
		infoFps.setFont(Font("Arial", 16));
		infoFps.setBorder(4, 2);
		infoFps.addLine("App Framerate: " + tostr(getAverageFps(), 1));
		auto tex = gl::Texture::create(infoFps.render(true));
		gl::draw(tex, ivec2(20, getWindowHeight() - tex->getHeight() - 20));
	}
}
Exemplo n.º 5
0
void MovieLoaderApp::movieReady()
{
	mMovie->play();
	
	// create a texture for showing some info about the movie
	TextLayout infoText;
	infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
	infoText.setColor( Color::white() );
	infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
	infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
	infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
	infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
	infoText.setBorder( 4, 2 );
	mInfoTexture = gl::Texture( infoText.render( true ) );
}
Exemplo n.º 6
0
void ardroneApp::setInfo(const std::string& path, const std::string& errorMessage){
    // create a texture for showing some info about the movie
    TextLayout infoText;
    infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.25f ) );
    infoText.setColor( Color::white() );
    infoText.addCenteredLine( path);
    if (!errorMessage.empty()) {
        infoText.addLine(errorMessage);
    } else {
        infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
        if (mMovie->getDuration() > 0.f) infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
        infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
        infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
    }
    infoText.setBorder( 4, 2 );
    mInfoTexture = gl::Texture( infoText.render( true ) );
}
void MovieBasicApp::onReadySignal()
{    
	// create a texture for showing some info about the movie
	TextLayout infoText;
	infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
	infoText.setColor( Color::white() );
	infoText.addCenteredLine( mMoviePath.filename().string() );
	infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
	infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
	infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
	infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
	infoText.setBorder( 4, 2 );
	mInfoTexture = gl::Texture( infoText.render( true ) );

	mMovie->setVolume(1.0f);
	mMovie->play();
}
Exemplo n.º 8
0
	void loadMovieFile( const std::string &moviePath )
	{
		glEnable(GL_TEXTURE_RECTANGLE_ARB);
		gl::Texture::Format format;
		format.setTargetRect();

		try {
			// load up the movie, set it to loop, and begin playing
			mMovie = qtime::MovieGl( moviePath );
			mMovie.setLoop();
//			mMovie.play();

			// create a texture for showing some info about the movie
			TextLayout infoText;
			infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) );
			infoText.setColor( Color::white() );
			infoText.addCenteredLine( getPathFileName( moviePath ) );
			infoText.addLine( toString( mMovie.getWidth() ) + " x " + toString( mMovie.getHeight() ) + " pixels" );
			infoText.addLine( toString( mMovie.getDuration() ) + " seconds" );
			infoText.addLine( toString( mMovie.getNumFrames() ) + " frames" );
			infoText.addLine( toString( mMovie.getFramerate() ) + " fps" );
			infoText.setBorder( 4, 2 );
			mInfoTexture = gl::Texture( infoText.render( true ) );
			
			setWindowSize(mMovie.getWidth(), mMovie.getHeight());
			mHasMovie = true;
		}
		catch( ... ) {
			console() << "Unable to load the movie." << std::endl;
			mMovie.reset();
			mInfoTexture.reset();
			mHasMovie = false;
			//exit(1);
		}
		mFrameTexture.reset();
	}
Exemplo n.º 9
0
void QTimeline::init()
{
    QTimeline::thisRef      = this;
    
    mApp                    = ci::app::App::get();
    
    registerCallbacks();
    
    // initialise AT LEAST one color for the menu color palette
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.86f, 0.18f, 0.11f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 1.00f, 0.34f, 0.00f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.86f, 0.62f, 0.00f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.00f, 0.65f, 0.58f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.45f, 0.60f, 0.00f, 1.0f ) );
    QTimelineMenuColorPalette::mColors.push_back( ci::ColorA( 0.50f, 0.50f, 0.50f, 1.0f ) );

    mTimeline = ci::Timeline::create();
    
    mTransportRect  = Rectf( 0, getWindowHeight() - TIMELINE_TRANSPORT_HEIGHT, getWindowWidth(), getWindowHeight() );
    
    mFontSmall              = ci::gl::TextureFont::create( ci::Font( "Helvetica", 12 ) );
    mFontMedium             = ci::gl::TextureFont::create( ci::Font( "Helvetica", 14 ) );
    mFontBig                = ci::gl::TextureFont::create( ci::Font( "Helvetica", 16 ) );
    
    mZoom                   = 1.0f;
    
    mIsVisible              = true;
    
    mMouseDragTimeBar       = false;
    mMouseOnTimeBar         = false;
    
    mSelectedMenu           = NULL;
    
    mCueManager             = new QTimelineCueManager();
    
    // create default track
    mTracks.push_back( QTimelineTrackRef( new QTimelineTrack( "track 0" ) ) );
    
    play( false, FREE_RUN );
    
    mRenderDebug            = true;
    
    mRenderHelp             = false;
    
    TextLayout layout;
	layout.clear( ColorA( 0.0f, 0.0f, 0.0f, 0.8f ) );
    layout.setBorder( 5, 5 );
	layout.setFont( ci::Font( "Helvetica", 12 ) );
	layout.setColor( Color( 0.0f, 0.8f, 0.8f ) );
    layout.setLeadingOffset( 3 );
	layout.addLine( "HELP\n\n" );
	layout.addLine( "? \t\t\t\t toggle help\n" );
	layout.addLine( "space_bar \t\t play/pause FREE RUN mode\n" );
	layout.addLine( "return \t\t\t play/pause CUE LIST mode\n" );
	layout.addLine( "delete \t\t\t set time to 0\n\n" );
    mHelpTex = gl::Texture( layout.render( true ) );
    
    updateTime();
    
    updateTimeWindow();

    // init BASS library
    BASS_Init( -1, 44100, 0, 0, NULL );
}
Exemplo n.º 10
0
void ardroneApp::update()
{
	if( mMovie )
		mFrameTexture = mMovie->getTexture();

    float s = 0.02;
    
    if(keys[cinder::app::KeyEvent::KEY_UP]) drone.controller.pitchAmount -= s;
    else if(keys[cinder::app::KeyEvent::KEY_DOWN]) drone.controller.pitchAmount += s;
    
    if(keys['a']) drone.controller.rollAmount -= s;
    else if(keys['d']) drone.controller.rollAmount += s;
    
    if(keys['w']) drone.controller.liftSpeed += s;
    else if(keys['s']) drone.controller.liftSpeed -= s;
    
    if(keys[cinder::app::KeyEvent::KEY_LEFT]) drone.controller.spinSpeed -= s;
    else if(keys[cinder::app::KeyEvent::KEY_RIGHT]) drone.controller.spinSpeed += s;
    
    // update the drone (process and send queued commands to drone, receive commands from drone and update state
    drone.update();
    
    // update position of simulator (OPTIONAL)
    droneSimulator.update();
    
    TextLayout infoText;
    infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.25f ) );
    infoText.setColor( Color::white() );
//    infoText.addCenteredLine( path);
//    if (!errorMessage.empty()) {
//        infoText.addLine(errorMessage);
//    } else {
//        infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" );
//        if (mMovie->getDuration() > 0.f) infoText.addLine( toString( mMovie->getDuration() ) + " seconds" );
//        infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" );
//        infoText.addLine( toString( mMovie->getFramerate() ) + " fps" );
//    }
    infoText.setBorder( 4, 2 );


    
    string controllerString = "fps: " + toString(getFrameRate()) + "\n";
    controllerString += "millisSinceLastSend: " + toString(drone.controller.getMillisSinceLastSend()) + "\n";
    controllerString += "\n";
    controllerString += "takeOff (t)\n";
    controllerString += "land (l)\n";
    controllerString += "calibrateHorizontal (c)\n";
    controllerString += "calibrateMagnetometer (m)\n";
    controllerString += "EMERGENCY (E)\n";
    controllerString += "\n";
    controllerString += "roll (a/d)        : " + toString(drone.controller.rollAmount) + "\n";
    controllerString += "pitch (up/down)   : " + toString(drone.controller.pitchAmount) + "\n";
    controllerString += "lift (w/s)        : " + toString(drone.controller.liftSpeed) + "\n";
    controllerString += "spin (left/right) : " + toString(drone.controller.spinSpeed) + "\n";
    controllerString += "\n";
    controllerString += "reset droneSimulator (r)\n";
    controllerString += "debug history (h)\n";
    controllerString += "fullscreen (f)\n";
    controllerString += "PAUSE (p)\n";
    
    infoText.addCenteredLine( controllerString);
    
    ofxARDrone::State &state = drone.state;
    string stateString = "";
    stateString += "isFlying : " + toString(state.isFlying()) + "\n";
    stateString += "isTakingOff : " + toString(state.isTakingOff()) + ", " + toString(state.isTakingOffMillis()) + "\n";
    stateString += "isLanding : " + toString(state.isLanding()) + ", " + toString(state.isLandingMillis()) + "\n";
    stateString += "isCalibratingHorizontal : " + toString(state.isCalibratingHorizontal()) + ", " + toString(state.isCalibratingHorizontalMillis()) + "\n";
    stateString += "isCalibratingMagnetometer : " + toString(state.isCalibratingMagnetometer()) + ", " + toString(state.isCalibratingMagnetometerMillis()) + "\n";
    
    
    stateString += "\n\nisConnected: " + toString(state.isConnected()) + ", " + toString(state.isCalibratingMagnetometerMillis()) + "\n";
    stateString += "altitude: "+ toString(state.getAltitude())+"\n";
    stateString += "emergency state: "+ toString(state.inEmergencyMode())+"\n";
    stateString += "battery level: "+ toString(state.getBatteryPercentage())+"%\n";
    stateString += "vx: "+ toString(state.getVx())+" vy: "+ toString(state.getVy())+" vz: "+ toString(state.getVz())+"\n";
    
    infoText.addCenteredLine(stateString);
    mInfoTexture = gl::Texture( infoText.render( true ) );
}