示例#1
0
void Sequence::update() {
    int nbUsers = gen.user.GetNumberOfUsers();

    if (nbUsers==0){
        printf("end update seq with no users\n");
        return;
    }

    Metric newMetric;
    newMetric.height = 0;
    newMetric.width = 0;

    for (int user=1; user<=nbUsers;user++){
        int indexUser=-1;
        XnPoint3D com;
        gen.user.GetCoM(user, com);
        for (int i=0; i < movingObjects.size(); i++) {
            if (movingObjects[i].getXnId()==user) {
                indexUser = i;
                movingObjects[i].update(newMetric); //tells the moving object that there is new data. he can update his self
            }
        }
        if (indexUser<0 && (com.Z > 0.001)) {
            for (int j=0; j < movingObjects.size(); j++) {
                if(movingObjects[j].getState() == SEPERATED){
                    movingObjects[j].setState(OUT_OF_SIGHT);
                    movingObjects[j].setXnId(0);
                }
            }
            movingObjects.push_back(MovingObject(user, gen, dir));
            indexUser = movingObjects.size() - 1;
            movingObjects[indexUser].update(newMetric); //tells the moving object that there is new data. he can update his self

        }
    }
}
MovingObject::MovingObject()
{
    MovingObject(QUEUESIZE);
}