Search Forums

(Advanced Search)

Latest Threads
Calculating and Reproduci...
Forum: Obi Fluid
Last Post: ZacharyP
1 hour ago
» Replies: 0
» Views: 5
Basic SDF implementation ...
Forum: Obi Cloth
Last Post: AdamZ101
12-11-2024, 03:01 PM
» Replies: 4
» Views: 137
The skinned renderer is u...
Forum: Obi Cloth
Last Post: josemendez
11-11-2024, 06:31 PM
» Replies: 1
» Views: 63
Garment explodes on Andro...
Forum: Obi Cloth
Last Post: josemendez
05-11-2024, 11:44 AM
» Replies: 3
» Views: 258
Foam Rendering suggestion...
Forum: Obi Fluid
Last Post: spikebor
05-11-2024, 10:11 AM
» Replies: 4
» Views: 462
The objects within the tw...
Forum: Obi Cloth
Last Post: ziziza93
05-11-2024, 05:08 AM
» Replies: 2
» Views: 411
Unity 6 Console Spam abou...
Forum: Obi Fluid
Last Post: josemendez
04-11-2024, 12:48 PM
» Replies: 1
» Views: 133
Fluid are always Opaque
Forum: Obi Fluid
Last Post: josemendez
04-11-2024, 08:51 AM
» Replies: 1
» Views: 752
does not render correctly...
Forum: Obi Fluid
Last Post: josemendez
31-10-2024, 12:52 PM
» Replies: 3
» Views: 1,174
Cloth grab with skinned m...
Forum: Obi Cloth
Last Post: josemendez
31-10-2024, 08:55 AM
» Replies: 1
» Views: 244

 
  Proxies with SkinnedMeshRenderers
Posted by: grigler - 27-06-2024, 03:28 PM - Forum: Obi Cloth - Replies (2)

Hey,

The documentation for cloth proxies says that they should be usable with either skinned cloths or normal cloths, however from looking at the code it seems like it's being driven from the MeshFilter component, which isn't a requirement of the SkinnedMeshRenderer.

is there an alternative?

Edit: Additionally, this cloth solution doesn't have a clear way of how to manage LODGroups. The results seem to be that any cloth will always be visible, breaking the lodgroup

Print this item

  Softbody-based Crawling
Posted by: wenhao_zheng - 27-06-2024, 10:40 AM - Forum: Obi Softbody - Replies (3)

Hi! 

As shown in the figure below, I try to use two soft bodies to grab a rigid body. For example, a claw machine.I expect the grabbing process to be achieved through friction.

I set the same collision material for both the claw soft body and the rigid body, with both dynamic and static friction set to 1.
In my attempt, I was able to grab the rigid body, but it soon fell slowly. In the real world, I would think that the friction is not enough. But I have set the friction to 1 in the collision material, and I expect that there should be no tangential movement of the object.
For reference I have attached my Obi Solver component configuration, although I have tried different things with it and I don't think the problem seems to be there.
Is it possible to achieve my needs based on ObiSoftbody? If it is feasible, I am very much looking forward to getting suggestions from developers.
Many thanks!

Please see the attachment for detailed configuration.
Thanks!



Attached Files Thumbnail(s)
                   
Print this item

  helicopter hook
Posted by: Koolio - 26-06-2024, 11:19 PM - Forum: Obi Rope - Replies (4)

Any guide or example on making a rope that works like a helicopter hook, ie bit like the jungle strike games.. where the end of the hook can latch onto gameobjects to pick them and swing them, but also hoist them up so the rope length would get shorter?

is this something simple that can be done with obi rope?

Print this item

Pregunta Particle Attachment on expanding rope
Posted by: Balou - 26-06-2024, 01:43 AM - Forum: Obi Rope - Replies (3)

Hi,

I've a rope around 1 unit long, it's attached to a rod by the first and last particle with 2 static particle attachments.
On this rope there is cursor, depending on an object position (a VR controller) the cursor will either have the cursor at 0 or 1 (source always at .5) . Imagine you are pulling a rope either from the start or end.
So this rope can get bigger if you pull, everything works fine here.
Now when pulling I want to attach the closest particle from the controller to it. I'm getting the closest particle (avoiding the first and last) and create the attachment using this script:

Code:
                particleAttachment = rope.gameObject.AddComponent<ObiParticleAttachment>();
                particleAttachment.enabled = false;
                particleAttachment.target = m_Controller;

                var group = ScriptableObject.CreateInstance<ObiParticleGroup>();
                group.particleIndices.Add(attachedParticleIndex);
                group.name = "Test";


                particleAttachment.particleGroup = group;
                particleAttachment.attachmentType = ObiParticleAttachment.AttachmentType.Static;
                particleAttachment.enabled = true;

And the behavior is weird, sometimes it works, sometimes points get stuck in the air like if they were attach to a world position. I feel like it's because I'm expanding the rope while dragging and sometimes the source particle can become the one attached?

Do you see any edge cases with this system?

Thanks a lot.

Print this item

  Shadow Problem
Posted by: 0xhex - 25-06-2024, 06:19 PM - Forum: Obi Fluid - Replies (1)

Hello,there is something wrong with shadows on fluids,
i will share 2 screenshot one for with shadow, one without shadow

in shadow it looks weird,i need to disable shadows for fluid particles!

[Image: kb0t27n.png]

[Image: s7boin9.png]

Print this item

  Elastic Deformation Question
Posted by: wenhao_zheng - 25-06-2024, 07:32 AM - Forum: Obi Softbody - Replies (2)

Hi! Sonrojado

I want to simulate human soft tissues through the ObiSoftbody toolkit.
I have two questions, both of which do not consider plastic deformation, but only elastic deformation:
① How to modify the elastic deformation effect of the soft body. For example, the elasticity of fat is different from that of muscle. I modified the Shape Matching Constraints in the test, but the effect does not seem to meet expectations.
② I want to simulate the elasticity value of each soft tissue, so I am considering obtaining the deformation of each particle through the API for calculation. Is my idea correct?

Thank you for your attention, I really want to know how to do my work, thank you. Gran sonrisa

Print this item

  Collision detection problom
Posted by: MakeLifeEasier - 24-06-2024, 04:07 AM - Forum: Obi Cloth - Replies (2)

Sorry to bother you. I want to create a system where when a cloth net collides with a rigid body, it indicates whether a collision has occurred. If a collision occurs, the scene should be reinitialized. However, with the current code, even though collisions appear to happen on screen, there is no indication of a collision being detected.
Here is the code attached to the  obi solver,  

Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiSolver))]
public class CollisionEventHandlerchuang : MonoBehaviour
{
    ObiSolver solver;
    public int contactCount;
    private bool collisionOccurred = false;

    void Awake()
    {
        solver = GetComponent<ObiSolver>();
    }

    void OnEnable()
    {
        solver.OnParticleCollision += Solver_OnCollision;
    }

    void OnDisable()
    {
        solver.OnParticleCollision -= Solver_OnCollision;
    }

    void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
    {

        contactCount = 0;
        collisionOccurred = false;

        //foreach (var contact in e.contacts)
        //{
        //    if (contact.distance < 0.001f)
        //    {
        //        collisionOccurred = true;
        //        contactCount++;
        //    }
        //}

        var world = ObiColliderWorld.GetInstance();

        // just iterate over all contacts in the current frame:
        foreach (Oni.Contact contact in e.contacts)
        {
            // if this one is an actual collision:
            Debug.Log("no bang chuang");
            if (contact.distance < 0.01)
            {
                ObiColliderBase col = world.colliderHandles[contact.bodyB].owner;
                if (col != null)
                {
                    Debug.Log("bang chuang");
                    collisionOccurred = true;
                    contactCount++;
                }
            }
        }

    }

    public bool IsCollisionOccurred()
    {
        return collisionOccurred;
    }

    public int GetContactCount()
    {
        return contactCount;
    }

    void OnDrawGizmos()
    {
        // Existing OnDrawGizmos code
    }
}
Here is another code subscribed the collision event,  it is expected to return true when the collision happens. However, the false is always returned.
Code:
using System.Collections.Generic;
using Unity.MLAgents;
using UnityEngine;
using Obi;

public class SatelliteEnvController : MonoBehaviour
{
   
    public ObiSolverInitializer obiSolverInitializer;

    public CollisionEventHandlerchuang collisionHandlerchuang;
    public CollisionEventHandler collisionHandler;


    void Start()
    {
   
        ResetScene();
        obiSolverInitializer.InitializeObiSolverPosition();

        collisionHandlerchuang = FindObjectOfType<CollisionEventHandlerchuang>();
        collisionHandler = FindObjectOfType<CollisionEventHandler>();

        if (collisionHandlerchuang == null)
        {
            Debug.LogError("CollisionEventHandlerchuang not found in the scene.");
        }
        if (collisionHandler == null)
        {
            Debug.LogError("CollisionEventHandler not found in the scene.");
        }

    }

    void FixedUpdate()
    {
        if (collisionHandlerchuang != null)
        {
            bool collisionOccurred = collisionHandlerchuang.IsCollisionOccurred();
            int contactCount = collisionHandlerchuang.GetContactCount();

            Debug.Log("Collision occurred: " + collisionOccurred);
            Debug.Log("Number of contacts: " + contactCount);

        }
    }

   

Print this item

Exclamación Rope saving and restore by Json
Posted by: tapLucas - 22-06-2024, 03:32 PM - Forum: Obi Rope - Replies (19)

Dev environment: Obi Rope version 6.5.4 / Windows 10 / Unity 2021


Hello, sorry to bother you.  I am working on a puzzle game and need to save the data of twisted ropes into a JSON file, then read the JSON during gameplay to restore the ropes to their previous twisted state. ()



I have implemented the save and load functions and can confirm that the saved data is correct because I have tested the vectors' paths of the ropes, and they match what was saved.

However, when I apply the data to the instantiated ropes, I cannot restore the ropes to their previous state. When I use the vectors stored in JSON to restore the positions of the rope's particles, the ropes can never maintain their previous twissted state. The ropes are always spread out or lying there alone.


I found some posts in the forum:

https://obi.virtualmethodstudio.com/foru...-116.html?
The first post from 2017 mentioned frequently calling ObiRopeCursor.ChangeLength() to restore the shape of the ropes, but this method does not work for me, and I am also unable to call the PushDataToSolver method mentioned in the post. (This method only implemented in class ObiStitcher) However, I understand the reason for calling ObiRopeCursor.ChangeLength(). Calling this method can increase the activeParticleCount. The number of actor.activeParticleCount may be much smaller than the number of actor.particleCount, but the number of actor.particleCount is limited by the particleCount in ObiActorBlueprint.

https://obi.virtualmethodstudio.com/foru...4112.html?
The second post was updated in February 2024, which is very recent and provides sample code. The save and load code in the post is very similar to mine, with the only difference being that the loop code during restoration ignores the legality of solver.positions[particlesIndices[i]]. During actual operation, the number of _rope.solverIndices may be much smaller than the total amount of data stored in JSON, resulting in either loss of some data or array out-of-bounds errors.


Here is the code I used to instantiate the rope / saving and restoring the ropes.


Instantiate the rope:
 
Code:
private GameObject InstantiateRope(GameObject objectToAttach1, GameObject objectToAttach2)
    {
        var rpObject = objectPool.GetRopeFromPool();
        ObiRope rope = rpObject.GetComponent<ObiRope>();
       
        Transform transformA = objectToAttach1.transform;
        Transform transformB = objectToAttach2.transform;
        Vector3 PositionA = transformA.position;
        Vector3 PositionB = transformB.position;
        Vector3 objectScale = transformA.localScale;
       
        Vector3 offset = new Vector3(0, objectScale.y + 0.05f, 0);

        Vector3 startPositionLS = transform.InverseTransformPoint(PositionA + offset);
        Vector3 endPositionLS = transform.InverseTransformPoint(PositionB + offset);
        //Vector3 tangentLS = (endPositionLS - startPositionLS).normalized;
        Vector3 tangentLS = Vector3.zero;

       
        ObiRopeBlueprint blueprint = ScriptableObject.CreateInstance<ObiRopeBlueprint>();
        blueprint.path.Clear();
        blueprint.pooledParticles = 100;
       
        // Build the rope path:
        int filter = ObiUtils.MakeFilter(ObiUtils.CollideWithEverything, 0);
        blueprint.path.AddControlPoint(startPositionLS, -tangentLS, tangentLS, Vector3.up, 1f, 0.1f, ropeThickness, filter,
            Color.white, "start");
       
        blueprint.path.AddControlPoint(endPositionLS, -tangentLS, tangentLS, Vector3.up, 1f, 0.1f, ropeThickness, filter,
            Color.white, "end");
       
        blueprint.path.FlushEvents();

        // Generate particles/constraints:
        blueprint.GenerateImmediate();
       
        ObiParticleAttachment attachment1 = rpObject.AddComponent<ObiParticleAttachment>();
        ObiParticleAttachment attachment2 = rpObject.AddComponent<ObiParticleAttachment>();

        // Set the blueprint:
        rope.ropeBlueprint = blueprint;
       
        // Attach both ends:
        attachment1.target = transformA;
        attachment2.target = transformB;
        attachment1.particleGroup = blueprint.groups[0];
        attachment2.particleGroup = blueprint.groups.Last();

        // Parent the actor under a solver to start the simulation:
        rpObject.transform.SetParent(obiSolverObject.transform);
       
        return rpObject;
    }


Save the positions of the particles in the rope:
 
Code:
public JSONObject SaveJson()
    {
        jsonObject.AddField("ropeLength", gameObject.GetComponent<ObiRope>().restLength);
        jsonObject.AddField("particles", GetRopeParticleData());
        return jsonObject;
    }

  JSONObject GetRopeParticleData()
    {
        var rope = gameObject.GetComponent<ObiRope>();
        var solver = rope.solver;
        var particlesIndices = rope.solverIndices;
        var positions = new List<Vector3>();
       
        for (int i = 0; i < particlesIndices.Length; i++)
        {
            //if (rope.IsParticleActive(i))  // I was considering save active particles only.
            {
                positions.Add(solver.positions[particlesIndices[i]]);
            }
        }
        var positionsArray = JSONObject.emptyArray;
        for (int i = 0; i < positions.Count; i++)
        {
            positionsArray.Add((JSONNode)positions[i]);
        }

        var ropeObject = JSONObject.emptyObject;
        ropeObject.AddField("positions", positionsArray);
        //ropeObject.AddField("velocities", velocitiesArray);  // Velocities are all zero, so I didn't save.
        return ropeObject;
    }




Load the positions of the particles from JSON and set to particles in the rope:

   
Code:
public void LoadJson(JSONObject jsonObject)
    {
        ropeLength = jsonObject["ropeLength"].floatValue;
        gameObject.GetComponent<ObiRopeCursor>().ChangeLength(RopeLength);
        particleDataToRestore = jsonObject["particles"];
        rope.OnBlueprintLoaded += Actor_OnBlueprintLoaded;
    }

public void Actor_OnBlueprintLoaded(ObiActor actor, ObiActorBlueprint blueprint)
    {
        if (particleDataToRestore == null)
            return;
        var solver = actor.solver;
        var particlesIndices = actor.solverIndices;

        /*for (int i = 0; i < actor.solverIndices.Length; ++i)
            solver.invMasses[actor.solverIndices[i]] = 0;*/
       
        var positionsJsonArray = particleDataToRestore["positions"];
        if (positionsJsonArray != null && positionsJsonArray.type == JSONObject.Type.Array)
        {
            for (int i = 0; i < positionsJsonArray.list.Count; i++)
            {
                if (i < particlesIndices.Length)
                {
                    solver.positions[particlesIndices[i]] = positionsJsonArray[i].ToVector3();
                    // actor.ActivateParticle(i);
                }
            }
        }
       
        /*for (int i = 0; i < actor.solverIndices.Length; ++i)
            solver.invMasses[actor.solverIndices[i]] = 1f;*/
       
        particleDataToRestore = null;
    }



Attached Files Thumbnail(s)
               
Print this item

  White Particles URP
Posted by: KleptoLizard - 22-06-2024, 05:22 AM - Forum: Obi Fluid - Replies (2)

In this post https://obi.virtualmethodstudio.com/foru...-3520.html you helped Locque create particles with a solid white color using the Built-In Pipeline.
But how can I do this in URP?
I tried taking the shader file you gave him and splicing the changes into a copy of ParticleShaderURP.shader but couldn't get it to work.
The pipelines are just too different.

Thanks

Print this item

  Temporarily make fluids in a container ignore other colliders/fluids
Posted by: Tobias - 21-06-2024, 03:31 PM - Forum: Obi Fluid - Replies (8)

Hello,

I'm new to ObiFluid and I'm currently working on a 2D bartender game where you can grab glasses with fluid, move them around and pour the fluids into other glasses (or onto the shelves).

For example, I'd like this to work:

  • Drag and drop the red fluid glass from below through the upper shelf collider and through the blue and green glasses without affecting the liquids at all - it should just pass through it.
  • Rotate the red fluid glass so the red fluid pours out. Once the red fluid has left its glass it should be stopped by any other glass (i.e. fill those glasses and mix with any fluids inside) or the shelf.

So, in short, I'd need a *grabbed glass with liquid* ignore all non-grabbed-glass colliders/liquids, and *liquid that has left a grabbed glass* to normally interact with the world.

Liquids can mix, so I don't think I could do anything like "liquid from the red emitter behaves differently" - it might be glass mixed with red and blue liquid that is grabbed, while other glasses also already have red or blue liquid.

I see two ways this could happen:
  • If I make the simulation 3D with very flat models, it would still look 2D in an orthographic camera and I could use the Z-axis to make a grabbed glass and its contents ignore any other collider. When the fluid leaves the grabbed glass trigger volume because it is poured I could adjust the Z-position of those now-outside-the-glass fluid particles back to the Z-position that everything non-grabbed is on.
  • If there is a way to have multiple simulations and to transfer colliders/fluids between simulations, I could temporary make a grabbed glass and its fluid a separate "grabbed glass" simulation and return any fluid that leaves the grabbed glass to the "main" simulation.

Do those ways sound possible? Is there any other (maybe better?) way to achieve this?



Attached Files
.png   Unity_2024-06-21 16.16.06.023.png (Size: 2.12 KB / Downloads: 18)
Print this item