Thursday, October 25, 2012

Thinking Outside of the Box: Let's get Physical


So many people have been begging for information on Physics that I'm posting the text first and will add graphics to illustrate the examples and such as I am able.

The outside of the lowly prim Box can be your best friend when it comes to physics meshes.  Min Barzane and I spent a good bit of time, a while ago, talking about and figuring out things about physics.  The conclusion we came to is you should:
  • simplify the physics shape as much as you can
  • concern yourself primarily with the actual collision surfaces: walkable surfaces, wall surfaces you don't pass through
  • use boxes, where only one face is visible, to create your physics meshes when needed.  This, in essence, creates a plane and a single plane generates two tris.  We will refer to boxes with only one face as a plane from here on in.
  • remember that you do not have to have perfectly aligned pieces when making your physics shape.  You always want to test your shapes (try Aditi where the Lindens give you money that can be used in this test grid and not come out of your own pocket) to make sure you can walk well on and not walk through any gaps.
Creating a plane with which to work.
  1. Create a box prim.
  2. Go into Edit on it and set the box's transparency to 100%.
  3. If you have trouble locating your faces, use Ctrl-Alt-T which will show all transparencies in red.
  4. To give you a more workable plane, select one of the side faces of the box to make opaque by zeroing the transparency.
  5. Depending on which side you chose, you will be able to taper the plane on X or Y.  You can also shear on X or Y.  This gives you more flexibility for fitting areas as you make your physics shape.





Whether you are making a house, a staircase, a doorway, or a chair, it is the actual surfaces that require collision that matter.  Let's look at some examples:

A wall with windows and a doorway.  Unless you intend to have people walk through your windows, you can treat them as part of the wall (meaning they don't need a hole in the physics mesh).  Use common sense.  If the walls aren't very thick, you may only need to collide with the inner wall.  If you do need to collide with both sides of the walls, only do surfaces for the walls and not the sides of the prims making up the walls.

You want to walk through a doorway, so you devise your "planes" to allow the entry way.  If the doorway is on a wall, make the prims 100% transparent and use Ctrl-Alt-R to see the transparent areas in red.  Use "Select Face, on the SL Edit window, and select the wall surfaces and set the transparency to 0% to make those wall surfaces opaque.  On the door way, you want the wall surfaces, but don't need to make the inner surfaces of the doorway opaque; the walls provide the perimeter of the area you walk through.

If you are creating a pre-hung door for sale (consists of 5 parts: the two side uprights known as the jambs, the top piece called the jamb header, the bottom threshold piece and the door), you can do the same, and make all the edge pieces 100% transparent.  Just the door?  The same holds true.  Check out the blog post on doing pivots for your doors.

Floors.  The box will be used for square floors.  The sides and bottom of the boxes are not walked on and are thus made 100% transparent.  With round floors you have to take care as you want to use the full cylinder.  Minimizing the sides on a cylinder could result in pockets where someone could fall through, so you really want to experiment and see if you can get away with any minimization.  How do you minimize?  The settings on the Mesh Studio Menu.  A setting of Low Poly on a cylinder creates 8 edges.  You can use that as a starting point and then use Circle + 1 or Circle -1 to add or lower the number of edges on your cylinder's circle till you have a walkable floor for your particular "floor plan".

A round balcony.  The inner part of the balcony needs to keep the user from going through it, but it does not need to be completely round to be effective.  Use your planes to define the arc of the balcony railing with as few box planes as possible.

Railings.  A railing is a good example of how much or how little of the mesh needs to be involved in the physics shape.  The collision surface is merely to keep the user from falling off the side of the steps where your railing is positioned.  Any single surface side will provide this, whether it is the top of the hand rail, its side, or the side made up by the balusters (again, treat it as if you're shoddily covering them up with planks since the physics mesh does not need to be perfect).

A roof on a house.  If you think your users will walk on your roof or fly through it, then by all means choose the inner or outer surface of your roof to supply collision.  If the roof extends past the boundary of the house, it is not necessary to match the dimensions.

Staircases.  Steps can be handled with one long or several short ramp planes depending on the direction and formation of the steps (like a spiral staircase).  

Chairs, benches and other seats.  The only important collision surface on a chair may be where the avatar actually sits.  First, this may be enough to define the area of the chair itself and second, it may be an effective way to handle the avvie being able to sit on the chair without the assistance of an animation.

These are just some examples to get you thinking.  So what else do you need to know?  When the physics shape is ultra simple you can sometimes get away with having to do little else than loading your LoD daes in the Level of Detail tab and the Physics dae file in the Physics tab of the SL Mesh Uploader window.

Aditi, aditi, aditi.  Experiment your heart out on on the Linden's dime.  Make sure your physics work right and THEN take it live to Agni (the main grid we're all on).

Until any of the  TPVs (Third Party Viewers) get the full Havoc license, only the LL Viewer has it, so you should definitely use it to upload any mesh particularly with physics.  I have had people tell me they successfully upload with their TPV and all I can say is after the first time mine failed me (a doorway that couldn't be entered), I chose not to lose money again by sticking to the LL Viewer.  Feel free to try the odds if you like.  The Lindens will love you for it.

Once you upload your mesh, don't forget to set your mesh to Prim in the Edit window's Features tab.  This is the one thing that almost everyone forgets sooner or later and wail their physics aren't working.

If it still isn't working the way it should, here are some videos that explain the decomposition  method:



Plus some other reference pages to help you out:

What is Decomposition?
http://wiki.secondlife.com/wiki/Mesh/Decomposing_a_mesh_for_physics_shape

Making Mesh Physics for SL:



Recently the Lindens updated the Physics Optimization wiki page.  Some good info here:

https://sites.google.com/site/tamaproducts/home/mesh-studio

So I hope this helps you understand this topic a bit better.  As always, please let me now how you like the articles and if you would like to see certain things covered.  More to come as always.

Happy Meshing!
~ele

No comments:

Post a Comment