Exemplo n.º 1
0
int main( int argc, char **argv ) {
    QApplication a( argc, argv );
    OctreeNode n1;
    GLWidget *w = new GLWidget();
    GLData* g = w->addObject();
    
    GLData* rnd = w->addObject();
    RandomSource src( rnd );
    QObject::connect( w->timer, SIGNAL(timeout()), &src, SLOT(timeOutSlot()) );
    
    std::cout << " genVBO()\n";
    /*
    g->setTriangles(); 
    g->setPosition(1,0,-6);
    g->setUsageStaticDraw();
    g->addVertex(-1.0f,-1.0f, 0.0f,  1.0f,0.0f,0.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) ); 
    g->addVertex( 1.0f,-1.0f, 0.0f,  0.0f,1.0f,0.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( 0.0f, 1.0f, 0.0f,  0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( 1.0f, 1.0f, 0.0f,  1.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( -1.0f, 1.0f, 0.0f,  1.0f,1.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    g->addVertex( -2.0f, 0.0f, 0.0f,  1.0f,1.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n1, _1, _2) );
    std::vector<GLuint> poly(3);
    //poly.resize(3);
    poly[0]=0; poly[1]=1; poly[2]=2;
    g->addPolygon( poly );
    poly[0]=2; poly[1]=1; poly[2]=3;
    g->addPolygon( poly );
    poly[0]=0; poly[1]=2; poly[2]=4;
    g->addPolygon( poly );
    poly[0]=0; poly[1]=5; poly[2]=4;
    g->addPolygon( poly );
    g->print();
    //std::cout << "removePolygon()\n";
    //g.removePolygon(0);
    std::cout << "removeVertex(4)\n";
    g->removeVertex(4);
    g->print();
*/
    // now try a quad.
    OctreeNode n2;
    GLData* q = w->addObject();
    q->setQuads();
    q->setPosition(2,0,-6);
    q->setUsageStaticDraw(); 
    q->addVertex(-3.0f,0.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-3.0f,1.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-4.0f,1.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    q->addVertex(-4.0f,0.0f,0.0f,0.0f,0.0f,1.0f, boost::bind(&OctreeNode::indexSwap, &n2, _1, _2));
    std::vector<GLuint> quad(4);
    quad[0]=0; quad[1]=1; quad[2]=2; quad[3]=3;
    q->addPolygon(quad);
    
    q->print();
    std::cout << "Q removeVertex(3)\n";
    //q->removeVertex(0);
    q->print();
    
    w->show();
    return a.exec();
}
Exemplo n.º 2
0
GLWidget::GLWidget(QWidget *parent) :
    QGLWidget(parent)
{
    m_timer = new QTimer(this);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()));
    m_timer->start(50);
}
Exemplo n.º 3
0
GLWidget::GLWidget(GameType type, QSize fieldSize, QWidget *parent) :
    QGLWidget(parent),
    _type(type)
{


    int fszX =fieldSize.width();
    int fszY =fieldSize.height();


    resize(600,600);
    setMinimumSize(600,600);
    setMaximumSize(600,600);

    makeCurrent();
    _painter = new QPainter();

    int fct = max(fszX, fszY);
    int sz = min(width()/(fct+2), height()/(fct+2));
    _scene = new Scene(_painter, QSize(width(), height()), QPoint(sz,sz), sz, fszX, fszY);
    _figures = new PlayersFigures(_painter, _scene);
    _gameRules = new GameRules(fszX, fszY, _figures);

    connect(&_timer,SIGNAL(timeout()), this ,SLOT(timeOutSlot()));

    setAutoFillBackground(true);

}
Exemplo n.º 4
0
GLWidget::GLWidget(QWidget* parent, int timerInterval, const QString& name, GLWidget* shareWidget) :
    QGLWidget(parent, shareWidget),
    mName(name)
{
    mTimer.setInterval(timerInterval);
    connect(&mTimer, SIGNAL(timeout()), this, SLOT(timeOutSlot()));
    mHasRememberedSize = false;
}
Exemplo n.º 5
0
Window::Window(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Window)
{
    ui->setupUi(this);

//   connect(ui->myGLWidget, SIGNAL(xRotationChanged(int)), ui->rotXSlider, SLOT(setValue(int)));
//   connect(ui->myGLWidget, SIGNAL(yRotationChanged(int)), ui->rotYSlider, SLOT(setValue(int)));
//   connect(ui->myGLWidget, SIGNAL(zRotationChanged(int)), ui->rotZSlider, SLOT(setValue(int)));

    connect(ui->singleStepButton, SIGNAL(clicked()), this, SLOT(timeOutSlot()));

    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
    m_timer = new QTimer( this );
    connect( m_timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()) );
    m_timer->start( 16 );
}
Exemplo n.º 6
0
CW1Part1::CW1Part1( int timerInterval, QWidget *parent, char *name ){
	srand((unsigned)time(0));

	if( timerInterval == 0 ){
		m_timer = 0;
	} else {
		m_timer = new QTimer( this );
		connect( m_timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()) );
		m_timer->start( timerInterval );
	}
}
Exemplo n.º 7
0
int CMiniJeu::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGLWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: miniJeuFini((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: timeOutSlot(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Exemplo n.º 8
0
GLWidget::GLWidget( CurveComparer* cc, QWidget *parent ) : QGLWidget( parent )
{
    this->cc = cc;

    int timerInterval = 1000 / 30; // second / fps
    timer = new QTimer( this );
    connect( timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()));
    timer->start( timerInterval );

    posX = 0.0f;
    posY = -7.0f;
    posZ = -50.0f;
    rotationY = 0.0f;
    rotationX = 0.0f;
}
myGLWidget::myGLWidget(int framesPerSecond, QWidget *parent, char *name)
    : QGLWidget(parent)
{
    setWindowTitle(QString::fromUtf8(name));
    if(framesPerSecond == 0)
        t_Timer = NULL;
    else
    {
        int seconde = 1000; // 1 seconde = 1000 ms
        int timerInterval = seconde / framesPerSecond;
        t_Timer = new QTimer(this);
        connect(t_Timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()));
        t_Timer->start( timerInterval );
    }
}
Exemplo n.º 10
0
myGLWidget::myGLWidget(int framesPerSecond, QWidget *parent, char *name)
    : QGLWidget(parent)
{
    setWindowTitle(QString::fromUtf8(name));
    std::cout << "Height Parent Test=" << parent->height() << std::endl;
    //move(820, 1000);
    hide();
    resize(250, 60);
    if(framesPerSecond == 0)
        t_Timer = NULL;
    else
    {
        int seconde = 1000; // 1 seconde = 1000 ms
        int timerInterval = seconde / framesPerSecond;
        t_Timer = new QTimer(this);
        connect(t_Timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()));
        t_Timer->start( timerInterval );
    }
}
Exemplo n.º 11
0
GLWidget::GLWidget(int framesPerSecond, QWidget *parent)
    : QGLWidget(parent)
{
    //setWindowTitle(QString::fromStdString(name));
    if(framesPerSecond == 0)
        t_Timer = NULL;
    else
    {
        int seconde = 1000;
        int timerInterval = seconde / framesPerSecond;
        t_Timer = new QTimer(this);
        connect(t_Timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()));
        t_Timer->start( timerInterval );        
    }

    this->setMinimumHeight(parent->minimumHeight());
    this->setMinimumWidth(parent->minimumWidth());
    this->setMaximumHeight(parent->maximumHeight());
    this->setMaximumWidth(parent->maximumWidth());
}
Exemplo n.º 12
0
GLWidget::GLWidget( QWidget *parent, char *name ) 
  : QGLWidget(parent) {
    timer = new QTimer(this);
    timer->setInterval(1000);
    connect( timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()) );
    timer->start();
    _fovy = 60.0;
    z_near = 0.1;
    z_far = 100.0;
    _up.x=0;
    _up.y=1;
    _up.z=0;
    _up *= 1/_up.norm();
    _eye.x=0;
    _eye.y=0;
    _eye.z=6;
    _center.x=0;
    _center.y=0;
    _center.z=0;
    //setCursor(cursor);
    updateDir();
}