示例#1
0
void VART::Transform::MakeTranslation(const VART::Point4D& translationVector)
{
    MakeIdentity();
    matrix[12] = translationVector.GetX();
    matrix[13] = translationVector.GetY();
    matrix[14] = translationVector.GetZ();
}
示例#2
0
文件: poligno.cpp 项目: jvanz/cg
void Poligno::desenha(void)
{
    /*Desenha o ponto se o objeto estiver selecionado*/
    unsigned int index;
    if(this->isSelecionado()) {
        glColor3f(1.0, 0.0, 0.0);
        for(index = 0; index < this->ListaPontos.size(); index++) {
            glBegin(GL_POINTS);
            VART::Point4D * ponto = this->ListaPontos[index];
            glVertex2f(ponto->GetX(),ponto->GetY());
            glEnd();
        }
        glBegin(GL_LINE_LOOP);
        glVertex2f(this->getBBox()->getMinX(),this->getBBox()->getMinY());
        glVertex2f(this->getBBox()->getMaxX(),this->getBBox()->getMinY());
        glVertex2f(this->getBBox()->getMaxX(),this->getBBox()->getMaxY());
        glVertex2f(this->getBBox()->getMinX(),this->getBBox()->getMaxY());
        glEnd();
    }
    /*Desenha o poligno*/
    glColor3f(r,g,b);
    glBegin(GL_POLYGON);
    for(index = 0; index < this->ListaPontos.size(); index++) {
        VART::Point4D * ponto = this->ListaPontos[index];
        glVertex2f(ponto->GetX(),ponto->GetY());
    }
    glEnd();

    this->desenhaFilhos();
}
示例#3
0
void VART::BoundingBox::ApplyTransform(const VART::Transform& trans) {
    VART::BoundingBox box = *this;

    VART::Point4D ptoBBox = trans * VART::Point4D(box.GetSmallerX(),box.GetSmallerY(),box.GetSmallerZ());
    this->SetBoundingBox(ptoBBox.GetX(),ptoBBox.GetY(),ptoBBox.GetZ(),ptoBBox.GetX(),ptoBBox.GetY(),ptoBBox.GetZ());
    this->ConditionalUpdate(trans * VART::Point4D(box.GetSmallerX(), box.GetSmallerY(), box.GetGreaterZ()));
    this->ConditionalUpdate(trans * VART::Point4D(box.GetSmallerX(), box.GetGreaterY(), box.GetGreaterZ()));
    this->ConditionalUpdate(trans * VART::Point4D(box.GetSmallerX(), box.GetGreaterY(), box.GetSmallerZ()));
    this->ConditionalUpdate(trans * VART::Point4D(box.GetGreaterX(), box.GetSmallerY(), box.GetSmallerZ()));
    this->ConditionalUpdate(trans * VART::Point4D(box.GetGreaterX(), box.GetSmallerY(), box.GetGreaterZ()));
    this->ConditionalUpdate(trans * VART::Point4D(box.GetGreaterX(), box.GetGreaterY(), box.GetGreaterZ()));
    this->ConditionalUpdate(trans * VART::Point4D(box.GetGreaterX(), box.GetGreaterY(), box.GetSmallerZ()));
    ProcessCenter();
}
示例#4
0
bool VART::BoundingBox::testPoint( VART::Point4D p )
{
	std::cout << "Test point" << std::endl;
	
    if (p.GetX() < smallerX)
        return false;
    if (p.GetX() > greaterX)
        return false;
    if (p.GetZ() < smallerZ)
        return false;
    if (p.GetZ() > greaterZ)
        return false;
    if (p.GetY() < smallerY)
        return false;
    if (p.GetY() > greaterY)
        return false;
    return true;

}
示例#5
0
void VART::Transform::MakeRotation(const VART::Point4D& refVec, const float radians)
{
    VART::Point4D projEmY;
    VART::Point4D vetTemp;
    VART::Transform tTemp;
    double anguloY;
    double anguloZ;

    //Decompor refVec
    //Angulo em Y (para levar o vetor ao plano XY)
    if (Zero(refVec.GetZ()))
    {
        anguloY = 0.0;
        this->MakeIdentity();
        vetTemp = refVec;
    }
    else
    {
        // se o vetor nao esta no plano XY...
        projEmY.SetXYZW(refVec.GetX(), 0, refVec.GetZ(), 0);
        projEmY.Normalize();
        if (refVec.GetZ() < 0)
            anguloY = -(projEmY.AngleTo(VART::Point4D(1,0,0,0)));
        else
            anguloY = projEmY.AngleTo(VART::Point4D(1,0,0,0));
        this->MakeYRotation(anguloY);
        vetTemp = (*this) * refVec; //refVec no plano XY
    }
    //Angulo em Z (para levar o vetor ao X)
    if (vetTemp.GetY() < 0)
        anguloZ = vetTemp.AngleTo(VART::Point4D(1,0,0,0));
    else
        anguloZ = -(vetTemp.AngleTo(VART::Point4D(1,0,0,0)));
    tTemp.MakeZRotation(anguloZ);
    this->CopyMatrix(tTemp * (*this));
    //Rodar
    tTemp.MakeXRotation(radians);
    this->CopyMatrix(tTemp * (*this));
    //voltar
    tTemp.MakeZRotation(-anguloZ);
    this->CopyMatrix(tTemp * (*this));
    tTemp.MakeYRotation(-anguloY);
    this->CopyMatrix(tTemp * (*this));
}
示例#6
0
VART::Point4D VART::Transform::operator *(const VART::Point4D& point) const
{
    VART::Point4D result;

    return VART::Point4D(  matrix[0]*point.GetX()  + matrix[4]*point.GetY()
                     + matrix[8]*point.GetZ()  + matrix[12]*point.GetW(),
                       matrix[1]*point.GetX()  + matrix[5]*point.GetY()
                     + matrix[9]*point.GetZ()  + matrix[13]*point.GetW(),
                       matrix[2]*point.GetX()  + matrix[6]*point.GetY()
                     + matrix[10]*point.GetZ() + matrix[14]*point.GetW(),
                       matrix[3]*point.GetX()  + matrix[7]*point.GetY()
                     + matrix[11]*point.GetZ() + matrix[15]*point.GetW());
}
示例#7
0
void VART::BoundingBox::ConditionalUpdate(const VART::Point4D& point) {
    ConditionalUpdate(point.GetX(), point.GetY(), point.GetZ());
}