Jump to content
  • entries
    941
  • comments
    5,894
  • views
    867,824

Cleaning up physics shapes


Josh

3,116 views

 Share

Before Leadwerks 3 existed, Leadwerks 2 used a little tool called "Phygen" to generate collision shape files for 3D models:

 

blogentry-1-0-84264300-1426910268.jpg

 

The user would input the parameters and then save that file with the same name as the model it was to be associated with, with the PHY file extension. This was not a very good system, but the idea of storing a physics shape in a PHY file that was automatically loaded along with the model was a good one.

 

In Leadwerks 3 we implemented prefabs to make it easier to have a ready-to-use game model. However, after using the system for a while it became obvious that 90% of your models just need a simple collision shape and no other special settings. The prefab system was overkill for a simple static model.

 

I've simplified physics shapes by adding physics shape generation in the model editor, for convex decomposition, boxes, spheres, cones, and cylinders. When you generate a physics shape it is created automatically from the model's bounds and saved as a PHY file alongside the model. Whenever that model is loaded, the engine will look for an associated physics shape file and load it at the same time.

 

blogentry-1-0-75791900-1426913060_thumb.jpg

 

The physics tab has been simplified with no more confusing physics shape fields to be adjusted:

 

blogentry-1-0-88344800-1426915095.jpg

 

However, under the hood the ability to assign an arbitrary physics shape to any entity is still there. If your map depends on this feature there is a hidden setting in the config file you can use to retain this feature in the editor. Just open your Leadwerks.cfg file and set the "EnableLegacyFeatures" value to 1 and it will appear. Existing maps will be unaffected, even if you don't enable this feature.

 

These changes improve the workflow because now you just open up a model, generate a shape of any type, save it, and you have a model with physics ready to go. It does mean physics shapes are more strongly associated with models, and I originally intended them to be assigned to any old entity. However, in practice the ability to set a physics shape to a light or camera or something in the editor is pretty useless, and it's better to focus on the way it's used 99% of the time instead of designing for edge cases.

  • Upvote 10
 Share

10 Comments


Recommended Comments

Just set EnableLegacyFeatures to 1 and it will appear. Building the shape into the model file with convex hulls also works.

Link to comment

I expect the title of the next blog post will be "I realised that nobody uses the editor therefore I replaced it with makeGame() method". wink.png

Link to comment

I agree with Olby when do we get the Make HitAAAGame() button? I think current gen engines sorely are missing this feature. I think Valve is using it in HL3

Link to comment

Leadwerks 2 actually had a hidden command MakeFPSGame(). If you called it, the engine would play a video of Rick Roll.

  • Upvote 2
Link to comment

Are "collision" shapes embedde in some FBX file still relevant ?

For example a complex static model can have a "collision" shape embedded on the FBX file, some times it is better made by ourselves than using convex decomposition.

 

Not so important point, but it can be good to keep that feature perhaps.

Link to comment

I'm now having second thoughts about this feature.

 

I really need the ability to have set a model to PolyMesh collision WITH Automatic asset reload. This allows me to have a automatically up to date collision mesh when I decide to test in the middle of modeling. And sometime the Convex Decomposition doesn't do as good a job as possible. The old ability to update a model and the physics at the same time automatically was invaluable.

 

Edit:

You cant generate a collision shape in game above a certain polygon count.

Link to comment

Thanks, it should be easy for me to add a polymesh option in the model editor, and much cleaner that way.

  • Upvote 1
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...