Results 1 to 5 of 5

Thread: Collision detection & locating objects coordinates

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2002
    Location
    England, York
    Posts
    7

    Collision detection & locating objects coordinates

    Hi,
    (working in a viewed from above world)
    I have a sphere that depending on user interaction rotates(z) then moves a given distance on the screen. I have created a series of flexible 'walls' on the screen from a massive array of coordinates for single dots that have all been plotted as small circles at each coordinate location necessary.
    I now need to prevent the ball being able to move through them.
    Given that all my rotations and movements of the ball are relative to where it was last time, i don't know how to get an exact opengl coordinate for where it is. If i could do this then i was proposing to pick 18 coordinates on its perimiter and test if these are within a margin(x) of any of the spheres that make up the walls.
    Please help with any suggestions of how to get the balls actual coordinates and if you have any suggestions for better collision detection methods that would be much appreciated.
    Could i even do a test to see if open gl is trying to draw an object (sphere) on top of another object (wall)?
    thanks
    Shaun

  2. #2
    Guest

    Re: Collision detection & locating objects coordinates

    You said that the user controls the sphere, so you do know where the sphere is at all times. Right? There is no velocity/acceleration/gravity involved right? Then it is a simple check between the sphere coordinates + radius to the wall.
    This is assuming 2D, since you do not mention which. If 3D, you basically do the same thing, but you have 1 more dimension to check.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2002
    Location
    England, York
    Posts
    7

    Re: Collision detection & locating objects coordinates

    Yes, i am in a 2d world. Unless i do trig claculations each time i move, to calculate a new position for the sphere from the orientation and distance moved, i don't know of a command that will simply tell me the current location relative to the 0,0 that the sphere started at before all the translates and rotates.
    is there such a command?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    Melbourne, Australia
    Posts
    224

    Re: Collision detection & locating objects coordinates

    hi!
    so you never know where your ball is, right?
    depending on what key is pressed you move your ball in wanted direction - if i understand you right

    it's not good not to have stored your ball's coordinates somewhere...you should have at least variables like
    float position[3]
    float angles[3]
    and each time you want to move your ball you should change them
    then each frame you should apply proper transformation (glRotate, glTranslate..) so your ball is in right place and you know where it is
    have fun!

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2002
    Location
    England, York
    Posts
    7

    Re: Collision detection & locating objects coordinates

    I thought that might be where we were heading and so implemented exactly that style system.
    thanks
    shaun

Similar Threads

  1. Collision Detection using View Matrix of two objects.
    By MrCybin in forum OpenGL: General
    Replies: 1
    Last Post: 12-07-2015, 03:42 PM
  2. Collision Detection - Distance between two objects
    By marshmallow in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-12-2015, 07:33 PM
  3. Collision detection between concave objects using occlusion queries
    By yalmar in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-21-2006, 01:46 PM
  4. Collision detection with objects in display lists
    By neilw in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-14-2002, 01:31 AM
  5. collision detection contest: collision crazy
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 09-19-2000, 02:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean