User:Carlosadc/GSoC Application

From K-3D

Jump to: navigation, search

GSoC 2008 Proposal: Cloth and Particle Simulator plug-in set

This is a project proposal for the google summer of code 2008


The need to portrait more realistic real world environments and situations had led to cloth and particle simulation implementations of vital importance to state of the art 3d modeling and animation software. Particle simulations play a big role when trying to recreate natural phenoma and Special effects such as rain, snow, fireworks, smoke, etc. Giving an immersive and convincing experience to the viewer. On the other hand cloth simulation plays a much bigger role for both artists and viewers as they help the artist speed up their workflow as they don't have to worry about animating things like the wrinkles in a shirt or the foldings in a pair of jeans but at the same time getting a very realistic appereaence and correct behavior.

The intention of this project is to incorporate a set of plug-ins to K-3D to be able to perform cloth and particle simulations.


The particles and cloth simulators have different Parameters and possible behaviors but when talking about physics interaction they have a common ground which is Ordinary Differential Equation(ODE) Solving. In this project we will implement RK4 to solve ODEs. The reason to choose RK4 is because it gives very accurate results being less explotion prone(depending on the stepsize) than other methods and quick to compute. Besides RK4 is heavily paralelizable as the components of the equation aren't codependent. The force fields that will affect the cloth and particle systems will be fully customizable with gravity as a default(due to it's common use) and some presets like wind and vortex fields, with the oportunity to create user scripting and also through the ngui(using a GenericForceField plugin with parameters as damping, direction, etc).

The particle simulator will consist essentially on a plug-in for an emitter(for both point and mesh particles) with options like emitter type(point, rectangular, spherical), gravity, randomness, particle life, etc. which can be combined with the force fields mentioned above. As I've already worked with particle simulators before, I'm familiar with all this and have coded almost all of it so most of the time will be spent into integrating(and rewritting) my code and also the rendering methodology which is needed for the point particles(billboarding). I was thinking on using having the possibility to connect a mesh to the system so you can create a mesh and just connect it to the emitter to use it as a base particle for the system. Note: please note that when I talk about point particles I'm not infering they are actually a point but probably just a texture in billboard, also I'm not completly shure this is how it should be, so this would be a proposal subject to mentors feedback.

The cloth simulator will be a k3d::mesh_modifier(maybe k3d::legacy::mesh_modifier depending on mentors opinion) where a user creates a mesh then applies the modifier and turns it into cloth. This will be proggresively developed so at first supporting only grid meshes until it can handle arbitrary shapes(I think this is the best way so progress is shown through out the development process). Cloth will also interact with the force fields mentioned above.

For both particle and cloth simulators there's going to be another plug-in that will be application type to be able to cache the entire simulation so it wont get computed each time the frame changes on the viewport. Besides this global cache, inside the simulators will be a cache functionality for the frames already viewed; This is because ODE's need the initial conditions, things like trying to view the system at frame 30 would have to go back recursively to time 0 and compute all the way back to frame 30 which would be too much unnecessary CPU computation, but using cached values at already viewed frames will save computation time and still don't need to compute the whole cloth simulation.


Through out the development of the project a set of plug-ins will be delivered that fully incorporates cloth and particle simulations. The plug-ins vary widely in extension and complexity so please see "Timeline" section for approximate delivery schedule and "Project details" for more information about each propsed plug-in.

Around a year ago I spent a semester at MIT as an exchange student and got the opportunity to write a Cloth simulator so I think I'm already on track. The project started as a Particle simulator which got extended to the cloth simulator so I implemented two methods for ODE solving, euler and runge kutta 4 (RK4). Besides, this last couple of days I've spent learning and programming for K-3D so I'm already familiar with k3dsdk and plug-in development for K-3D.

Plug-in set

Summarizing the plug-in set, description and approximate development time the list(subject to change by mentors advice and feedback) would be:

ODE Solver

  • Description: This is not exactly a plug-in but an external source to compute and solve the differential equations needed for the simulation.
  • Time: I already have a working code for this one, I'm still going to optimize some routines and recode some parts to work alongside with my plug-ins

Force Fields

  • Description: Plug-ins to handle external force fields, please note that gravity is not included as it is part of the systems(for my experience this is what works best). Force fields to be implemented: Wind, vortex, spherical, etc. Also Generic Force fields and position dependent force field equations are to be implemented(probably through scripting or by node property editing)
  • Time: Applying force fields to particle systems is just a matter of adding and substracting forces to the force equation governing the system so is relatively easy to generate, shouldn't take more than a day. Generic force fields might take a little bit more, like 2 days basically because position dependant force field equations require equation parsing.

Particle Emmiter

  • Description: Plug-in to handle an emmiter. This plug-in will be a k3d::mesh_modifier(as I said before probably k3d::legacy::mesh_modifier) to be applied to a mesh so it acts as an emmiter. So if for example a grid is created the emmiter mesh_modifier plug-in will turn it into an emmiter( in this case an area emmiter ). Using K-3D connection functionality it will also have the possibility to connect it to a mesh to turn points into mesh particles.
  • Time: This is one of the main plug-ins so it should take about a week or two.

Cloth Modifier

  • Description: This plug-in will be a k3d::mesh_modifier to be applied to a mesh so it acts as a piece of cloth. this plug-in will have several steps and will gradually evolve from being able to take only grids (sheets of cloth) to become fully implemented and support arbitrary shapes.
  • Time: As I mention on the description of this plug-in it will evolve gradually so many commits are expected. As the mesh compatibility increases also the difficulty to setup the cloth system increases. So the first part of this plug-in shouldn't take more than 2 days(as I've already worked with grid like cloth) and then about two to three weeks to complete.

Cache plugin

  • Description: Application plug-in to be implemented for ngui. This plug-in will cache the whole animation so it doesn't recompute when viewport changes frames.
  • Time: To fully implement this plug-in the easy way would be to generate external files and variables but that overhead is unnessesary. To actually perform good in the K-3D environment the plug-in will be implemented seamlessly in K-3D with a cache similar to the undo system already implemented on K-3D.

GSoC Agenda

Google summer of code period isn't still summer vacations for me, I still have classes up to mid July. This is not a problem because as I said on the application I'm only taking two classes, Numeric Linear Algebra and Modern Physics. I'm seeing the possibility to just take an exam on the Modern Physics class now and don't take it(as I already know the content) so that would just leave me with the other class. So school-wise I won't be too busy, this other class is only 4 hours a week and probably another 2 or 3 for homework per week.

Besides school I'm conducting some research with a professor for point cloud triangulation. The research part is almost done and so are most of the proof of concept applications and benchmarking. I don't know if this is going to be extended until the GSoC period but I felt like it is my obligation to put all possible things. Besides this research I'm not working on any other research project right now.

I just finished working for the local government and I'm currently unemployed. I'm not planning on taking any other job meanwhile and I'm hoping to treat the GSoC as my full-time job.

So basically this is more or less my agenda for the GSoC period of course, as I said above I'm going to be able to work full-time which probably is more than the time I'm going to need to finish the project but leaving time to be able to polish and maybe add some other features proposed.


Image:screen01.png Image:screen02.png


Sample plug-in done :-)

Current Progress

This sample plug-in by now is a simple cloth simulator. Right now it only handles the default 5x5 grid.

Use mode: To run the plug-in, open K-3D and add a grid mesh. After the grid mesh is created select the vertices you want the cloth to hang from (with the usual point selection tool) and then (right click)->(Mesh Modifier)->(ClothModifier) to start the cloth modifier. Now, all you need to do is connect the Time variable of the ClothModifier to the Time variable of the time source (Connect)->(TimeSource)->(Time). Now just slide the timeline bar to make it move or use the "continous playback" button on the Timeline plug-in to let it go. while running you can change parameters such as cloth stiffness, gravity and damping and it will be affected real time.

Limits: Right now the cloth simulator just go forward i.e. each time the time is modified the ODE equation solver advances one step. also most of the plug-in is hard coded (structural springs) and I'm still using regular pointers (not boost). Just wanted to give my progress and remind that it still on early development.

Download: code

Who am I?


My name is Carlos Andres Dominguez Caballero and I'm 22 studying my final year in Physics and Mathematics with Computer Science Major in Mexico. My passion and work is computer graphics. I have been programming in C/C++ for about 8 years. Through out high school and my undergrad I've had the oportunity to work on several projects like a cloth simulator, a raytracer, a new multiresolution point based rendering data-structure similar to QSplat(Still on research so probably better than QSplat for Projective Atlases) a 3d curve editor and surface generator, GPU optimized text indexing, etc. Most of them are uploaded on my website[1] and I also invite you to check my resume at [2].

[1] Carlos Dominguez website [2] Resume

Personal tools