Jump to content
  • entries
    945
  • comments
    5,899
  • views
    930,147

Amazing Tools


Josh

4,871 views

 Share

This is just so cool. You can generate simple primitives for any entity. A convenient "Fit Shape" button will wrap the primitive around the entity, with an option to include the entity's children. However, the real power comes when you generate physics shapes from models. You can right-click on any model and get a menu to generate a physics shape. The polygon mesh and convex hull will look familiar if you've used the PhyGen tool in Leadwerks Engine 2. There's also a new option called "Convex Decomposition".

blogentry-1-0-61437300-1341894966_thumb.png

 

Convex decomposition is an advanced algorithm that takes a polygonal mesh and outputs a series of convex shapes. This is helpful because real physics calculations require geometry with actual volume instead of just being a polygon soup. Convex decomposition can turn any polygonal mesh into a physics shape, such as the Stanford bunny shown below:

blogentry-1-0-24584400-1341894948_thumb.jpg

 

This means you can generate accurate physics shapes for any model, without creating special physics models in 3ds Max or Blender.

 

Take complex objects like this Utah teapot and generate a physics shape for it, then attach that shape to the model and save it as a prefab. Here you can see the physics shape that was calculated for the teapot using convex decomposition. Navigation is turned on to make the teapot into a dynamic obstacle AI will avoid going through:

blogentry-1-0-74194200-1341895117_thumb.png

 

It's taken a long time to build a game development platform that accelerates development without restricting you, but I think the results are worth it. I hope you are looking forward to using these tools as much as I am.

  • Upvote 4
 Share

14 Comments


Recommended Comments

Very cool stuff! Does this work at all with models with movable joints? I suppose you would do a separate convex decomp for each model child in the heirachy?

Link to comment

Very cool stuff! Does this work at all with models with movable joints? I suppose you would do a separate convex decomp for each model child in the heirachy?

In LE2 we followed a rule that only top-level entities should be physically active. This is because when a parent moves, the child moves with it, and that would override the physics behavior. I am toying with the idea of allowing physics at any stage in the hierarchy, in which case the parent motion would get ignored by the child.

Link to comment

so no more saving OBJ's if i follow correctly? this creates the physics shape from the MDL mesh? if so, thats great since that was always annoying to have to create OBJ's and GMF's.

 

Can you explain what you mean by "attach that shape to the model and save it as a prefab"? How is the shape attached to the model? And how is it being saved as a prefab? Is a prefab a separate file type?

 

Also, was there not a plan at one point to have some sort of visual physics editor to allow for easy construction of joints? Is this still a possibility? Or has this already been included into the editor?

Link to comment

so no more saving OBJ's if i follow correctly? this creates the physics shape from the MDL mesh? if so, thats great since that was always annoying to have to create OBJ's and GMF's.

You can still model a separate physics model and convert it into a convex hull shape, but you can just create a convex decomposition on the original visual model. A hand-made collision shape will be more accurate, but it's not always needed. We can probably also make them out of brushes and save them in the editor.

 

Can you explain what you mean by "attach that shape to the model and save it as a prefab"? How is the shape attached to the model? And how is it being saved as a prefab? Is a prefab a separate file type?

There's a property in the physics settings that lets you choose a *.phy file. This overrides the auto-generated shape, if one is chosen in the drop-down box above that. If you want to reuse the model + physics, just save it as a *.pfb (prefab) file. Like 3D World Studio, these can be reused and carry more information than just a dumb model file. In fact, you'll probably be using prefabs when you build a scene more than plain models (since a prefab is a model + extra info like physics). This is better than resaving the model from the editor, because you can still update the model in Blender or whatever, and the extra info you add won't get overwritten by your modeling program.

 

Also, was there not a plan at one point to have some sort of visual physics editor to allow for easy construction of joints? Is this still a possibility? Or has this already been included into the editor?

You're looking at the beginning of that. I haven't actually implemented joints yet, but I'm thinking about making them an entity. That way they can have scripts attached to them, and they can be displayed in the editor with the regular rendering routine.

Link to comment
I am toying with the idea of allowing physics at any stage in the hierarchy, in which case the parent motion would get ignored by the child.

I hope it can be disabled to ignore the child, because I would really like that if someone pulls on an arm, the whole body would follow the movement.

There shouldn't be a problem when multiple force sources affect a body, because naturally all the forces just add/substract on the body.

Link to comment

Thanks for the explanation of the prefab - makes sense. I assume the prefab also stores scripts that have been attached as well?

 

Yes, several times I had wished the joints in LE2 were entities. That would be great to be able to use the standard entity commands on them as well as be able to see them. I think we would have alot more complex physics setups with some sort of visual representation of where the joints (and PINS!) are located in regards to the physics bodies.

Link to comment

 

I hope it can be disabled to ignore the child, because I would really like that if someone pulls on an arm, the whole body would follow the movement.

There shouldn't be a problem when multiple force sources affect a body, because naturally all the forces just add/substract on the body.

That happens right now if you connect two bodies with a joint. It sounds like you are describing a mixture of forward kinematics (animation) and inverse kinematics (physics), which actually doesn't sound unrealistic. We already have code to move and rotate a physics body where we want it to be. Maybe animation can use this when the child entity has mass.

Link to comment

Make sure the collision mesh is always slightly bigger then the model, in the picture of the teapot, some parts of the collision mesh are smaller then the teapot, which could look weird when it actually collides with something.

Link to comment

@Benton, I do not think you would be able to see any problem with anything intersecting with the teapot because, there is probably less than one cm in difference. I do not think you could see a sword,gun,finger,ect,ect... intersecting with the pot. If the difference was alot larger I would agree with you.

Link to comment

Maybe but the code should still work to make sure there is no intersecting. Because it might be only an inch with the teapot, but with other models it might be more...

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...