Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

140 Neutral

About Silex

  • Rank
  1. I have a somewhat unusual situation in which I want to test for intersection with a theoretical plane, so I want to transform to the camera's modelview matrix and then do a ray-plane collision test rather than testing for OGL object collision. The problem lies in transforming the ray to the camera's modelview. I call a function each frame to update the camera and then save the resulting modelview and projection matrices like so: glMatrixMode(GL_PROJECTION); glLoadIdentity(); fr_x = near_clip * tan( RAD(fov) ); fr_y = fr_x / ((float)dim.x / (float)dim.y); glFrustum( -fr_x, fr_x, -fr_y, fr_y, near_clip, far_clip); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(-90.0, 1.0, 0.0, 0.0); glRotatef(-90.0, 0.0, 0.0, 1.0); glTranslatef( -distance, 0.0, 0.0 ); glRotatef( theta, 0.0, 1.0, 0.0); glRotatef( phi, 0.0, 0.0, 1.0); glTranslatef( -target[0], -target[1], -target[2]); glGetDoublev(GL_PROJECTION_MATRIX,proj); glGetDoublev(GL_MODELVIEW_MATRIX,model); I get this: note: the "X" is where I clicked with the cursor I need that ray to shoot out from the camera rather than the origin. How do you do that? Cheers! [Edited by - Silex on July 30, 2006 10:14:19 PM]
  2. Hi, I'm building a pick ray using the method described in the OpenGL FAQ. I've got as far as building the ray from mouse coordinates. I now need to transform the ray so I can test for intersection using the inverse modelview matrix. My question is: what's the best way to do this? Cheers!
  3. An existing DOM. Essentially I'm tagging metadata to position information with XML so that it can be used by other subscribers. In other words, instead of sending binary (x,y) I'm sending <data t=12345 x=foo y=bar>sadDsaA323AsSs</data>.
  4. I have a need to exchange streams of data packed in xml format over a local network. I've used libxml to parse xml files in the past, but I don't believe it has any methods for serializing. Does anyone have experience with this sort of thing? Cheers!
  5. I realize now I didn't make my problem very clear. This is not to be done once, but automated from a c program. I suppose I am looking for the sort of behavior you would get when searching for a game server on a LAN. Cheers!
  6. I have written a number of simple client/server applications with unix sockets, but I've never had a need to scan a network before. Presume there are a number of machines on a local network that offer certain services. How do I scan each address on the subnet to see if this kind of service is offered on it? Thanks!
  7. Fixed. Apparently I was initializing the texture too early, or something like that. :D Thanks for the help!
  8. I believe the texture is being displayed correctly, however some other texture settings are affecting how its being drawn. To verify this, I changed the glVertex* calls to have the quad cover only half of the screen, and indeed I get half the screen covered in green! Someone on the opengl.org forums suggested I explicitely set glTexEnv to GL_REPLACE so that the texture isn't modulated with the color specified by glColor (since I do indeed use green to draw fonts elsewhere). This didn't help, however. I don't know what else I could try.
  9. Neither works for me. By using the call the glFrustrum I get a black screen (the clear color) and nothing is showing up. Using the identity method, as reproduced below, yields a grey screen with GL_LIGHTING and a screen set to the glColor(...) without GL_LIGHTING. glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture( GL_TEXTURE_2D, debug_tex ); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBegin(GL_QUADS); glTexCoord2f( 0.0f, 1.0f); glVertex2d(-1.0, -1.0); glTexCoord2f( 1.0f, 1.0f); glVertex2d( 1.0, -1.0); glTexCoord2f( 1.0f, 0.0f); glVertex2d( 1.0, 1.0); glTexCoord2f( 0.0f, 0.0f); glVertex2d(-1.0, 1.0); glEnd(); What could be going wrong? Here's how I load the texture in the init code: SDL_Surface* tex_image; if ((tex_image = SDL_LoadBMP("image.bmp"))) { glGenTextures(1, &debug_tex); glBindTexture(GL_TEXTURE_2D, debug_tex); glTexImage2D( GL_TEXTURE_2D, 0, 3, tex_image->w, tex_image->h, 0, GL_BGR, GL_UNSIGNED_BYTE, tex_image->pixels ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printf("loaded image!\n"); } else { printf("couldn't load image!\n"); } if (tex_image) SDL_FreeSurface(tex_image);
  10. should i draw the quad first, before any other primitives?
  11. I'm getting live feed from a webcam which I want to have as background for an augmented reality type application. As it stands, my draw function called each frame does this: (0) set up projection for depth (1) for each object in world: draw (2) set up 2D ortho view (3) draw text on top I'm a little unfamiliar with opengl texturing, but I'd like to set up it so that I'm stretching a texture to cover the entire viewport, and have everything else drawn as normal (except wireframe, in this case) on top regardless of camera orientation. How do I set up my projection matrix to achieve this? How do I make sure the video covers the entire viewport? Thanks!
  12. That narrows it down...let's see, this is how I print: glMatrixMode(GL_PROJECTION); glPushMatrix(); //push temporary projection matrix glLoadIdentity(); gluOrtho2D(0,width,0,height); glMatrixMode(GL_MODELVIEW); glPushMatrix(); //push temporary modelview matrix glLoadIdentity(); glTranslated(x,y,z); glScalef(15,15,15); glfStringCentering(GL_FALSE); glfDrawSolidString(text); glMatrixMode(GL_PROJECTION); glPopMatrix(); //reset old projection matrix glMatrixMode(GL_MODELVIEW); glPopMatrix(); The glfDrawSolidString function just calls glTranslate a few times to place the characters in the string, so I don't think the problem is in there. Am I doing anything wrong in the code above?
  13. Well, first of all I am using glProject. I'm using it instead of drawing the text as 3D objects because in theory it should be easy enough to just draw text at a 2D location projected from a 3D point, and that's what I'd like to get working here. Second, I'm pretty sure viewport takes the values in the format I'm using. [Edited by - Silex on January 2, 2006 1:31:13 PM]
  14. I'm drawing 2D labels (text) that follow my 3D objects around, but as the 3D objects move away from origin the labels move further and further away from the actual 3D object. ASCII art: /\ /\ / .origin \/ object0 \/ object1 \/ object2 The diamonds are the 3D meshes. "object*" are the 2D text labels. Here are the functions I call to get the 2D screen location of a 3D object: double x,y,z; double view[16]; double proj[16]; int viewport[4]; viewport[0]=0; viewport[1]=0; viewport[2]=width; viewport[3]=height; glGetDoublev(GL_MODELVIEW_MATRIX,view); glGetDoublev(GL_PROJECTION_MATRIX,proj); //glGetIntegerv(GL_VIEWPORT,viewport); gluProject((double)ox, (double)oy, (double)oz, view, proj, viewport, &x,&y,&z); print(x,y,z,text); The reason glGetIntergerv(GL_VIEWPORT,viewport) is commented out is that I use four seperate viewports, and with it the labels are completely in the wrong place. By using the total size of the window size each time they match up a lot better, with the exception of the problem I describe above.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!