Search Unity

Assets Obi Particle Based Physics (Cloth, Rope, Fluid) thread

Discussion in 'Works In Progress' started by arkano22, Jun 30, 2015.

?

Performance vs compatibility

Poll closed Oct 9, 2015.
  1. I don't care about performance, keep my data intact please.

    0 vote(s)
    0.0%
  2. I don't care if I have to re-do some stuff, as long as it runs faster.

    14 vote(s)
    100.0%
  1. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    79
    I moved the resources to the Assets folder and have generated the topology and used 'initialize'. When I enter editing mode I can see all the red particles, just not the particle editor panel. Everything else seems to be working because I can manually select some particles and pin/unpin them. Just can't see any of the particle editing tools.
     
    tpenney likes this.
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    HI Paul,

    I can see the tools fine in 5.3.4, maybe it is a 5.4 thing? I´ll check it out and get back to you.

    Edit: now that I think of it...how are you pinning/unpinning particles without being able to see the editor menu? o_O This is how the menu looks, do you see anything like it at all?

     
    Last edited: May 22, 2016
  3. AiryKai

    AiryKai

    Joined:
    Apr 16, 2014
    Posts:
    52
    Ok, I started using the Obi and... It doesn't work for me. Every time when I try to click Edit Particles, I get errors:

    Unable to find required resource at 'Editor Default Resources/EditorParticle.mat'
    UnityEditor.EditorGUIUtility:LoadRequired(String)
    Obi.ObiParticleActorEditor:CreateParticleMaterial() (at Assets/Obi/Editor/ObiParticleActorEditor.cs:162)
    Obi.ObiParticleActorEditor:OnSceneGUI() (at Assets/Obi/Editor/ObiParticleActorEditor.cs:171)
    UnityEditor.DockArea:OnGUI()

    NullReferenceException: Object reference not set to an instance of an object
    Obi.ObiParticleActorEditor.OnSceneGUI () (at Assets/Obi/Editor/ObiParticleActorEditor.cs:172)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.SceneView.CallOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2056)
    UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1405)
    UnityEditor.SceneView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1242)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    IndexOutOfRangeException: Array index is out of range.
    Obi.ObiParticleActorEditor.DrawGizmoForMyScript (Obi.ObiActor actor, GizmoType gizmoType) (at Assets/Obi/Editor/ObiParticleActorEditor.cs:808)
    UnityEditor.DockArea:OnGUI()

    RenderTexture warning: Destroying active render texture. Switching to main context.
     
  4. zappapa

    zappapa

    Joined:
    Dec 12, 2010
    Posts:
    57
    Did you ever create a tutorial for this^?
     
  5. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi AiryKai,

    You need to follow the installation instructions you´ll find both in the readme and the quickstart guide. Unity will be unable to find the required editor resources if you don´t.

    cheers!
     
  6. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi Zappapa,

    No, however fuse characters are no different from regular characters in regard to this. Set up is done in the same way as with regular (unanimated) cloth. You can take a look at the manual to see exactly how.

    cheers!
     
  7. AiryKai

    AiryKai

    Joined:
    Apr 16, 2014
    Posts:
    52
    Oh, thank you, I understand. It looks a bit strange and I didn't notice it. :)
     
    arkano22 likes this.
  8. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi everyone,

    I´m fully aware that Obi's documentation and manual have lots of room for improvement. Today I added a tutorial on character clothing to the manual, which is one of the most poorly documented areas. You´ll find it at the very end of the manual page. Here's a direct link:

    Character skirt

    The set up is almost identical to that of regular cloth due to the unified nature of Obi, but still it's nice to have a fully documented example. Hope this is helpful, Zappapa! :)

    Any suggestions and/or comments are more than welcome!
     
  9. VargaPD

    VargaPD

    Joined:
    Mar 6, 2015
    Posts:
    61
    Thank you, Nii-sama! (Sorry, Unity-chan always reminds me the Nissan joke :D ) So much changed since the last tutorial you did in this topic. It is really helpful. :)
     
    arkano22 likes this.
  10. AiryKai

    AiryKai

    Joined:
    Apr 16, 2014
    Posts:
    52
    What can generate this error?

    Invalid AABB a
    UnityEngine.GeometryUtility:TestPlanesAABB(Plane[], Bounds)
    Obi.ObiSolver:CheckVisibility() (at Assets/Obi/Scripts/Solver/ObiSolver.cs:607)
    Obi.ObiSolver:EndFrame(Single) (at Assets/Obi/Scripts/Solver/ObiSolver.cs:538)
    Obi.ObiSolver:LateUpdate() (at Assets/Obi/Scripts/Solver/ObiSolver.cs:650)
     
  11. 6789077

    6789077

    Joined:
    May 27, 2014
    Posts:
    4
    Thanks for this. Helpful
     
    arkano22 likes this.
  12. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    This is an error in a Unity function which is used to test whether some bounds are visible to the camera. The error happens when the bounds are extremely big or NaN, which I would assume is caused by extreme particle velocities.

    It's hard to say without more information on your scene setup or what you were doing when this happened, though.
     
  13. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    I remember someone in this forum asked if Obi could be used to make dynamic vegetation and I said yes. However I did not provide any guidelines on how to do it, so here's another example in the manual:

    Dynamic Vegetation

    Again the setup is done in the same way as with any cloth, so the example focuses more on how to organize the actors and the solver for performance, and some details about getting the simulation to look nice.

    cheers!
     
    Last edited: May 26, 2016
    ElectroMantis likes this.
  14. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    397
    Hi @arkano22 we bought your plugin yesterday and we're really impressed with what it can do, we have some feedback already and a couple of issues:

    It's a bit difficult to select the edges at the moment and also because there are so many subscripts it's difficult to copy the components from one to the next and it gets a bit chaotic there.

    Two shaders when doing a PC build have errors which we think is also causing a crash in our game:

    Code (CSharp):
    1.  
    2. Shader error in 'Hidden/NormalReconstructionShader': failed to open source file: 'ObiParticles.cginc' at line 27 (on d3d9)
    3.  
    4. Compiling Vertex program with DIRECTIONAL SHADOWS_OFF LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF
    5. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING
    6.  
    7.  
    8. Shader error in 'Obi/Particles': failed to open source file: 'ObiParticles.cginc' at line 120 (on d3d11_9x)
    9.  
    10. Compiling Vertex program with SHADOWS_DEPTH
    11. Platform defines: UNITY_NO_LINEAR_COLORSPACE UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF3
    The stack trace is:

    Code (CSharp):
    1. ========== OUTPUTING STACK TRACE ==================
    2.  
    3. 0x1E92059E (libOni) VertexOrientations
    4. 0x1E91EEF0 (libOni) CreateSolver
    5. 0x04F3E72E (Mono JIT Code) (wrapper managed-to-native) Oni:CreateSolver (int,int,int)
    6. 0x04F3E2C4 (Mono JIT Code) Obi.ObiSolver:Initialize ()
    7. 0x04F3E1D2 (Mono JIT Code) Obi.ObiSolver:Awake ()
    8. 0x04E8F541 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    9. 0x100F12E9 (mono) mono_set_defaults
    10. 0x1005D968 (mono) mono_runtime_invoke
    11. 0x00D8067E (Era) [c:\buildslave\unity\build\runtime\scripting\backend\mono\scriptingbackendapi_mono.cpp:446] scripting_method_invoke
    12. 0x00E05B49 (Era) [c:\buildslave\unity\build\runtime\scripting\backend\scriptinginvocation.cpp:191] ScriptingInvocation::Invoke
    13. 0x00D6FD9E (Era) [c:\buildslave\unity\build\runtime\scripting\backend\scriptinginvocation.h:50] ScriptingInvocation::Invoke
    14. 0x00E05CCC (Era) [c:\buildslave\unity\build\runtime\scripting\backend\scriptinginvocationnoargs.cpp:144] ScriptingInvocationNoArgs::InvokeChecked
    15. 0x00D70AA2 (Era) [c:\buildslave\unity\build\runtime\mono\monobehaviour.cpp:335] MonoBehaviour::CallMethodInactive
    16. 0x00D70CA9 (Era) [c:\buildslave\unity\build\runtime\mono\monobehaviour.cpp:1302] MonoBehaviour::CallAwake
    17. 0x00D73038 (Era) [c:\buildslave\unity\build\runtime\mono\monobehaviour.cpp:1405] MonoBehaviour::AddToManager
    18. 0x00D7113C (Era) [c:\buildslave\unity\build\runtime\mono\monobehaviour.cpp:1291] MonoBehaviour::AwakeFromLoad
    19. 0x00E1CE6B (Era) [c:\buildslave\unity\build\runtime\serialize\awakefromloadqueue.cpp:294] AwakeFromLoadQueue::InvokeAwakeFromLoad
    20. 0x00E1CF83 (Era) [c:\buildslave\unity\build\runtime\serialize\awakefromloadqueue.cpp:237] AwakeFromLoadQueue::AwakeFromLoad
    21. 0x00C6BCF8 (Era) [c:\buildslave\unity\build\runtime\gamecode\cloneobject.cpp:151] AwakeAndActivateClonedObjects
    22. 0x00C6C6A2 (Era) [c:\buildslave\unity\build\runtime\gamecode\cloneobject.cpp:302] InstantiateObject
    23. 0x00EA65BF (Era) [c:\buildslave\unity\build\artifacts\generated\common\runtime\unityengineobjectbindings.gen.cpp:35] Object_CUSTOM_INTERNAL_CALL_Internal_InstantiateSingle
     
  15. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi Nihil,

    Thanks for the feedback! Yes, there's a lot of components involved in making the cloth work so it's not easy to copy them one by one. But that's the price paid for having a modular solver i'm afraid, as it would be (another kind of) chaos having everything crammed up in a single component. I´ll think of a way to make it possible to copy/delete all components at once.

    Not sure what you mean about selecting the edges, do you mean the particles?

    About the errors, they're likely to be unrelated as a shader compilation error cannot cause a crash under any circumstances. The errors complain about not being able to open "ObiParticles.cginc". There could be a couple reasons for this:

    - The file is not present in the build. Double check it is right next to the shaders using it, and that Unity is including it in the build.

    - For some reason the file is not present at all in your project... I double checked that it is included in the package, so it should be there.

    About the crash, can you give me more info on it? what kind of error is it? (access violation?) does it happen only in the build or in the editor too?

    cheers!
     
  16. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    397
    Hey thanks for the quick reply!

    Yes selecting the particles, I meant the vertices yesterday not edges ( was late ). It makes it difficult to select on character cloth.

    Yes the file right next to the shader, I did try to include it in the list of shaders that always come with the build but because it's a cg shader, Unity isn't accepting it, I think it's more of an error as it says with DX9 on line 19 and 27 respectively.

    I did think so too that the crash is probably unrelated but it started happening after I added the plugin in the game. It only happens on a build, never in the editor and it happens when I'm loading one of the scenes of my game. I'll investigate more but the crash only gives the stack trace that I posted above.

    I also forgot to mention that in ObiFluidEventHandler.cs and in some other classes the Debug.LogException and Debug.DrawRay needed an #if UNITY_EDITOR setup to them as it wouldn't allow me to do any builds at all.

    Sorry for the many negatives, I really want to use your plugin :)


    EDIT: I can verify that once I removed the obi cloth from the character I had it on the crashes stopped. It's worth mentioning that the character's setup in an asset bundle ( including the solver ). I have a crash dump if you want me to include
     
    Last edited: May 28, 2016
  17. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    HI Nihil,

    I´ve started a conversation with you, so that we can track the issue down faster. check out your pm's!

    Also, there's no need to #if out Debug.Log and Debug.DrawRay calls in builds...as their purpose is precisely to provide logging and debug info in builds :).
     
  18. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,884
    Hello! This asset is massively impressive, good job! :cool:

    I wonder something, let's say I have very long curtain in my game, how do I set it up so the player can swashbuckle by grabbing and climbing it like in any good old epic movie?
     
  19. VargaPD

    VargaPD

    Joined:
    Mar 6, 2015
    Posts:
    61
    Maybe with Inverse Kinematics? Just wondering, never done a thing like this before.
     
  20. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,884
    I'm asking because so far it seems it works for thing interacting with each other passively (collision) put having something that is actually dynamically pin and drag/constrain from that pin (for example gravity) I'm sot sure. There was an answer where he said that you could pin and move the pin independently but specifically rules out (maybe in the context of that question only) interactions (ie joint). We have seen the system have physique interaction with pinned object, but I haven't seen them dynamically pinned (like swashbuckling the curtain). In fact if the tearing works with swashbuckling (ie jumping and using a knife on the curtain to slowly descend) that will be a cool demo to market the asset in a very spectacular fashion (better than uncharted!). :cool:
     
  21. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi Neoshaman,

    First a distinction must be made between "fixing" and "pinning" a particle in Obi. In that particular answer I think i was talking about fixing, which just freezes a particle in place. More specifically, in freezes it in the cloth's local transform space. So if you parent the cloth under a rigidbody, all fixed particles will blindly follow the rigid body movements, however the rigid body will not be aware of the cloth at all. No forces from the cloth will be transferred to the rigid body, so this is one-way interaction.

    Then, there's pin constraints. These are proper physical constraints, which strive to keep a particle in a certain position relative to a rigid body. Any forces applied to that particle, are also felt by the rigid body, and vice-versa. So this is proper two-way interaction, and the way to go in your particular use case.

    Certainly you can generate/delete pin constraints dynamically without much effort. Getting the guy to swing single-handedly from a curtain isn´t a big deal, however some other stuff (like climbing up/down the curtain, for instance) is more complex than it might seem at first, these are the first two issues that come to mind:

    - Determining what/where to pin particles: Your character hands would have to generate pins dynamically to the nearest cloth particles. If your cloth is dense enough, iterating trough all particles each frame to find the k-nearest ones might not be a fast enough solution. You cannot raycast a deforming mesh easily, either, so hand positioning would be quite difficult to get right too.

    - Animation/physics interaction: The character itself would need to have some sort of physical simulation applied to itself in order to look half decent. I´m thinking of rag doll-like physics.

    This said, I haven´t tried to do anything similar to this with Obi. Might find a better way to do it once I actually get my hands dirty. Once I have some spare time I will and report back results.
     
    Last edited: May 31, 2016
  22. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,884
    That sound cools, to climb, maybe we can cache some point with an ordered list at regular interval to be use as grab point, we won't have to grab every point for it to works so it reduce searching.

    Obviously the character should be another system, Maybe with the help of FinalIK and puppetMaster. But the possibility as to be there, and it seems it is :D

    I don't know how the "tears" system works, but a dramatic and gameplay compliant one need some form of control that would allow to tell when to tear and when not (for example in order to introduce a feeback system to say when it will break). I supposed we can break bond at will during runtime too (to fake the knife descent)?

    Thanks that's a great asset anyway! Good job!
     
  23. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    The tearing system currently works by tension. You can specify a tension threshold for each edge, so if it is surpassed, the edge will split one of the particles at its ends in two. It will generally pick whichever has the highest mass of the two. The cloth component exposes a single "Tear threshold" property in the inspector which affects all edges at once, for convenience.

    You can also just call Tear(edgeIndex) and it will tear whichever edge you tell it to. You can figure out which edges start/end in a particular vertex by using the included half-edge data structure, but that requires some knowledge about this particular data structure and mesh topology in general.
     
  24. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,884
    Ha! Great! I want to code a convex hull (valve's quickhull 3D) for a creature generator and I must learn half egdes, could not be more fitting lol SOLD
     
  25. AiryKai

    AiryKai

    Joined:
    Apr 16, 2014
    Posts:
    52
    One more question... How can I turn off the simulation and delete the object from ObiSolver using scripts?
    And enable it back when necessary?
     
  26. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    To turn off/on the simulation, simply disable/enable the ObiSolver component in the standard Unity way of doing things :):

    Code (CSharp):
    1. object.GetComponent<ObiSolver>().enabled = false; //or true to re-enable
    The simulation will freeze on disable and continue where it left after you re-enable the solver.

    Removing an actor from the solver is also quite simple:

    Code (CSharp):
    1.  
    2. // remove the actor from its current solver:
    3. actor.GetComponent<ObiCloth>().RemoveFromSolver(null);
    4.  
    5. // you can change the actor's solver in here, for example:
    6. actor.solver = anotherSolver;
    7.  
    8. // add the actor to the new solver:
    9. actor.GetComponent<ObiCloth>().AddToSolver(null);
     
  27. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi everyone,

    Just a couple news here:

    - ObiRope 1.0 is now under review and should be available in a few days. Some of you who have helped me with Obi in the past will receive a voucher in exchange for the feedback/help, so expect random surprises :).

    - The next version of ObiCloth will support proper MeshColliders, both concave and convex. DistanceFieldColliders from 1.x and their awkward setup will be no longer needed, so they won´t make a return. (disclaimer: everything that applies to Unity's MeshColliders applies here too, so use sparingly)

    - In about a month and a half I will be getting some more help with Obi, so this will no longer be a one-man enterprise. Expect better documentation and support.

    cheers!
     
    Last edited: Jun 3, 2016
    chiapet1021 and hopeful like this.
  28. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    A sneak peek of MeshColliders. The dragon seen here has 65535 vertices (which is the maximum allowed by Unity for a single mesh) and about 100.000 triangles. All mesh triangles and all cloth particles are considered for collision -not using brute force of course-. There's no decimated version of the mesh used for collisions or anything. All of this runs at 70 fps in a two-core CPU, no GPU involved at all. Also, cloth pieces have aerodynamics, self-collision and intercollisions activated.

    At the end of the video you can see the particle-based representation of the cloth, rendered using spherical impostors with the new ObiParticleRenderer component.



    This stuff also works for the upcoming Obi physics (fluids, ropes, etc), so everyone benefits from it. (Aaaand the blood explosion at the end of the next video is why ObiFluid isn´t out yet. :D)

     
    Last edited: Jun 4, 2016
    hopeful likes this.
  29. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,884
    Will there be a collision engine that you can put as an asset too? I wish for a collision engine without the physics since I'm using unity. Only having simple slide like collision as sugar.
     
  30. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi neoshaman,

    A collision engine doesn´t make much sense without physics, or your objects won´t be able to react to the collisions at all. If you want a sliding reaction, just use PhysicMaterials and set the bounciness (restitution) factor to zero, and the friction to whatever you want (also zero for perfect sliding).

    Take a look here:
    http://docs.unity3d.com/Manual/class-PhysicMaterial.html

    Obi's collision engine is specialized for particles (perfectly round little spheres) and would´t work for arbitrary shapes.
     
  31. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,025
    Looking forward to Obi Fluids. :)
     
    arkano22 likes this.
  32. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,884
    Haha, I know what you mean I used some shortcut, I used to make game in blitzbasic and there wasn't that "pesky physics" to constantly try to neutralize.

    It does make sense in the way I just want collider to stop each other from penetration automatically rather than bouncing and other "energy" stuff that makes everything explode for no good reason. In game physics are often very unrealistic, I want to be able to just listen for collisions, not have penetration, and write custom code to respond to it. Have you ever had to used the character collider? It's a monstrosity! kinetic don't register collision and rigid body just kill your performance (it's trying to apply physics where I want none).

    When I started moving from blitz3D to unity3D (directx7 is n more supported and bug :( there was no real shader support anyway) Physics was my darnedest grips :mad: It hog resource for no good reason and it was impossible to have sensible gameplay at all. I cope with it by NOT making the (frame perfect) game I wanted (on top of the input latency unity have).

    NO 3D sonic clone on unity for me :( nor tony hawk skateboarder clone, those curve need mesh collision and I need a spherical collider at best that register multiple collision. Stuff Blitz3D use to eat each morning for breakfast. I'm so sad, I haven't found a replacement yet. Some people do make game like that but their control are so sloppy I would rather don't bother.

    The way OBI's physics interested me is that you have sphere on arbitrary mesh, that's my use case!

    It's a problem I have with all modern game engine anyway. I don't have (yet) the skills to bypass those stuff.
     
  33. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Yes, I know what you mean. Well, I have written a few collision/physics engines of my own in the past for very specific use cases in very limited hardware (an old-school 2D platformer, a 3D simulation of a snow globe, and some others) but except the obvious performance gap, I´ve yet to come with something that cannot be done with a regular physics engine.

    If you do not want collisions to "apply forces" so to speak, just freeze rotations of your rigid bodies (so that torques aren´t applied) and set friction and restitution to zero. voilá! no collision response at all (no rotation, no friction, no bouncing).

    Edit: Obi does sphere on arbitrary mesh, but also does Unity... the only reason I re-did it all is because Obi only uses lots of particles (which lack orientation, are only a position) and I can take advantage of that for performance. But for a regular game, you can just use spherical colliders and mesh colliders.
     
    Last edited: Jun 4, 2016
  34. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,884
    On another tangential note, Do you plan to have a "fur" asset? I don't mean per "hair strand simulation" but more like old school "scale" like fur. Basically "grass" but for character and animal.
    Something like that
     
  35. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Nope, not at the moment.
     
  36. adamz

    adamz

    Joined:
    Jul 18, 2007
    Posts:
    957
    I saw your Mesh Colliders video... can this also work with skinned meshes? It looks great! If so, do you know if it'll work with UCC?
     
    Last edited: Jun 4, 2016
  37. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi adam!

    Thanks! Nope, MeshColliders do not work with skinned meshes. They're meant for level geometry (concave/convex) or rigidbodies (convex).

    Deformable vs deformable mesh collision detection is extremely expensive and not very useful, actually. Character clothing is never done that way, skin constraints and primitive colliders are used instead (both already supported by Obi).

    cheers!
     
  38. _Amael_

    _Amael_

    Joined:
    Aug 20, 2012
    Posts:
    19
    Congratulations on a brilliant asset, everything that I've seen and read about Obi Cloth looks very impressive!

    I was wondering if it's possible to:

    1) Convert a mesh to an ObiCloth object at runtime and add it to a simulation
    2) Add or remove cloth particles (mesh vertices) from an ObiCloth object at runtime via scripting?
    3) Add or remove mesh vertices from a high-res mesh that's being controlled by an ObiClothProxy?
    4) Set the positions of cloth particles for an ObiCloth object at runtime? (to snap the cloth to a shape and resume simulation from that shape)

    Many thanks!
     
  39. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi Amael, and thanks for your kind words!

    1) Possible, though potentially slow if the mesh is dense. However the process is a Coroutine (you can check the editor scripts to see how to invoke it) so you could yield it until it's done to avoid a hiccup in the game.

    2) Yes, doable, but you need good knowledge of Obi's internals (it is easier to activate/deactivate existing particles). Check the Tear() method in ObiCloth to see how it's done. Basically you allocate new particles from the solver, and then resize the actor arrays to hold the new data.

    3) Nope, nothing stops you from modifying ObiClothProxy to add this functionality, but it doesn´t come in the box.

    4) Yes, totally doable. Once 2.2 is out (currently under review) check how the new ObiParticleHandle component does it. Basically you call Oni.SetParticlePositions() during OnFixedParticlesUpdated().

    If you need help with any of this, just ask.

    cheers!
     
  40. supneo

    supneo

    Joined:
    Jul 29, 2012
    Posts:
    23
    Hi @arkano22 i have problems to load obi in my project:

    1.- Include the Obi package in your project. Right click in the project window, “Import Package” → “Custom Package”, then select Obi.unitypackage.
    2.- Move the “Obi/Editor Default Resources” and “Obi/Gizmos” folders to the Assets folder in your project.
    4.- Generate an Obi Mesh Topology asset for the mesh you want to simulate. Right click on your assets folder, Create->Obi->Obi Mesh Topology. In the inspector, assign the desired mesh to the “Input” property and click “Generate”.
    5.- Go to GameObject->3D object->Obi->Obi Cloth (with solver). This will create an Obi Cloth object and a solver, properly set up. Add a MeshRenderer and MeshFilter (or a Skinned Mesh Renderer) to the Obi Cloth object, with the mesh and/or materials you wish to use. Select the Obi Cloth object and assign the Obi Mesh Topology asset you just created to its “Shared Topology” property.
    6.- In the Obi Cloth inspector, click on “Initialize”. You're done!

    And nothing , no obi for create objects , obi no load and no errors in console , in a new project obi works but in my project not load , :-(
     
  41. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi supneo,

    It's very difficult to tell what's going wrong with so little information, those steps are just the quickstart guide instructions copy-pasted but they provide no clue on what you're actually doing. Let's try to diagnose it:

    -Are you able to enter particle edition mode?
    -Can you see the particle edition menu?
    -Does the indicator next to the "Initialize" button read "Initialized"?
    -Which kind of mesh are you using? Is it a skinned mesh or a regular one? Can you see it in the scene view?

    cheers,
     
  42. supneo

    supneo

    Joined:
    Jul 29, 2012
    Posts:
    23
    no nothing menus and particle edition mode , does not leave the tab obi , the strange thing is that does not fail and a new project this if it works properly.
     
  43. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi supneo,
    Check out your personal messages, we'll figure out your problem there to avoid flooding the forum. thanks!
     
  44. _Amael_

    _Amael_

    Joined:
    Aug 20, 2012
    Posts:
    19
    Thanks for the reply and all the info, that all sounds great. One last question: is it possible to modify ObiMeshTopology objects at runtime via scripting?

    What I'm trying to achieve is cutting or tearing of a very simple mesh along an arbitrary line (i.e. not along an existing edge line on the mesh) at runtime. I can generate the cutting line on the mesh by splitting edges to add new vertices & triangles, but I'd need to update the cloth topology with the mesh changes. Ideally I'd like to avoid completely regenerating all of the topology and just modify part of the topology data/object with the new mesh data, but I understand this may not be possible (or would take a lot of modification work from me).

    Thanks again!
     
  45. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi Amael,

    That's also possible to do, but requires very solid knowledge of mesh topology handling (and of course linear algebra). The ObiMeshTopology is basically a half-edge data structure, which is a quite standard way of approaching this problem. Lists of faces, halfedges and vertices are provided, and you can modify them as you see fit.

    The basic structure is generated using C++ inside the plugin, then handed over to the C# side for further modifications. The standard Tear() method modifies this structure to generate a new vertex, add two new edges and modify two existing edges whenever a cloth vertex tears, but can only do so at an existing vertex position. It does not re-generate the whole structure each frame as that would be too slow. You can take a look at this method to see how it updates the structure, and extend it to generate new edges and vertices at any position. For reference, this is the paper implemented by Obi:

    Fast Simulation of Cloth Tearing - seer ufrgs

    cheers!
     
    Last edited: Jun 8, 2016
  46. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    685
    Obi rope is here! https://www.assetstore.unity3d.com/en/#!/content/55579 Looks super cool, can't wait to try it out!

    Do you have any video of those pulleys in action?

    Also, is there any timeline for when mesh collider support will be added? I see this has made its way back into obi cloth, but I'm not seeing it listed in supported collision types for Obi rope?
     
    Last edited: Jun 14, 2016
  47. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi Macdude!

    MeshColliders wil be added to ObiRope in about a week (plus Asset Store reviewing time). I´m also working on a new constraint type for ObiRope that will also make its debut at the same time.

    No pulley videos yet, but I will make a promotional video soon and pulleys will be there!

    cheers,
     
  48. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Just to let you guys know,

    In about 15 days, I will be out on a journey for about a month. As some of you know, I´ve been living in New Zealand for a year and I´m about to return to my home country (Spain) visiting some other places on my way back. During this time support and updates will be slower than usual, please bear with me. After this break, things will be back on track with more energy than ever.

    Thanks everyone for the great support, I really appreciate it.
     
  49. ElectroMantis

    ElectroMantis

    Joined:
    Sep 15, 2013
    Posts:
    78
    Been following this for a while, and just saw your rope asset on the store. Do you have a dedicated topic open for that asset yet?

    I've been trying to use a rigidbody based rope system for my game, but it doesn't do well under tension. I thought your new system looked very interesting. Looking forward to seeing the pulley demo.
     
  50. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    649
    Hi SecondBake,

    Nope, I haven´t started a rope-only thread yet but I will soon. Anyway, "tension" is always problematic for an iterative solver. Hanging a very heavy object from a very light rope is comparable to putting a very heavy rigid body on top of a very light one (try it in Unity to see what happens...). Obi fixes this by brute force: since each iteration is much cheaper than that of Unity's physics, it can get away with, say, 100 parallel stretch iterations at +60fps while keeping the rope under relative tension.

    I´ve managed to hang a 50 kg object from a 5kg rope this way, see attached video. However if you´re doing a pulleys-based game or something similar, you should use a different method for the stiff parts of your rope that can cope with very high tensions.



    Non-iterative or at least, less iterative (fully implicit) general solvers are quite uncommon in games, because they tend to be expensive even for simple simulations, and they come with their own set of problems.

    Using single-constraint ropes (ala Worms, if you've ever played it) that cannot bend under gravity is a way to accomplish tension-resistant ropes, as it greatly reduces the amount of iterations needed for zero-stretch. It all depends if this is suitable for your particular use case.

    Edit: These guys (https://www.cs.ubc.ca/sites/cs/files/research/papers/2011/05/strands2preprint.pdf) use a hybrid eulerian-lagrangian approach for ropes which seems quite robust. However setting up the system of constraints seems far from trivial, specially when done 100% dynamically. This is in my "investigate this" pile of papers, and I might implement something similar in the future. Cannot promise anything though.
     
    Last edited: Jun 16, 2016
    macdude2 and ElectroMantis like this.
unityunity