color getPhong( const normal& i_N, const vector& i_V, const float cosinePower, const eiBool i_keyLightsOnly, const eiBool unshadowed) { color C = 0; vector R = reflect( normalize(i_V), normalize(i_N) ); while( illuminance( P(), i_N, PI/2.0f ) ) { float isKeyLight = 1; //if( i_keyLightsOnly != 0 ) //{ // lightsource( "iskeylight", isKeyLight ); //} if( isKeyLight != 0 ) { const float nonspecular = 0.0f; //lightsource( "__nonspecular", nonspecular ); if( nonspecular < 1 ) { vector Ln = normalize(L()); SAMPLE_LIGHT_2(color, C, 0.0f, C += Cl()*pow(max<float>(0.0f,R%Ln),cosinePower)*(1.0f-nonspecular); ); } }
color getDiffuse( const normal& i_N, const eiBool keyLightsOnly, const eiBool unshadowed ) { eiBool isKeyLight = eiTRUE; color C = 0; while ( illuminance( P(), i_N, PI/2.0f ) ) { //if( keyLightsOnly != eiFALSE ) //{ // lightsource( "iskeylight", isKeyLight ); //} if( isKeyLight != eiFALSE ) { float nondiffuse = 0.0f; //lightsource( "__nondiffuse", nondiffuse ); if( nondiffuse < 1.0f ) { SAMPLE_LIGHT_2(color, C, 0.0f, C += Cl() * (normalize(L()) % i_N) * (1.0f-nondiffuse) ); } } } return C; }
void main1_3(void *arg) { color Kd = color(diffuse(), diffuse(), diffuse()); normal Nf = faceforward(normalize(N()), I()); vector V = -normalize(I()); while (illuminance(P(), Nf, PI / 2.0f)) { color C = 0.0f; SAMPLE_LIGHT_2(color, C, 0.0f, C += Cl() * ( color_() * Kd * (normalize(L()) % Nf) + cosinePower() * specularColor() * specularbrdf(normalize(L()), Nf, V, 0.1f/*roughness()*/) ) ); Ci() += C; } if ( ! less_than( &transparency(), LIQ_SCALAR_ALMOST_ZERO ) ) {//transparent Ci() = Ci() * ( 1.0f - transparency() ) + trace_transparent() * transparency(); }//else{ opacity } setOutputForMaya(); }
void hint(void) { int d = 0, x = 0, y = 0; Brick *b = nil; if(level.c.d != -1) { if((b = bmatch(level.c)) != nil) { d = level.c.d; x = level.c.x; y = level.c.y; } } else for(d = Depth - 1; d >= 0; d--) for(y = 0; y < Ly; y++) for(x = 0; x < Lx; x++) if(level.board[d][x][y].which == TL && isfree(Cl(d,x,y)) && (b = bmatch(Cl(d,x,y))) != nil) goto Matched; Matched: if (b == nil) return; level.board[d][x][y].clicked = 1; b->clicked = 1; b->redraw = 1; updatelevel(); sleep(500); if(level.c.d == -1) level.board[d][x][y].clicked = 0; b->clicked = 0; b->redraw = 1; updatelevel(); sleep(500); level.board[d][x][y].clicked = 1; b->clicked = 1; b->redraw = 1; updatelevel(); sleep(500); if(level.c.d == -1) level.board[d][x][y].clicked = 0; b->clicked = 0; b->redraw = 1; updatelevel(); }
Foam::tmp<Foam::volVectorField> Foam::liftModels::noLift::F() const { return Cl() *dimensionedVector ( "zero", dimensionSet(1, -2, -2, 0, 0), vector::zero ); }
U64 AttacksFrom(POS *p, int sq) { switch (TpOnSq(p, sq)) { case P: return BB.PawnAttacks(Cl(p->pc[sq]), sq); case N: return BB.KnightAttacks(sq); case B: return BB.BishAttacks(OccBb(p), sq); case R: return BB.RookAttacks(OccBb(p), sq); case Q: return BB.QueenAttacks(OccBb(p), sq); case K: return BB.KingAttacks(sq); } return 0; }
void main() { DDRA=255; DDRB=255; DDRD=0xf0; while(1) { PORTD=0xef; _delay_ms(10); if(((PIND&0x01)==0x00)||c==1) { while((PIND&0x0f)==0x0f) { c=1; Al(); } } else if(((PIND&0x02)==0x00)||c==2) { while((PIND&0x0f)==0x0f) { c=2; Bl(); } } else if(((PIND&0x04)==0x00)||c==3) { while((PIND&0x0f)==0x0f) { c=3; Cl(); } } else if(((PIND&0x08)==0x00)||(c==4)) { while((PIND&0x0f)==0x0f) { c=4; Dl(); } } } }
void main1(void *arg) { color Kd = color(diffuse(), diffuse(), diffuse()); normal Nf = faceforward(normalize(N()), I()); vector V = -normalize(I()); while (illuminance(P(), Nf, PI / 2.0f)) { color C = 0.0f; color last = 0.0f; int num_samples = 0; while (sample_light()) { C += Cl() * ( color_() * Kd * (normalize(L()) % Nf) + cosinePower() * specularColor() * specularbrdf(normalize(L()), Nf, V, 0.1f/*roughness()*/) ); ++ num_samples; if ((num_samples % 4) == 0) { color current = C * (1.0f / (scalar)num_samples); if (converged(current, last)){ break; } last = current; } } C *= (1.0f / (scalar)num_samples); Ci() += C; } if ( ! less_than( &transparency(), LIQ_SCALAR_ALMOST_ZERO ) ) {//transparent Ci() = Ci() * ( 1.0f - transparency() ) + trace_transparent() * transparency(); }//else{ opacity } setOutputForMaya(); }
void redrawlevel(int all) { Brick *b; int d, x, y; for(d = 0; d < Depth; d++) for(y = 0; y < Ly; y++) for(x = 0; x < Lx; x++) { b = &level.board[d][x][y]; if(b->which == TL && (all || b->redraw)) { drawbrick(Cl(d,x,y)); markabove(d,x,y); } b->redraw = 0; } draw(screen, screen->r, img, nil, ZP); flushimage(display, 1); }
/** Initialise the environment for the specified grid size. * \param iGridRes Integer grid resolution. * \param iGridRes Integer grid resolution. */ void CqLightsource::Initialise( TqInt uGridRes, TqInt vGridRes, TqInt microPolygonCount, TqInt shadingPointCount, bool hasValidDerivatives ) { TqInt Uses = gDefLightUses; if ( m_pShader ) { Uses |= m_pShader->Uses(); m_pShaderExecEnv->Initialise( uGridRes, vGridRes, microPolygonCount, shadingPointCount, hasValidDerivatives, m_pAttributes, boost::shared_ptr<IqTransform>(), m_pShader.get(), Uses ); } if ( m_pShader ) m_pShader->Initialise( uGridRes, vGridRes, shadingPointCount, m_pShaderExecEnv.get() ); if ( USES( Uses, EnvVars_L ) ) L() ->Initialise( shadingPointCount ); if ( USES( Uses, EnvVars_Cl ) ) Cl() ->Initialise( shadingPointCount ); // Initialise the geometric parameters in the shader exec env. if ( USES( Uses, EnvVars_P ) ) { CqMatrix mat; QGetRenderContext() ->matSpaceToSpace( "shader", "current", m_pShader->getTransform(), NULL, QGetRenderContextI()->Time(), mat ); P() ->SetPoint( mat * CqVector3D( 0.0f, 0.0f, 0.0f ) ); } if ( USES( Uses, EnvVars_u ) ) u() ->SetFloat( 0.0f ); if ( USES( Uses, EnvVars_v ) ) v() ->SetFloat( 0.0f ); if ( USES( Uses, EnvVars_du ) ) du() ->SetFloat( 0.0f ); if ( USES( Uses, EnvVars_dv ) ) dv() ->SetFloat( 0.0f ); if ( USES( Uses, EnvVars_s ) ) s() ->SetFloat( 0.0f ); if ( USES( Uses, EnvVars_t ) ) t() ->SetFloat( 0.0f ); if ( USES( Uses, EnvVars_N ) ) N() ->SetNormal( CqVector3D( 0.0f, 0.0f, 0.0f ) ); }
void MeiLift::setForce() const { const volScalarField& nufField = forceSubM(0).nuField(); const volScalarField& rhoField = forceSubM(0).rhoField(); vector position(0,0,0); vector lift(0,0,0); vector Us(0,0,0); vector Ur(0,0,0); scalar magUr(0); scalar magVorticity(0); scalar ds(0); scalar dParcel(0); scalar nuf(0); scalar rho(0); scalar voidfraction(1); scalar Rep(0); scalar Rew(0); scalar Cl(0); scalar Cl_star(0); scalar J_star(0); scalar Omega_eq(0); scalar alphaStar(0); scalar epsilon(0); scalar omega_star(0); vector vorticity(0,0,0); volVectorField vorticity_ = fvc::curl(U_); #include "resetVorticityInterpolator.H" #include "resetUInterpolator.H" #include "setupProbeModel.H" for(int index = 0;index < particleCloud_.numberOfParticles(); index++) { //if(mask[index][0]) //{ lift = vector::zero; label cellI = particleCloud_.cellIDs()[index][0]; if (cellI > -1) // particle Found { Us = particleCloud_.velocity(index); if( forceSubM(0).interpolation() ) { position = particleCloud_.position(index); Ur = UInterpolator_().interpolate(position,cellI) - Us; vorticity = vorticityInterpolator_().interpolate(position,cellI); } else { Ur = U_[cellI] - Us; vorticity=vorticity_[cellI]; } magUr = mag(Ur); magVorticity = mag(vorticity); if (magUr > 0 && magVorticity > 0) { ds = 2*particleCloud_.radius(index); dParcel = ds; forceSubM(0).scaleDia(ds,index); //caution: this fct will scale ds! nuf = nufField[cellI]; rho = rhoField[cellI]; //Update any scalar or vector quantity for (int iFSub=0;iFSub<nrForceSubModels();iFSub++) forceSubM(iFSub).update( index, cellI, ds, nuf, rho, forceSubM(0).verbose() ); // calc dimensionless properties Rep = ds*magUr/nuf; Rew = magVorticity*ds*ds/nuf; alphaStar = magVorticity*ds/magUr/2.0; epsilon = sqrt(2.0*alphaStar /Rep ); omega_star=2.0*alphaStar; //Basic model for the correction to the Saffman lift //Based on McLaughlin (1991) if(epsilon < 0.1) { J_star = -140 *epsilon*epsilon*epsilon*epsilon*epsilon *log( 1./(epsilon*epsilon+SMALL) ); } else if(epsilon > 20) { J_star = 1.0-0.287/(epsilon*epsilon+SMALL); } else { J_star = 0.3 *( 1.0 +tanh( 2.5 * log10(epsilon+0.191) ) ) *( 0.667 +tanh( 6.0 * (epsilon-0.32) ) ); } Cl=J_star*4.11*epsilon; //multiply McLaughlin's correction to the basic Saffman model //Second order terms given by Loth and Dorgan 2009 if(useSecondOrderTerms_) { Omega_eq = omega_star/2.0*(1.0-0.0075*Rew)*(1.0-0.062*sqrt(Rep)-0.001*Rep); Cl_star=1.0-(0.675+0.15*(1.0+tanh(0.28*(omega_star/2.0-2.0))))*tanh(0.18*sqrt(Rep)); Cl += Omega_eq*Cl_star; } lift = 0.125*M_PI *rho *Cl *magUr*Ur^vorticity/magVorticity *ds*ds; //total force on all particles in parcel forceSubM(0).scaleForce(lift,dParcel,index); if (modelType_=="B") { voidfraction = particleCloud_.voidfraction(index); lift /= voidfraction; } } //********************************** //SAMPLING AND VERBOSE OUTOUT if( forceSubM(0).verbose() ) { Pout << "index = " << index << endl; Pout << "Us = " << Us << endl; Pout << "Ur = " << Ur << endl; Pout << "vorticity = " << vorticity << endl; Pout << "dprim = " << ds << endl; Pout << "rho = " << rho << endl; Pout << "nuf = " << nuf << endl; Pout << "Rep = " << Rep << endl; Pout << "Rew = " << Rew << endl; Pout << "alphaStar = " << alphaStar << endl; Pout << "epsilon = " << epsilon << endl; Pout << "J_star = " << J_star << endl; Pout << "lift = " << lift << endl; } //Set value fields and write the probe if(probeIt_) { #include "setupProbeModelfields.H" // Note: for other than ext one could use vValues.append(x) // instead of setSize vValues.setSize(vValues.size()+1, lift); //first entry must the be the force vValues.setSize(vValues.size()+1, Ur); vValues.setSize(vValues.size()+1, vorticity); sValues.setSize(sValues.size()+1, Rep); sValues.setSize(sValues.size()+1, Rew); sValues.setSize(sValues.size()+1, J_star); particleCloud_.probeM().writeProbe(index, sValues, vValues); } // END OF SAMPLING AND VERBOSE OUTOUT //********************************** } // write particle based data to global array forceSubM(0).partToArray(index,lift,vector::zero); //} } }
void SetPosition(POS *p, char *epd) { int j, pc; static const char pc_char[13] = "PpNnBbRrQqKk"; for (int sd = 0; sd < 2; sd++) { p->cl_bb[sd] = 0ULL; #ifndef LEAF_PST p->mg_pst[sd] = 0; p->eg_pst[sd] = 0; #endif } p->phase = 0; for (int pc = 0; pc < 6; pc++) { p->tp_bb[pc] = 0ULL; p->cnt[WC][pc] = 0; p->cnt[BC][pc] = 0; } p->castle_flags = 0; p->rev_moves = 0; p->head = 0; for (int i = 56; i >= 0; i -= 8) { j = 0; while (j < 8) { if (*epd >= '1' && *epd <= '8') for (pc = 0; pc < *epd - '0'; pc++) { p->pc[i + j] = NO_PC; j++; } else { for (pc = 0; pc_char[pc] != *epd; pc++) ; p->pc[i + j] = pc; p->cl_bb[Cl(pc)] ^= SqBb(i + j); p->tp_bb[Tp(pc)] ^= SqBb(i + j); if (Tp(pc) == K) p->king_sq[Cl(pc)] = i + j; p->phase += phase_value[Tp(pc)]; #ifndef LEAF_PST p->mg_pst[Cl(pc)] += Param.mg_pst_data[Cl(pc)][Tp(pc)][i + j]; p->eg_pst[Cl(pc)] += Param.eg_pst_data[Cl(pc)][Tp(pc)][i + j]; #endif p->cnt[Cl(pc)][Tp(pc)]++; j++; } epd++; } epd++; } // Setting side to move if (*epd++ == 'w') p->side = WC; else p->side = BC; // Setting castling rights epd++; if (*epd == '-') epd++; else { if (*epd == 'K') { p->castle_flags |= 1; epd++; } if (*epd == 'Q') { p->castle_flags |= 2; epd++; } if (*epd == 'k') { p->castle_flags |= 4; epd++; } if (*epd == 'q') { p->castle_flags |= 8; epd++; } } // Setting en passant square (only if capture is possible) epd++; if (*epd == '-') p->ep_sq = NO_SQ; else { p->ep_sq = Sq(*epd - 'a', *(epd + 1) - '1'); if (!(BB.PawnAttacks(Opp(p->side), p->ep_sq) & p->Pawns(p->side))) p->ep_sq = NO_SQ; } // Calculating hash keys p->hash_key = InitHashKey(p); p->pawn_key = InitPawnKey(p); }