Beispiel #1
0
void TesseractWidget::mousePressEvent(QMouseEvent *event) {
    if (mousetracked) {
        QVector<QMap<int,Bnode>::iterator>vec;
        if (event->button()==Qt::LeftButton) {
            if (creatingblock) {
                Bnode b=Bnode(currentblocktype,(TheWorld->Myself->LookAt+tempc)/2,((TheWorld->Myself->LookAt-tempc)/2).Abs());
                QVariantMap qvm;
                qvm.insert("type","addblock");
                qvm.insert("bt",b.Type);
                qvm.insert("posx",b.Position.x);
                qvm.insert("posy",b.Position.y);
                qvm.insert("posz",b.Position.z);
                qvm.insert("hsx",b.HalfSize.x);
                qvm.insert("hsy",b.HalfSize.y);
                qvm.insert("hsz",b.HalfSize.z);
                emit TheSocket->sendVariantMap(qvm,-1);
                creatingblock=0;
            } else {
                tempc=TheWorld->Myself->LookAt;
                creatingblock=1;
            }
        } else if (event->button()==Qt::RightButton) {
            if (creatingblock)
                creatingblock=0;
            else {
                if ((vec=TheWorld->ThroughBlock(TheWorld->Myself->Position,TheWorld->Myself->LookAt)).size()) {
                    QVariantMap qvm;
                    qvm.insert("type","rmblock");
                    qvm.insert("num",vec[0].key());
                    emit TheSocket->sendVariantMap(qvm,-1);
                }
            }
        }
    }
}
Beispiel #2
0
void TesseractWidget::recvVariantMap(int,QString,quint16,const QVariantMap &qvm) {
    if (qvm["type"].toString()=="wsize") {
        TheWorld->Size=Coordinate(qvm["x"].toDouble(),qvm["y"].toDouble(),qvm["z"].toDouble());
        Player::CanGo=TheWorld->Size;
    } else if (qvm["type"].toString()=="addblock") {
        Bnode b=Bnode(qvm["bt"].toString(),Coordinate(qvm["posx"].toDouble(),qvm["posy"].toDouble(),qvm["posz"].toDouble()),Coordinate(qvm["hsx"].toDouble(),qvm["hsy"].toDouble(),qvm["hsz"].toDouble()));
        TheWorld->Blocks.insert(qvm["num"].toInt(),b);
        QMap<int,Bnode>::iterator it=TheWorld->Blocks.find(qvm["num"].toInt());
        emit TheWorld->blockCreateSignal(it);
    } else if (qvm["type"].toString()=="rmblock") {
        emit TheWorld->blockDestroySignal(TheWorld->Blocks.find(qvm["num"].toInt()));
        TheWorld->Blocks.remove(qvm["num"].toInt());
    } else if (qvm["type"].toString()=="rmuser") {
        TheWorld->Players.remove(qvm["num"].toInt());
    } else if (qvm["type"].toString()=="adduser") {
        Player p;
        p.Name=qvm["name"].toString();
        TheWorld->Players.insert(qvm["num"].toInt(),p);
    } else if (qvm["type"].toString()=="mvuser") {
        if (qvm["num"]!=TheWorld->Myself.key())
            TheWorld->Players[qvm["num"].toInt()].Position=Coordinate(qvm["x"].toDouble(),qvm["y"].toDouble(),qvm["z"].toDouble());
    } else if (qvm["type"].toString()=="essentialplugin") {
        if (PM->Plugins.find(qvm["name"].toString())==PM->Plugins.end()) {
            QMessageBox::warning(0,"Exiting","Missing Plugin: "+qvm["name"].toString());
            close();
        }
    }
}
Beispiel #3
0
Link_Data::Link_Data (int link) : Class_Index (link)
{
	Anode (0);
	Bnode (0);
	Length (0);
	Aoffset (0);
	Boffset (0);
	Use (0);
	Type (0);
	AB_Dir (0);
	BA_Dir (0);
	Shape (0);
}
Beispiel #4
0
void TesseractWidget::paintGL() {
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(75,aspect,.1,1000);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(TheWorld->Myself->Position.x,TheWorld->Myself->Position.y,TheWorld->Myself->Position.z,TheWorld->Myself->LookAt.x,TheWorld->Myself->LookAt.y,TheWorld->Myself->LookAt.z,TheWorld->Myself->HeadVector.x,TheWorld->Myself->HeadVector.y,TheWorld->Myself->HeadVector.z);
    emit TheWorld->drawBeginSignal();
    for (QMap<int,Bnode>::iterator it=TheWorld->Blocks.begin(); it!=TheWorld->Blocks.end(); ++it) {
        bool Cancel=0;
        emit TheWorld->drawBlockSignal(it,Cancel);
        if (Cancel==0) {
            if (it.value().PointedAt==0)
                DrawBlock(it.value(),2);
            else
                DrawBlock(it.value(),3);
        }
    }
    if (creatingblock)
        DrawBlock(Bnode(currentblocktype,(TheWorld->Myself->LookAt+tempc)/2,((TheWorld->Myself->LookAt-tempc)/2).Abs()),1);
    for (QMap<int,Player>::iterator it=TheWorld->Players.begin(); it!=TheWorld->Players.end(); ++it)
        if (it!=TheWorld->Myself)
            DrawPlayer(it.value());
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    emit TheWorld->drawDoneSignal();
    SetColor(TheWorld->BlockTypes[currentblocktype].Color);
    renderText(20,20,currentblocktype);
    glEnable(GL_LIGHTING);
    glEnable(GL_DEPTH_TEST);
    glFlush();
}