Jump to content

Amazing Tools

Josh

2,119 views

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.



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?

Share this comment


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.

Share this comment


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?

Share this comment


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.

Share this comment


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.

Share this comment


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.

Share this comment


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.

Share this comment


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.

Share this comment


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.

Share this comment


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

Share this comment


Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

  • Blog Entries

    • By Josh in Josh's Dev Blog 8
      You might have seen this graphic comparing the size of the world in different games. I've played Fuel, and never reached the end of the world in that game. You can drive for a very long time on those roads.

      We want to use the new engine for realistic simulations of air and ground movements. At normal cruising altitude of a commercial airliner, the pilot has a view range of about 400 kilometers. The image below shows that area (800 x 800 km). You can see the areas of the biggest games ever fit neatly into the corner of just our visible area.

      The gray space above is not the total world size, it is just the area you can see at once from high altitude. The total world size is about 50 times bigger.
      This is what I am working on now.
    • By Josh in Josh's Dev Blog 26
      Gamers have always been fascinated with the idea of endless areas to roam.  It seems we are always artificially constrained within a small area to play in, and the possibility of an entire world outside those bounds is tantalizing.  The game FUEL captured this idea by presenting the player with an enormous world that took hours to drive across:
      In the past, I always implemented terrain with one big heightmap texture, which had a fixed size like 1024x1024, 2048x2048, etc.  However, our vegetation system, featured in the book Game Engine Gems 3, required a different approach.  There was far too many instances of grass, trees, and rocks to store them all in memory, and I wanted to do something really radical.  The solution was to create an algorithm that could instantly calculate all the vegetation instances in a given area.  The algorithm would always produce the same result, but the actual data would never be saved, it was just retrieved in the area where you needed it, when you needed it.  So with a few modifications, our vegetation system is already set up to generate infinite instances far into the distance.

      However, terrain is problematic.  Just because an area is too far away to see doesn't mean it should stop existing.  If we don't store the terrain in memory then how do we prevent far away objects from falling into the ground?  I don't like the idea of disabling far away physics because it makes things very complex for the end user.  There are definitely some tricks we can add like not updating far away AI agents, but I want everything to just work by default, to the best of my ability.
      It was during the development of the vegetation system that I realized the MISSING PIECE to this puzzle.  The secret is in the way collision works with vegetation.  When any object moves all the collidable vegetation instances around it are retrieved and collision is performed on this fetched data.  We can do the exact same thing with terrain   Imagine a log rolling across the terrain.  We could use an algorithm to generate all the triangles it potentially could collide with, like in the image below.

      You can probably imagine how it would be easy to lay out an infinite grid of flat squares around the player, wherever he is standing in the world.

      What if we only save heightmap data for the squares the user modifies in the editor?  They can't possibly modify the entire universe, so let's just save their changes and make the default terrain flat.  It won't be very interesting, but it will work, right?
      What if instead of being flat by default, there was a function we had that would procedurally calculate the terrain height at any point?  The input would be the XZ position in the world and the output would be a heightmap value.

      If we used this, then we would have an entire procedurally generated terrain combined with parts that the developer modifies by hand with the terrain tools.  Only the hand-modified parts would have to be saved to a series of files that could be named "mapname_x_x.patch", i.e. "magickingdom_54_72.patch".  These patches could be loaded from disk as needed, and deleted from memory when no longer in use.
      The real magic would be in developing an algorithm that could quickly generate a height value given an XZ position.  A random seed could be introduced to allow us to create an endless variety of procedural landscapes to explore.  Perhaps a large brush could even be used to assign characteristics to an entire region like "mountainy", "plains", etc.
      The possibilities of what we can do in Leadwerks Engine 5 are intriguing.  Granted I don't have all the answers right now, but implementing a system like this would be a major step forward that unlocks an enormous world to explore.  What do you think?

    • By Haydenmango in Snowboarding Development Blog 6
      So I've been researching snowboarding lately to get an idea of what animations and mechanics I need to create for my game.  I have learned lots of interesting things since I've only seen snow once or twice in my entire life and have never even tried snowboarding or any other board sports (skateboarding, surfing, etc.) for that matter.
       
      Snowboarding tricks are quite interesting as they are mostly derived from skateboarding.  Snowboarding tricks pay homage to their equivalent skating tricks by sharing many concepts and names.  For example basic grabs in snowboarding share the same concepts and names as skateboarding: indy, mute, method, stalefish, nosegrab, and tailgrab.  Something interesting to note is in snowboarding you can grab Tindy or Tailfish but this is considered poor form since these grabs can't be done on a skateboard (due to the board not being attached to the skaters feet) and grabbing these areas is generally something a novice snowboarder does when failing or "half-assing" a normal grab.  Check out this diagram to see how grabs work -
       
       
      So, after reading lots of text descriptions for tricks I was still confused by what all these terms meant and how they were actually applied.  So my next step was to look up these tricks actually being done and I found some really cool videos showing off how to do various tricks.  This video in particular is the best reference material I've found as it contains nearly every trick back to back with labeled names and some tweaks -
       
      Sadly my rigged model doesn't handle leg animations with the snowboard that well so I can't animate as many tricks as I want to.  Regardless there will still be around 15 total grab/air tricks in the game.  Now it's time for me to stop procrastinating and start animating!  
×
×
  • Create New...