Results 1 to 5 of 5

Thread: Outline Collision Resolution Mayhem!

  1. #1

    Default Outline Collision Resolution Mayhem!

    Hello All, Newb Clanlib User and Wannabe Game creator Dincu is here!

    First, thanks for reading my first post on the forum, and if you reply my post double thanks.

    Ok, now, lets go down to business :P

    My team and I have been working on a game uses SpriteRTS as a base. During our many coding adventures we discovered that our collision system wasn´t working right, and we had no idea why. After some more coding adventures (on debugging land) we decided to put some color to the outlines to see what was going out, and to our surprise we saw that the were very far away from our objects on the screen (see in attachment that the outline of the tank and building are far away from their owners...). After some more adventures we also observed that when we put the object closer to the origin (0, 0) the outline got closer and in 0,0 got together...

    My guess is that the outlines are working on a different resolution than the screen or something (the example´s default is 1024, 768) and they are actually at the same point but in different resolution.

    Any help is really really appreciated since i should say collision is a important component of the destruction of a tank :P

    Hoping for a reply, see you later foks! (and Thanks and Tanks)
    Dincu, the Happy Coder.

    PS: Vladimirdlc is another of the members of team... he posted here before about boring database stuff... buh... :P (another member is missing, maybe he will post later)
    Attached Images Attached Images  

  2. #2
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    I guess it's silly to ask, but are you not translating the outline with the sprite?

    If so, it's possible you're translating while opengl is in a different state. It's vital you do your operations while on the same scale/translation matrix.
    Last edited by catch22; 07-24-2009 at 07:42 PM.

  3. #3

    Default

    I guess it's silly to ask, but are you not translating the outline with the sprite?

    If so, it's possible you're translating while opengl is in a different state. It's vital you do your operations while on the same scale/translation matrix.

    Well, we are defenely translationg the outline with the sprite, that doesn´t appear to be the problem... after all, we can see the outline move with the tank, and when the tank reach the point 0,0 he is just over the tank. but the farther we move from the center, the father the outline moves... it is like it was moving at a diferent scale than the tank (since both report to be in the same position). Also, the pic is directly from the spriteRTS example, without any modification from our part beside drawing the outline.

    Also, what do you mean by diferent state from the OpenGL? As a famous (between the 3 people i know :P) NewB Programer i don´t know of such things! Elaborate please :P

  4. #4
    Lesser Wizard
    Join Date
    Jun 2007
    Posts
    109

    Default

    Quote Originally Posted by Dincu View Post
    Well, we are defenely translationg the outline with the sprite, that doesn´t appear to be the problem... after all, we can see the outline move with the tank, and when the tank reach the point 0,0 he is just over the tank. but the farther we move from the center, the father the outline moves... it is like it was moving at a diferent scale than the tank (since both report to be in the same position). Also, the pic is directly from the spriteRTS example, without any modification from our part beside drawing the outline.

    Also, what do you mean by diferent state from the OpenGL? As a famous (between the 3 people i know :P) NewB Programer i don´t know of such things! Elaborate please :P
    Right. It's likely you are modifying the GC in some manner and not putting it back before doing your collision translation.

    Just an example... I have a scrolling world and in order for my "layers" to work properly I have to do a lot of matrix changing to keep things inline.

    Code:
    if(area.is_initialized())
    {
    	area.update(micro_second);
    	gc.pop_modelview();
    	gc.set_translate(-area.get_camera().x, -area.get_camera().y);
    	area.draw();
    	gc.pop_modelview();
    	gc.set_translate(area.get_camera().x, area.get_camera().y);
    }
    
    gc.pop_modelview();
    hud_draw();
    
    // GUI
    gui.exec(false);
    gui_draw_windows(gc, wm);
    if(area.is_initialized())
    	gc.set_translate(-area.get_camera().x, -area.get_camera().y);
    But this is mainly because I am translating the GC itself.

    However, I ran into a similar problem you are referring to with my AdvancedCanvas demo while using different scaling between the framebuffer and the main GC.

    You'll notice in that demo after making changes to the gc you must be sure to pop the model view matrix so following objects return to their predicted state.

    EDIT: I guess what I'm saying is you're probably missing a pop_modelview() somewhere

  5. #5

    Default

    Hello Again :P

    I just wanted to say that already solved the problem... or problems rather :P

    It was 1 problem made into 2 problems:

    The original problem was that we weren´t setting the hotspot rotation of the collision body of the object (the tank) to origin_center, and so when we were turning the tank a couple of times, the tank kinda lost the original position, and wasn´t constant when colliding with objects on the map.

    The second problem was really not a problem, but a problem for the debugger :P
    When we were drawing the outline, we kinda missed that the outline wasn´t drawing from point 0,0, but from where the tank was positioned, and already in relation of the screen... so of course, the father we got from the origin, the farther the outline got from us... :P

    Well, that is all... Thanks catch22 for trying to help me... but believe me, we aren´t not getting into stuff so deep as to mess to much with the gc yet :P (or at least i am not.. maybe Mr. Boring and Mr. Serious are ):P

    Thanks Again,
    Dincu, Happy Programer

Similar Threads

  1. Collision...
    By catch22 in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 07-17-2009, 04:07 PM
  2. Collision thingy
    By attle in forum Novashell Game Creation System
    Replies: 2
    Last Post: 04-29-2009, 11:25 PM
  3. High precision/resolution time, multicore issues
    By z42 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 03-17-2008, 07:34 PM
  4. resolution, mouse cursor, etc
    By Uhfgood in forum Novashell Game Creation System
    Replies: 1
    Last Post: 09-06-2007, 12:40 AM
  5. Resolution Independent Drawing
    By glorified_ameba in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 03-28-2007, 05:33 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •