void display2()
{
  glClear(GL_COLOR_BUFFER_BIT);
  glLoadIdentity();
  star2();
  glutSwapBuffers();
}
Beispiel #2
0
pardisoMatrix DDGMatrices::delta2( meshMetaInfo & aMesh )
{
	pardisoMatrix star_2= star2(aMesh);
	//pardisoMatrix d_1 = d1(aMesh);
	pardisoMatrix duald0 = dual_d0(aMesh);

	pardisoMatrix star_1_inv = star1(aMesh);
	star_1_inv.elementWiseInv(0.0000000);

	return star_1_inv * duald0 * star_2;
	//return (star_1_inv % d_1)* star_2;
}
void MyModel_Pixels::initialise()
{
    for(size_t i=0; i<ni; ++i)
        y[i] = y_max - (i + 0.5)*dy;

    for(size_t j=0; j<nj; ++j)
        x[j] = x_min + (j + 0.5)*dx;

    double rsq;

    double limb_darkening_coefficient = 1.0;

    // Argh column-major order
    // Star image
    double tot = 0.0;
    for(size_t j=0; j<nj; ++j)
    {
        for(size_t i=0; i<ni; ++i)
        {
            rsq = x[j]*x[j] + y[i]*y[i];
            if(rsq < 1.0)
            {
                star(i, j) = 1.0 -
                    limb_darkening_coefficient*(1.0 - sqrt(1.0 - rsq));
            }
            else
                star(i, j) = 0.0;
            tot += star(i, j);
        }
    }
    for(size_t j=0; j<nj; ++j)
        for(size_t i=0; i<ni; ++i)
            star(i, j) /= tot;

    arma::mat star2 = star;
    int m, n;
    for(int i=0; i<(int)ni; i++)
    {
        m = DNest4::mod(i - (int)ni/2, (int)ni);
        for(int j=0; j<(int)nj; j++)
        {
            n = DNest4::mod(j - (int)nj/2, (int)nj);
            star2(m, n) = star(i, j);
        }
    }

    fft_of_star = arma::fft2(star2);
}
Beispiel #4
0
//Main Event Loop
void EventHandler::EventLoop()
{
    struct timeval myTimeval;
    struct timezone myTimezone;
    gettimeofday(&myTimeval, &myTimezone);
    srand(myTimeval.tv_usec);

    Star star(-10.0f,0.0f,0.0f,10.0f); //top left
    Star star2(0.0f, 10.0f, -10.0f,0.0f); //bot right
    Star star3(-10.0f, 0.0f, -10.0f,0.0f); //bot left
    Star star4(0.0f, 10.0f, 0.0f,10.0f); //top right
    SDL_Event event;
    while(!m_bQuit)
    {
        if(SDL_PollEvent(&event))
        {          
            switch(event.type)
            {
                case SDL_QUIT:
                    m_bQuit=true;
                    break;
                case SDL_KEYDOWN:
                {
                    if(event.key.repeat)
                    {
                        break;
                    }
                    ShipIntf *pShip = 0;
                    uint32 command = 0;
                    switch(event.key.keysym.scancode)
                    {
                        case SDL_SCANCODE_B:
                            //TBD do test things
                            break;
                        case SDL_SCANCODE_X:
                            m_bQuit=true;
                            break;
                        case SDL_SCANCODE_Q: //Stop the ship exactly where it is,
                        case SDL_SCANCODE_R: //Reset to 0 position
                        case SDL_SCANCODE_A: //left
                        case SDL_SCANCODE_D: //right
                        case SDL_SCANCODE_W: //up
                        case SDL_SCANCODE_S: //shoot
                        case SDL_SCANCODE_E: //bomb
                            pShip=m_ships[0];
                            break;

                        case SDL_SCANCODE_U: //Stop the ship exactly where it is,
                        case SDL_SCANCODE_P: //Reset to 0 position
                        case SDL_SCANCODE_J: //left
                        case SDL_SCANCODE_L: //right
                        case SDL_SCANCODE_I: //up
                        case SDL_SCANCODE_K: //shoot
                        case SDL_SCANCODE_O: //bomb
                            if(m_ships.Length() > 1)
                            {
                                pShip = m_ships[1];
                            }
                            break;
                        default:
                            break;
                    };
                    if(pShip)
                    {
                        command=KeyDown(event.key.keysym.scancode);
                        pShip->ProcessInput(command);
                    }   
                }
                break;
                case SDL_KEYUP:
                {
                    ShipIntf *pShip = 0;
                    uint32 command = 0;
                    switch(event.key.keysym.scancode)
                    {
                        case SDL_SCANCODE_Q: //Stop the ship exactly where it is,
                        case SDL_SCANCODE_R: //Reset to 0 position
                        case SDL_SCANCODE_A: //left
                        case SDL_SCANCODE_D: //right
                        case SDL_SCANCODE_W: //up
                        case SDL_SCANCODE_S: //shoot
                        case SDL_SCANCODE_E: //bomb
                            pShip=m_ships[0];
                            break;
                        case SDL_SCANCODE_U: //Stop the ship exactly where it is,
                        case SDL_SCANCODE_P: //Reset to 0 position
                        case SDL_SCANCODE_J: //left
                        case SDL_SCANCODE_L: //right
                        case SDL_SCANCODE_I: //up
                        case SDL_SCANCODE_K: //shoot
                        case SDL_SCANCODE_O: //bomb
                            if(m_ships.Length() > 1)
                            {
                                pShip = m_ships[1];
                            }
                            break;
                        default:
                            break;
                    };
                    if(pShip)
                    {
                        command=KeyUp(event.key.keysym.scancode);
                        pShip->ProcessInput(command);
                    }   

                }
                break;
                case SDL_USEREVENT:
                {
                    //All of the user event types should have a ship pointer
                    ShipIntf *pShip = reinterpret_cast<ShipIntf*>(event.user.data1);
                    pShip->ProcessInput(event.user.code);
                }                    
                break;
                default:
                    break;
            }
        }
        
        //Do the physics stepping
        m_world.Step(m_timeStep, m_velocityIterations, m_positionIterations);
        m_world.ClearForces();

        ProcessEffects();
        
        //clear the screen
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        star.Draw();
        star2.Draw();
        star3.Draw();
        star4.Draw();
        //Draw objects that need to be drawn
        m_walls.Draw();

        //Ships store/draw their own bullets
        ProcessShips();
        
        //Display the back buffer
        SDL_GL_SwapWindow(m_pWindow);
        
        //Sleep to not eat the machine
        SDL_Delay(60);
    }

}