Elencu007

07-27-2013, 10:20 AM

Hello, people. I have a function that outputs the x, y and z coordinates of a vertex after selecting it from 3D sphere mesh. Each vertex in my project also has an id. Now, I need a certain vertex, for example the vertex with the id=40 to move in a different direction, so I have to give it new x, y and z coordinates. Here is the function:

void mouse(int button, int state, int x, int y)

{

GLint viewport[4];

GLdouble modelview[16],

projection[16];

GLfloat wx=x, wy, wz;

if(state!=GLUT_DOWN)

return;

if(button==GLUT_RIGHT_BUTTON)

exit(0);

glGetIntegerv(GL_VIEWPORT,viewport);

y=viewport[3]-y;

wy=y;

glGetDoublev(GL_MODELVIEW_MATRIX,modelview);

glGetDoublev(GL_PROJECTION_MATRIX,projection);

glReadPixels(x,y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&wz);

gluUnProject(wx,wy,wz,modelview,projection,viewpor t,&ox,&oy,&oz);

glutPostRedisplay();

printf("made pick on %f %f %f \n", ox, oy, oz);

pick(x,y);

Vertex.x=ox;

Vertex.y=oy;

Vertex.z=oz;

processhits (nhits, buffer);

if (vertexSelectat==40)

{

Vertex.x=-54.261713;

Vertex.y=-18.614050;

Vertex.z=-163.609310;

}

}

In my project, Vertex is defined as follows:

typedef struct Vertex {

float x, y, z;

int id;

} Vertex;

After I build the project, I get 6 errors "syntax error: missing ';' before '.' after every line where I specify Vertex coordinates. I am new to both OpenGL and C++ so sorry if this is a silly question. Waiting for some help, thank you for your time :). If you request, I can attach the whole project here.

void mouse(int button, int state, int x, int y)

{

GLint viewport[4];

GLdouble modelview[16],

projection[16];

GLfloat wx=x, wy, wz;

if(state!=GLUT_DOWN)

return;

if(button==GLUT_RIGHT_BUTTON)

exit(0);

glGetIntegerv(GL_VIEWPORT,viewport);

y=viewport[3]-y;

wy=y;

glGetDoublev(GL_MODELVIEW_MATRIX,modelview);

glGetDoublev(GL_PROJECTION_MATRIX,projection);

glReadPixels(x,y,1,1,GL_DEPTH_COMPONENT,GL_FLOAT,&wz);

gluUnProject(wx,wy,wz,modelview,projection,viewpor t,&ox,&oy,&oz);

glutPostRedisplay();

printf("made pick on %f %f %f \n", ox, oy, oz);

pick(x,y);

Vertex.x=ox;

Vertex.y=oy;

Vertex.z=oz;

processhits (nhits, buffer);

if (vertexSelectat==40)

{

Vertex.x=-54.261713;

Vertex.y=-18.614050;

Vertex.z=-163.609310;

}

}

In my project, Vertex is defined as follows:

typedef struct Vertex {

float x, y, z;

int id;

} Vertex;

After I build the project, I get 6 errors "syntax error: missing ';' before '.' after every line where I specify Vertex coordinates. I am new to both OpenGL and C++ so sorry if this is a silly question. Waiting for some help, thank you for your time :). If you request, I can attach the whole project here.