Exemplo n.º 1
0
int main(int argc, char* argv[])
{
    // Virtual Worldの作成
    WorldPtr world = createWorld();
    RobotPtr robot = createRobot(world);

    // Agentの作成
    ActionPtr        action = createAction(robot);
    DistSensorPtr    sensor = createDistSensor(robot);
    EnvironmentPtr   env    = createEnvironment(sensor);
    ThreadedAgentPtr agent  = createAgent(sensor, action);

    // 初期化
    env->init();
    agent->init();
    robot->init();

    QApplication app(argc, argv);
    MainWindow window;
    window.setWorldModel(world);
    window.setRobotModel(robot);
    window.setEnvironment(env);
    window.setAgent(agent);

    window.show();
    return app.exec();
}
Exemplo n.º 2
0
static void display(void) {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -10.0f, 10.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    // Isometric view
    glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
    glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
    
    /*
    glMatrixMode(GL_PROJECTION);
    
    glLoadIdentity();
    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);
    double aspect = (double)viewport[2] / (double)viewport[3];
    gluPerspective(60, aspect, 1, 40);
    
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    */
    // Move back
    //glTranslatef(-6, 0, 0);
    
    // Create the robot
    glRotatef(bodyRotate.y, 0, 1.0f, 0);
    createRobot();
    
    glutSwapBuffers();
}
Exemplo n.º 3
0
void RobotManager::addRobot(Robot::Dynamics dynamics)
{
    Robot* robot = createRobot(dynamics);

    // abort, if robit is unknown
    if (robot == 0)
        return;

    m_robots.append(robot);

    if (m_robots.size() == 1)
        setActiveRobot(robot);

    emit robotCountChanged();
}
Exemplo n.º 4
0
void Canvas::setup(int bots, int lights, QVector<QPointF> botLoc, QVector<QPointF> lightLoc, int **matrix) {

    this->addLine(0,0,400,400);
    if (bots == 0)
    {
        bots = 1;
        qDebug() << "ERROR: Invalid number of robots. Defaulting to 1.";
    }
    if (lights == 0)
    {
        lights = 1;
        qDebug() << "ERROR: Invalid number of lights. Defaulting to 1.";
    }

    if (botLoc.size() < bots)
    {
        botLoc.clear();
        botLoc = defaultBotLoc(bots);
        qDebug() << "ERROR: Not enough robot locations. Using the default locations.";
    }
    if (lightLoc.size() < bots)
    {
        lightLoc.clear();
        lightLoc = defaultLightLoc(lights);
        qDebug() << "ERROR: Not enough light locations. Using the default locations.";
    }
    m_robotManager->setKMatrix(matrix);
    Robot* robot;
    for(int i = 0; i < bots; i++) {
        robot = new Robot();
        robot->setTransformOriginPoint(ROBOT_HEIGHT, ROBOT_HEIGHT);

        robot->setPos(botLoc[i]);

        createRobot(robot);
    }
    LightSource *light;
    for (int i = 0; i < lights; i++)
    {
        light = new LightSource();
        light->setPos(lightLoc[i]);
        // TODO: take intensity from a file
        light->setIntensity(100);
        createLight(light);
    }
}
Exemplo n.º 5
0
void KleptobotFactory::doSomething()            //if factory can create robot and creates it, play sound
{
    if(getWorld()->canCreateRobot(getX(), getY()))
        if(createRobot())
            getWorld()->playSound(SOUND_ROBOT_BORN);
}