Exemplo n.º 1
0
void Particle::update( const Channel32f &channel,  const ci::Channel32f &rChan, const ci::Channel32f &gChan, const ci::Channel32f &bChan, const ci::Vec2i &mouseLoc )
{
	
    //calculate the vector that points from the particl to the mouse.
    mDirToCursor = mouseLoc - mLoc;
    mDirToCursor.safeNormalize(); //normalize it so it gives us a unit vector.
    
    
    Vec2f newLoc = mLoc + mDirToCursor * 100.f;
    newLoc.x = constrain( newLoc.x, 0.0f, channel.getWidth() - 1.0f );
    newLoc.y = constrain( newLoc.y, 0.0f, channel.getHeight() - 1.0f );
    
    
    
    //mRadius = channel.getValue( mLoc ) * mScale;
    mRadius = channel.getValue( newLoc ) * mScale;
    
    Vec2i mLoci = (Vec2i) mLoc;
        
    r = rChan.getValue( newLoc );
    g = gChan.getValue( newLoc );
    b = bChan.getValue( newLoc );    
    
    //console() << r << ", " << g << ", " << b << std::endl;
    //console() << channel.getValue(mLoc) << std::endl;
    //console() << "hello" << std::endl;
    
}
Exemplo n.º 2
0
Texture::Texture( const Channel32f &channel, Format format )
	: mObj( shared_ptr<Obj>( new Obj( channel.getWidth(), channel.getHeight() ) ) )
{
#if defined( CINDER_MAC )
	bool supportsTextureFloat = gl::isExtensionAvailable( "GL_ARB_texture_float" );
#elif defined( CINDER_MSW )
	bool supportsTextureFloat = GLEE_ARB_texture_float != 0;
#endif

	if( format.mInternalFormat < 0 ) {
#if ! defined( CINDER_GLES )
		if( supportsTextureFloat )
			format.mInternalFormat = GL_LUMINANCE32F_ARB;
		else
			format.mInternalFormat = GL_LUMINANCE;
#else
		format.mInternalFormat = GL_LUMINANCE;
#endif	
	}

	mObj->mInternalFormat = format.mInternalFormat;
	mObj->mTarget = format.mTarget;

	// if the data is not already contiguous, we'll need to create a block of memory that is
	if( ( channel.getIncrement() != 1 ) || ( channel.getRowBytes() != channel.getWidth() * sizeof(float) ) ) {
		shared_ptr<float> data( new float[channel.getWidth() * channel.getHeight()], checked_array_deleter<float>() );
		float *dest = data.get();
		const int8_t inc = channel.getIncrement();
		const int32_t width = channel.getWidth();
		for( int y = 0; y < channel.getHeight(); ++y ) {
			const float *src = channel.getData( 0, y );
			for( int x = 0; x < width; ++x ) {
				*dest++ = *src;
				src += inc;
			}
		}
	
		init( data.get(), GL_LUMINANCE, format );
	}
	else
		init( channel.getData(), GL_LUMINANCE, format );
}
Exemplo n.º 3
0
void DirVector::update(const Channel32f &channel, const Vec2f &windDirection){
	//console() << "Update1: << " << mDir << ", " << mRotationVector << endl;
	
	//mDir = Vec2f(1.0f, 0.0f);
	
	mDir = mRotationVector; //mouseLoc - mLoc;
	mDir.safeNormalize();
	//mDir.normalize();
    
	Vec2f newLoc = mLoc + mDir * 100.f;
	newLoc.x = constrain(newLoc.x, 0.f, channel.getWidth() - 1.f);
	newLoc.x = constrain(newLoc.x, 0.f, channel.getHeight() - 1.f);
	
	mRadius = channel.getValue(newLoc) * 7.0f;
	//console() << "Update2: << " << mDir << endl;
}
Exemplo n.º 4
0
void Particle::update( const Channel32f &channel, const Vec2i &mouseLoc )
{
	mDirToCursor		= mouseLoc - mLoc;
    
	float distToCursor	= mDirToCursor.length();
	float time			= app::getElapsedSeconds();
	float dist			= distToCursor * 0.025f;
	float sinOffset		= sin( dist - time ) + 1.0f;
	
	mDirToCursor.normalize();
	mDirToCursor		*= sinOffset * 100.0f;
	
    Rectf rect( mLoc.x, mLoc.y, mLoc.x + mRadius, mLoc.y + mRadius );
    gl::drawSolidRect( rect );
    
	Vec2f newLoc		= mLoc + mDirToCursor;
	newLoc.x			= constrain( newLoc.x, 0.0f, channel.getWidth() - 1.0f );
	newLoc.y			= constrain( newLoc.y, 0.0f, channel.getHeight() - 1.0f );
	
	mRadius				= channel.getValue( newLoc ) * mScale;
}
Exemplo n.º 5
0
void Circle::update(const Vec2i &mouseLoc, const Channel32f &channel)
{
    mMouseLoc           = mouseLoc;
    mDirToCursor        = mMouseLoc-mLoc;
    
    float distToCursor  = mDirToCursor.length();
    float time          = app::getElapsedSeconds();
    float dist          = distToCursor * 0.025f;
    float sinOffset     = sin(dist-time)+1.0f;
    
    mDirToCursor.normalize();
    mDirToCursor        *= sinOffset * 100.0f;
    
    Vec2f newLoc        = mLoc+mDirToCursor;
    newLoc.x            = constrain(newLoc.x, 0.0f, channel.getWidth()-1.0f);
    newLoc.y            = constrain(newLoc.y, 0.0f, channel.getHeight() - 1.0f);
    
    mRadius             = channel.getValue(newLoc)*mScale+2.0f;
    
    float gray=channel.getValue(mLoc);
    mColor=Color(gray,gray,gray);
}