Thursday, October 25, 2012

The Pivotal Point of this Message

This is the first in a series of posts on physics with your Mesh Studio.  In this particular example, we will also cover creating a pivot point on a door.  As I worked on this, I realized it really was almost identical in content to a tutorial made by Ashasekayi Ra for Blender.  For those that work in Blender as well, I highly recommend Asha's great tutorials.  The main difference in mine will be how you can create a pivot point using Mesh Studio.

First, I've set up my prims for the door utilizing a full box and four more boxes that are hollowed for the decorative trim.  Presently, I have everything left unlinked because I need to set up a center at the hinge end to the left of the door.


For this, I can easily do it by utilizing a setting in the Edit Menu called Copy Selection.  With the main, large prim of the door selected, I touch the hinge end of the prim and it creates a copy of the prim perfectly aligned to the original.

Copy Selection is a function you should really play with as it not only copies single prims, but will also duplicate linksets, sculpts and meshes.  This includes the textures.
I've added a red tint to the newly created prim.  I am making this a Prim Face material so I can make it transparent once I've uploaded it.


Always try to make faces, you don't want to generate mesh, 100% transparent to lower the number of tris in your build on upload.  For the prim we are using to define the new pivot center, we only really need the top face of the box as it will both tell the uploader what the overall width of the door is (faking it out) and the depth (which is identical to the main door prim as my choice).  At this point, I can link everything with the main, large door prim as my root.  I add the Object2JoinedMesh script to the root.


I use this setup to create the highest LoD by choosing the default setting of 4/24 on the MS menu.  Make sure you name the root.  It's just easier to identify things when named.  Now I will make a version for the Medium LoD level with just the menu.  This time I set to Low Poly after I renamed the root to identify it as the Medium LoD.  Next, I'll make some modifications to create and use for the lower LoDs.  The easiest thing is to remove detail, in this case, that is the hollowed boxes.  When I create the DAE file, I use the Low LoD setting as this will take it down to 2/8.  What this does, is create the minimum amount of tris per face.  Each prim face generates 2 tries.  (Example, a box has 6 sides, so that is 12 tris).


Last I now turn to making the physics shape.  Hopefully you noticed that the red face we made was included in all the LoD levels I've made.  It MUST also be included in the physics shape.  However, with physics, the key is to leave only the necessary collision surfaces.  We know we need to keep that red face for the pivot to work.  I think I only need the front and back faces on the remaining door prim, so I make all the others transparent.  This leaves me with only 3 faces or 6 tris.  Very good, indeed!


On upload, I use the the high version, the medium and set the low version in both the Low LoD and Lowest LoD.  Then in the physics tab, I load from file and use this last version I made.  When I calculate, I see that I have
  • Server cost: 0.750000
  • Streaming cost: 0.403195
  • Physics cost: 0.360000
Sweet!

When I upload  and rez the door, I use Select Face in the Edit Menu and to select the single top face material to 100% transparent.  I also go into the Features tab on the mesh and set it to Prim (important to do this).  This is what allows me to walk through the area on the left of the door, but not through the closed door.  


One thing to note: If you upload a mesh that does not have physics assigned through the dae, it seems only the convex hull and none choices appear. When the mesh has physics assigned through the dae, all three appear. If you link your non-physics mesh to a prim, all three appear. If you link a prim to your non-physics mesh, only convex hull and prim are available.

And now when you rotate the door, you'll see it rotates on it's hinged edge as expected.

Something to keep in mind. The piece you create to enlarge the bounding box and set the pivot point can be made even smaller than I've shown. This piece is mesh even if set to transparent. So it will block someone from moving through it. I didn't worry about the size because I placed it at the top and it is only one face (2 tris) and I would expect this to end up within a wall. It could have easily been put at the bottom to end up on the floor. So just remember this when designing the piece you use and where best to put it.

Happy Meshing!
~ele

No comments:

Post a Comment