Advertisement Jump to content
  • Advertisement

3dnewbie

Member
  • Content Count

    114
  • Joined

  • Last visited

Community Reputation

100 Neutral

About 3dnewbie

  • Rank
    Member
  1. I don't think so, no. It's not a translate first, then rotate problem (i think). I can move wherever i want, no problem, the grid doesn't get in my way. But when i have a grid of say 40^2, and i move from the center (which rotates fine) all the way to the left, and i rotate, the rest of the grid i left 'behind' is still moving around 0,0. I'll post a vid this afternoon.
  2. I'll probably post a short clip to demonstrate what's going wrong. Let me make clear, i can rotate around myself no problem with the mouse, and i can look everywhere, but when i move to the left or wherever, it's like i translate, but still rotate around the original axis (0,0). The 0,0 never moves, i move around it. Like a line that keeps me centered there. It's like i rotate, but not translate. Hope i don't sound to confusing here.
  3. (mods, please move the other post in opengl forum to nothingness, this is more relevant forum i think) Hi, I've posted questions about this before but i was busy with other projects since then, and now i would like to get back into it and fix some outstanding problems. I hope gamedev community can answer my questions, i'll provide relevant code and screenshots. Please, be aware that i don't know that much about ogl code, i'm a average c programmer and i use GLUT for compatibility. My program displays a 2d gridmatrix in a 3d environment where i can move with either the keyboard or the mouse (used for fps freeview, still using forward and backward keys to move). The keyboard seems to work fine, but the mouse function although it seems ok, really isn't. The problem is that it always rotates around it's axis from where the matrix was created from (with matrix i mean the grid i created). So if i move all the way to the left of the grid, when i rotate around myself with the mouse, the whole grid moves around me. I added code as some requested, hope it is not to much and it's understandable. screenshot : screen main rendering code: GLfloat fps; GLvoid render(void) { static GLint frame=0; static GLint timebase=0; GLint time=0; pthread_t tid_network; static GLint init=1; static GLfloat user_x_prev=0; static GLfloat user_y_prev=0; /* Clear color and depth buffer */ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* Reset MODELVIEW and PROJECTION matrices */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* We move -6 into the z-axis */ glTranslatef(0,0,-6.0); /* We rotate the matrix with 95.0 on the x-axis */ glRotatef(95.0,1.0f,0.0f,0.0); /* Transformations for FREELOOK */ if(FREELOOK) { if(init) { user_x=user_x_prev; user_y=user_y_prev; init=0;} glRotatef(user_x,1.0f,0.0,0.0f); glRotatef(-user_y,0.0f,0.0,1.0f); glTranslatef(0.0f,0.0,a); glTranslatef(b,0.0f,0.0f); user_x_prev=user_x; user_y_prev=user_y;} else { init=1;} /* We perform zoom function if requested. This is the only navigational control that is put here. Zoom does not work properly in the idle() function. */ glTranslatef(0.0f,0.0f,f); /* Zoom in/out */ glMatrixMode(GL_PROJECTION); /* Calculate our frame rate */ frame++; time=glutGet(GLUT_ELAPSED_TIME); if ((time-timebase) > 1000) { fps = frame*1000.0/(time-timebase); timebase = time; frame = 0; } /* Display options */ if(GRID) display_grid(); if(OBJECTS) display_objects(); if(OBJECT_PROPERTIES) display_object_properties(); if(COORDINATE) display_coordinate(); if(STATISTICS) display_stats(); if(EVENTVIEW) display_events(); /* Engine options */ engine_options(); } glFlush(); glutSwapBuffers(); } my display_grid() code: (it creates quads and overlays them with lines to create a nice matrix) GLint x,y,z; GLint sector_size=SECTOR_SIZE; /* 2 */ GLint grid_size=GRID_SIZE; /* variable say 30 */ GLint grid_start=GRID_START; /*currently -5 */ GLint grid_object=GRID_OBJECT; GLvoid display_grid(GLvoid) { glBegin(GL_QUADS); for(x=grid_start;x<grid_size;x+=sector_size) { for(y=grid_start;y<grid_size;y+=sector_size) { /* Set color for QUADS */ glColor4f(0.0f,0.0f,0.2,1.0f); /* Draw QUADS */ glVertex3f(x,y,0); /* Left bottom */ glVertex3f(x+sector_size,y,0); /* Right bottom */ glVertex3f(x+sector_size,y+sector_size,0); /* Right upper */ glVertex3f(x,y+sector_size,0); /* Left upper */ } } glEnd(); glBegin(GL_LINES); for(x=grid_start;x<grid_size;x+=sector_size) { for(y=grid_start;y<grid_size;y+=sector_size) { /* Set color for LINES */ glColor4f(0.0f,0.2f,0.0,0.5f); /* Draw lines */ glVertex3f(x,y,0); glVertex3f(x+sector_size,y,0); glVertex3f(x+sector_size,y,0); glVertex3f(x+sector_size,y+sector_size,0); glVertex3f(x+sector_size,y+sector_size,0); glVertex3f(x,y+sector_size,0); glVertex3f(x,y+sector_size,0); glVertex3f(x,y,0); } } glEnd(); } my idle() function: GLvoid idle(GLvoid) { /* Transformations for CONTROL */ glRotatef(c,1.0f,0.0f,0.0f); /* Tilt x-axis */ glRotatef(d,0.0f,1.0f,0.0f); /* Tilt y-axis */ glRotatef(e,0.0f,0.0f,1.0f); /* Tilt z-axis */ glTranslatef(0.0f,0.0,a); /* Forward/Backward */ glTranslatef(b,0.0f,0.0f); /* Left/Right */ glutPostRedisplay(); } my mouse_move() code: GLfloat user_x,user_y,user_z; GLvoid mouse_move(GLint x,GLint y) { user_x+=(y-user_pos_y); user_pos_y=y; user_y+=(x-user_pos_x); user_pos_x=x; if(user_x>360.0f) user_x-=360.0f; if(user_x<0.0f) user_x+=360.0f; if(user_y>360.0f) user_y-=360.0f; if(user_y<0.0f); user_y+=360.0f; }
  4. Hi, I've posted questions about this before but i was busy with other projects since then, and now i would like to get back into it and fix some outstanding problems. I hope gamedev community can answer my questions, i'll provide relevant code and screenshots. Please, be aware that i don't know that much about ogl code, i'm a average c programmer and i use GLUT for compatibility. My program displays a 2d gridmatrix in a 3d environment where i can move with either the keyboard or the mouse (used for fps freeview, still using forward and backward keys to move). The keyboard seems to work fine, but the mouse function although it seems ok, really isn't. The problem is that it always rotates around it's axis from where the matrix was created from (with matrix i mean the grid i created). So if i move all the way to the left of the grid, when i rotate around myself with the mouse, the whole grid moves around me. I added code as some requested, hope it is not to much and it's understandable. screenshot : screen main rendering code: GLfloat fps; GLvoid render(void) { static GLint frame=0; static GLint timebase=0; GLint time=0; pthread_t tid_network; static GLint init=1; static GLfloat user_x_prev=0; static GLfloat user_y_prev=0; /* Clear color and depth buffer */ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* Reset MODELVIEW and PROJECTION matrices */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /* We move -6 into the z-axis */ glTranslatef(0,0,-6.0); /* We rotate the matrix with 95.0 on the x-axis */ glRotatef(95.0,1.0f,0.0f,0.0); /* Transformations for FREELOOK */ if(FREELOOK) { if(init) { user_x=user_x_prev; user_y=user_y_prev; init=0;} glRotatef(user_x,1.0f,0.0,0.0f); glRotatef(-user_y,0.0f,0.0,1.0f); glTranslatef(0.0f,0.0,a); glTranslatef(b,0.0f,0.0f); user_x_prev=user_x; user_y_prev=user_y;} else { init=1;} /* We perform zoom function if requested. This is the only navigational control that is put here. Zoom does not work properly in the idle() function. */ glTranslatef(0.0f,0.0f,f); /* Zoom in/out */ glMatrixMode(GL_PROJECTION); /* Calculate our frame rate */ frame++; time=glutGet(GLUT_ELAPSED_TIME); if ((time-timebase) > 1000) { fps = frame*1000.0/(time-timebase); timebase = time; frame = 0; } /* Display options */ if(GRID) display_grid(); if(OBJECTS) display_objects(); if(OBJECT_PROPERTIES) display_object_properties(); if(COORDINATE) display_coordinate(); if(STATISTICS) display_stats(); if(EVENTVIEW) display_events(); /* Engine options */ engine_options(); } glFlush(); glutSwapBuffers(); } my display_grid() code: (it creates quads and overlays them with lines to create a nice matrix) GLint x,y,z; GLint sector_size=SECTOR_SIZE; /* 2 */ GLint grid_size=GRID_SIZE; /* variable say 30 */ GLint grid_start=GRID_START; /*currently -5 */ GLint grid_object=GRID_OBJECT; GLvoid display_grid(GLvoid) { glBegin(GL_QUADS); for(x=grid_start;x<grid_size;x+=sector_size) { for(y=grid_start;y<grid_size;y+=sector_size) { /* Set color for QUADS */ glColor4f(0.0f,0.0f,0.2,1.0f); /* Draw QUADS */ glVertex3f(x,y,0); /* Left bottom */ glVertex3f(x+sector_size,y,0); /* Right bottom */ glVertex3f(x+sector_size,y+sector_size,0); /* Right upper */ glVertex3f(x,y+sector_size,0); /* Left upper */ } } glEnd(); glBegin(GL_LINES); for(x=grid_start;x<grid_size;x+=sector_size) { for(y=grid_start;y<grid_size;y+=sector_size) { /* Set color for LINES */ glColor4f(0.0f,0.2f,0.0,0.5f); /* Draw lines */ glVertex3f(x,y,0); glVertex3f(x+sector_size,y,0); glVertex3f(x+sector_size,y,0); glVertex3f(x+sector_size,y+sector_size,0); glVertex3f(x+sector_size,y+sector_size,0); glVertex3f(x,y+sector_size,0); glVertex3f(x,y+sector_size,0); glVertex3f(x,y,0); } } glEnd(); } my idle() function: GLvoid idle(GLvoid) { /* Transformations for CONTROL */ glRotatef(c,1.0f,0.0f,0.0f); /* Tilt x-axis */ glRotatef(d,0.0f,1.0f,0.0f); /* Tilt y-axis */ glRotatef(e,0.0f,0.0f,1.0f); /* Tilt z-axis */ glTranslatef(0.0f,0.0,a); /* Forward/Backward */ glTranslatef(b,0.0f,0.0f); /* Left/Right */ glutPostRedisplay(); } my mouse_move() code: GLfloat user_x,user_y,user_z; GLvoid mouse_move(GLint x,GLint y) { user_x+=(y-user_pos_y); user_pos_y=y; user_y+=(x-user_pos_x); user_pos_x=x; if(user_x>360.0f) user_x-=360.0f; if(user_x<0.0f) user_x+=360.0f; if(user_y>360.0f) user_y-=360.0f; if(user_y<0.0f); user_y+=360.0f; }
  5. 3dnewbie

    GLUT mousemove question

    No that is not the problem. I don't want to warp the mouse pointer. Besides, as the man page states, it should rarely (if never be used). I just want to be able to rotate around my axis when i'm using the mouse, instead of rotating against my previous position.
  6. Hi everyone. I have a problem with my implemention of mousemove. I use both keyboard and mouse freelook in my fps, whereas keyboard works fine by rotating an angle on a plane, when i use the mouse, although it looks like it works, in contrast to the keyboard (which uses a glrotatef) the mousemove function keeps moving around the same axis (0,0). So i can move all the way to the left, but it will make giant leaps if you know what i mean. I contrary to the keyboard navigation which always revolves nicely around itself. I know i sounds like a gltranslate/glrotate problem, but seeing i use a more simpler and easier implementation for my 'freelook' implemenation, i'm not sure it is such a problem. (by freelook i mean being able to see everywhere (up,down,left,right like in a fps). F.e. #include "fps.h" GLfloat user_x,user_y,user_z; GLvoid mouse_move(GLint x,GLint y) { user_x+=(y-user_pos_y); user_pos_y=y; user_y+=(x-user_pos_x); user_pos_x=x; if(user_x>360.0f) user_x-=360.0f; if(user_x<0.0f) user_x+=360.0f; if(user_y>360.0f) user_y-=360.0f; if(user_y<0.0f); user_y+=360.0f; glutPostRedisplay(); } This is simply what i use for my keyboard navigation: GLvoid idle(GLvoid) { /* Start some necessary transformations */ /* Navigation controls */ glTranslatef(0.0f,0.0,a); /* Forward/Backward */ glTranslatef(b,0.0f,0.0f); /* Left/Right */ /* NOTE: Zoom function is in main display loop */ glRotatef(c,1.0f,0.0f,0.0f); /* Tilt x-axis */ glRotatef(d,0.0f,1.0f,0.0f); /* Tilt y-axis */ glRotatef(e,0.0f,0.0f,1.0f); /* Tilt z-axis */ glutPostRedisplay(); } I hope you understand my problem. If not i can elaborate.
  7. Ok, i am wondering how to handle this. Imagine i'm coding on a 1024x768 resolution. Everything looks fine, but then someone runs my software on his 640x480 platform and all of a sudden my eventviewer is to large to handle his screen estate. I mean stuff that has dynamic boundaries like a world isn't that bad i guess, but a eventviewer or a box with a message has boundaries. How do i fix this ? I can imagine a few solutions, but i'm not sure this is the proper way. 1. take the resolution upon startup and use that to calculate boundaries for boxes 2. only 1 resolution. don't run on anything less or more. 3. disallow resize of the window but how do games do this? they usually start at one resolution and then you can set it yourself ingame. Do they start at the lowest resolution possible? I'm really at a loss how to implement this properly. And another question regarding those boxes. If i have a event in my eventviewer, do i really have to hardcode the size of the event so that it not goes through the eventbox? It seems like a tacky/hacky way to do this. Any help on how to approach this would be greatly appreciated. I'm programming on a mac on 1680x1050 now, and you can imagine that although it looks good on this machine, it would certainly be cropped on a ibook with 1024x768. Any help greatly appreciated!
  8. sorry, please move if not appropiate topic, but i couldn't find where to put it otherwise. but WHAT is up with the spyware on this site. Man, this is like the 10th time if not more that some errsafe clone tries to install itself. Today i even had it at work. This was a CLEAN install, and yet when i visit gamedev, it immetiately pops up errsafe or something alike. sorry, but this make me not want to visit this website more. please remove these annoying (and potentially dangerous) ads so we can all enjoy the knowledge available on this site again. until then, this site will not be visited by me again. [Edited by - LessBread on May 25, 2007 2:10:26 PM]
  9. ah, i'm sorry. i thought i probably misunderstood the question posed. I haven't done much with texturing yet, and seeing i want to use it later on in my project, where i have a scene of hundreds of objects, which i all want to have a photorealistic look, of which at least 100 preferably different photos, but i'll settle for 1 if i have to :-). Mind you, how will the performance be ? There have been games like this as well right? Ofcourse, i could devise something that doesnt render those objects which are not in my frustum, which should save alot of fps already. Also, what does the poster mean? 16 Simultaneous textures means 16 Simultaneously (but can be different) photos right ? But nevermind then ;-)
  10. Just a question; if i want to use lots of different photos as textures, say 100 different photos (all in same scene) on different cubes, can i do this?
  11. I can't figure out what i'm doing wrong here: It's a console which displays events. Because i dont want events to display out of the box (events that go out of the boundaries of the frame i created for the console, i slice and dice them into say 85 chars. Now this works fine, but whenever i start my test of sending long strings to the console, what happens is, instead of the first line displaying in order, it shows the second part of the long line 85 chars. It chooses the branch where my comment is made (see COMMENT 1) while(tmp->prev!=NULL&&i++<LINE_MAXIMUM) { glColor4f(atof(tmp->red),atof(tmp->green),atof(tmp->blue),atof(tmp->alpha)); event_ptr=tmp->event; len=strlen(tmp->event); /* Display our events and wrap them nicely if the string is longer then EVENT_LENGTH */ while(1) { strncpy(event_string,event_ptr,EVENT_LENGTH); event_string[EVENT_LENGTH]='\0'; // COMMENT 1 /* Obviously the first time called it doesnt think len==strlen(tmp->event) while it also obviously should be! */ if(len==strlen(tmp->event)) renderbitmapfont(x_event,y_event+=x_event,0,"%s:%s:%s",tmp->timestamp,tmp->hostname,event_string); /* A strange bug manifests itself here. The first line it receives alway behaves like a later part of a string, and never shows the first part. Why it does this i have no idea. */ else renderbitmapfont(x_event,y_event+=x_event,0,"%s",event_string); if(len<=EVENT_LENGTH) break; len-=EVENT_LENGTH; event_ptr+=EVENT_LENGTH; } tmp=tmp->prev; } unset_ortho();
  12. Hi, I use this to fake a pseudo freelook like in fps, but it always rotates around coordinate 0,0. So when i go left a bit, the orbit increases because it stills rotates around 0,0, even though 0,0 is not in the centre anymore. It would like it to always rotate around the center of the screen. I hope you know what i mean. How would i go about doing this ? /* Rotations for FREELOOK */ if(FREELOOK) { if(init) { user_x=user_x_prev; user_y=user_y_prev; init=0;} glRotatef(user_x,1.0f,0.0f,0.0f); glRotatef(-user_y,0.0f,0.0f,1.0f); user_x_prev=user_x; user_y_prev=user_y;} else { init=1;}
  13. 3dnewbie

    Troubles with GLUT sighandler

    well i could split it up but the translate does work in the timercall. so should i then put the actual drawing in the main loop and the translate in the timer function? for example i set a bool value in the timer func and check for it in the main drawing function then draw what i want to draw? seems a bit hacky that way..
  • 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!