# vurentjie

Member

45

134 Neutral

• Rank
Member
1. ## camera space help

ok thanks, i was just trying to figure it out there logically without thinking about it as a matrix operation. But anyway i feel kinda chuffed and silly at the same time, as i did manage to debug my problem. i was testing with hardcoded figures so i translated the camera 4 units up x, then i rotated it 90 degrees so i set a hardcoded camera matrix (not the inverted one) up as follows 0 -1 0 4 1 0 0 0 0 0 0 0 0 0 0 1 can you see the mistake? if the rotation part was like that but i did the translation first then then x-translation should be 0, and the y-translation should be 4 like so, 0 -1 0 0 1 0 0 4 0 0 0 0 0 0 0 1 but alas because i just shoved the figures in there and it completely slipped by. just glad to know that it is working now...made me really tired second guessing myself.
2. ## camera space help

ok i havent had any replies yet, usually i think this is because i havent explained myself well enough, anyhow, i think i have figured out some of my problem, is it correct to say that if i translate my camera then rotate it, then the inverse will also mean an inverse order of operations so for cam translate -> cam rotate the inverse transform would be cam inverserotate -> cam negate translate
3. ## camera space help

hi, i have been trying to write a camera class in actionscript, as i have understood and tried to implement, all points needed to be transformed by the inverse of the camera transform before being projected, i have tried this by first finding the inverse of the 4x4 camera matrix, where i have just focused on the 3x3 rotation part and the translation part, after finding this i have assumed the following CameraMatrixInverse X CoordinateMatrix = TransformedCoordinateMatrix; For the most part the inverse camera matrix seems correct, after calculation the rotation part has been transposed, but I am not sure about the translation part, the reason is if the point's original position is at <0,0,0> the translation is correct relative to the cameras total transform(a translation and rotation), if the point's original position is at <1,0,0> and i just translate the camera 4 units up the x-axis the transformed point is now at <-3,0,0> which seems correct, and if i rotate the camera by 90 degrees about the y-axis the transformed point calculates to <0,0,3>, but i am not quite sure if this is entirely correct... i am sure i am missing something, possibly some kind of camera direction vector, and the more i try to visualize the implementation the more confused i get, i have made a diagram of what is confusing me. You can view it here http://www.skyfies.net/troubleshoot.php Advice, clarification and correction is much appreciated
4. ## get screen size function

ok i did a bit of research on web, and i think what should be done is this.... Rect outAvailableRect; GetAvailableWindowPositioningBounds ( GetMainDevice(), &outAvailableRect); screenwidth = outAvailableRect.right - outAvailableRect.left; screenheight = outAvailableRect.bottom - outAvailableRect.top; is this more or less correct way to go about it?
5. ## get screen size function

hi, i want to write a small function that will detect the user's screen size, i have done a bit of research on the topic for windows it is a pretty simple call to GetSystemMetrics, i looked at Xlib calls, and these seem not to difficult either,something like Display *display_name; display_name = XOpenDisplay(NULL); DisplayWidth(display_name,screen), DisplayHeight(display_name,screen)); i am trying to find out more about the mac system, if anybody has information on this, it would be appreciated. I will continue googling, but thought I would drop a post here, hopefully somebody could provide me some advice. I don't own a mac myself, but can test on a friends. I think I should be looking at the Carbon API, but is this all? this last question sounds a bit duh?!? anyway advice appreciated.
6. ## vertex normal just checkin myself

yes thank you, after i read here yesterday, i go think about it some more, and i did understand that larger areas might have longer normals, and sorry about confusion over auto-magic-ally, i just thought perhaps it was not typo, thank you again, the advice you have shared is so appreciated. it is also nice to try write out what you think should happen, i find it helps me to make more sense of a situation-or find where not making sense.
7. ## vertex normal just checkin myself

thank you for the reply, i must go sleep a bit now, but will comment quickly, i did not realize about normalizing face normals, i retype your txt here to ask/comment at specific, for each vertex zero vertex normal (because going to add to later-yes?) for each face find face normal and normalize//i dont quite understand by "face area factored in", should i be normalizing face normal here? for each face points that are this vertex add face normal to vertex normal normalize normal your's is very nice example of workflow - if you can maybe explain just for interest sake what you mean by face area will automagically be factored in[\quote] maybe just a brief explanation as this is too brief for me to make something of.also not quite sure whether i should/shouldn't normalize face normal as you say autoMAGICally which also confuse me :)
8. ## vertex normal just checkin myself

hi, i want to begin experimenting with smooth shaded mesh objects in opengl, and just want to double check some of the math involved as well as some questions involving the programing operations. i do not ask for someone to do this for me, but advice is always valuable and saves time and the odd ache. so from the many, many articles i have read, and opinions and advice on posts on gamedev, as well as teaching myself about vectors and matrices from a textbook, i think i can grasp the basic concept, 1)i will create a 'closed-rounded' mesh object using mainly a struct for vert position, possibly struct for face data, and possibly vertex data from array, this is not problematic. 2)next i should make a function that computes the normal for each face, via three vertex points on that face and the cross-product to find the perpendicular. 3)then 'somehow' i will have to find a way to find shared vertices for adjacent faces for a closed-object that consists of an arbitrary amount of faces, some function (advice on how to go about this would be appreciated), 4)then i will add together adjacent face normals for a shared vertex - from what i have read, and the math that i have studied in the last while, averaging the normal here, by dividing by amount of faces, is trivial(i might be wrong though), but i am guessing i am not because for the next step, 5)i will normalize the vector to unit length, by firstly computing the vector length then dividing respective x-y-z components by this length...i write this from memory so might be wrong here will double check though. 6)now i have my vertex normals. if it is for a shared vertex the normal will be used for each instance where that vertex is called(i want to use GL_SMOOTH). can anyone please correct if any of this stands wrong.my main difficulty i am guessing is building function to find shared vertices - from thinking about it i am thinking a loop through all faces is first step, but then would i have to take that specific face for each loop iteration and loop again to compare against other faces - is there any math formula to solve this shorter way. Anyway I have said a lot here.Thanks in advance for any feedback.
9. ## stranging fickering with sdl/opengl

ok, thanks for the replies, i have found the cause of my problem and well it does entail glSwapBuffers, it is not because i haven't included it, but basically i found my solution by trying all different gl libs, sdl,sfml,glfw, then eventually a bit of advice from someone, and then checking the manual for glfw at least....which says Quote: There are two ways to handle events in GLFW: Block the event loop while waiting for new events. Poll for new events, and continue the loop regardless if there are any new events or not. The first method is useful for interactive applications that do not need to refresh the OpenGLTM display unless the user interacts with the application through user input. Typical applications are CAD software and other kinds of editors. The second method is useful for applications that need to refresh the OpenGLTM display constantly, regardless of user input, such as games, demos, 3D animations, screen savers and so on. so basically i need to know how i halt the event loop, but don't exit the program... i would guess in SDL i could not use while(SDL_PollEvent(&event)) as this is continually polling for events...but i am totally unsure here...going to have to fiddle some more.
10. ## stranging fickering with sdl/opengl

hi, i have a strange display problem, i first noticed the problem with my own code, but compiling other code gives the same results, i am using using sdl_opengl to drawn with opengl functions, basically any sdl prog that i run on my machine that uses sdl_opengl causes strange flickering to happen, the first time i noticed this was when a windows update reminder popped up from my bottom taskbar, where this pop-up overlapped with my own program window it flickered wildly, also if i click 'start' on the bottom windows taskbar and the 'start' main menu pops up, the drop shadow effect along its edges also flickers madly where it overlaps my sdl window, this only happens with calls to sdl_opengl, otherwise it handles fine, i don't know if anybody else has encountered this before, perhaps it has something to do with my pc setup, or maybe it is something to do with sdl, i don't know, if anyone knows anything about this please tell.
11. ## 3d editor world coords

i eventually found my solution, and that also resolved my misunderstanding, basically i am using gluUnproject, i have a 3d world and a grid for reference, that spans along the x-z plane 10 units in both positive negative directions, and a origin at (0,0,0), the y-axis is represented with a simple red line. i then draw a point on the screen at say position (5.0,5.0,-5.0), when i click with mouse at a different place in the world the point should move to that position, basically i was having problems with my gluUnproject values because I was calling my glGetIntegerv for modelview at the wrong place in my code, i eventually placed it after my camera transformations, and managed to get a decent working result, at least for the near-clip of the camera-space, so now when i click on the mouse it moves the point to a new position in front of the camera view that lies on the near-clip plane, so from here what i think i must do is calculate the vector between the near and far-clip point, then using the coordinates of the point(old point) before the click, calculate a vector that runs through 'old point' and is perpendicular to the near-far vector, then calculate the point of intersection...and that would be my new point. this point will eventually become a cursor to place verts within the 3d world, i need to refresh on the math now, eeek..... ...anyhow, from other articles i have read, i am thinking of utilizing the c++ vector library for some of these operations....i haven't used it before.
12. ## world coords problem

hi, i just want to ask a couple of questions regarding the foundation of a 3d editor, most 3d editors come with a standard ortho/perspective toggle, there is also a cursor positioned within the world co-ordinate system, what is the best ways to move this cursor about by using mouse-clicks within ortho and perspective views, the way i have been trying recently is using gluUnproject, and while i can get the desired results for the near and far clipping with this function, i can't seem to get the desired results on the grid platform that i have built, the main reason is that my grid platform has its origin at 0,0,0 which means that some of it falls outside the nearclip, and gluUnproject only caters for world coords within the scope of near and far-clip, if i translate my grid deeper into the viewport beyond the nearclip, then the center is no longer located at 0,0,0, and i would have to make adjustments for further drawing, however this means that it is well in the bounds between near and far-clip and i can use the z-ray to calculate other values of z that will fall on all points of the grid, and thus move my world cursor according to these.... is what i am saying here even possible?making sense? please advise? from what i thought i understood the near-clip would merely clip anything falling oustide its bounds within the viewframe, so if i had a firstperson camera that could translate its position, i could bring things outside the nearclip into the view by moving backward, however the way i set up my camera is that it translates the modelview matrix, and not the projection matrix, this becomes a problem when using gluUnproject as it is somehow connected to the near and far clip that is set within the projection matrix,which the camera view is not affecting at all, and therefore my near/far clip results in gluUnproject omitting a portion of my grid...... sorry i am getting completely frustrated withmyself trying to explian my point, i wish i could post a minimal code, but there is always the guilt and fear of being reprimanded for clogging the forum with code(would that happen?)..i seriously think if i posted some code i could get a better answer. anyhow if you can make sense of some of this please advise on a direction i could take.... i just realised that i might be able to post an image which would explain my situation perfectly will try that.
13. ## 3d editor world coords

hi, i just want to ask a couple of questions regarding the foundation of a 3d editor, most 3d editors come with a standard ortho/perspective toggle, there is also a cursor positioned within the world co-ordinate system, what is the best ways to move this cursor about by using mouse-clicks within ortho and perspective views, the way i have been trying recently is using gluUnproject, and while i can get the desired results for the near and far clipping with this function, i can't seem to get the desired results on the grid platform that i have built, the main reason is that my grid platform has its origin at 0,0,0 which means that some of it falls outside the nearclip, and gluUnproject only caters for world coords within the scope of near and far-clip, if i translate my grid deeper into the viewport beyond the nearclip, then the center is no longer located at 0,0,0, and i would have to make adjustments for further drawing, however this means that it is well in the bounds between near and far-clip and i can use the z-ray to calculate other values of z that will fall on all points of the grid, and thus move my world cursor according to these.... is what i am saying here even possible?making sense? please advise? from what i thought i understood the near-clip would merely clip anything falling oustide its bounds within the viewframe, so if i had a firstperson camera that could translate its position, i could bring things outside the nearclip into the view by moving backward, however the way i set up my camera is that it translates the modelview matrix, and not the projection matrix, this becomes a problem when using gluUnproject as it is somehow connected to the near and far clip that is set within the projection matrix,which the camera view is not affecting at all, and therefore my near/far clip results in gluUnproject omitting a portion of my grid...... sorry i am getting completely frustrated withmyself trying to explian my point, i wish i could post a minimal code, but there is always the guilt and fear of being reprimanded for clogging the forum with code(would that happen?)..i seriously think if i posted some code i could get a better answer. anyhow if you can make sense of some of this please advise on a direction i could take....

here is sample code i use i declare these globally....from redbook example-glut src GLint viewport[4]; GLdouble mvmatrix[16], projmatrix[16]; GLint realy; /* OpenGL y coordinate position */ GLdouble wx=4; GLdouble wy=4; GLdouble wz=4; then in my render func....... glClearColor(0.3,0.3,0.3,1.0); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glViewport(0,0,wide,high); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective(45.0,(float)(wide/high),1.0,200.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity (); glGetDoublev (GL_PROJECTION_MATRIX, projmatrix); glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix); glGetIntegerv (GL_VIEWPORT, viewport); glEnable (GL_DEPTH_TEST); i use these in mouse func to move about glTranslatef(transx,transy,-otherzoom); glRotatef(rotx,1,0,0); glRotatef(roty,0,1,0); contents of rendergrid().................center at 0,0,0 glBegin(GL_LINES); for(i = -10; i <= 10; i++) { glVertex3f(i,0,-10); glVertex3f(i,0,10); glVertex3f(10,0,i); glVertex3f(-10,0,i); } glEnd(); the point with init value coords of wx wy wz; glBegin(GL_POINTS); glColor3f(1.0,1.0,1.0); glVertex3f(wx,wy,wz); glEnd(); in my mouse func for right button....... case SDL_BUTTON_RIGHT: realy = viewport[3] - (GLint) event.button.y - 1; now here is where i test values of z-ray------> from 0.0 to 1.0 ----usually there would be two one at near clip other at far clip, ----for 0.0 this yield result for wz = about 1.0 which is near clip ---which will move point to wx,wy,1.0 gluUnProject ((GLdouble) event.button.x, (GLdouble) realy, 0.0, mvmatrix, projmatrix, viewport, &wx, &wy, &wz); fprintf (stdout,"World coords at z=0.0 are (%f, %f, %f)\n", wx, wy, wz); ---therefore if i adjust nearclip to 5.0 i will get wz = 5.0; ---which will move point to wx,wy,5.0 ---but i shouldn't be adjusting my nearclip all the time am i not comprehending this properly? will do x,y positions later but fornow i want to be able to move point anywhere along z-axis, this restricts me to move point to minimum val of -1.0 on z-axis.... should i draw the grid deeper inside viewport, beyond the bounds of the near clip plane??and adjust from there or am i totally missing the point?i reckon the latter.....any advice,pointers, or places i can read about this?

hi, i need some advice for using gluUnproject, i do not have any problem getting the results from gluUnproject, but needs some theoretical assistance, so i am going to draw my scenario...... first.... i have a scene drawn within a viewport that takes up the size of the window, the viewport's lens is a gluperspective lens with near clipping at 1.0 and far clipping at 200.0. inside the viewport have a drawn a grid that spans 10 units in both positive and negative direction of the x and z axis, the y(up-down) axis is represented with a simple vertical red line. the most important thing is that the grid's center origin lies at 0,0,0. now when i use unprojecting to get world coords for near z-clip and far z-clip i get the desired results(the far-clip is out by + - .00060). so i draw a glpoint on the screen to test where it falls in the 3d world, i give the point an initial 5,5,-5 position (as the z-axis runs toward the negative into the screen??), then i use a mouse click to translate this point to a new position, i am not using an equation yet to work out a point between the the near and far-clip, instead i am testing the results for setting the z-ray-value of gluUnproject from 0.0(nearest) to 1.0(furtherest)......... set at 0.0 in gluUnproject the point will move to the nearest clip position on the z-axis (the near clip is 1.0 so it moves to -1.0) on the z-axis, at 1.0 in gluUnproject the point will move to -200.0 on the z-axis, if i use any value between 0.0 and 1.0 in gluUnproject i cannot predict where it wall fall on the z-axis, but if i change the near clip in gluPerspective i can predict where it will fall with setting 0.0 in gluUnproject e.g. gluPerspective(45,ratio,1.0,200.0) gluUnproject(?,?,0.0,?,?,?,?,?,&wz) a point with z-value of wz will fall at near clipping which is 1.0 or -1.0(?) on the z-axis. gluPerspective(45,ratio,5.0,200.0) gluUnproject(?,?,0.0,?,?,?,?,?,&wz) a point with z-value of wz will fall at near clipping which is now 5.0 or -5.0(?) on the z-axis. i apologise if this is a little confusing, my question mainly is how would i be able to get the point to fall on any positive or negative z-value of the grid which has an origin at 0,0,0 so far i can get the point to move up and down the z-axis on one side of the origin, but only by a hacked and stupid way. i can not get the point to fall on the the origin or the other side of it. would i have to draw the grid deep inside the viewport, or what? i explain this so terribly so if this is just too confusing i can post a minimal code. any help??
×

## Important Information

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!