Wednesday, October 22, 2014

Basketball Simulation in Houdini with Rigid Bodies

Back to rigid body simulation! We've covered this before in Maya, that post can be found here, this time we're looking at Houdini. Being a program that specializes in visual effects, accessing the tools to crate the simulation was not that bad. But I'm getting ahead of myself, first we have to model the props.

Starting off in Maya with the basketball, there is actually a really quick and easy way to get the ridges in the ball, while keeping a nice, clean edge flow.  The way you do it is by taking a default sphere and changing the subdivisions to 16 and 16 and just rerouting the edges on the top and bottom. This will get the edges ready for the ridges.



After that it's just smoothing the mesh and extruding the proper faces to get those ridges. I chose to texture the ball too for more practice though I did not bring that into Houdini for the simulation.


Next I modeled the rim and tried some nets. Everything fell into place really well for the rim. I started with a torus and just extruded from there everything came out nice and symmetrical so adding edge loops for 3 mode was no problem at all. I even decided to take it a step further and add the hooks that hold the net, though in hindsight I probably should have followed my reference better and added more then 5 hooks.


On the other hand the net gave me some trouble. I tried two similar methods with different designs. The method I used was the quad draw, and I mapped out where I wanted the faces to go. I only did this for a small patch then I duplicated and used a bend deformer to rotate it around. The first one kind of reminds me of the plastic things that keep a six pack of soda together. I didn't include a net in the Houdini scene because I don't think my geometry would be good enough for simulation with its current topology, additionally that would be something other then rigid body simulation (more along the lines of nCloth in Maya.)


The other main piece of geometry the ball reacted with was the backboard. I modeled this using regular tools like add edge loop and extrude. Somewhere along the line though my geometry got sloppy. And I could no longer place edge loops on certain faces. This meant I could not add the sufficient holding edges for 3 mode. Because the back board is pretty angular though this wasn't much of a problem, I just kept it in 1 mode.


The final geometry I modeled for this simulation was the ground. I started off with a poly plane and added edge loops where needed. The round part at the free throw line I made using the quad draw tool (I really like that tool.) I the extruded the faces that made up the court lines. In a scenario like a game, these would probably be textures. I just wanted to exaggerate them so they are visible in Houdini.


The last step left in Maya is to line up everything. The project required us to have the rim 10ft tall and the ball be 15ft from  the rim. There is a lot of good reference out there for the dimensions of a basketball court. These are the images I used.


You might have noticed from the first image (or maybe you know from playing basketball) that the rim is 15 ft away from the free throw line, which lines up perfectly with the modeled ground geo. Managing the scale and dimensions can also be done while you model each piece, not necessarily at the end, it all depends on preference. Speaking of preference this step can also be done in Houdini with its image plane system, though I prefer to do it in Maya.

On that note, let's move on to Houdini. From Maya we want to export .obj files of the geometry to import into Houdini (In my case I had some objects that were meant for 3 mode, and the smooth node in Houdini was ruining their shape. In this case what I did was [Modify-Convert-Smooth Mesh Preview to Polygons] this took my 3 mode model and turned it to 1 mode by adding a lot more topology). This is done using the file node that comes in every geometry node you tab in. Once all that is in you want to make the ball a RBD Object, the backboard and rim be Static Objects, and spawn in a Ground Plane. 


Doing this will get you the necessary nodes in your AutoDopNetwork. From here it's all a matter of changing the right settings to get the desired result. There are many different ways to make the shot and it would de pretty boring if I just listed all of my values one by one. So instead I'll show you something a bit more fun.

                                     

Oooohh, so close. One thing I will mention about the settings that may help you if you decide to try this, when you get the ball on the right trajectory and its just about to enter the hoop but it bounces off of nothing and misses. This is an issue in the Geometry Representation under the Bullet Data menu of the rim. That was the biggest hurdle I had to deal with but after a bit of online research I managed to solve it. Now let's take a look at what I came up with.

                                    

A few things that I could have done differently had there been more time was, the ball doesn't rotate enough on the way to the rim if at all. I tried fixing this with the angular velocity on the ball, but I'm not sure if that was the right way to go. Another thing was the ball only bounces once after it hits the ground. Realistically I'd imagine it would bounce more, but adjusting the bounciness on both the ground and the ball didn't change this. Perhaps again they weren't drastic enough of changes. The last thing was the gravity, it just didn't feel like the ball had the proper weight of a real ball, but that could be a host of different sliders. If anyone knows any solutions to any of these issues please let me know. See you next time.

No comments:

Post a Comment