Search Unity

[RELEASED] Truss Physics for Unity3D. Soft-body simulation plugin.

Discussion in 'Assets and Asset Store' started by Heartbroken, Aug 22, 2015.

  1. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Truss Physics for Unity3D

    Truss Physics is a Unity3D extension package. Its purpose is the soft-body simulation. The soft bodies in Truss Physics are represented by mass-springs systems with optional internal pressure which allows to simulate a wide range of materials from jelly-like and springy to almost rigid but deformable. The simulation is done on CPU with extensive usage of SIMD and muli-threading optimizations.

    Asset Store page

    Package content:


    Standalone demo:
    RedCar Demo (Zip 9.5MB)

    Demo video:
     
    Last edited: Sep 2, 2015
    5T4RD35TR0Y3R, ZiadJ and theANMATOR2b like this.
  2. Hightlander

    Hightlander

    Joined:
    May 30, 2013
    Posts:
    29
    I like this demo and physics. It must named as "Russian driving simulator". :D
    It would be more fun if debris remained on map after respawn. ;)
     
  3. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    I guess you can select vertices for your soft body effect is there a falloff?
     
  4. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    Hi Heartbroken


    Downloaded the evaluation copy(btw nice to have the opportunity to try it out! :)), and the cute car from assetstore, dissembled the car model, and tried out to set up a working soft body with truss physics.

    This all went well and now i´m nearly satisfied with the behavior of car body…

    What i discovered in the process:

    Really would like to have a tutorial, about the car setup, in which you set up the different parts, and share some knowledge of placing the nodes, and the way to connect them for their purpose. This could be easily split in more parts…
    I myself, have first setup only the hull of car, this gives funny effects, but i had connect the links to the center, to get some stiffness!


    Some thoughts which could be implemented:

    I saw that i can create a truss from mesh and probably it would be faster, but i have done it manually.
    Symmetric editing? For nodes and links - most of the objects have some kind of symmetry!) ?
    Selecting more elements with shift key?
    Also one group should be there by default: All!
    I noticed that i can give different values to the links. I think some kind of visual feedback would be nice, the simplest would be coloring of links. Set the range and colors and then visualize it. Sure the density of links is important too…
    I was pretty unsure about the values, perhaps some calculation of volume and how many links are assigned and then choose a standard (metal, rubber….) and from that some fine-tuning.
    It would be good to have a fade off time in addition to deactivation time.


    Overall an impressive package, and really giving opportunities not available before. A sure purchase this week. Looking forward to the evolution of truss physics. :)


    Thanks

    Michael
     
  5. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Hi Michael

    Thanks for your interest

    Sorry, my tutorials aren't ready yet, so for the moment I can only refer to BeamNG wiki. BeamNG is a great project which, as anyone can guess, was the inspiration for Truss Physics, and as BeamNG already has a lot of cool stuff, it's a great place to get the idea of what mass-springs systems can be used for.
    Check for example BeamNG's tutorial for vehicle creation:
    http://wiki.beamng.com/Introduction_to_Vehicle_Creation

    Thanks for your suggestions as well, I put them on the backlog. Just a couple of moments:
    - You can mirror selected vertices by applying the transform with 'Clone' option checked and 'Scale' equal to -1 along axis of symmetry.
    - You can select several elements by clicking them while holding ctrl key. I thought it's how it usually works in Unity, no?

    Anyways, thanks for taking time to check Truss Physics. I really appreciate that :)
     
  6. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    804
    I tried it as well. Is there a way to cap cpu usage? If you have traffic, 25 cars will take it down to 10 fps on my pc. Like deactivating it if nothing is colliding yet? Would you need to use a standard collider and a rigidbody as well?

    How did you set up your red car? I can't seem to move the softbody, neither via transform nor via rigidbody and forces.
     
    Last edited: Aug 24, 2015
  7. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Truss Physics is not a car simulation library. It is a general purpose soft-body simulation engine. It is possible to use it to model different things including vehicles, though there are for sure much easier and cheaper ways to do this.

    For the CPU usage you can define TX_SHOWTIMING symbol in the player settings, this will output the simulation and interpolation time onto the game screen.

    You also can use Unity's profiler. BehaviourUpdate->TxWorld.Update should show the Truss Physics timing.

    You can use standard collides and rigid bodies if you want though it's not mandatory. Truss Physics can work without them.
     
  8. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    804
    I know how to profile it, the question was about capping ;)
    I know that it isn't a car simulation library, I have my own for that and I am searching for good deformation. Your solutions looks and handles exactly like I wanted it to, is easy to edit and the results look good, but I can't seem to get it attached to my car rigidbody, so that the car is taking its deformable parts with it, that's why I asked about the red car demo
     
  9. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Ah, ok. Then I should ask what is 'capping' :)

    To attach a soft body to a rigid body you use Tx Constraint component
    http://heartbroken.bitbucket.org/trussphysics/document/user-manual/usage/constraint/

    Your rigid body should have Tx Rigid Body component attached
    http://heartbroken.bitbucket.org/trussphysics/document/user-manual/usage/rigid-body/

    Truss asset of your soft body should have a named set with nodes you want to attach to the rigid body. This is done in Truss Designer
    http://heartbroken.bitbucket.org/trussphysics/document/user-manual/usage/truss-designer/

    When this all is ready, in the soft-body's constraint component you set the Base Body property as your rigid body, add a snap, and set the snap nodes property as the nodes set you've prepared in previous step.

    That's about it. Should work.


    I will publish RedCar demo but later. It's not ready yet.

    Cheers :)
     
  10. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    804
    I am not a native speaker, maybe I will find another word ;)
    To set a value of how much cpu it is using, if it is using too much, to scale simulation down a bit.
    I tried deactivating the whole tx soft body when not in use, but the mesh got resetted to the original state.
     
  11. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Me neither :)

    Ok I see. But I don't have such thing. You can tell engine how many worker threads it's allowed to create, but besides this it will use as much CPU as it needs to run the simulation.

    You can try to use TxSoftBody.Disable()/TxSoftBody.Enable() functions to pause the simulation of soft bodies you currently don't need.

    hth
     
  12. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    804
    The worker threads value is negative, is that normal?
     
  13. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
  14. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    804
    Ah, well, sorry. I didn't look it up since the first few things I searched are still todo in the manual ;)
     
  15. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Yep. It's still WIP :)
     
  16. Soul-Challenger

    Soul-Challenger

    Joined:
    Dec 30, 2010
    Posts:
    152
    Hello Heartbroken,

    kudos for the release!

    I find Truss to be very usable indeed. One suggestion would be to add the possibility make groups of links (and assign different colors to each group) with a visibility toggle. Right now it can get a bit messy visually, when editing an object with many links.

    Managed to integrate Truss to my rigidbody-based car :)

    RootObject: (Unity)Rigidbody, TxRigidBody, CarControllerScript
    ChildObject: TxSoftBody, TxConstraint(5 nodes constrained to TxRigidBody)

    Had some worries because the SoftBody's transform would lag behind the RigidBody's transform at higher speeds. Changing Interpolate to "interpolate" instead of "none" fixed that.

    Thanks for posting the BeamNG wiki info. That will come in handy.

    Performance-wise, I think it's pretty fine. Tested ten cars with softbodies (Fixed Timestep = 0.02)

    Cheers :)
     
  17. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    847
    This looks brilliant, are there any figures on how it performs on mobile devices, like roughly how many links and nodes could I have in a scene? Would love to use this on my cars to do damage, do you think it would be feasible to have two cars similar to the red car demo running on mobile devices?
     
  18. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    847
    Will the system work if I gave the truss stuff disabled and only turn it on when a collision happens between Unity colliders?
     
  19. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Hello Soul,

    I'm happy to hear it works for you. Would be great to see it in your game when you have something to show :)

    You can make groups of nodes, links or faces in Truss Designer (named sets), but it's not clear how to color them as they can intersect. Yes it's hard to edit a truss with many links, but you can hide some of them and only leave those you're editing.

    Right, Truss Physics always interpolates the soft bodies transforms. This matches the rigid body "Interpolate" mode. I thought to make a mode without interpolation but as the interpolation is quite cheep I left it for the future.

    Cheers :)
     
  20. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Thanks. No I don't have any figures for performance on mobiles yet. I hope someone will try it and share :)
    There are several things which affect performance - except the number of links and nodes it's the simulation step size and the number of iterations. RedCar will hardly work good on mobiles because of its soft-body wheels. Wheels can rotate very fast and to work properly their require quite small simulation step. But if you make a usual rigid body car with only deformable frame attached on top of it, it will be much cheaper and, I believe, should work on mobiles too. Though I didn't try.
     
  21. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    It can work in theory, but currently I afraid it won't because it assumes that disabled soft bodies do not move. I will need to check this.
     
  22. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Sorry I missed your last question. Yes, currently Truss Physics overwrites the object transform after each simulation step. That's why it's impossible to change the object transform from script. I'm already working on this.
     
  23. sashahush

    sashahush

    Joined:
    Sep 5, 2012
    Posts:
    75
    Hey there! I'm evaluating Truss at the moment and this looks quite promising, it really reminds me of ncloth in maya.
    I went through the tutorials ok until I reached the constraint one.
    1. Could someone perhaps explain how to connect two objects in a step by step process?
    The tutorial had a parent to child Setup is this important?
    2. How do you setup a metal type of object, which deforms and stays deformed. spring/bend settings.
    3. can the nodes break apart? Or is the truss unbreakable?

    My goal is to a breakable airplane, a unity rigid object with fly script with truss soft bodies as the physical pieces of the plane. Is this possible?

    a car example would perfect for people who are starting I think, soon?
    If I can get this to work you've got a customer for life!!!
    Cheers!
     
  24. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Hi!

    1.
    To connect two bodies you use Tx Constraint component
    http://heartbroken.bitbucket.org/trussphysics/document/user-manual/usage/constraint/

    The component should be added to a soft body. The component has a property 'Base Body' which can be either soft, rigid or static body. Thus it connects the attached soft body (body A) to the base body (body B). Body B is optional, if it's missing body A will be attached to the world.

    The constraint component also has a list of 'Snaps' which actually do the job. Without snaps the constraint does nothing. To add a snap you press 'Add' button next to the snaps list and then set the new snap properties.

    The snap properties are a little bit different whether your base body is soft or not. For non-soft base body a snap expects a set of nodes of attached soft body which will be fixed relatively to the base body transform. For soft base body each snap connects *one* node of attached soft body to a node or to an edge of base soft body ('edge' here means a line going through any two nodes of a soft body).

    The nodes sets you use in snap properties like 'Nodes', 'Node' or 'Nodes B' should be defined in Truss assets you use for your soft bodies. See Truss Designer - Nodes tab - Named Set.
    http://heartbroken.bitbucket.org/trussphysics/document/user-manual/usage/truss-designer/

    2.
    To setup your soft body deformation you use Truss Designer - Links tab - Elastic Deformation
    http://heartbroken.bitbucket.org/trussphysics/document/user-manual/usage/truss-designer/

    3.
    No, the nodes cannot break. Yes, the truss is unbreakable.

    To make a breakable object you assemble it from several bodies and connect them with constraints. Each snap of a constraint has 'Strength' property which can be adjusted to make the snap break after certain load. A snap also has 'Master' flag which means that if this snap is broken whole constraint is broken.

    HTH
     
    chiny1 likes this.
  25. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    Hi Heartbroken
    Just a simple wish: can we get a Mac version of RedCar Demo?

    Cheers
    Michael
     
  26. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
  27. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    Perfect! :)
    Thanks
    Michael
     
  28. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Hello. I've added a poll to this thread. I want you let me know if someone is interested in Truss Physics version for Unity 4. Currently I develop Truss Physics in Unity 4 and then check that the package can also be imported to Unity 5 project. Now I'd like to switch to Unity 5 as working with native plugins there is easier, but then Truss Physics won't be compatible with Unity 4 anymore. So please answer the question at the top of the page and/or leave your comment if you have some thoughts on the matter. Thank you very much.
     
  29. Lesnikus

    Lesnikus

    Joined:
    Aug 29, 2015
    Posts:
    47
    I noticed that the car has a soft tires. They realistic spring. I think the wheels are not made on WheelCollider, because there is no such:



    This is the best implementation of the car, which I saw in Unity. I would be happy to see it on the Asset Store, with good documentation and easy addition of its car models. Or in this Asset.

    The only thing that bothers me: how many cars can be on the screen at the same time?
     
  30. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Awesome that you support unity 4.x.
    Reading in deph now and considering.
     
  31. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    @Heartbroken
    Truss is now out for a month. I bought it 2 weeks ago. When will there be some more information about Scripting Api, or Tutorials?

    Cheers
    Michael
     
  32. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Hello Michael,

    The plan is to provide the support for users (like you) on the first place and then transform the solutions developed in the process into tutorials and/or scripting API improvements. So if you have any specific questions feel free to contact me directly by email from the Asset Store page or PM.

    Cheers
     
  33. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    780
    I have this on my wishlist and will buy it as soon as I can assuming it is being switched over to Unity 5. However, if I buy it in its current condition am I likely to have to pay an upgrade charge for Unity 5 version?
     
  34. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Truss Physics does work in Unity 5 in it's current condition, and it is actually free for evaluation. Just download it from the project site, import into your Unity 5 project and see if it works for you.
     
  35. sicga123

    sicga123

    Joined:
    Jan 26, 2011
    Posts:
    780
    Thanks for the quick reply.
     
  36. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Hello.
    Trying to do a quick test.

    I assign soft body to the car chassis, all in a single mess.
    The truss is build from mesh from a lower res mesh.
    When In hit play the original chassis is scaled down. And collapses.

    Any hint to avoid downscalling and to get a material similar to a car chassis?
     
  37. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Hello
    When you create a truss from a mesh you usually need to add manually some extra links to make the truss stable.
    Of course, truss designing is not a trivial task. I'd suggest to practice on simpler models first, a cube for example. See Simple Truss demo scene from the package.
     
  38. Lesnikus

    Lesnikus

    Joined:
    Aug 29, 2015
    Posts:
    47
    I think it would be better if the author has added a "Red Car" demo in asset. I noticed that most people are interested in the use of "Truss Physics" for realistic car damage.

    Heartbroken, I ask you to add a demo car in "Truss Physics", please. It will be great!
     
    5T4RD35TR0Y3R likes this.
  39. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Yes adding red car would help. Could you at least place an screenshot of the nodes used for the red car as well as the link properties?

    edit: at least add the car scene for paid users
     
    Last edited: Sep 21, 2015
    Lesnikus and 5T4RD35TR0Y3R like this.
  40. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    +1 please add red car to demo scene. Thanks!
     
  41. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864






    I've created this truss for a single mesh car, hope it works.
     
  42. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Here my testing ressult, as catastroffic as previous.



    I'll send teh model to the dveloper as well as the truss mesh to see if he can tell em what is wrong here.
     
  43. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Not bad, keep trying! :)

    Try to make very simple truss for your car. Like 8 nodes, 24 links and 12 faces. Check if it's stable.
    Then add some nodes, links and faces. Check if it still works. If not add some links to fix it.
    You just need to get the idea and you'll be able to build anything :)
    https://en.wikipedia.org/wiki/Eiffel_Tower

    Cheers
     
  44. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Ok I will but the thing is that later I used the truss mesh for visual and trus mesh for deformation.

    The deformation itself looks correct but it behaves like a cloth! and the params are the same as the default of the simple truss cube. It is very weird.
     
  45. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Sure. 'Build From Mesh...' tool only create links from the mesh edges. That's only surface links. To make the truss stable you have to manually add internal links.
    Ok, send me your model I'll make a simple truss which will keep the shape. As an example.
     
  46. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Ok! thank you for your support!.
    This is what I was achieving


    I also thought of internal connections but the cube has only external links. Did a quick test with some internatl links and the shape does not collapse that much. I will send you my car so you han help me with a concept of trush for internal links as I'm not sure what is the best configuration. Also if you could send me an screenshot of you link structure for your car would help.
     
  47. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Ok, started to have som results!!

    A simple 10 node truss. At this moment it behaves in a bery elastic way, I'll try to modify to get a plastic behavior. Oh finally starting to see the light.

     
  48. TooManySugar

    TooManySugar

    Joined:
    Aug 2, 2015
    Posts:
    864
    Managed to get the plastic effect. The weird thing is that changing the node wight changes the rigidity of the material. This makes no sense to me, shoulnt the deformation be ruled by the params of the links?
     
  49. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Not rigidity but deformation. It does make sense. Imagine a spring with two weights on its ends. Doesn't the weights of 1 kg will deform the spring stronger than say 1 g?
     
  50. mensch-mueller

    mensch-mueller

    Joined:
    Nov 25, 2014
    Posts:
    156
    @TooManySugar
    I had the same issues with the car. In the beginning it was very wobbly. You had to stiffen it internally. I also used too many nodes. You only stiffened the hull. You had to insert a link, for example from left front top to right bottom of your car. and many others...

    @Heartbroken
    It would be nice, if we had the ability to create same basic truss, and then insert a nodes on a link(subdivide a link).
    And to set a node on a geometry with a raycast, so that it sits exactly on a model. It takes a lot of time to adjust the nodes.
    It would be good to have a tutorial on this kind of matter, how to set up nodes(how many and where), and how to link them(to get a desired behavior)

    Cheers Michael
     
    Last edited: Sep 23, 2015
    Slipangle likes this.