Advertisement Jump to content
  • Advertisement

steven katic

  • Content Count

  • Joined

  • Last visited

Community Reputation

276 Neutral

About steven katic

  • Rank
  1. interesting observations...   of note is:   RE: it seems that this type of data structure / API could be used for most everything in a game.   It also seems to me that this type of data structure / API could be  is used for most everything in game software applications.   That doesn't really sound controversial at all does it?   It seems to me that another level of abstraction would be required that provides an environment for such a data structure to be defined. This level of abstraction also already exists at the domain specific language level. e.g. in games we may talk, as you do, about lists of game objects and operations that are performed by or on them. Taking a look at any other substantial software application generally reveals similar notions : e.g.  a commercial wharehousing system coul have lists of cliients, suppliers, and products for example, and each list could typically have operations that are performed by or on them. The major difference being the language used to communicate notions specific to the applications domain: a Wharehouse or aGame.   So I can imagine names may exist for these types of what you call "data structures" that would be domain specific, and perhaps defined as long as the abstraction level and its language provides advantages e.g.improved levels of communucation amongst developers.    So other than that, I do not see that the term you are asking about exists, nor do I see any advantages to introducing one, without a beneficial reason ( such as those defined by all other posters on this thread). Domain specific languages can be seen a beneficial. i.e. The pros (e.g. improved comminication) and cons(e.g.unnecessary complexity) should seriously be considered to be used well.  Anyhow... its food for a little bit of thought...maybe?   It gets harder when to try to look for exceptions to the notions described above, which i'm pretty sure exist..but would take more thought to talk about.   Did that help?    
  2. steven katic

    [FIXED]Open simple obj file -> nothing

    now might be a good time to get really familiar with glDrawArrays and gldrawelements. look for as many examples as you need to. you ultimately will end up explicitly specifiying the structure of your data in a format that is restricted by opengl function specs: typically when you specify GL_TRIANGLES your data should conform to a "set of 3 floats in the array of floats represents a vertex of a triangle". edit: and so every sequence of 3 verts (of 3 floats) will represent a triangle. another useful thing to research now would be arrays of structures vs structures of arrays. I feel I am still being a little bit vague here, so I welcome anyone to be more succinct and specific with an explanation for the OP. Still... I hope this helps   
  3. steven katic

    [FIXED]Open simple obj file -> nothing

    what changes did you see?
  4. steven katic

    [FIXED]Open simple obj file -> nothing

    diegoSTLS makes a good point: "You just need to parse the file correctly, once you got the file data into memory it doesn't matter what format the file was." ok, so W is for freeform surfaces in obj.   And why should the 4 be a 3? (maybe I haven't given enough hints?)
  5. steven katic

    [FIXED]Open simple obj file -> nothing

    debugging is the most important skill to learn: so start by walking thru the code and see if it matches exactly with what you think it is doing.  A few things jump out at me:  the 4 in glBufferData(GL_ARRAY_BUFFER, obj.getVertexNumber() * 4 * sizeof(GLfloat), obj.getVertexCoords()->data(), GL_STATIC_DRAW); the GL_TRIANGLES in glDrawArrays(GL_TRIANGLES, 0, obj.getVertexNumber());   should the 4 be 3? why should it be 3?   And the parsed file vert positions looks off:   say like what does 1, -1, -1, 1,  represent?   I was expecting to see something like 1,-1,1 to represent say the (xyz) coordinates of a vert.
  6. steven katic


    Hi,   And how did you go with finding a solution?   Here is one example (of many) of what it should look like:
  7. steven katic

    glm/opengl orbital camera C++

    Hi nate?(oops) mynameisnafe, I see you've worked out the correct angles of rotation input to the camera rotate method: It is the total angle since its creation, and not the delta angle, as I incorrectly suggested in my first post. I do not understand what your code is doing. It can get tricky fine tuning the operation of a camera so it's a good idea to come up with a plan. So, for example, I think about the following: Decouple the input angles from the input source. Looks like you have done that with the m_horizontalAngle and m_verticalAngle variables. So that's good. Next, How do we update them? This is not clear to me from the code you posted. Here is a typical usecase/scenario I would expect to see for the user rotating the camera with the mouse: Operation: The user presses and holds down a designated mouse button, then drags the mouse to move the camera view around. The recipe:   // two new variables to add to the current camera rotation angles. //(Perhaps a little overengineering going on here. But it does indicate our explicit intent for now). int m_pitchDelta;// = 0; member vars: init somewhere else or make static? int m_yawDelta;// = 0; On mouse button down (say typically the left button): Intialise the camera system input parameters for the next rotation. I see this line "if( pMouse->bRight == true )" in your code and assume it means "if the right mouse button is down"?.   // on right button down set the start position of the new transformation // values that will modify the current values (in m_horizontalAngle and m_verticalAngle variables) if( pMouse->bRight == true) {  POINT p;  GetCursorPos(&p);     m_pitchDelta = p.x;    m_yawDelta = p.y;   } Note: That's all you need at this stage. I would keep it simple until it works, then add all your other bells & whistles (i.e. stuff related to the angle restrictions and filtered/timing speeds) they just get in the way for me at the moment. So, ideally at this moment in the process the Modelview Matrix *V has already been initialized and typically the full MVP has also already been constructed and now all that is happening each frame is The MVP is passed to the shader, the shader is activated and scene drawn. Oh,...And you are holding that right mouse button down....(ready to move the mouse). Now the only change we are interested in is when the mouse moves (with that right button down, basically dragging the camera view around). We want the Camera to move around relative to the mouse pointer position as it moves. I cannot quite see this happening in your code. But you can put the camera update code in the WM_MOUSEMOVE case section to make this intention explicit:   case WM_MOUSEMOVE:  {   POINT p;   GetCursorPos(&p);      // get the amount of the last mouse movement   m_pitchDelta -= p.x;  m_yawDelta -= p.y;  // modify the current angles    m_horizontalAngle -= m_yawDelta;  m_verticalAngle -= m_pitchDelta;      // ?please explain? I wouldn't modify the source of our input(yet, if ever?)  // move into rect/window space    //p.x -= rWindow.left;  //p.y -=;    // relative to rect/window centre //p.x -= (rWindow.right - rWindow.left)/2;    //p.y -= (;    //********* Camera->Update()********************************************//  //to rotate using euler angles as input.    glm::mat4 R = glm::yawPitchRoll(m_horizontalAngle, m_verticalAngle,0.0f);       //Then you could do the following to Update() a camera transformation:    glm::vec3 T = glm::vec3(0, 0,-dist);    position = glm::vec3(R * glm::vec4(T,0.0f));  m_direction = origin;//glm::normalize(position);   m_up = glm::vec3(R * glm::vec4(m_real_up, 0.0f));  m_right = glm::cross(m_direction,m_up);    m_viewMatrix = glm::lookAt(position, m_direction,m_up);   //************************************************************************//   //then update the MVP that typically goes to the shader at render time   OnMouseMove(MouseMove(p));         } Four important lines here are: The 2 lines that update the mouse movement since the last movement (would typically be one raw pixel on a responsive ui thread) and, The 2 lines that Just modify the current angles of camera rotation. Can you see them? That makes sense to me so far, what do you think? Have I missed anything? Give it a go, and let us know maybe.   ps. Ok. Heres's one minor part I missed: where the parameters m_horizontalAngle, m_verticalAngle are converted to radians before being fed to glm::yawPitchRoll() ? Could be more I missed.
  8. steven katic

    glm/opengl orbital camera C++

    RE: Do I need to use/do glm::quat things or do I need rotX, rotY, rotZ, for some code where the camera spins around on a sphere centred on the model? You can use either strategy (i.e. quaternions or euler angles ala degrees). Some people argue about the pros and cons of each too (there is always arguing going on somewhere [mostly?] in the world so we'll leave that alone).   I just so happen to have been playing around with an FPS and Orbit cameras recently, so this might help: It's one in a zillion! ..I mean It's one of those zillion. glm can be a great tool. You can save yourself a smidge of code by calling something like: glm::mat4 R = glm::yawPitchRoll(yawf,pitchf,0.0f); to rotate using quaternions euler angles as input.   Then you could do the following to Update() a camera transformation: glm::vec3 T = glm::vec3(0,0,dist); T = glm::vec3(R*glm::vec4(T,0.0f)); *position = *target + T; *look = glm::normalize(*target-*position); *up = glm::vec3(R*glm::vec4(*UP,0.0f)); *right = glm::cross(*look,*up); *V = glm::lookAt(*position, *target, *up); That was easy! A Spam of code! Now we just have to translate that into english. anyone?   But lets back up a bit. As far as I can tell you are describing an orbit camera! Let me try and paraphrase your stated goal: The orbit camera works the opposite way to FPS, ...yeah?. Rather than the position of the camera staying fixed, the target remains fixed, while the camera moves or rotates around the target. How does that sound? That's an orbit camera. An obviously good analogy so let's use it? Since you don't seem very sure about it, I suggest we just stick with that analogy. Sound OK?   Then think about this:   Say we have a target position (the centre of a model..say) We get the distance(dist) between the target position(target) and the camera position(position) and turn it into a vector: glm::vec3 T = glm::vec3(0,0,dist); // turn it into a vector Then translate this vector by the current rotation matrix: T = glm::vec3(R*glm::vec4(T,0.0f)); Then adding this translation vector to the target position gives us the new camera position: *position = *target + T; That's it.. well almost. So far, we have the new position for the camera to moved to. All we do next is update the camera look, up and right vectors(re-orientate the camera) and view matrix or to be really dry we can say "Recalculate the orthonormal basis and then the view matrix" and its done (ready for the next frame).   The problem with giving code examples is that sometimes there are diminishing returns from explanations of them.. or maybe not... if you can figure it out yourself ... like a puzzle. Trying to figure out what a piece of code does is all part of programming (and lets me off the hook for being lazy!).   You might ask some interesting questions like " What is T or  V or UP"? No,.. just kidding! They are obvious questions, with hopefully obvious answers.   Something a little more interesting you might ask is:   * How do we get the distance(dist) between the target position(target) and the camera position(position) ? //First set the position then the target and use glm::distance():  void SetPosition(const glm::vec3& p)  {  *position = p; }  void SetTarget(const glm::vec3& tgt)  {  *target = tgt; distance = glm::distance(*position, *target);  } glm::distance() is like most bits of code: you can do internals of them yourself instead of using glm if you wish.   So, most of this (I think) comes from The targetcamera section of an Opengl Cookbook: Nothing particularly new in there, Mainly fairly neat code examples using glm that is good to play with. Not sure if I remember it being very "beginner friendly" though. But it does spell out the full code per class that is very easy to modify and to drop into something suitable. Among other things it contains an (FPS) free camera and (orbit/turntable/arcball?) target camera both derived from a base camera class: just what you seem to be starting on, it seems, from your post.   *Another question: What if you wanted to use good ol' fashion degrees (euler angles) ? (that, I assume is your mention of rotX, rotY, rotZ?). Just replace the quaternion form with the euler form at this line: An alternative to using glm::yawPitchRoll() is to do it ourselves using glm::rotate(): // correction: this is not quaternions. This is a euler angles version also..sorry //glm::mat4 R = glm::yawPitchRoll(yawf,pitchf,0.0f); // produce equivalent effect using glm::rotate() float xr = pitchDegrees;  float yr = yawDegrees; glm::mat4 ViewTranslate = glm::mat4(1.0f);  glm::mat4 RY = glm::rotate(ViewTranslate,yr,glm::vec3(0.0f,1.0f,0.0f));//yaw  glm::mat4 RX = glm::rotate(RY,xr,glm::vec3(1.0f,0.0f,0.0f));//pitch    glm::mat4 R = glm::rotate(RX,0.0f,glm::vec3(0.0f,0.0f,1.0f));//no roll, currently redundant but exists anyway Both methods depend on how you get your input angles with something like camera->Rotate() method like so: Rotate(const float yaw, const float pitch, const float roll) {  yawf=glm::radians(y);  pitchf=glm::radians(p);  rollf=glm::radians(r);  // and/or you can store angles in degrees.        yawDegrees = yaw;  pitchDegrees = pitch;  rollDegrees = roll; Update(); } What is passed to Rotate can be the mouse Delta positions i.e.The position relative to its last position (or some filtered value thereof).    Getting you hands on the Cookbook may help.  A source code download comes with this bit of leisurely reading. With this target camera you have the added bonus of setting the target to any position you desire (a staple of any good 3D model editor I imagine). Hence the authors' emphasis on this orbit camera being a target camera. Cameras are fun. The hard part might be figuring out how to build this into your achitecture? 
  9. steven katic

    Some question about transformation

    Hi jenny,   RE: " I saw Nate Robbin's tutorial but a confused how to make it work."   Thats not a good sign. You will be struggling with this until you do understand the fundamental concepts that Nate's samples are based on. Have you downloaded the examples and ran them?: Have you played around with the values in them to learn by doing and seeing the effects of changing parameters? You cannot get around doing something like this in order to grasp the fundamental knowledge you need to get to a solution. There are no short cuts. It is a matter of finding material suitable to the way you learn.   So here are a few things to try: Search on terms like "opengl camera". there is lots of info around: only you know what will suit you. Start by reading this: Or even scanning it for (more hands on) examples to here: This stuff is an example of the easiest/simplest and well explained info you must grasp before you try to solve your problem (otherwise you will continually be asking people to hold your hand on every little step of your journey into 3d graphics likely making very little progress).   Let us know if this helps
  10. steven katic

    OpenGL and OpenCV matrix

    Didn't even know what OpenCV was until now. These googled example references may help you perform what has been suggested (i.e. The kind of things that would result from suggestions like the one from 3TATUK2):
  11. yeah, exactly the first thing I thought Alvaro: what is jenny_wui's definition of z rotation. However in the meantime: searching the net on the title phrase such as "extract rotation from 3X3 opengl rotation matrix" will help.  This might help too: personally If I had a choice I would tend to store representations of rotations as variables to be placed into matrices as opposed to an angle extraction option.
  12. steven katic

    Porting C++ to Android

    you may need to put the following line in your  file to see the log output:   LOCAL_LDLIBS := -llog   Sorry, no you don't , you only need to do this to use the logging library: i.e to log your own native messages to the LogCat window.
  13. steven katic

    Porting C++ to Android

    I cannot see anything wrong in the code as such. have you checked if the library was built? it should show up in the console window. And the .so library file should be in the libs folder. what are the messages in the logcat window?
  14. steven katic

    How to get good fast?

    How to get good fast? here is something else that may help too. Find a workflow strategy that suits you, and keep refining it.   I believe this happens naturally anyway, wether you are/become aware of it or not. but if you keep it in mind, it could accelerate the process that leads to "getting good fast(er)". Then work on developing other strategies. Godmil's remarks above are of interest to me here: "Make lots of mistakes and persevere in fixing them. You'll learn more from fixing mistakes than doing anything else."   In this sense, getting better at programming faster, means always trying to make less and less mistakes each time you program and about fixing the ones you do make asap. And you may get better faster by applying a strategy that will enable you to fix mistakes as they happen and especially if you are able to do it by yourself(i.e. with your own thinking routine/cognitive skills).   So, its a cognitive thing too ( a way of thinking): honing your problem solving skills to find and fix mistakes more quickly. has anyone ever been good enough never to make mistakes? Not that I know of yet. But you can get good so you make fewer, and/or fix the mistakes fast. I believe every "successful" programmer has their own personal workflow routine that works, wether they are aware of it or not. I also believe that a programmer can benefit from being aware of their personal strategy and honing it. Then developing/adapting/adopting others in a flexible fashion. For me its part of what attracts me to developing/programming. As an example here's a summary of one of my general strategies: while(developing software) { research (a little) code(a little) test(a little) } It tends to kepp things fresh and interesting. I have to say this process describes my optimum goals, and is as flexible as I judge it to be for the project. For example, research(a little) may turn out to be research(a lot) if I'm programming in a new domain that requires more knowledge I'm less familiar with or research(just about nothing) if it is a problem I have dealt with many times before. code(alittle) and test(alittle): these tend to be not so flexible and depends on my confidence in the new code I write. The term (alittle) represents an arbitrary amount that depends on my confidence level in my ablility to obtain the desired result quickly with minimal testing( there is a bit risk mangement involved). This is a very important strategy. The potential for errors increases, as the amount of code I write increases. I don't think this point can be emphasised enough, especially for beginners. Maybe some experienced programmers here appreciate my point here: especially those of us that have attempted to help a beginner who may invariably post a bit of code or mountains of code desperately asking for help to debug it because they have "lost thier way" after hours or even days of trying to fix it! I can't help thinking such a beginner is not moving in the right direction, and its not just debugging skills that is needed, but a thinking strategy... . Anyhow, while coding a little and then testing a little, and an error occurs, I can be pretty confident I'm very close to the context/source of that error (i.e. it's usually related to the code added after the last successful test [obviously?]). There are pros and cons about this strategy that are interesting in thier own right that would be great to discuss(bit nerdy maybe?): but this post seems a bit too long as it is (I don't usually post much), and it might be going a bit off topic? But results of this strategy have proven successful time and time again.   This is by no means the only or best strategy, others may have just as valid, or better strategies that work depending on the nature of the project and the individuals preferences/ability to adapt to that nature in a timely fashion. I use this kind of strategy to pick up/refresh  a new (language/ platform/ technolgy) when required for a project that may come along. That is to say, it's useful even if you are an experienced programmer learning something new. I think that there is a lot more that could be said for developing debugging skills(i.e. mistake management). It still seems to be a critical bottleneck even for some experienced programmers. I don't know if the OP would mind hearing about other programmer's personal strategies like this. I wouldn't mind. Or perhaps a thread with a more specific heading could be more appropriate for it.   So to sum up: As you spend time developing you will develop a routine (or workflow strategy) consciously or not, and becoming more aware of it and even directing it could help you become good fast. what do others think?   ps: I like to think I have become good, but sometimes I wish someone told me something like this along time ago, because I'm thinking it just might have made me "good faster". I don't really know. Cheers 
  15. steven katic

    gluUnProject Value's arn't Correct.

    Quote: Written by ajm113: So far if the entities is in the center of the screen it works, but if I move the cursor position off a little a bit near the edge of the window the values go very high then necessary. Need more info: Is the cursor actually over one of your dots when you get the very high values? A likely cause is: that if the pixel is not one part of one of your 3d dots in the 3d space, or any other object you placed in that space, it could be the depth of the far clipping plane of your viewing frustum that you are 'hitting', hence the very high values? This might be a little food for thought. [Edited by - steven katic on January 31, 2010 4:15:43 PM]
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!