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
    I meant something different.
    For rigid body, the mass of Unity Rigidbody should be 15, not Truss Rigid Body Mass Scale.
    For soft body, select all nodes in Truss Designer and set total mass to 5. As you can see, current mass for your tire is 630. Set Mass Scale back to 1.
     
  2. tomsseisums

    tomsseisums

    Joined:
    Oct 8, 2012
    Posts:
    23
    Ah, I see now, got a little confused with all the mass properties.

    Now I set them correctly, had to change the filling/pressure properties.
    Played around with it a little more, but I still cannot get them to stick perfectly together.

    And then I have some trouble controlling pressure. I can either overinflate, therefore lose the shape, or underinflate when it becomes gooey. Or is it so, so, so, precise?

    The best result is when I overinflate the tire, though, the rim is still sticking out:


    And obviously, overinflation results in massively distorted shape which makes it totally unstable.
     
  3. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Try to turn on the Unity Rigidbody interpolation.

    There's a lot of things you can try. Make tire links more stiff, add internal links, add more links on the surface (each quad should have two diagonal links). Experiment.
     
  4. tomsseisums

    tomsseisums

    Joined:
    Oct 8, 2012
    Posts:
    23
    Yeah, Interpolation fixed the dance. Hmm... why so? Due to there being no way to run in actual sync with PhysX?
    Maybe there's a way to get around the Interpolation fix?

    And yeah, will go on and try to increase links and work with stiffness.

    Could you maybe emphasize a little by describing each of link properties...
    Currently I can only deduce what the Spring Stiffness [how stiff the link is in relation to neighboring links?], Spring Dampening [strength applied to keep it in shape?], Elastic Deformation [not actually sure] and Stretching Limit [how much can the length of the link increase by?] does, maybe you could shed some greater light upon it?
     
  5. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    No, Truss Physics is in sync with PhysX. The difference is that Truss Physics always does the interpolation and there's no way to turn it off. So when a soft body is attached to a non-interpolated rigid body they can look separated. That's a visual bug. It happens because the bodies are rendered in different time frames. Slow down the time and you'll see what's happening.

    Stiffness and Damping coefficients are the parameters of harmonic oscillations equation.
    Elastic Deformation limit is the maximum deformation which can restore. If the deformation (either stretching or compressing) is bigger it becomes plastic and do not restore. The value is absolute, in meters.
    Stretching Limit is the maximum allowed plastic stretching. The value is relative. For example, if a link of length L with small Elastic Deformation and Stretching Limit of 2 was stretched to 3L and then released, it will restore to 2L and stay like that.
     
    Fibonaccov likes this.
  6. tomsseisums

    tomsseisums

    Joined:
    Oct 8, 2012
    Posts:
    23
    Nice! Now that's some info!

    It seems that changes to rigidbody inertia tensor and center of mass are ignored if Truss is used? I also attempted to use the available TxNative.RigidSetMass() and apply changes that way, but got no result..
     
  7. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    TxNative.RigidSetMass() should work. Did you find the rigidID to pass there?
     
  8. tomsseisums

    tomsseisums

    Joined:
    Oct 8, 2012
    Posts:
    23
    I quick-fixed by directly adding the method to TxRigidBody... heh:
    Code (CSharp):
    1. public void UpdateMass()
    2. {
    3.     Rigidbody rb = m_rigidBody;
    4.     TxNative.RigidSetMass(m_rigidID, rb.mass * m_massScale, rb.centerOfMass, rb.inertiaTensor * m_massScale, rb.inertiaTensorRotation);
    5. }
    So, in my own code, I set the center of mass on my own RigidBody and afterwards call this method on corresponding rigid.

    Though, I am doing this in run time.... if that changes anything.

    UPDATE: Hmm... wait a sec. Something is working all of a sudden, don't know what I changed. Right after writing the original post.
     
    Fibonaccov likes this.
  9. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Looks correct. Should work.
     
  10. tomsseisums

    tomsseisums

    Joined:
    Oct 8, 2012
    Posts:
    23
    Daamn!

    Thanks for the help!

    P.S. Yes, the RigidSetMass works, don't know what I had messed up there the first time.

    I did make some great progress, but it appears that Truss need loads of tweaking and fine-tuning to get natural results. Was thinking I will tune stuff for my needs fast, but heh, timeconsuming. :) Will give it a shot later on!

    Wouldn't mind that RedCar demo to see how the tire has been set up. I actually would be good with a scene with just the tire, lol. At least the relations for links, the stiffness/damping/elasticity, placement etc. I end up having e18 values in stiffness but the mesh is still acting "weak". Added extra internal links... had improvement, but nothing much. Messed around with adiabatic and internal pressure - yeah, I can get some results, but nothing predictable/controlled.

    Have been tweaking since my last post that one rim+tire combo but I am giving up for now. :D

    Anyways... one last question...group.

    Is it correct that nodes should match the vertices of the mesh, because the mesh is being updated based on nodes? And if so, why there is the option to create new nodes? If not, then how does Truss translate vertices of the mesh?
     
  11. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Decrease the simulation step. The stiffness value like e18 doesn't make much sense if your simulation step isn't like e-9.
    As long as your simulation step is e-3 the max stiffness you can get is e6.
    https://en.wikipedia.org/wiki/Harmonic_oscillator
    https://en.wikipedia.org/wiki/Nyquist-Shannon_sampling_theorem

    The demos in the package were supposed to answer the rest of your questions.
     
  12. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    487
    Hello, i just started using Truss physics for one of my prject and it would be nice to only see links from front surface and keep others hidden for an easiest setup of the collider.
     
  13. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    487
    hello,

    it's sometimes hard to understand how truss physics is behaving with the geometry, especially in this case:
    truss problem.jpg
    if someone know how to help me
     
  14. AbyssWanderer

    AbyssWanderer

    Joined:
    Mar 15, 2016
    Posts:
    77
    Hello, guys.

    First of all, I wasn't so impressed since... I don't remember when I was so impressed with technology in Unity. Obi Cloth simulations comes to mind, but Truss goes far beyond.
    I am really happy about the purchase, only looking on demo-scenes impresses me already - not talking about RedCar demo.

    One thing I would ask/suggest - make 10-20 minutes video tutorial. This doesn't have to be masterpiece lesson, just ordinary talking in bad microphone with bad pronounsiation =) Any quality tutorial would be already great. Cause let's face it: documentation is almost non-existent.
    Maybe AndersOrum has some time and mood to create video, as a user that also was new to this asset and now explored it over a year?

    Don't get me wrong, I know this asset won't work out of the box, and I'm ready to research it. But just 10-minutes video would already help a lot, and creation of such video would also take 10-15 minutes.
    I really want more users to purchase this miraacleous asset, but the entrance barrier is veeery steep.
     
    blackant and crudeMe like this.
  15. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    487
    finally got it to work like i want it to be (more or less)
     
    Last edited: Dec 16, 2016
    TooManySugar and Shadow-X6 like this.
  16. Black_Racer

    Black_Racer

    Joined:
    Dec 21, 2016
    Posts:
    2
    Hello, guys!
    Hearbroken This Truss Physics is a great work!
    Please help me, i must repeat similar Red Car Demo for the student's work, I wrote the code for the car but can give realistic parameters for the body and the wheels are configured How TxTruss body and wheel Asset? As far as I see they use through a bunch TxConstraints edge and tench body has suspension simulation parameters. TxSceneSetting I also correct parameters are not known, for Wheels I use Substep Power = 5, but it leads to a strong freeze for car body. For me it is very important to help with this ...
     
  17. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    430
    I understand how the truss physics work..... but how do we move nodes at runtime? IE; Steer an axle? Is there an equivalent to a "hydro" from beamNG? Im messing with making a simple rolling red wagon cart for testing and how would I move the nodes or edges to steer the Front hubs? Are we supposed to use the axle torque with mechanical stops?

    Or am I missing something obvious?

    Thanks for any help. :)
     
  18. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    You can change the actual length of a link by modifying its plastic deformation value.
     
  19. devotid

    devotid

    Joined:
    Nov 14, 2011
    Posts:
    430
    So what is the proper way to find a specific named link in code and then change its position? (ie: plastic deformation value). I cant seem to find anything on "setting" any values in the docs.... I only see read only stuff like NumberOfNodes or NumberOfFaces etc.

    Whats a simple way of adjusting the length of a link named "Movable_Link1" in a truss called "TX_SteeringLink_Truss".

    Ive put a couple straight weeks into getting this far and will def be purchasing this asset. Thanks for all that you have done. Its amazing.
     
  20. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Code (CSharp):
    1. int linkIndex = softBody.truss.FindLinkSet("Movable_Link1")[0];
    2. softBody.linkPlastic[linkIndex] = 0.1f; // Make the link 0.1 meter longer
     
    Fibonaccov, satolas and devotid like this.
  21. wiljameson9

    wiljameson9

    Joined:
    Jan 3, 2017
    Posts:
    2
    Has anyone been able to use this with a skinned character mesh? I have it going somewhat, but the character mesh does not follow the deformations of the truss mesh (though it does have some effect). I've tried messing with the skinning envelope, but I don't think that's the problem.
     
  22. wiljameson9

    wiljameson9

    Joined:
    Jan 3, 2017
    Posts:
    2
    OK I think I'm on the right track for the skinned mesh stuff. Both the skinned mesh renderer and the truss soft body want to deform the mesh. I hacked up a test that syncs the character's SkinnedMeshRenderer.sharedMesh with a separate MeshFilter that the soft body operates on, and it mostly sorta works. The results are a little wonky, though, since the soft body is operating on the entire mesh and I only have trusses for a small section. Maybe I can use vertex colors or something to build a submesh for the soft body, then copy that result back into the SMR?
     
  23. TristanCS

    TristanCS

    Joined:
    Sep 30, 2016
    Posts:
    5
    Importing the package into an empty project works fine, but importing into my current project has all the truss assets frozen in place when clicking play. There's no errors in the console and I'm struggling to imagine what would cause this.

    This is using the evaluation package from the website and Unity 5.4.0f3. Has anyone else had this problem?
     
  24. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Do I understand correctly, you import the package into your project, run a demo from the package and it doesn't work?
     
  25. TristanCS

    TristanCS

    Joined:
    Sep 30, 2016
    Posts:
    5
    Yes, precisely.
     
  26. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Interesting. And if you remove everything except truss physics?
     
  27. TristanCS

    TristanCS

    Joined:
    Sep 30, 2016
    Posts:
    5
    The project is 40GB currently, so this isn't terribly easy to test for. I'll get back to you when it's done. It's a coal mining simulation being developed in Australia. I'm hoping to be able to use this system for light and heavy vehicle "interaction".
     
  28. TristanCS

    TristanCS

    Joined:
    Sep 30, 2016
    Posts:
    5
    I've deleted everything in the project bar truss physics and its plugins and it's still frozen. Any useful logs I should look for? I'll also try making a build of this.
     
  29. TristanCS

    TristanCS

    Joined:
    Sep 30, 2016
    Posts:
    5
    A build was still frozen. I tried re-importing via the project window and it was still frozen, then I deleted the library folder and forced it to re-import everything and it began to work. To do that with the entire project I'd need to wait overnight, so we'll see in the morning.

    Edit: This is now working, horay!
     
    Last edited: Feb 9, 2017
  30. maf90

    maf90

    Joined:
    Jan 31, 2017
    Posts:
    1
    Hi Heartbroken,
    I have 2 question .
    1. how can I constraint 2 rigid body together ?
    2 . how can I use a truss with just 2 point and one link that 2 point connecting together ? (when I setup a truss like this it just crash unity)
    Thank you :)
     
  31. satolas

    satolas

    Joined:
    Feb 13, 2017
    Posts:
    21
    Hello Everyone :)
    First of all, thanks for Heartbroken for that amazing Physic engine.

    As an Architect making research in structures and especially Truss structures I'm really happy to see this kind of Asset for Unity in the Store !

    To start, I will for sure try it with some Truss structures and real time deformations and share the results.
    And I thought I could try to make a little car also, because is a nice context to design debug tools and try the truss physics in real time by playing.

    @Heartbroken and @AndersOrum And of course all the others :)
    Maybe I'll ask some question in this research it is here the write place to do so ?

    Question :
    Apart from the TrussPhysics engine, do you used the unity built-in vehicle controller or another one ? like easy suspension, realistic car controller... ? I thing it could be interesting for people here to know the possibility to combine truss Physics with others assets.

    Best regards !
    satolas
     
  32. stalker_23b

    stalker_23b

    Joined:
    Jul 28, 2011
    Posts:
    87
    Hello,
    i cant open any link of truss physics on bitbucket, and can't find trial version. Where i can get it? I really want to evaluate and buy the package!
     
  33. westwoodsk

    westwoodsk

    Joined:
    Mar 8, 2017
    Posts:
    3
    @Heartbroken is there any tutorial 4 Truss Physics or only who purchased the plugin can access to it?
     
  34. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Sure, the package has a set of sample scenes, one can call them a tutorial.
     
  35. Shadow-X6

    Shadow-X6

    Joined:
    Apr 29, 2016
    Posts:
    99
    Hi
    I have TrussPhysics And I create Car Simulator but i need help with TrussPhysics :)
    Thanx
     
  36. westwoodsk

    westwoodsk

    Joined:
    Mar 8, 2017
    Posts:
    3
    @Heartbroken dude, we've just purchased your tool and could you help us on couple issues, first can you give us detail tutorial for how to recreate the vehicle in your demo scene that you display on youtube ? Second, if you can't spare on time on tutorial, can you be kindly share the vehicle that you displayed in your demo scene to us?
     
  37. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Hi westwoodsk. Could you PM me your invoce #?
     
  38. crudeMe

    crudeMe

    Joined:
    Jul 8, 2015
    Posts:
    89
    Can you actually provide car demo scene with invoice number?
     
    chiny1 likes this.
  39. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    PM
     
  40. westwoodsk

    westwoodsk

    Joined:
    Mar 8, 2017
    Posts:
    3
    just send you in conversation and marked in red color of invoice number.
     
  41. Shadow-X6

    Shadow-X6

    Joined:
    Apr 29, 2016
    Posts:
    99
    You can do make tutorial vehicle with TrussPhysics ? :)
     
    StephenL likes this.
  42. thaerxmx

    thaerxmx

    Joined:
    Oct 23, 2015
    Posts:
    1
    can you make video tutorial vehicle with TrussPhysics or any basics video tutorial ? :mad:
     
    StephenL likes this.
  43. satolas

    satolas

    Joined:
    Feb 13, 2017
    Posts:
    21
    Hello everyone,

    You can find out how the physics are made for the car exemple with the demo scenes of the Truss Physics package, more precisely the pressure (wheels) the constraints (parts) the simple truss (frame).

    The car is basically a soft body with constraints that attach the wheels/doors/hood/trunk to the nodes of the car Truss.
    Like always with Unity, try out with some very basic exemples first :
    - A cube (like the one in the simple truss demos scene) and add wheels to it.
    - For the wheels, you have to design a Truss that allow deformation, I found this images that could help.



    The idea is to get things moving step by step from a very simple system to a more complicated one.

    - Very important is the Truss design (The shape of the Truss will determine how your mesh will be affected by the environnement)
    and
    - The Nodes, since you can select a node and affect a "name Set" to it that will be found by the script it will be usefull to attach wheels or determine the central axis of it for exemple.

    Alsoe important I wish; The Create Truss from Mesh has to be understood as a way to design a Truss that will affect a Mesh, but not as a way to create the truss from the mesh you will put ingame.
    In other words, the mesh that you see ingame, will be often more complicated (more faces/polygons) than the Trussphysics Truss that you create and that will deform it.
    For exemple in 3dsmax : one mesh will be the mesh with textures/materials ingame, the other one will be the Truss design (proxy), kind of bounding box with some details, but not has much has the ingame mesh.

    Maybe all this seams very simple, but I thought it could be nice to give some keys that I learned using that wonderfull engine so far :)

    see you soon and thanks again to Heartbroken for that amazing engine !
     
    Last edited: Apr 9, 2017
  44. Shadow-X6

    Shadow-X6

    Joined:
    Apr 29, 2016
    Posts:
    99
    So, just connect the nodes on the car and do not mind that I have a script attached CarController ? :)
     
  45. monkeykane

    monkeykane

    Joined:
    Apr 22, 2017
    Posts:
    2
    Hi @Heartbroken

    So great physics softbody plugins!

    I would like to know that could be created "tx truss physics asset" in runtime? For example, we 'd like to slice softbody in runtime, and render meshes has been sliced yet, but how to slice" tx truss asset" for each seperated render meshes in runtime?

    Thanks a lot!

    wkwu
     
  46. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    Hi

    Here's a script which creates a truss asset in run-time:
    Code (CSharp):
    1. using System;
    2. using System.Reflection;
    3. using UnityEngine;
    4.  
    5. [RequireComponent(typeof(TxSoftBody))]
    6. public class TetrahedralTruss : MonoBehaviour
    7. {
    8.     void OnEnable()
    9.     {
    10.         // Build tetrahedron truss
    11.  
    12.         m_truss = TxTruss.CreateInstance<TxTruss>();
    13.  
    14.         m_truss.nodePosition = new Vector3[4] { new Vector3(1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, -1), new Vector3(-1, 1, -1) };
    15.         float NODE_MASS = 1;
    16.         m_truss.nodeMass = new float[4] { NODE_MASS, NODE_MASS, NODE_MASS, NODE_MASS };
    17.  
    18.         m_truss.linkNodes = new int[12] { 0, 1, 2, 3, 0, 2, 0, 3, 1, 2, 1, 3 };
    19.         float LINK_LENGTH = 1.414213562373095f; // Sqrt(2)
    20.         m_truss.linkLength = new float[6] { LINK_LENGTH, LINK_LENGTH, LINK_LENGTH, LINK_LENGTH, LINK_LENGTH, LINK_LENGTH };
    21.         float LINK_STIFFNESS = 1e5f;
    22.         m_truss.linkStiffness = new float[6] { LINK_STIFFNESS, LINK_STIFFNESS, LINK_STIFFNESS, LINK_STIFFNESS, LINK_STIFFNESS, LINK_STIFFNESS };
    23.         float LINK_DAMPING = 1e3f;
    24.         m_truss.linkDamping = new float[6] { LINK_DAMPING, LINK_DAMPING, LINK_DAMPING, LINK_DAMPING, LINK_DAMPING, LINK_DAMPING };
    25.         float LINK_ELASTIC = 1e1f;
    26.         m_truss.linkElastic = new float[6] { LINK_ELASTIC, LINK_ELASTIC, LINK_ELASTIC, LINK_ELASTIC, LINK_ELASTIC, LINK_ELASTIC };
    27.         float LINK_BREAKING = 0; // Not used
    28.         m_truss.linkBreaking = new float[6] { LINK_BREAKING, LINK_BREAKING, LINK_BREAKING, LINK_BREAKING, LINK_BREAKING, LINK_BREAKING };
    29.         float LINK_STRETCHING = 1e0f;
    30.         m_truss.linkStretching = new float[6] { LINK_STRETCHING, LINK_STRETCHING, LINK_STRETCHING, LINK_STRETCHING, LINK_STRETCHING, LINK_STRETCHING };
    31.         int LINK_FLAGS = 3; // Not used
    32.         m_truss.linkFlags = new int[6] { LINK_FLAGS, LINK_FLAGS, LINK_FLAGS, LINK_FLAGS, LINK_FLAGS, LINK_FLAGS };
    33.  
    34.         m_truss.faceNodes = new int[12] { 0, 1, 2, 0, 3, 1, 0, 2, 3, 1, 3, 2 };
    35.         int FACE_FLAGS = 3; // Collision and skinning
    36.         m_truss.faceFlags = new int[4] { FACE_FLAGS, FACE_FLAGS, FACE_FLAGS, FACE_FLAGS };
    37.         int FACE_MATTER = 0;
    38.         m_truss.faceMatter = new int[4] { FACE_MATTER, FACE_MATTER, FACE_MATTER, FACE_MATTER };
    39.         float FACE_ENVELOPE = 0.1f;
    40.         m_truss.faceEnvelope = new float[4] { FACE_ENVELOPE, FACE_ENVELOPE, FACE_ENVELOPE, FACE_ENVELOPE };
    41.  
    42.         m_truss.hideFlags = HideFlags.DontSave;
    43.  
    44.         // Set to the soft body
    45.  
    46.         TxSoftBody softBody = GetComponent<TxSoftBody>();
    47.  
    48.         // Soft body is created in OnEnable message so need to disable it
    49.         // before setting a truss and then enable it back
    50.         softBody.enabled = false;
    51.         softBody.SetTruss(m_truss);
    52.         softBody.enabled = true;
    53.     }
    54.  
    55.     void OnDisable()
    56.     {
    57.         Destroy(m_truss);
    58.     }
    59.  
    60.     TxTruss m_truss;
    61. }
    62.  
    63. static class TxTrussExt
    64. {
    65.     // A hacky extension to set a private member
    66.     public static void SetTruss(this TxSoftBody _body, TxTruss _truss)
    67.     {
    68.         Type type = typeof(TxSoftBody);
    69.         FieldInfo field = type.GetField("m_truss", BindingFlags.NonPublic | BindingFlags.Instance);
    70.         field.SetValue(_body, _truss);
    71.     }
    72. }
    73.  
    Hope it helps.

    Cheers
     
    Fibonaccov likes this.
  47. monkeykane

    monkeykane

    Joined:
    Apr 22, 2017
    Posts:
    2
    Hi @Heartbroken got it and can word well! Thanks a lot!
    But, our meshes may be more complex than Tetrahedral, so truss asset could be created from complex mesh in runtime and withou any rendering spike?

    And an other question is truss mesh could be sliced with render mesh?
    Thanks

    wkwu
     
    Last edited: Apr 23, 2017
  48. Shadow-X6

    Shadow-X6

    Joined:
    Apr 29, 2016
    Posts:
    99
    HeartBroken
    You do make video for Tutorial TrussPhysics Vehicle ?
    Thanx :)
     
  49. samshosho

    samshosho

    Joined:
    Apr 12, 2010
    Posts:
    370
    EntryPointNotFoundException: TxShapeExists

    error in all scenes, running Unity 4.6
    any ideas ?

    EntryPointNotFoundException: TxShapeExists
    TxNative.ShapeExists (Int32 _shapeID) (at Assets/Truss Physics/Native/TxNative.cs:1135)
    TxSoftBody.DestroySoftBody () (at Assets/Truss Physics/Runtime/TxSoftBody.cs:322)
    TxSoftBody.Destroy () (at Assets/Truss Physics/Runtime/TxSoftBody.cs:165)
    TxComponent.OnDisable () (at Assets/Truss Physics/Runtime/TxComponent.cs:102)
     
  50. Heartbroken

    Heartbroken

    Joined:
    Nov 18, 2012
    Posts:
    132
    No ideas. It still works on my side. Did you try it on an empty project?
     
unityunity