Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Are there techniques for simulation of cloth and hair in an efficient (in other words, not too CPU-intensive) manner? I only need to calculate the key points as the drawing will be done in 2D.

share|improve this question
    
What are the "key points"? What do you mean by that term? –  Nicol Bolas Oct 31 '11 at 8:08
add comment

1 Answer

Verlet integration is relatively lightweight, and can be scaled easily by adjusting the number of total particles present in the cloth (so you can scale the simulation from a very smooth, 10,000 particle scenario to one that only uses nine "key" particles or so). The quality and verisimilitude of the simulation will suffer as you scale the system down, however.

The Jacobson article on Gamasutra discusses Verlet physics from a very basic perspective and builds upon that (he focuses on character physics, but the technique is applicable to cloth as well). Alternatively, here's a blog post (and a follow-up) on building cloth simulations with Verlet integration. You can find plenty of other resources using Google should you need further information (for example, this article, this collection of sample OpenGL implementations, et cetera).

The technique can be applied to hair as well, and you can similar scale it in that context -- you can either use several sets of "strands" of connected particles to simulate bands of hair, or simply treat it like cloth directly (with an appropriate, more hair-like texture).

If you have a GPU available, you could also look at offloading some of the computation on to the GPU to free up the CPU for other tasks; depending on the task balance in your game already, this may or may not be a feasible optimization for the CPU.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.