void update( float time ) { if ( ! ( target && iData.isValid() && active && morph.count() > 1 ) ) return; time = ctrlTime( time ); if ( target->verts.count() != morph[0]->verts.count() ) return; target->verts = morph[0]->verts; float x; for ( int i = 1; i < morph.count(); i++ ) { MorphKey * key = morph[i]; if ( interpolate( x, key->iFrames, time, key->index ) ) { if ( x < 0 ) x = 0; if ( x > 1 ) x = 1; if ( x != 0 && target->verts.count() == key->verts.count() ) { for ( int v = 0; v < target->verts.count(); v++ ) target->verts[v] += key->verts[v] * x; } } } target->upBounds = true; }
void update( float time ) { const NifModel * nif = static_cast<const NifModel *>( iData.model() ); QModelIndex uvGroups = nif->getIndex( iData, "UV Groups" ); // U trans, V trans, U scale, V scale // see NiUVData compound in nif.xml float val[4] = { 0.0, 0.0, 1.0, 1.0 }; if ( uvGroups.isValid() ) { for ( int i = 0; i < 4 && i < nif->rowCount( uvGroups ); i++ ) { interpolate( val[i], uvGroups.child( i, 0 ), ctrlTime( time ), luv ); } // adjust coords; verified in SceneImmerse for ( int i = 0; i < target->coords[0].size(); i++ ) { // operating on pointers makes this too complicated, so we don't Vector2 current = target->coords[0][i]; // scaling/tiling applied before translation // Note that scaling is relative to center! current += Vector2( -0.5, -0.5 ); current = Vector2( current[0] * val[2], current[1] * val[3] ); current += Vector2( -val[0], val[1] ); current += Vector2( 0.5, 0.5 ); target->coords[0][i] = current; } } target->upData = true; }
void update( float time ) { if ( ! ( target && active ) ) return; localtime = ctrlTime( time ); int n = 0; while ( n < list.count() ) { Particle & p = list[n]; float deltaTime = ( localtime > p.lasttime ? localtime - p.lasttime : 0 ); //( stop - start ) - p.lasttime + localtime ); p.lifetime += deltaTime; if ( p.lifetime < p.lifespan && p.vertex < target->verts.count() ) { p.position = target->verts[ p.vertex ]; for ( int i = 0; i < 4; i++ ) moveParticle( p, deltaTime/4 ); p.lasttime = localtime; n++; } else list.remove( n ); } if ( emitNode && emitNode->isVisible() && localtime >= emitStart && localtime <= emitStop ) { float emitDelta = ( localtime > emitLast ? localtime - emitLast : 0 ); emitLast = localtime; emitAccu += emitDelta * emitRate; int num = int( emitAccu ); if ( num > 0 ) { emitAccu -= num; while ( num-- > 0 && list.count() < target->verts.count() ) { Particle p; startParticle( p ); list.append( p ); } } } n = 0; while ( n < list.count() ) { Particle & p = list[n]; p.vertex = n; target->verts[ n ] = p.position; if ( n < target->sizes.count() ) sizeParticle( p, target->sizes[n] ); if ( n < target->colors.count() ) colorParticle( p, target->colors[n] ); n++; } target->active = list.count(); target->size = size; }