Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Hardcode a vertex

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    4

    Hardcode a vertex

    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:

    Code :
    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,viewport,&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:

    Code :
    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.
    Last edited by Elencu007; 07-28-2013 at 08:19 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •