How should the object be defined to behave as one?

0

I created a function using the OpenGl libraries to create a piece of Chess (the King's piece), what happens is that I first make the body by rotation, and in the end I create the cross as a sweep of the figure. But when plotted they behave like 2 different objects, that is, they do not rotate as the same object but each one on their own. I do not know if I'm explaining myself well.

void DrawRey(void){

int nSlices=200;
double dTheta=2.0*PI/nSlices;
int nPoints=13;
for (int i=0; i<nSlices;i++)
{
    double theta=i*dTheta;
    double theta_next=(i+1)*dTheta;


        //glVertex3f(x,y,z);

    glBegin(GL_POLYGON); 
    for (int j=0; j<nPoints; j++)
    {
        double x=PuntosRey[j][0];
        double y=PuntosRey[j][1];
        double z=PuntosRey[j][2];
            //glVertex3f(Points[j][0]*cos(theta)+Points[j][2]*sin(theta),Points[j][1],-Points[j][0]*sin(theta)+Points[j][2]*cos(theta));
        glVertex3f(x,y,z);

        double xNext=PuntosRey[j][0]*cos(theta_next)+PuntosRey[j][2]*sin(theta_next);
        double yNext=PuntosRey[j][1];
        double zNext=-PuntosRey[j][0]*sin(theta_next)+PuntosRey[j][2]*cos(theta_next);
        //glVertex3f(xNext,yNext,zNext);

        PuntosReySig[j][0]=xNext;
        PuntosReySig[j][1]=yNext;
        PuntosReySig[j][2]=zNext;


    }
    glEnd(); 

    for (int j=0; j<nPoints; j++)
    {
        PuntosRey[j][0]=PuntosReySig[j][0];
        PuntosRey[j][1]=PuntosReySig[j][1];
        PuntosRey[j][2]=PuntosReySig[j][2];
    }
    //glVertex3f(x,y,z);
}

int nSlicesC=10;
double dx=PI*0.35;
double dy=PI*0.35;
double dz=PI*0.35;
int nPointsC=13;
for (int i=0; i<nSlicesC;i++)
{
    glBegin(GL_QUADS); 
    for (int j=0; j<nPointsC; j++)
    {
        double x=PuntosCruz[j][0];
        double y=PuntosCruz[j][1];
        double z=PuntosCruz[j][2];

        glVertex3f(x,y,z);

        double xNext=x;
        double yNext=y;
        double zNext=z+dz;
        //glVertex3f(xNext,yNext,zNext);

        PuntosCruzSig[j][0]=xNext;
        PuntosCruzSig[j][1]=yNext;
        PuntosCruzSig[j][2]=zNext;


    }
    glEnd(); 
    for (int j=1; j<nPointsC; j++)
    {
       glBegin(GL_POLYGON); 


        glVertex3f(PuntosCruzSig[j][0],PuntosCruzSig[j][1],PuntosCruzSig[j][2]);    
        glVertex3f(PuntosCruz[j][0],PuntosCruz[j][1],PuntosCruz[j][2]);     
        glVertex3f(PuntosCruz[j-1][0],PuntosCruz[j-1][1],PuntosCruz[j-1][2]);               
        glVertex3f(PuntosCruzSig[j-1][0],PuntosCruzSig[j-1][1],PuntosCruzSig[j-1][2]);


       glEnd();
    }

    for (int j=0; j<nPointsC; j++)
    {
        PuntosCruz[j][0]=PuntosCruzSig[j][0];
        PuntosCruz[j][1]=PuntosCruzSig[j][1];
        PuntosCruz[j][2]=PuntosCruzSig[j][2];
    }
}
glFlush();

}

    
asked by pakoxtror 08.10.2018 в 00:27
source

0 answers