Пример #1
0
bool CPalet::detectionCollision(CVector3 *_poPosBoule, int *i)
{
    CVector3 positionObjet;
    this->getPosition(&positionObjet);

    float ys=_poPosBoule->fGetY();
    float yc=positionObjet.fGetY();
    float zs=_poPosBoule->fGetZ();
    float zc=positionObjet.fGetZ();
    float L=2*scale->fGetY()*0.4;
    float l=2*scale->fGetZ()*1.2;

    Rectangle rect(yc,zc,L+0.3,l+0.3);
    if (rect.contains(ys,zs))
    {
        if (fabs(ys-yc)<((l/2))) {
            *i=0;
        }
        else {
            *i=1;
        }
        return true;
    }
    return false;
}
Пример #2
0
/**
 * @brief CGLArea::paintGL
 *
 * Fonction de dessin sur la fenetre openGL
 */
void CGLArea::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLoadIdentity();
    //    paintRef();



    GLfloat ambientLight[] = {0.2f, 0.2f, 0.2f, 1.0f};
    GLfloat lightColor[] = {0.6f, 0.6f, 0.6f, 1.0f};
    GLfloat lightPos[] ={10,0,-15,1};

    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
    glLightfv(GL_LIGHT0, GL_SPECULAR, lightColor);
    glLightfv(GL_LIGHT0, GL_POSITION, lightPos);


    maSphere->vSetMaterialColor();


    CVector3 oPos;
    maSphere->vGetPosition(&oPos);

    glLoadIdentity();
    glTranslatef(oPos.fGetX(), oPos.fGetY(), oPos.fGetZ());

    // For each face...
    for(int j=0; j<maSphere->iGetNbFaces(); j++)
    {


        glBegin(GL_POLYGON);
        // For each vertex of the face
        for(int k=0;k<maSphere->iGetNbVertices(j);k++)
        {
            CVector3 oVertex;
            CVector3 oNormal;
            maSphere->vGetVertex(j,k,&oVertex);
            maSphere->vGetNormale(j,k,&oNormal);
            glNormal3f(oVertex.fGetX(), oVertex.fGetY(), oVertex.fGetZ());
            glVertex3f(oVertex.fGetX(), oVertex.fGetY(), oVertex.fGetZ());
        }
        glEnd();
    }
}
Пример #3
0
bool CBord::detectionCollision(CVector3 *_poPosBoule, int *i)
{
    CVector3 positionObjet;
    this->getPosition(&positionObjet);

    double ys=_poPosBoule->fGetY();
    double yc=positionObjet.fGetY();
    double zs=_poPosBoule->fGetZ();
    double zc=positionObjet.fGetZ();
    double L=2*scale->fGetY();
    double l=2*scale->fGetZ();
    if((fabs(ys-yc))<((l/2)+0.25))
    {
        return true;
    }
    if((fabs(zs-zc))<((l/2)+0.25))
    {
        return true;
    }
    return false;
}