Cinematic Physics In XSI Part 1

Tutorial collection, comprehensive listings on main site.

Cinematic Physics In XSI Part 1

Postby Tutorial on Sat Jan 24, 2009 8:55 pm

category
Modelling

description
Creating cinematic physics, similar to those seen in Half-Life 2 : Episode 2.

keywords
model, models, modelling, cinematic, physics, physic, xsi.

In Half Life 2 Episode 2 Valve incorporated "cinematic physics" into the game, which are simply rigid body, or soft body simulations that are "baked" into an animation to take the load off of your CPU, not actually a feature of the engine. With Cinematic physics, simulations of thousands of rigid bodies are possible with minimal performance impact. Mesh deformations are also possible.



The collapsing bridge and the building being split apart by the strider's beam of doom are examples of cinematic physics.

The simulation that we are making in this tutorial will be simple one, so after you learn the process, I recommend that you read your package's help files to learn about making more complex simulations.

The Simulation

The first one we're going to make will be similar to the building being destroyed in the trailer. We're going to make a brick wall that gets blown up.

First, make the ground.

Image

Image

Pretty aint it?

Then make the ground a passive rigid body, by making it passive it means that by default it will collide with other rigid bodies, but it will not be effected by forces, and will not move (unless it's animated) To do this press "4" on your keyboard, or click on this button and set it to simulation.
Image
Then click "rigid body" (under create) and then click passive rigid body. Now you have a physically simulated ground. And I know it's hard to believe, but it gets even more exciting than this.

Image

Now we will make a single brick.

click on "Primitive" under "get" on the left button panel and go to polygon mesh, then "cube".

Image

But bricks aren't usually shaped like cubes, so elongate it a little and raise it above the "ground"

Image

then you'll want to press "2" on your keyboard, and change the menu to "animation.

Under "create" go to "Skeleton" and click "draw 3d chain".

Image

Click anywhere on a viewport and a "null" should appear, then place the null in the center of your brick. (you can just copy the Cartesian coordinates of the brick onto the null to get the positioning exactly right.

Image

Now click on your brick and select "parent" in the lower right hand side of your screen.

Image

(if your monitor is displaying at a low resolution then you may have to right click on the "constrain" button for "parent" to show up. After you press "parent" click on the newly placed "null" and right click. It won't look like anything happened, but if you move the brick the null should move with it.

ok, now RIGHT CLICK on the brick and press "control+D" on your keyboard then translate the newly created brick over to the right.

Image
then repeat the process until you have the bottom row of bricks completed.

Image

Now RIGHT CLICK and drag over the edge of all your bricks (selection is in blue)

Image and press "control+D" again to duplicate, then translate them all upwards, then do it a few more times till you have a wall of bricks.
Image


Now press "ALT+8" on your keyboard and the scene explorer should show up.

Image

Select all of the cubes (if you click on the first one then hold shift and click on the last one, it'll select all in between)

Image

With all the cubes selected press "4" on your keyboard to get you back into the simulation options then click on "rigid body" again, but this time select active rigid body.

Image

A window should pop up, scroll down till you see a slider with the word "elasticity" next to it, drag this slider down till it's at or close to 0 (you don't want your bricks bouncing like rubber) and set both friction values to something a little higher (you don't want your bricks sliding all over each other) But friction is relatively expensive on a large number of objects, so don't exceed .7 if you want to watch your simulations in real time

Image

Alright, now that you've got active and passive rigid bodies, time to test our simulation! click on the little right facing arrow at the bottom of the screen

Image

and... Nothing should happen. This wall is floating in outer space, there's no gravity, so now click on "force" under "get" and select "gravity".

Image

A little green gravity icon should appear near the center of your screen, but it's hard to see/select. When you create anything in XSI it's always gets selected by default, so just translate it out of the way so it's easier to see. Now press the arrow! Chances are that the wall is going to compress a little and act like... a wall. If not then don't sweat. Follow the next set of directions. If your simulation is working at this point then ignore the next paragraph!!!!

Hopefully you still have all your bricks selected, if you don't then open scene explorer again and select them all. Now click on "environment" under "modify" and click "apply force" and click on your gravity icon.

Image Woot.

Now you might notice that the simulation is very fast and very short, to fix that look at the number on the right side of the timeline at the bottom of your screen, and change that number to something a lot higher, like 250.

Image

Then click on the "playback" button under the timeline and set it to real time playback. (SAVE BEFORE YOU DO THIS, if your simulation is too intensive for your computer to keep up with it at its playback rate then it'll resimulate the scene over and over and over again until you force quit, if your simulation is too intensive keep it at (play all frames)

Image


While I'd say it's not really necessary with a simulation this small, it's important that you learn to cache simulations. so click on "rigid body" but this time, click on the one under "modify" and click "edit simulation properties.

Image

towards the middle of the box that pops up there should be a check box called "caching" check it. What this will do is save the animation once it's simulated once, so if you simulate a really heavy scene, then want to watch it again, you don't have to re-simulate, it also allows you to click and drag on the slider to see the simulation at any point in time. Later you will want to look up the different "playback modes" in the help files to help you figure out which you will want to use later, but for now we can stick with whatever the default is. A little lower on the box you'll notice a simulation substepping slider, that's basically an "accuracy" slider, the higher it is the more calculations it will do during the simulation. for the over the top explosion kinda simulations we're doing, it doesn't need to be very accurate, so keep it default as well.

But now back to the simulation. You bricks will probably be swaying around or falling over or something ghetto, without you even having to touch them, that's fine.

Image

It makes no sense to have a static wall be animated, so most of the time this wall be playing the "idle" animation in game, which is just the first frame on loop at 1 fps

But now for the explosion. Go to "forces" again, under "get" and select "attractor" (drag is highlighted because I'm an idiot, ignore it, press attractor)

Image a sphere should spawn, and a menu should pop up. in the menu set the amplitude to something crazy high (to mimic an explosion) I went with 40,000. then increase the range a little, I went with 20. Next you'll want to move the force to be slightly behind the wall, and close to the ground. you should get something a little like this
Image


Because of things like friction with the ground, as well as other bricks, and simulated mass, the explosion may or may not look realistic, that's something that you'll get better with later. (for a quick fix you can select all your bricks press "Alt+enter" and look for a box where you can enter "mass" then you can increase the amplitude of your explosion, or you can click on the ground and press "alt+enter" and raise the dynamic and static friction.)

Image

Preparing For Source

But this animation isn't ready for the source engine yet, once you're happy with your results go back to the "edit simulation properties" window and press "lock cache"

Image

Now you should go into the scene explorer (alt+8) and select all your cubes one more time. After that press "1" on your keyboard to put you in the modeling layout and scroll down to "poly. Mesh" under "create" then select "merge".

Image

A window should pop up, and you should drag the "tolerance" slider to the left then click the "delete" button. (I'm serious)

Image

Now drag the timeline slider around. UH OH! the bricks aren't moving anymore, but the bones still are.

Image

Now we have to find a way to connect the polygons to these bones. Well first you'll want to delete your "attractor" and your "gravity" because nothing is being simulated anymore, so they're just taking up space. then you'll want to click on your newly formed mesh and press "2" on your keyboard to go to the animation layout.

Select your wall model, then Under "deform" click on "envelope" then click "set envelope"

Image

a box should pop up about making the envelope a local operator, select yes (don't worry about figuring out what it does) then click and drag a box over all of your bones and right click.

Image There now it should all be enveloped, click the play button and see if everything is alright. In most situations everything will be alright, but sometimes you can get some ugly stretching.
Image

To fix the stretching you should click on the "weight panel" button in the lower right, it looks like a paintbrush, and something like this should show up on the left side of the screen.

Image

If you don't have all the colors and cubes listed then you need to have the model selected.

now you should lower the radius of your paintbrush. and scroll forward in the simulation so that the bones are far apart and easy to see which objects are causing problems. click on a null that is causing problems for you and look in the upper right to see what number it is,

Image

then on the weight panel select that bone (bones are listed in an odd numerical order, null 165 will be listed before null 15 because the numerical value isn't what counts, it's the order in which the numbers appear, it's like alphabetical order, but with numbers). In my case it's "null19" that's messing up.

Image

With your model still selected press "w" on your keyboard and click on the vertexes that are far away from the bone (be careful to only get the vertexes associated with that bone. There, now that bone is all fixed up, repeat this step with all the bones that are messed up (you'll get quick at it, don't worry)

Image

There, all fixed up.

Image

Now to plot the bones open up the scene explorer (alt+8) and select all the bones, then press "2" on the keyboard to get to the animation window. Down under "tools" click on the "plot" button, and then select "all transformations"

Image

Then this box should show up, just press ok.

Image

Now just export this as a reference model at frame 1, and export a skeletal animation for frames 1-whatever, and lastly export another skeletal animation for it at its final relaxed state, with bricks on the ground and not moving.

Mess Around

Now you can go back and mess with different forces and change the gravity value, or even make more complex structures, like a building made out of individual planks of wood, just remember, always have a bone parented to each model. Also remember the XSI has great documentation on rigid body simulations


Huge Simulations

Sometimes the limits of your own machine, make it hard to plot animations with thousands or tens of thousands of objects, when this is the case, simulate everything, turn down the accuracy, cache it, then save it. After that delete a large section of the bones, and save the new file under a different name, then go back to the original simulation, and delete the section that you didn't delete last time, plus whatever else you want to delete, then save it under a different name. What you're accomplishing is splitting up the simulation but not affecting the already cached motions, if you export and plot all of these separately then it'll be possible to plot more objects than your computer is capable of doing at one time. Valve splits up all of their simulations that have many objects.

Coming Soon

The next tutorial will be on soft body simulations, like the collapsing bridge. And even though I tried very hard to keep things palatable, I'm sure I botched a description somewhere, or omitted a step that is just second nature, so if anyone has any problems following this, let me know.

Stoopdapoop
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Re: Cinematic Physics In XSI Part 1

Postby Corigami on Sun Jan 25, 2009 2:39 am

YES! THANK YOU! I would be making something right now with this tutorial... Except a capacitor on my brand new mobo just exploded.

;____;
User avatar
Corigami
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Tue Oct 21, 2008 9:56 pm
Location: Kansas

Re: Cinematic Physics In XSI Part 1

Postby Akimine on Sun Jan 25, 2009 9:03 am

Really nice and well-written :)
Akimine
Dumpling
Dumpling
 
Joined: Sun Dec 14, 2008 9:48 am

Re: Cinematic Physics In XSI Part 1

Postby Au-heppa on Sun Jan 25, 2009 12:08 pm

Gasp. Nice one. Thanks a buuuuunch.
User avatar
Au-heppa
Regular
Regular
 
Joined: Fri Jun 29, 2007 7:34 pm
Location: Oulu

Re: Cinematic Physics In XSI Part 1

Postby korge on Sun Jan 25, 2009 8:48 pm

EPIC. I always wondered how that scene worked behind the scenes.

thanks!
zombie@computer wrote:Thank god the government knows best.
User avatar
korge
Pheropod
Pheropod
 
Joined: Fri Dec 28, 2007 4:16 pm

Re: Cinematic Physics In XSI Part 1

Postby Habboi on Sun Jan 25, 2009 9:21 pm

Yeaaaah. After scrolling through all that. I think I'll give it a pass but really well done on writing all that and figuring out cinematic physics.

With this tut, I expect more maps to use it :)
http://www.habboi.co.uk - Habboi's Portfolio

3D Art Director working on indie title "A Hat in Time" by Gears for Breakfast.
http://hatintime.com/
User avatar
Habboi
Veteran
Veteran
 
Joined: Fri Apr 15, 2005 9:52 pm

Re: Cinematic Physics In XSI Part 1

Postby stoopdapoop on Sun Jan 25, 2009 9:53 pm

ha, thanks guys.

But habboi, it's not really that involved, the largest body of the tutorial is just setting up the simulation in xsi, which can be done very quickly, I just felt that it was important to explain what everything does so that people could jump in with little to no experience then go on to make something good with just the knowledge they've gained from this tutorial. I also covered things that could possibly go wrong or make things difficult to find. I don't like tutorials that just show you how to do one thing, but don't explain what you're actually doing.

But if you've poked around with simulations before, then the rest will be very quick.
I'm Brown
Image
User avatar
stoopdapoop
Veteran
Veteran
 
Joined: Sun Aug 21, 2005 2:14 am
Location: Ann Arbor, MI

Re: Cinematic Physics In XSI Part 1

Postby SlappyBag on Sun Jan 25, 2009 10:40 pm

This is hella handy - I'm looking forward to using it myself
User avatar
SlappyBag
Veteran
Veteran
 
Joined: Sun Jun 26, 2005 9:16 am
Location: Brighton, UK

Re: Cinematic Physics In XSI Part 1

Postby Mess on Mon Jan 26, 2009 12:23 am

excellently fantastic!
Image
User avatar
Mess
Interlopers Staff
Interlopers Staff
 
Joined: Tue Apr 26, 2005 11:53 am

Re: Cinematic Physics In XSI Part 1

Postby ScarT on Mon Jan 26, 2009 4:39 pm

Any chance you could post an example map/model? Looks really interesting but to be honest I can't be assed to setup XSI, the scene and all that, only to find out it doesn't fit my needs :)
User avatar
ScarT
Senior Member
Senior Member
 
Joined: Sat Apr 02, 2005 7:33 pm
Location: Denmarkian Land

Re: Cinematic Physics In XSI Part 1

Postby stoopdapoop on Mon Jan 26, 2009 11:27 pm

well if you have episode 2, portal, or tf2, then there will be plenty of examples that you can check out in model viewer. Also there were two examples in the youtube video that I posted.

If you can simulate it in XSI, then you can put it in source.

But this thread has a few videos, many of which are in engine.
I'm Brown
Image
User avatar
stoopdapoop
Veteran
Veteran
 
Joined: Sun Aug 21, 2005 2:14 am
Location: Ann Arbor, MI

Re: Cinematic Physics In XSI Part 1

Postby TicTac on Tue Jan 27, 2009 1:43 am

Anybody know how to apply a force in 3ds max's Reactor that will behave the same way as XSI's Attractor?
A link to a tut would be nice, as well as a loving, hand-written solution :D
Competent Level Designer, 3D Artist.
I don't really look like my avatar
User avatar
TicTac
Veteran
Veteran
 
Joined: Sat Aug 02, 2008 1:30 am
Location: Philadelphia

Re: Cinematic Physics In XSI Part 1

Postby Lord Ned on Thu Jan 29, 2009 4:41 pm

Now to get this into source, all you would have to do is apply a material and export right? Won't you hit bone limits though?
Resident Source Guru, Competent Level Designer, Talented Artist, Horrible Speller
User avatar
Lord Ned
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Thu Jul 17, 2008 8:42 pm

Re: Cinematic Physics In XSI Part 1

Postby TicTac on Thu Jan 29, 2009 6:26 pm

My guess is that you would, and this is why (if you look in mdlviewer) that each cinematic physics 'prop' is really >5 models. The TF2 explosion for example, is around 7 models (I think).

The multiple models, however could also be to achieve better, more realistic lighting, since in Source the lighting of a dynamic prop is calculated based on the amount of light at the props origin.
Competent Level Designer, 3D Artist.
I don't really look like my avatar
User avatar
TicTac
Veteran
Veteran
 
Joined: Sat Aug 02, 2008 1:30 am
Location: Philadelphia

Re: Cinematic Physics In XSI Part 1

Postby stoopdapoop on Thu Jan 29, 2009 7:32 pm

I've made tens of test with different simulations and I've never hit a bone limit (I still don't know how high the bone limit is)

But you're right, I kinda skimmed over the "huge simulation" section should have explained it in a little more detail.

and yeah, texture it and import into source, all should work well.
I'm Brown
Image
User avatar
stoopdapoop
Veteran
Veteran
 
Joined: Sun Aug 21, 2005 2:14 am
Location: Ann Arbor, MI
Next

Return to Tutorials

Who is online

Users browsing this forum: Exabot [Bot]

cron