Obi Official Forum
Help tearing cloth access - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html)
+--- Thread: Help tearing cloth access (/thread-3371.html)



tearing cloth access - maygdirf - 21-03-2022

Hi there!
I was wondering whether is possible to access which triangles of the mesh is displaced when a collision with a tearing cloth happens. In particular, I would like to know the velocities of the particles hit and their displacement in the normal direction to the hitting. Is there anyone who can help me please?


RE: tearing cloth access - josemendez - 21-03-2022

(21-03-2022, 09:15 AM)maygdirf Wrote: Hi there!
I was wondering whether is possible to access which triangles of the mesh is displaced when a collision with a tearing cloth happens. In particular, I would like to know the velocities of the particles hit and their displacement in the normal direction to the hitting. Is there anyone who can help me please?

Hi there!

You can subscribe to the ObiTearableCloth.OnClothTorn. This event will pass a ObiClothTornEventArgs struct as argument, which contains the particle index torn as well as the updated faces in the cloth's half-edge structure.

Using the particle index, you can get its velocity using the particle API:
http://obi.virtualmethodstudio.com/manual/6.3/scriptingparticles.html

let me know if you need further help.

kind regards,


RE: tearing cloth access - maygdirf - 21-03-2022

(21-03-2022, 11:57 AM)josemendez Wrote: Hi there!

You can subscribe to the ObiTearableCloth.OnClothTorn. This event will pass a ObiClothTornEventArgs struct as argument, which contains the particle index torn as well as the updated faces in the cloth's half-edge structure.

Using the particle index, you can get its velocity using the particle API:
http://obi.virtualmethodstudio.com/manual/6.3/scriptingparticles.html

let me know if you need further help.

kind regards,
Hi Jose! Thanks for your reply.

I forgot to say that I'm new with Obi, so I'm a little inexperienced with this. I'm trying to understand the "ObiTearableClothRenderer.cs" in order to understand how to use ObiClothTornEventArgs but it seems so messy.
Is there like an example of what I'm trying to do? Thanks in advice!


RE: tearing cloth access - josemendez - 21-03-2022

(21-03-2022, 01:24 PM)maygdirf Wrote: Hi Jose! Thanks for your reply.

I forgot to say that I'm new with Obi, so I'm a little inexperienced with this. I'm trying to understand the "ObiTearableClothRenderer.cs" in order to understand how to use ObiClothTornEventArgs but it seems so messy.
Is there like an example of what I'm trying to do? Thanks in advice!

Hi!

This is a regular C# event, that you can subscribe to like this:

Code:
cloth.OnClothTorn += CallMeWhenClothIsTorn;

You must make sure the "CallMeWhenClothIsTorn" method (sample name, you can call it as you wish) has the following signature:

Code:
void CallMeWhenClothIsTorn(ObiTearableCloth cloth, ObiClothTornEventArgs tearInfo)

That's it. You can then use tearInfo.particleIndex inside that method to retrieve data about that particle.

If you're unfamiliar with C# programming, you might want to take a look at the basics first. Events/delegates are an intermediate-level language feature, Obi assumes that you know what they are and how to use them.


RE: tearing cloth access - maygdirf - 23-03-2022

(21-03-2022, 01:31 PM)josemendez Wrote: Hi!

This is a regular C# event, that you can subscribe to like this:

Code:
cloth.OnClothTorn += CallMeWhenClothIsTorn;

You must make sure the "CallMeWhenClothIsTorn" method (sample name, you can call it as you wish) has the following signature:

Code:
void CallMeWhenClothIsTorn(ObiTearableCloth cloth, ObiClothTornEventArgs tearInfo)

That's it. You can then use tearInfo.particleIndex inside that method to retrieve data about that particle.

If you're unfamiliar with C# programming, you might want to take a look at the basics first. Events/delegates are an intermediate-level language feature, Obi assumes that you know what they are and how to use them.
Thank you very much, now it's clear!