• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Volgogradetzzz

Friction impulse. Need formula.

13 posts in this topic

Hello. For normal impulse I used Chris Heckers papers. All works fine, but formula don't take friction into account. I believe that there's equivalent for friction (not just tangent velocity * cof) but I couldn't google it.
0

Share this post


Link to post
Share on other sites
[quote name='Volgogradetzzz' timestamp='1300955461' post='4789860']
Hello. For normal impulse I used Chris Heckers papers. All works fine, but formula don't take friction into account. I believe that there's equivalent for friction (not just tangent velocity * cof) but I couldn't google it.
[/quote]

Friction is complicated. In the naive sense, rigid body dynamics with a Coulombic friction force (which is what you are describing) is not even solvable. The classic and ancient example of this is Painleve's paradox, which has remained unresolved until relatively recently.

As a result, if you want to do friction using the classical Coulomb approximation, you are in for a very rude awakening (as I am sure you have just discovered!) A more well posed way to formulate friction is to use the principle of maximum dissipation. This basically says that the friction force will try to reduce the velocity (ie kinetic energy) as much as possible in the tangent direction to the collision impulse force, subject to some constraints on the magnitude of the velocity. This constraint forms a "cone" shape, and so it is commonly called a "friction cone". To solve this constraint, many LCP solvers use a piecewise linear approximation of the friction cone to ensure the constraint is not violated. For a more precise and careful discussion of these issues, there are some really great papers by David E. Stewart. Here is a good one to start with (in my opinion):


David E. Stewart, (2000) "Rigid Body Dynamics with Friction and Impact", SIAM Review [url="http://www.amath.washington.edu/courses/533-winter-2011/Stewart00.pdf"]PDF[/url]
2

Share this post


Link to post
Share on other sites
Just take the contact point velocity, V and normal N, form the tangential velocity

T = V - V.N*N

Then create an impulse to remove some portion of this velocity in the same way you did to remove the normal velocity :)

Cheers, Paul.
1

Share this post


Link to post
Share on other sites
You may find my post useful:

http://www.gamedev.net/topic/596977-collisions-involving-friction-explained-partly/

I wrote up a description of Brian Mirtich's algorithm. For 2D (non-resting) collisions there isn't a single formula but there's a quick algorithm. For 3D collisions the algorithm involves numeric integration which may be too slow for your application.
1

Share this post


Link to post
Share on other sites
In 3d, you usually need 2 tangential direction, which must exist even if the tangential velocity is zero. and then, the impulse calculation is similar to normal impulse calculation, just change the normal vector with tangential vector. And then you relate the friction impulse with the normal impulse
0

Share this post


Link to post
Share on other sites
Thanks everyone. I was affraid that it's complicated and so it is. I'm certainly investigate papers that you're link, but for now I think I'll take approach that [b]wildbunny[/b] and [b]Bow_vernon[/b] said.
And one more question - is it OK that if I take COF (coefficient of friction) zero (like with COR, 0 - is 'full' friction, i.e. no sliding), but tangent velocity decreases not by 100%, but only by some part? I've used same formula as for normal impulse - only normal was changed to tangent direction...
Update: also notice some problem - if two objects fall down (their velocities is like [0; 10] vector) and are close one to another (so collision occurs every frame) then friction decreases velocity and bodies become to fall slowly :blink:.
0

Share this post


Link to post
Share on other sites
Well you've arrived there. with 0 CoF the object should slide, you gotta relate the friction impulse magnitude with the normal impulse, like:
fMax = fN * CoF
then you clamp the friction so its value is between [-fMax,fMax]. Anyway, how did you calculate the friction impulse? can you show some code?
0

Share this post


Link to post
Share on other sites
Normal impulse:
[code]var jNnum:Number = -(1 + e) * (vab.dot(n));
var jNdenom:Number = bodyA.invMass + bodyB.invMass + rap.cross(n) * rap.cross(n) * bodyA.invInertia + rbp.cross(n) * rbp.cross(n) * bodyB.invInertia;
jN = jNnum / jNdenom;[/code]
Friction impulse is all the same. Only changes are:
e -> f; //cof
n -> t; //tangent normal

It's hard to understand - why shoud we multiply fMax = fN * CoF? How to achieve full friction (i.e. no slide) in this case - suppose I want bodies to stop sliding immidiatelly after first contact?
0

Share this post


Link to post
Share on other sites
What I do(has been simplified)
[code]
jn = kN * -vn; //no bounce
jn = Max(0,jn); //no pull

fMax = jn * CoF;
jt = kT * -vt; //full stop
jt = Clamp(jt, -fMax, fMax);
[/code]
Oh and read erin catto's ppt for more info, anyway. Sorry if I didnt help, Im confused @.@
1

Share this post


Link to post
Share on other sites
[quote name='Volgogradetzzz' timestamp='1301062050' post='4790346']
Ok. I think I got it. Thank you.
[/quote]

Are you working in 3d, or 2d? 3d is slight more complex than 2d, but still doable :)

Cheers, Paul.
0

Share this post


Link to post
Share on other sites
Volgo, what formula did you end up using and how is it working out ? I'm thinking about adding friction to my 2D simulator as well.

Thanks.
0

Share this post


Link to post
Share on other sites
According to Erin Catto presentation GDC2006 and as [b]Bow_vernon[/b] said, for 2D friction can be count like this:
1. Get normal impulse - see post #8.
2. Get tangent impulse:
[code]var jTnum:Number = -vab.dot(t);
var jTdenom:Number = bodyA.invMass + bodyB.invMass + rap.cross(t) * rap.cross(t) * bodyA.invInertia + rbp.cross(t) * rbp.cross(t) * bodyB.invInertia;
jT = jTnum / jTdenom;[/code]

3. You need to clamp friction impulse:

[code]if(jT < -jN * cof || jT > jN * cof)
{
jT = jN * cof;
}[/code]

4. Get total impulse as:

[code]j = n * jN + t * jT[/code]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0