Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Can I attach particeattachment in script?
#11
Quote:This might be obvious, but you should *not* rely on the Y values of all waist particles being *exactly* the same. Even if whoever modeled the skirt made the wait perfectly horizontal, vertices won't have the same height due to floating point error. You should pick one representative particle (for instance the topmost one) and then compare all others with it, using a threshold.
Hello. My original goal was to find particles  located on wasitline of the skinnedclothbluprint  based on the assumption that all vertices in waistline of the cloth ( which are located in the highest position in the cloths like skirts and pants) have same Y position, so I just need to get the highest positions's particles for setting wasitline particles. But after I realized all the vertices in the waistline part in the cloth asset mesh, I changed my goal to find the number of the amount in the waistline of the cloth mesh, so I can just need to find the toppest skinned cloth blueprint's particle around waistline using the number. To do this, I have to find amount of the highest vertices in the waistline in every cloth assets mesh. The problem is, each cloth asset mesh has different amount of the vertices in their waistline, so I need to find a way to get amount of the vertices in the wasitline in script during runtime. Currently, I'm trying to solve this with finding connected vertices which has only 3 connected vertices cause except the this highest vertices and lowest vertices in the cloth mesh, all verices have 4 connected vertices each(I know for obi, mesh is converted to the trianlges  but what Im trying to do is find connected vertices in the orignal cloth mesh which has quads). If I,from the toppest vertice , start to find connected vertices which have 3 connected vertices, then I can find all vertices in the waistline, then I can get a number of this waist line vertices' amount, which can be used to find right particles in the waistline in the cloth blueprint. I'm trying to get this using obi script, fbx file reading in during runtime using c#, and trlib2(not using all of them to do this during the runtime, just trying to fine fastest way). And I'm stuck now. Is there any way to solve this? after reading your reply, I'm trying to use skin radius value with 0, but it takes long time to do all the cloth assets that we already made, to each different body types that we have to check(in our situation, there's some cases that big body wears small cloth or small body wears big clothes. Does this - skin radius with 0 value - cause that any small clothes go through skin of the big body?

**and we have baggy clothes too, so clothes shouldnt be attached just on skin of the body like bodycon style.


Quote:Quite possibly, editor UI breaking in this way usually means there's been an error while rendering the editor. Did you add any custom code to the blueprint and/or blueprint editor?

When/how are you calling this code?


All of the cloth meshes' vertices are more than 1000 and less than 4~5000. And I didnt put any custom code into obi package code, but I'll check it again just in case. And this code is called only once in the Awake method. And the cloth gameobject of this skinned cloth blueprint is disabled before play, so I can just make it enabled after this code's script works during the runtime.
Reply
#12
(20-09-2024, 09:21 AM)gahyun11 Wrote: Hello. My original goal was to find particles  located on wasitline of the skinnedclothbluprint  based on the assumption that all vertices in waistline of the cloth ( which are located in the highest position in the cloths like skirts and pants) have same Y position, so I just need to get the highest positions's particles for setting wasitline particles. But after I realized all the vertices in the waistline part in the cloth asset mesh, I changed my goal to find the number of the amount in the waistline of the cloth mesh, so I can just need to find the toppest skinned cloth blueprint's particle around waistline using the number. To do this, I have to find amount of the highest vertices in the waistline in every cloth assets mesh. The problem is, each cloth asset mesh has different amount of the vertices in their waistline, so I need to find a way to get amount of the vertices in the wasitline in script during runtime. Currently, I'm trying to solve this with finding connected vertices which has only 3 connected vertices cause except the this highest vertices and lowest vertices in the cloth mesh, all verices have 4 connected vertices each(I know for obi, mesh is converted to the trianlges  but what Im trying to do is find connected vertices in the orignal cloth mesh which has quads). If I,from the toppest vertice , start to find connected vertices which have 3 connected vertices, then I can find all vertices in the waistline, then I can get a number of this waist line vertices' amount, which can be used to find right particles in the waistline in the cloth blueprint. I'm trying to get this using obi script, fbx file reading in during runtime using c#, and trlib2(not using all of them to do this during the runtime, just trying to fine fastest way). And I'm stuck now. Is there any way to solve this?

There's many other options.

One is to use an edge loop detection algorithm: start at the topmost edge and iterate trough edges, picking always the edge opposite to the current one until you return to where you started.

Or, a border detection algorithm: build a half-edge data structure out of the mesh, and pick half-edges that have no pair. Out of all of them, the ones above the centroid of the mesh will be the waist.

Or, a hole detection algorithm, and again the topmost hole will be the waist.

(20-09-2024, 09:21 AM)gahyun11 Wrote: after reading your reply, I'm trying to use skin radius value with 0, but it takes long time to do all the cloth assets that we already made, to each different body types that we have to check(in our situation, there's some cases that big body wears small cloth or small body wears big clothes.


(20-09-2024, 09:21 AM)gahyun11 Wrote: Does this - skin radius with 0 value - cause that any small clothes go through skin of the big body?

**and we have baggy clothes too, so clothes shouldnt be attached just on skin of the body like bodycon style.

Skin radius = 0 just drives the particle using full animation, no simulation. Whether it goes trough the body or not entirely depends on how well skinned the cloth mesh is. If skin weights are not properly authored, it may of course go trough the body.

Note that regardless of the method used (attachments or skin radius), you need to detect the waist particles: be it to create a particle group with them, or to set their skin radius.
(20-09-2024, 09:21 AM)gahyun11 Wrote: All of the cloth meshes' vertices are more than 1000 and less than 4~5000. And I didnt put any custom code into obi package code, but I'll check it again just in case. And this code is called only once in the Awake method. And the cloth gameobject of this skinned cloth blueprint is disabled before play, so I can just make it enabled after this code's script works during the runtime.

Are there any errors popping up in the console when this happens?
Reply
#13
(20-09-2024, 09:47 AM)josemendez Wrote: There's many other options.

One is to use an edge loop detection algorithm: start at the topmost edge and iterate trough edges, picking always the edge opposite to the current one until you return to where you started.

Or, a border detection algorithm: build a half-edge data structure out of the mesh, and pick half-edges that have no pair. Out of all of them, the ones above the centroid of the mesh will be the waist.

Or, a hole detection algorithm, and again the topmost hole will be the waist.




Skin radius = 0 just drives the particle using full animation, no simulation. Whether it goes trough the body or not entirely depends on how well skinned the cloth mesh is. If skin weights are not properly authored, it may of course go trough the body.

Note that regardless of the method used (attachments or skin radius), you need to detect the waist particles: be it to create a particle group with them, or to set their skin radius.

Are there any errors popping up in the console when this happens?
Hello! Thank you for your answer. Now I just set every particle into  a group before I attach particle attachment component into cloth asset, cause I figured out it is little hard and takes time to adapt algorithm to find the vertices on the waistline. Anyway it works well!
And about the any errors... I didnt get any errors. I might try it again to figure out,.in which specific situation this happens.
Btw, Im trying to download obi cloth 6.5.2 from package manager. What is the name of git url of obi cloth?
Reply
#14
(04-10-2024, 07:12 AM)gahyun11 Wrote: Hello! Thank you for your answer. Now I just set every particle into  a group before I attach particle attachment component into cloth asset, cause I figured out it is little hard and takes time to adapt algorithm to find the vertices on the waistline. Anyway it works well!

Hi!

I'm not entirely sure I understand how this is a solution to the original problem? If you set every particle into a single group, you'll only be able to attach the entire cloth which is the same as having no cloth simulation at all, but a lot more expensive. If you mean having a separate group for each individual particle, you still need to figure out which of those groups are part of the waistline. Either way, the problem of finding and attaching specific parts of the cloth is unsolved?

(04-10-2024, 07:12 AM)gahyun11 Wrote: Btw, Im trying to download obi cloth 6.5.2 from package manager. What is the name of git url of obi cloth?

Only Unity packages are stored in git repositories, assets are stored in the Asset Store. So they have no git url. If you need an older version, send an email to support(at)virtualmethodstudio.com and we'll send it to you.

kind regards,
Reply
#15
(19-09-2024, 10:12 AM)josemendez Wrote: This might be obvious, but you should *not* rely on the Y values of all waist particles being *exactly* the same. Even if whoever modeled the skirt made the wait perfectly horizontal, vertices won't have the same height due to floating point error. You should pick one representative particle (for instance the topmost one) and then compare all others with it, using a threshold.


Initial particle positions are just copied from vertex positions. If your vertex weld distance or minimum particle distance are not zero, they might be moved around afterwards to meet these constraints.


Quite possibly, editor UI breaking in this way usually means there's been an error while rendering the editor. Did you add any custom code to the blueprint and/or blueprint editor?


When/how are you calling this code?

kind regards,

I didnt add any custom code to obi asset, and I found this link, NullReferenceException Blueprint Edit (virtualmethodstudio.com) and edit obi asset as the last comment said, then the ui issue is solved. 

Btw, Im currently trying to make a trench coat following obi cloth proxy character cloth tutorial(Obi Physics for Unity - Character Clothing using Proxies (virtualmethodstudio.com)), but the particle keeps falling from the body! I know there is a issue about simulating sample of obi cloth proxy (CharacterCloth Scene in sample - cloth directory, Unity 2021 not working? (virtualmethodstudio.com)) But obi version of mine is 6.5, and version of unity is 2022.3.2 as you can see, and if I play the scene of Character Cloth, cloth mesh is broken like a screen below( this still happens my coworker's computer who using obi 6.5)
   

And this is a trench coat that I made with proxy following tutorial
   

I would understand if this happens only in CharacterCloth Sample scene, but even I used same model(I just copied from CharacterCloth scene) and made a coat blueprint with optimizing it, adding tethering group and generating tether,And I created trenchcoatSkin then added 2 channel, particle of the skinned cloth object keeps falling. Should I update obi from 6.5 to 7 or Did I something wrong? Thank you


*I got IndexoutofRnage exception from 128 line from ObiClothProxy.cs
Code:
                    slavePositions[data.slaveIndex] = s2l.MultiplyPoint3x4(skinnedPos);
Reply
#16
(10-10-2024, 09:39 AM)gahyun11 Wrote: I didnt add any custom code to obi asset, and I found this link, NullReferenceException Blueprint Edit (virtualmethodstudio.com) and edit obi asset as the last comment said, then the ui issue is solved. 

The solution in that thread's last comment won't solve the issue, will only keep the error from logging to the console. The editor won't work properly, since properties are still null. The proper solution to this bug (caused by Unity improperly managing public members when multiple inspectors are open) is to close all secondary inspectors.

This was circumvented in Obi 7.0, as we use Unity's new Stage API instead which doesn't trigger the error.

(10-10-2024, 09:39 AM)gahyun11 Wrote: Btw, Im currently trying to make a trench coat following obi cloth proxy character cloth tutorial(Obi Physics for Unity - Character Clothing using Proxies (virtualmethodstudio.com)), but the particle keeps falling from the body! I know there is a issue about simulating sample of obi cloth proxy (CharacterCloth Scene in sample - cloth directory, Unity 2021 not working? (virtualmethodstudio.com)) But obi version of mine is 6.5, and version of unity is 2022.3.2 as you can see, and if I play the scene of Character Cloth, cloth mesh is broken like a screen below( this still happens my coworker's computer who using obi 6.5)

As explained in that link, Unity completely changed the way meshes are stored in Unity 2021. More specifically, 2021.2. This is not just a one-time/specific version thing, they changed the format permanently for all future versions. As a result, from 2021.2 onwards (2022, 2023, 6) some of the sample scenes in Obi 6 that were created in an older Unity version won't work correctly, because the format they stored meshes in is different from the one Unity is expecting. So using Obi 6.5 together with Unity 2022.3 will certainly exhibit the issue as it's pairing an older Obi version with a newer Unity version.

Also see our troubleshooting guide for a detailed explanation.

In Obi 7 the minimum Unity version was bumped to 2021.3.4 LTS and all sample scenes re-done using it, so this is no longer a problem.

(10-10-2024, 09:39 AM)gahyun11 Wrote: I would understand if this happens only in CharacterCloth Sample scene, but even I used same model(I just copied from CharacterCloth scene) and made a coat blueprint with optimizing it, adding tethering group and generating tether,And I created trenchcoatSkin then added 2 channel, particle of the skinned cloth object keeps falling. Should I update obi from 6.5 to 7 or Did I something wrong? Thank you

Not sure without taking a look at your setup and the values painted in the skinmap.

In Obi 7 proxy creation has been redone from scratch and is fully automatic - you only have to specify a decimation value when generating the blueprint and the mesh automatically gets simplified for cloth generation. There's still the option of providing an arbitrary, manually authored proxy mesh should you need it. So updating is certainly a good option.

kind regards,
Reply
#17
(10-10-2024, 10:43 AM)josemendez Wrote: The solution in that thread's last comment won't solve the issue, will only keep the error from logging to the console. The editor won't work properly, since properties are still null. The proper solution to this bug (caused by Unity improperly managing public members when multiple inspectors are open) is to close all secondary inspectors.

This was circumvented in Obi 7.0, as we use Unity's new Stage API instead which doesn't trigger the error.
Hello. I updated from obi 6 to 7 frew days ago, and now i am dealing with setting particles of obi sample trench coat to groups so I can edit their properties' values in the script. And after I added groups and set particles into them I got this UI layout issue again.

   

As you can see, the ui layout of the obi cloth blueprint is messed again.



and this is part of the script that I wrote to set particles.
Code:
coat.ClearParticleGroups();
        coat.AppendNewParticleGroup("red");
        coat.AppendNewParticleGroup("white");
        coat.AppendNewParticleGroup("blue");

as you can see, what I did was just cleaning particle groups, then appending new particle groups in runtime. then I exited playmode, tried to open the blueprint in editor, and got this issue again. I thought it was fixed already in obi 7. Can you tell me what I did wrong?
Reply
#18
(Yesterday, 09:38 AM)gahyun11 Wrote: what I did was just cleaning particle groups, then appending new particle groups in runtime. then I exited playmode

Modifying particle groups at runtime and having them persist once you get back to edit mode is not a supported use case. Our code is explicitly designed to disallow this, look at ObiActorBlueprint.cs InsertParticleGroup and ClearParticleGroups methods: they do completely different things based on the value of UNITY_EDITOR and Application.isPlaying.

There's two reasons for this: one is that Unity's editor API is of course only available in-editor, so doing this in standalone builds is simply impossible since standalone applications can't modify the asset database (there's no editor asset database!).

The other one is that even if technically possible when entering play mode inside the editor, persisting changes involves writing subasset data to disk which is an *extremely slow* operation. Typically, adding new particle groups at runtime means they will also be used at runtime so any operations involving them must be as fast as possible and must not persist outside of play mode.

Unity follows a similar convention on most of its built-in assets. See:
https://docs.unity3d.com/Manual/Modifyin...pting.html

If you want to persistently modify particle groups and have them written to disk as assets, you must modify them using editor scripts, not at runtime.

(Yesterday, 09:38 AM)gahyun11 Wrote: As you can see, the ui layout of the obi cloth blueprint is messed again.

This is a different error from the one you'd get in Obi 6 due to currentProperty being null due to Unity not correctly initializing public fields in custom editor. The problem here is that particle groups have been added to the a shared blueprint (instead of an instance of it) but have not been persisted to disk. As stated above, this is not supposed to be possible. We'll add an extra check to the editor window in upcoming versions.

Both issues prevent UI rendering from completing successfully, so they manifest in the same way.

kind regards,
Reply
#19
josemendez Wrote:The solution in that thread's last comment won't solve the issue, will only keep the error from logging to the console. The editor won't work properly, since properties are still null. The proper solution to this bug (caused by Unity improperly managing public members when multiple inspectors are open) is to close all secondary inspectors.

This was circumvented in Obi 7.0, as we use Unity's new Stage API instead which doesn't trigger the error.



Hello. I updated obi to 7 few days ago and now Im dealing with setting particles into groups again so I can set value of any properties of each group's particles that I need.
I just wrote the code below to create groups and I am facing again same issue of messy ui layout after editing particles of blueprint through script.


   
Code:
  coat.ClearParticleGroups();
        coat.AppendNewParticleGroup("red");
        coat.AppendNewParticleGroup("white");
        coat.AppendNewParticleGroup("blue");


The current project that I am working is totally diffrent newish project and I didnt edit any obi class sciprt nor library script. Can you tell me how to fix this?
Reply
#20
(Yesterday, 10:48 AM)gahyun11 Wrote: Hello. I updated obi to 7 few days ago and now Im dealing with setting particles into groups again so I can set value of any properties of each group's particles that I need.
I just wrote the code below to create groups and I am facing again same issue of messy ui layout after editing particles of blueprint through script.



Code:
  coat.ClearParticleGroups();
        coat.AppendNewParticleGroup("red");
        coat.AppendNewParticleGroup("white");
        coat.AppendNewParticleGroup("blue");


The current project that I am working is totally diffrent newish project and I didnt edit any obi class sciprt nor library script. Can you tell me how to fix this?

As I just answered in the above post, it is not possible to do what you want. Obi is explicitly designed to disallow this use case. Unity generally also disallows this, except for a handful of asset types.

kind regards,
Reply