void Businger(short a, double zmu, double zmt, double d0, double z0, double v, double T, double DT, double DQ, double z0_z0t, double *rm, double *rh, double *rv, double *Lobukhov, long maxiter){ double L, cm, u_star=0., ch, T_star=0., cv, Q_star=0.; double z0v, z0t, z0q; long cont; double tol; FILE *f; //first guess of Obukhov length if(DT<0){ L=1.E5; }else{ L=-1.E5; } cont=0; tol=1.0E99; do{ if(cont>0) tol=10*T_star+100*u_star+1000*Q_star; //Conductances Star(a, zmu, z0, d0, L, 0.0, v, 1.0, 0.0, 1.0, &u_star, &cm, &z0v, (*Psim), (*roughT)); //momentum if(z0_z0t==0.0){ //rigid surface Star(a, zmt, z0, d0, L, u_star, DT, u_star*z0/1.4E-5, 1.0, 0.0, &T_star, &ch, &z0t, (*Psih), (*roughT)); //heat flux Star(a, zmt, z0, d0, L, u_star, DQ, u_star*z0/1.4E-5, 1.0, 0.0, &Q_star, &cv, &z0q, (*Psih), (*roughQ)); //water vapour flux }else{ //bending surface Star(a, zmt, z0, d0, L, u_star, DT, 1.0, 0.0, 1.0/z0_z0t, &T_star, &ch, &z0t, (*Psih), (*roughT)); //heat flux Star(a, zmt, z0, d0, L, u_star, DQ, 1.0, 0.0, 1.0/z0_z0t, &Q_star, &cv, &z0q, (*Psih), (*roughQ)); //water vapour flux } //Obukhov length L=-u_star*u_star*(T+tk)/(ka*g*(T_star-0.61*Q_star*(T+tk))); cont++; }while(fabs(100*T_star+100*u_star+1000*Q_star-tol)>0.01 && cont<=maxiter); if(d0>zmu || d0>zmt){ f = fopen(FailedRunFile, "w"); fprintf(f,"Error:: Displacement height greater than measurement elevations\n"); fclose(f); t_error("Fatal Error! Geotop is closed. See failing report."); } if(zmu<=z0 || zmt<=z0t || zmt<=z0q){ f = fopen(FailedRunFile, "w"); fprintf(f,"Error:: Elevation of sensors lower than roughness length: zmu=%f zmt=%f z0=%f z0t=%f\n",zmu,zmt,z0,z0t); fclose(f); t_error("Fatal Error! Geotop is closed. See failing report."); } *rm=cm*cm/(ka*ka*v); *rh=ch*cm/(ka*ka*v); *rv=cv*cm/(ka*ka*v); *Lobukhov=L; }
/* A function which draws **************************************************************************/ void Draw( void ) { int cx = 0.0, cy =0.0; /* Clear the screen ... */ glClear( GL_COLOR_BUFFER_BIT ); /*------------------------------------------------------ * Draw the star as a fill polygon *-----------------------------------------------------*/ glPolygonMode ( GL_FRONT, GL_FILL ); glColor3f( STEELBLUE ); Star( R1, R2, P, cx, cy ); /*------------------------------------------------------ * Draw the star as a line polygon *-----------------------------------------------------*/ glPolygonMode ( GL_FRONT, GL_LINE ); glColor3f( COBALT ); Star( R1, R2, P, cx, cy ); glutSwapBuffers(); return; }
void Sky::frame(){ if(stars.size() < 300){ int res = rand()%100; if(res == 0){ int x = rand()%width - (int)width/2; int y = rand()%height - (int)height/2; int min = HIGH - (int)(HIGH/10); int z = rand()%(HIGH-min) + min; stars.push_back(Star(Pd(x, y, z))); } } if(stars.size() > 150){ int res = rand()%200; if(res == 0){ stars.erase(stars.begin() + (rand()%stars.size())); } } if(stars.size() > 100){ int res = rand()%60; if(res == 0){ vector<Star>::iterator it; it = stars.begin() + (rand()%stars.size()); it->big = !it->big; } } }
BOOL CAG_RegEx::Eval() { // First pop the operator from the stack if(m_OperatorStack.size()>0) { char chOperator = m_OperatorStack.top(); m_OperatorStack.pop(); // Check which operator it is switch(chOperator) { case 42: return Star(); break; case 124: return Union(); break; case 8: return Concat(); break; } return FALSE; } return FALSE; }
int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; // TODO: 在此添加您专用的创建代码 //得到一个窗口对象(CWnd的派生对象)指针的句柄(HWND) HWND hWnd = this->GetSafeHwnd(); //GetDC该函数检索一指定窗口的客户区域或整个屏幕的显示设备上下文环境的句柄 //以后可以在GDI函数中使用该句柄来在设备上下文环境中绘图。 HDC hDC = ::GetDC(hWnd); if(this->SetWindowPixelFormat(hDC)==FALSE) {//设置像素格式 return 0; } if(this->CreateViewGLContext(hDC)==FALSE) {//创建RC并选为所用 return 0; } if(!this->InitGL()) {//初始化openGL return 0; } this -> SetCenterStar(Star(5.972E24,_3DVector(0,0,0),0xFF9900)); this -> LoadDataFromFile("planets.txt"); this -> InitPlanets(); this -> SetTimer(1,25,NULL); return 0; }
void wipeStars(Star stars[], Planet planets[]) { for (int i=0;i<NUM_STARS;++i) { if (!isHomeworld(stars[i],planets)) { stars[i]=Star(); } } }
void StarSeemTest::star_external_ffem() { QFETCH(QString, data); AudioBuffer c; QVERIFY2(c.read(data), ("Failed reading test wave; " + data).toUtf8().data()); /*=== WORLD による分析 ===*/ int timeLength = GetSamplesForDIO(c.format().sampleRate(), c.length(), msFramePeriod); int fftLength = GetFFTSizeForStar(c.format().sampleRate()); double *f0 = new double[timeLength]; double *t = new double[timeLength]; double **specgram = new double*[timeLength]; specgram[0] = new double[timeLength * (fftLength / 2 + 1)]; for(int i = 1; i < timeLength; i++) { specgram[i] = specgram[0] + i * (fftLength / 2 + 1); } Dio(c.data()[0], c.length(), c.format().sampleRate(), msFramePeriod, t, f0); Star(c.data()[0], c.length(), c.format().sampleRate(), msFramePeriod, f0, timeLength, specgram); /*=== WORLD による分析ここまで ===*/ /*=== StarSeem による分析 === */ Envelope *e = new Envelope; QVERIFY2(DioFfem().estimate(e, c.data()[0], c.length(), c.format().sampleRate(), msFramePeriod), "Failed dio FFEM"); // Envelope が正しいか確認する for(int i = 0; i < e->size(); i++) { QVERIFY2(e->value(i) == f0[i], "Error; invalid f0 envelope"); } Specgram *testset = new Specgram; QVERIFY2(StarSeem(e).estimate(testset, c.data()[0], c.length(), fftLength, c.format().sampleRate(), msFramePeriod), "Failed STAR SEEM"); /*=== StarSeem による分析ここまで === */ // 比較開始 for(int t = 0; t < timeLength; t++) { for(int f = 0; f <= fftLength / 2; f++) { if(testset->value(t, f) != specgram[t][f]) { QString s; s = "t = " + QString::number(t) + ", f = " + QString::number(f); s += " actual :" + QString::number(testset->value(t, f)) + " , expceted :" + QString::number(specgram[t][f]); // WORLD 自体は同じだから値が全く同じでないとおかしい。 QFAIL(("Error ;" + s).toUtf8().data()); } } } delete[] specgram[0]; delete[] specgram; delete[] t; delete[] f0; }
StarsBackground::StarsBackground() : Entity(false) { for (unsigned int i = 0; i < 100; i++) { int dy = rand() % 10 + 7; mStars.push_back(Star(rand() % 240, (rand() % 240) * dy, dy)); } }
void update() { if (input().down(Gosu::kbLeft) || input().down(Gosu::gpLeft)) player.turnLeft(); if (input().down(Gosu::kbRight) || input().down(Gosu::gpRight)) player.turnRight(); if (input().down(Gosu::kbUp) || input().down(Gosu::gpButton0)) player.accelerate(); player.move(); player.collectStars(stars); if (std::rand() % 25 == 0 && stars.size() < 25) stars.push_back(Star(starAnim)); }
HorizontalWidget::HorizontalWidget( QWidget* parent ) :QWidget( parent ), sphereRadio( 120.0 ), m_azimuth( 0 ), m_zenith( 0 ) { QVBoxLayout* mainLayout = new QVBoxLayout; setLayout( mainLayout ); QWidget* examinerWidget = new QWidget; examinerWidget->setFixedSize( 490, 300 ); mainLayout->addWidget(examinerWidget); m_rootNode = new SoSeparator; m_rootNode->addChild( Ejes( ) ); m_rootNode->addChild( Text() ); m_rootNode->addChild( Sphere() ); m_rootNode->addChild( Horizon() ); m_rootNode->addChild( AzimuthLine() ); m_rootNode->addChild( ZenithLine() ); m_rootNode->addChild( Star() ); SoQtExaminerViewer* myRenderArea = new SoQtExaminerViewer( examinerWidget ); myRenderArea->setSceneGraph( m_rootNode ); SbColor col( 0.86f, 0.86f, 0.86f ); myRenderArea->setBackgroundColor(col); myRenderArea->show( ); QWidget* labelsWidget = new QWidget; mainLayout->addWidget( labelsWidget ); QGridLayout* labelsLayout = new QGridLayout; labelsWidget->setLayout( labelsLayout ); QLabel* m_AzimuthLabel = new QLabel; m_AzimuthLabel->setText( "Azimuth:" ); labelsLayout->addWidget( m_AzimuthLabel, 0, 0, 1, 1 ); m_azimuthValue = new QLabel; m_azimuthValue->setText( QString::number( m_azimuth ) ); labelsLayout->addWidget( m_azimuthValue, 0, 1, 1, 3 ); QLabel* m_zenithLabel = new QLabel; m_zenithLabel->setText( "Zenith:" ); labelsLayout->addWidget( m_zenithLabel, 1, 0, 1, 1 ); m_zenithValue = new QLabel; m_zenithValue->setText( QString::number( m_zenith ) ); labelsLayout->addWidget( m_zenithValue, 1, 1, 1, 3 ); }
INT CTraceLog::InitData() { INT iRet = FAIL; strncpy(m_szLogPath, g_Cfg->GetKeyValue("LogPath"), MAX_PATH); m_wLogFileSaveDay = atoi(g_Cfg->GetKeyValue("LogFileSaveDay")); m_bEnableRarLog = atoi(g_Cfg->GetKeyValue("EnableRarLog")); iRet = Create(MAX_LOGITEM_NUM, MAX_LOGITEM_LEN*MAX_LOGITEM_NUM); if(SUCCES == iRet) Star(); return iRet; }
CelestialWidget::CelestialWidget( QWidget* parent ) :QWidget( parent ), sphereRadio( 120.0 ), m_declination( 0 ), m_rightAscension( 0 ) { QVBoxLayout* mainLayout = new QVBoxLayout; setLayout( mainLayout ); QWidget* examinerWidget = new QWidget; examinerWidget->setFixedSize( 490, 300 ); mainLayout->addWidget(examinerWidget); m_rootNode = new SoSeparator; m_rootNode->addChild( Ejes() ); m_rootNode->addChild( Sphere() ); m_rootNode->addChild( CelestialEquator() ); m_rootNode->addChild( Ecliptic() ); m_rootNode->addChild( Points() ); m_rootNode->addChild( RightAscension() ); m_rootNode->addChild( Declination() ); m_rootNode->addChild( Star() ); SoQtExaminerViewer* myRenderArea = new SoQtExaminerViewer( examinerWidget ); myRenderArea->setSceneGraph( m_rootNode ); SbColor col( 0.86f, 0.86f, 0.86f ); myRenderArea->setBackgroundColor(col); myRenderArea->show( ); QWidget* labelsWidget = new QWidget; mainLayout->addWidget( labelsWidget ); QGridLayout* labelsLayout = new QGridLayout; labelsWidget->setLayout( labelsLayout ); QLabel* m_rightLabel = new QLabel; m_rightLabel->setText( "Right Ascension:" ); labelsLayout->addWidget( m_rightLabel, 0, 0, 1, 1 ); m_rightValue = new QLabel; m_rightValue->setText( QString::number( m_rightAscension ) ); labelsLayout->addWidget( m_rightValue, 0, 1, 1, 3 ); QLabel* m_declinationLabel = new QLabel; m_declinationLabel->setText( "Declination:" ); labelsLayout->addWidget( m_declinationLabel, 1, 0, 1, 1 ); m_declinationValue = new QLabel; m_declinationValue->setText( QString::number( m_declination ) ); labelsLayout->addWidget( m_declinationValue, 1, 1, 1, 3 ); }
Star StarShip::createStar() { QPointF dir = chooseRandomDirection(); QPoint pos = chooseRandomPosition(); int random = (rand() % 2); int size = 24; // BIG if (random == 0) { size = 8; // SMALL } else if (random == 1) { size = 16; // MEDIUM } Star newStar = Star(pos); newStar.setDirection(dir); newStar.setSize(size); return newStar; }
void CelestialWidget::CoordinatesChanged( cSunCoordinates coordinates ) { m_rightAscension = coordinates.dRightAscension; m_rightValue->setText( QString::number( m_rightAscension ) ); m_declination = coordinates.dDeclination; m_declinationValue->setText( QString::number( m_declination ) ); //Right Ascension SoSeparator* ascension = RightAscension(); m_rootNode->replaceChild( 5, ascension ); //Declination SoSeparator* declination = Declination(); m_rootNode->replaceChild( 6, declination ); //Star SoSeparator* star = Star(); m_rootNode->replaceChild( 7, star ); }
void readStars(QTextStream &stream, Galaxy &galaxy) { QString line = stream.readLine().trimmed(); while (!line.isNull()) { if(line.contains("StarId")) { QStringRef idRef(&line,6,line.indexOf(' ')-6); unsigned id=idRef.toInt(); galaxy.addStar(Star(stream, galaxy, id)); } else if(line.contains('}')) { break; } line = stream.readLine().trimmed(); } }
void HorizontalWidget::CoordinatesChanged( cSunCoordinates coordinates ) { m_azimuth = coordinates.dAzimuth; m_azimuthValue->setText( QString::number( m_azimuth ) ); m_zenith = coordinates.dZenithAngle; m_zenithValue->setText( QString::number( m_zenith ) ); //Azimuth Line update SoSeparator* azimuth = AzimuthLine(); m_rootNode->replaceChild( 4, azimuth ); //Zenith Line update SoSeparator* zenith = ZenithLine(); m_rootNode->replaceChild( 5, zenith ); //Star update SoSeparator* star = Star(); m_rootNode->replaceChild( 6, star ); }
// Same as above, but each star gets some acceleration Stars::Stars(bool speed) { useSpeed = speed; opacity = 1; stars.reserve(10000); for (int i=0; i<10000; i++) stars.push_back(Star(this)); for (std::vector<Star>::iterator i=stars.begin(); i!=stars.end(); ++i) { i->position.x = (double(rand())/RAND_MAX); i->position.y = (double(rand())/RAND_MAX); i->position.z = (double(rand())/RAND_MAX)*-1; i->position.x *= 5000; i->position.x += 50; i->position.y *= 5000; i->color.x = 1.0-(double(rand())/RAND_MAX) * 0.4 + 0.3; i->color.y = 1.0-(double(rand())/RAND_MAX) * 0.4 + 0.2; i->color.z = 1.0-(double(rand())/RAND_MAX) * 0.4 + 0.1; i->size = rand() % 3 + 1; i->velocity.x = -1.6; i->velocity.y = (double(rand())/RAND_MAX)*-1*0.05; i->firstChaotic = true; } }
void ofApp::setup() { snapCounter = 0; bSnapshot = true; phase = 0; radius = 40; rotationRadius = 500; lightSource = ofLight(); lightSource.setPointLight(); lightSource.setAttenuation(0.15f, 0.0013f, 0.f); // setup colors ofColor colors[4] = { ofColor(255, 100, 100), ofColor(255, 255, 100), ofColor(255, 255, 255), ofColor(100, 100, 255) }; // randomly select a color from 0.0-1.0 float colorRatio = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); if (colorRatio > 0.666f) { lightColor = colors[2].getLerped(colors[3], (colorRatio-0.666f)/(1-0.666f)); } else if (colorRatio > 0.333f) { lightColor = colors[1].getLerped(colors[2], (colorRatio - 0.333f) / (0.666f - 0.333f)); } else{ lightColor = colors[0].getLerped(colors[1], colorRatio / (0.333f)); } lightSource.setDiffuseColor(ofColor(255,255,255)); lightSource.setSpecularColor(lightColor); lightSource.setPosition((cos(phase) * rotationRadius), 0, sin(phase) * rotationRadius); //material.setShininess(40); //material.setSpecularColor(lightColor); // setup stars int numStars = 200 + rand() % 200; for (int i = 0; i < numStars; i++) { float theta = (float)rand(); float phi = (float)rand(); stars.push_back(Star(theta, phi, 2 * rotationRadius, ofColor(255, 255, 255))); } // setup camera cameraTheta = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); cameraTheta = (0.5-cameraTheta)*(3.1415926535)*(.6); // -.6pi to .6pi range cameraPhi = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); cameraPhi = (0.5-cameraPhi)*(3.1415926535)*(0.5); //-0.2pi to 0.2pi range camera.setPosition(150*sin(cameraTheta), 150*sin(cameraPhi), 150*cos(cameraTheta)); camera.lookAt(ofVec3f(0.f,0.f,0.f)); // GL configs ofSetVerticalSync(true); ofEnableDepthTest(); ofSetSmoothLighting(true); ofSetSphereResolution(64); ofDisableArbTex(); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glLightModelf(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); // load texture imgIn.load(fname); texture = imgIn.getTexture(); glEnable(GL_DEPTH_TEST); quadric = gluNewQuadric(); // Create A Pointer To The Quadric Object gluQuadricTexture(quadric, GL_TRUE); // Create Texture Coords gluQuadricNormals(quadric, GLU_SMOOTH); // Create Smooth Normals }
void MainState::logic() { ship.updatePosition(); //Erase any bullet that is not on screen, or move them is they are on screen for(std::list<Bullet>::iterator itBullet = activeBullets.begin(); itBullet != activeBullets.end(); ++itBullet) { if(itBullet->getXPos() < 0 || itBullet->getXPos() > SCREEN_WIDTH || itBullet->getYPos() < 0 || itBullet->getYPos() > SCREEN_HEIGHT) { itBullet = activeBullets.erase(itBullet); --itBullet; } else { itBullet->move(0, -20); } } //Move or remove aliens for(std::list<Alien>::iterator itAlien = activeAliens.begin(); itAlien != activeAliens.end(); ++itAlien) { if(itAlien->getXPos() < 0 || itAlien->getXPos() > SCREEN_WIDTH || itAlien->getYPos() < 0 || itAlien->getYPos() > SCREEN_HEIGHT) { itAlien = activeAliens.erase(itAlien); --itAlien; } else { itAlien->move(0, 2); for(std::list<Bullet>::iterator itBullet = activeBullets.begin(); itBullet != activeBullets.end(); ++itBullet) { if(itAlien->collidesWith(*itBullet)) { itAlien->takeDamage(10); itBullet = activeBullets.erase(itBullet); --itBullet; } } if(itAlien->getCurrentHP() <= 0) { itAlien = activeAliens.erase(itAlien); --itAlien; } } } for(std::list<Star>::iterator it = activeStars.begin(); it != activeStars.end(); ++it) { if(it->getYPos() > SCREEN_HEIGHT) { it = activeStars.erase(it); --it; } else { it->move(0, 1); } } //Spawn new aliens if the time is right ticksUntilNextAlien--; if(ticksUntilNextAlien == 0) { int numAliens = (rand() % 3) + 1; for(int i = 0; i < numAliens; i++) { activeAliens.push_back(Alien((rand() % (SCREEN_WIDTH - 20) + 20), 30)); } ticksUntilNextAlien = ALIEN_TICK_INTERVAL; } ticksUntilNextStar--; if(ticksUntilNextStar == 0) { activeStars.push_back(Star()); //std::cout << activeStars.size() << std::endl; ticksUntilNextStar = STAR_TICK_INTERVAL; } }
Star Star::rotate(double dist) { Point p = point().rotate(dist); return Star(p.x, p.y, r, bear); }
Nfa* Nfa::Plus(Nfa* nfa) { return Concatenate(nfa, Star(nfa)); }
//************************************************************************************************************* void Render(float alpha, float elapsedtime) { LPDIRECT3DSURFACE9 oldtarget = NULL; D3DXMATRIX vp, inv, tmp1, tmp2; D3DXVECTOR3 axis(0, 1, 0); D3DXVECTOR3 eye(0, 0, -5); D3DXVECTOR3 look(0, 0, 0); D3DXVECTOR3 up(0, 1, 0); D3DXVECTOR2 cangle = cameraangle.smooth(alpha); D3DXVECTOR2 oangle = objectangle.smooth(alpha); float expo = exposure.smooth(alpha); D3DXMatrixRotationYawPitchRoll(&world, cangle.x, cangle.y, 0); D3DXVec3TransformCoord(&eye, &eye, &world); D3DXMatrixLookAtLH(&view, &eye, &look, &up); D3DXMatrixMultiply(&vp, &view, &proj); D3DXMatrixInverse(&inv, NULL, &view); memcpy(&eye, inv.m[3], 3 * sizeof(float)); if( mesh == mesh1 ) { // skullocc D3DXMatrixScaling(&world, 0.4f, 0.4f, 0.4f); world._42 = -1.5f; } else if( mesh == mesh2 ) { // knot D3DXMatrixScaling(&world, 0.8f, 0.8f, 0.8f); } else { // teapot D3DXMatrixScaling(&world, 1.5f, 1.5f, 1.5f); } D3DXMatrixRotationYawPitchRoll(&tmp1, oangle.x, oangle.y, 0); D3DXMatrixMultiply(&world, &world, &tmp1); D3DXMatrixInverse(&inv, NULL, &world); fresnel->SetVector("eyePos", (D3DXVECTOR4*)&eye); fresnel->SetMatrix("matWorld", &world); fresnel->SetMatrix("matWorldInv", &inv); fresnel->SetMatrix("matViewProj", &vp); D3DXMatrixScaling(&world, 20, 20, 20); skyeffect->SetMatrix("matWorld", &world); D3DXMatrixIdentity(&world); skyeffect->SetMatrix("matWorldSky", &world); skyeffect->SetMatrix("matViewProj", &vp); memcpy(tmpvert, quadvertices, 36 * sizeof(float)); if( SUCCEEDED(device->BeginScene()) ) { device->SetRenderState(D3DRS_SRGBWRITEENABLE, false); device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); // STEP 1: render sky device->GetRenderTarget(0, &oldtarget); if( firstframe ) { device->SetRenderTarget(0, aftersurfaces[0]); device->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0); device->SetRenderTarget(0, aftersurfaces[1]); device->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0); device->SetRenderTarget(0, avglumsurfaces[4]); device->Clear(0, NULL, D3DCLEAR_TARGET, 0x11111111, 1.0f, 0); device->SetRenderTarget(0, avglumsurfaces[5]); device->Clear(0, NULL, D3DCLEAR_TARGET, 0x11111111, 1.0f, 0); firstframe = false; } device->SetRenderTarget(0, scenesurface); device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0); device->SetRenderState(D3DRS_ZENABLE, FALSE); device->SetTexture(0, skytexture); skyeffect->Begin(NULL, 0); skyeffect->BeginPass(0); { skymesh->DrawSubset(0); } skyeffect->EndPass(); skyeffect->End(); device->SetRenderState(D3DRS_ZENABLE, TRUE); // STEP 2: render object device->SetTexture(0, texture); device->SetTexture(1, fresneltexture); device->SetTexture(2, skytexture); device->SetTexture(3, roughspecular); fresnel->Begin(NULL, 0); fresnel->BeginPass(0); { mesh->DrawSubset(0); } fresnel->EndPass(); fresnel->End(); device->SetVertexDeclaration(vertexdecl); // STEP 3: measure average luminance MeasureLuminance(); // STEP 4: adapt luminance to eye AdaptLuminance(elapsedtime); // STEP 5: bright pass BrightPass(); // STEP 6: downsample bright pass texture DownSample(); // STEP 7: blur downsampled textures Blur(); // STEP 8: ghost LensFlare(); // STEP 9: star Star(); // STEP 10: final combine hdreffect->SetTechnique("final"); hdreffect->SetFloat("targetluminance", targetluminance); device->SetRenderTarget(0, oldtarget); device->SetTexture(0, scenetarget); // scene device->SetTexture(1, blurtargets[0]); // blur device->SetTexture(2, blurtargets[1]); // star device->SetTexture(3, ghosttargets[0]); // ghost device->SetTexture(4, afterimages[1 - afterimagetex]); device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); device->SetRenderState(D3DRS_SRGBWRITEENABLE, true); oldtarget->Release(); hdreffect->Begin(NULL, 0); hdreffect->BeginPass(0); { device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, sizeof(D3DXVECTOR4) + sizeof(D3DXVECTOR2)); } hdreffect->EndPass(); hdreffect->End(); if( drawhelp ) { // render text device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1); device->SetRenderState(D3DRS_ZENABLE, FALSE); device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); device->SetTexture(0, text); device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, textvertices, 6 * sizeof(float)); device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); device->SetRenderState(D3DRS_ZENABLE, TRUE); } // clean up device->SetTexture(1, NULL); device->SetTexture(2, NULL); device->SetTexture(3, NULL); device->SetTexture(4, NULL); device->SetTexture(5, NULL); device->EndScene(); } device->Present(NULL, NULL, NULL, NULL); }
int main() { Star(); return 0; }
/* ********************************** @ Implemented by Hung Q. Nguyen & Daniel Santos @ Note: + 4/30: First time Implemented + 5/01: Modified the method * ***********************************/ void Universe::Universe::fetchStar() { // Instanciate Stars and push it to starList for (unsigned int i = 0; i < numStars; i++) starList_.push_back(Star(window_.getSize(), starList_)); }