Ejemplo n.º 1
0
void MainWindow::connectSim(SimThread *sim)
{
    QObject::connect(ui->startButton,SIGNAL(clicked()),sim,SLOT(simRun()));
    QObject::connect(ui->stopButton,SIGNAL(clicked()),sim,SLOT(simStop()));
    QObject::connect(ui->stepButton,SIGNAL(clicked()),sim,SLOT(simStep()));
    QObject::connect(ui->stepButton,SIGNAL(clicked()),this,SLOT(updateMemory()));
    QObject::connect(ui->setupButton,SIGNAL(clicked()),this,SLOT(doSetup()));
    QObject::connect(this,SIGNAL(kbdKeypress(quint8)),sim,SLOT(keypress(quint8)));
}
Ejemplo n.º 2
0
void draw(void)
{
    // set the background color of the world
    cColorf color = camera->getParentWorld()->getBackgroundColor();
    glClearColor(color.getR(), color.getG(), color.getB(), color.getA());

    // clear the color and depth buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // render world in the window display
    camera->renderView(width, height);

    // check for any OpenGL errors
    GLenum err;
    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    // Swap buffers
    glutSwapBuffers();

    if (inContact >= 0) 
    {
        float x =  lastContactPoint.x;
        float y =  lastContactPoint.y;
        float z =  lastContactPoint.z;

        float fx = -force_scale*lastForce.x ;
        float fy = -force_scale*lastForce.y ;
        float fz = -force_scale*lastForce.z ;

        if (loading == 0)
            dBodyAddForceAtPos(obj[inContact].body,fx,fy,fz,x,y,z);
    }

    simStep();
}