Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Collision Response Help (AABB)
Author Message
tiedye1

Posted: Tue Oct 15, 2013 10:21 am   Post subject: Collision Response Help (AABB)

Hi, lately I have been trying to create a 2D platformer engine in C++ with Direct2D. The problem I am currently having is getting objects that are resting against each other to interact correctly after accelerations like gravity have been applied to them.

Right now I can detect collisions and respond to them correctly (I think) and when objects collide they remember what other objects they're resting against so objects can be pushed by other objects (note that there is no bounce in any collisions so when objects collide they are guaranteed to become resting until something else happens). Every time the simulation advances, the acceleration for objects is applied to their velocities (for example vx += ax * t, where t is time elapsed since last advancement).

After these accelerations are applied, I want to check if any objects that are resting against each other are moving at different speeds than their counterparts and depending on that difference either unlink the two objects so they are no longer resting, or even out their velocities so they are moving at the same speed once again. I am having trouble creating an algorithm that can do this across many resting objects.

Here's a diagram to help explain my problem

Sponsor
Sponsor

tiedye1

Posted: Tue Oct 15, 2013 6:48 pm   Post subject: RE:Collision Response Help (AABB)

Can anyone offer and guidance?
Raknarg

Posted: Tue Oct 15, 2013 8:04 pm   Post subject: RE:Collision Response Help (AABB)

If you can't get any help here you can also try stack overflow
tiedye1

Posted: Tue Oct 15, 2013 8:46 pm   Post subject: RE:Collision Response Help (AABB)

Alright
Raknarg

Posted: Tue Oct 15, 2013 9:41 pm   Post subject: RE:Collision Response Help (AABB)

Collision and physics are probably one of the most annoying things to program imo. Are you familiar with mathematics and programming?
tiedye1

Posted: Wed Oct 16, 2013 8:26 am   Post subject: RE:Collision Response Help (AABB)

I am familiar with programming and have taken grade 10 math as I am now in grade 11. I do like math a lot so I've gone ahead a bit. I've been programming for quite a while now.

Right now I have already written all the collision detection and response code. I just need to define this function so I can add gravity and other accelerations.
Raknarg

Posted: Wed Oct 16, 2013 9:06 am   Post subject: RE:Collision Response Help (AABB)

Ok, let's say you have two cubes floating around with no acceleration or gravity and they collide, do they collide properly? Does that part at least work? Or does it work a little differently?
tiedye1

Posted: Wed Oct 16, 2013 12:20 pm   Post subject: RE:Collision Response Help (AABB)

They do collide properly, and react properly. Each frame it checks when objects collide and if they collide during that frame they advance forward that amount of time and then calculated the reaction for that collision considering the object mass, if its static, axis that the collision occurred on, and objects resting against them. This all works fine (mostly).

I can post my current project if you want, its a visual studio 2012 project.
Sponsor
Sponsor

 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 8 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: