Jump to content
  • Advertisement
Sign in to follow this  

picking and change alpha....not the same but still

This topic is 4074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everybody ,-the same problem ....but a litte bite smaller...- can you please tell me whay I didn't pick hte correct place: so I have to draw icosahedron by bolygons and each one with different color and for this part ,it is right now sems okay ,but I need in additional change the aplha value for each pick of each one and what I did some thing like this : what I static void Render(GLenum mode) { GLint i; for (i = 0; i < 20; i++) { if (mode == GL_SELECT) { glLoadName(i); } glColor4fv(objects.color); glBegin(GL_POLYGON); icoNormVec(i); glVertex3fv(&vdata[tindices[0]] [0]); glVertex3fv(&vdata[tindices[1]] [0]); glVertex3fv(&vdata[tindices[2]] [0]); glEnd(); if (mode == GL_SELECT) { glPopName(); } } } static void Mouse(int button, int state, int mouseX, int mouseY) { GLint hit; if (state == GLUT_DOWN) { hit = DoSelect((GLint) mouseX, (GLint) mouseY); if (hit != -1) { if (button == GLUT_LEFT_BUTTON) { RecolorTri(hit); } else if (button == GLUT_MIDDLE_BUTTON) { GrowTri(hit); } else if (button == GLUT_RIGHT_BUTTON) { DeleteTri(hit); } glutPostRedisplay(); } } } static void Draw(void) { glPushMatrix(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho (3.0, 3.0, 3.0, 3.0,0.0,0.0); glMatrixMode(GL_MODELVIEW); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glScalef(zoom, zoom, zoom); Render(GL_RENDER); glPopMatrix(); glutSwapBuffers(); } but I get just randomly picking and not to all . Is this because that I didn't use 3d mouse position but realy I didn't know how ..:-( Can you plase tell me what is the wrong ....thanks any way !!!!!!! S H E R E E /***********************************************************/ Hello , thanks for your attention. the rest functions are as following : static GLint DoSelect(GLint x, GLint y) { GLint hits; glSelectBuffer(MAXSELECT, selectBuf); glRenderMode(GL_SELECT); glInitNames(); glPushName(~0); glPushMatrix(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPickMatrix(x, windH - y, 4, 4, vp); gluOrtho2D(-3, 3, -3, 3); glMatrixMode(GL_MODELVIEW); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); glScalef(zoom, zoom, zoom); glRotatef(zRotation, 0, 0, 1); Render(GL_SELECT); glPopMatrix(); hits = glRenderMode(GL_RENDER); if (hits <= 0) { return -1; } return selectBuf[(hits - 1) * 4 + 3]; } static void RecolorTri(GLint h) { objects[h].color[3] =((rand() % 100) + 50) / 150.0; } static void DeleteTri(GLint h) { objects[h] = objects[objectCount - 1]; objectCount--; } static void GrowTri(GLint h) { float v[2]; float *oldV; GLint i; v[0] = objects[h].v1[0] + objects[h].v2[0] + objects[h].v3[0]; v[1] = objects[h].v1[1] + objects[h].v2[1] + objects[h].v3[1]; v[0] /= 3; v[1] /= 3; for (i = 0; i < 3; i++) { switch (i) { case 0: oldV = objects[h].v1; break; case 1: oldV = objects[h].v2; break; case 2: oldV = objects[h].v3; break; } oldV[0] = 1.5 * (oldV[0] - v[0]) + v[0]; oldV[1] = 1.5 * (oldV[1] - v[1]) + v[1]; } } static void Render(GLenum mode) { GLint i; for (i = 0; i < 20; i++) { if (mode == GL_SELECT) { glLoadName(i); } glColor4fv(objects.color); glBegin(GL_POLYGON); icoNormVec(i); glVertex3fv(&vdata[tindices[0]] [0]); glVertex3fv(&vdata[tindices[1]] [0]); glVertex3fv(&vdata[tindices[2]] [0]); glEnd(); if (mode == GL_SELECT) { glPopName(); } } } thanks S H E R E E [Edited by - Sheree on March 26, 2007 1:58:07 PM]

Share this post


Link to post
Share on other sites
Advertisement
Are DoSelect, RecolorTri, GrowTri and DeleteTri glut functions or did you write them. If the latter, please post the code to those functions because that is perhaps where the bug is.

-me

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!