Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  how to remove fixed state
#11
(14-02-2019, 10:32 AM)Richard Wrote: I tried the other way, but it did not work like the image. What is wrong?

I read the page. How can I specify fixed particle and inverse mass values?
Reply
#12
(14-02-2019, 10:58 AM)Richard Wrote: I read the page. How can I specify fixed particle and inverse mass values?

Like it says in the page:

Code:
int particleSolverIndex = actor.particleIndices[<your particle index here>];

solver.invMasses[particleSolverIndex] = <your value here>

Set it to 0 to fix a particle, set it to any positive value to unfix it.
Reply
#13
(14-02-2019, 10:51 AM)josemendez Wrote: Hi,

What do you mean "the other way"?

Honestly I don't know what your use case is, but adding that many pin constraints for a dress just doesn't make sense to me. Why'd you want to do that? Pin constraints are used to enable two-way coupling with rigidbodies... looks like you'd want to use either fixed particles or skin constraints, if you're trying to create character clothing. Also having a mesh collider for a deformable object doesn't make sense, specially when Obi has built-in collision detection for cloth.

You suggested two ways. One is to inverse particles, the other is pin constrains. I would like to use fixed particles. I tried to use the object as pinned to slot. If I do that, obi collision needs other collision such as box, cupsele, sphere, mesh. But it looks wrong.

(14-02-2019, 11:04 AM)josemendez Wrote: Like it says in the page:

Code:
int particleSolverIndex = actor.particleIndices[<your particle index here>];

solver.invMasses[particleSolverIndex] = <your value here>

Set it to 0 to fix a particle, set it to any positive value to unfix it.

Thank you for your time so much! , but how can I see particle index? 
And the the any positive value affect the effect of result?
Reply
#14
(14-02-2019, 11:14 AM)Richard Wrote: You suggested two ways. One is to inverse particles, the other is pin constrains. I would like to use fixed particles. I tried to use the object as pinned to slot. If I do that, obi collision needs other collision such as box, cupsele, sphere, mesh. But it looks wrong.

Fixed particles are attached to the actor's transform. They do not inject any forces to any rigidbody, in case there was one. They just move/rotate/scale together with the actor transform.

Pin constraints on the other hand, enable a two-way force exchange between the particles and any rigid body in the hierarchy of the collider they're pinned to.

Both methods can be used to attach particles, but they behave very differently. So you need to use one or the other depending on what you want to do.

So, let's start again: what are you trying to do? is it character clothing?

In that case, you don't need fixed particles, use skin constraints. There's two tutorials on how to create character cloth here:
http://obi.virtualmethodstudio.com/tutor...thing.html
http://obi.virtualmethodstudio.com/tutor...cloth.html

If it is not character clothing, can you explain what you're trying to achieve?
Reply
#15
(14-02-2019, 11:14 AM)Richard Wrote: You suggested two ways. One is to inverse particles, the other is pin constrains. I would like to use fixed particles. I tried to use the object as pinned to slot. If I do that, obi collision needs other collision such as box, cupsele, sphere, mesh. But it looks wrong.


Thank you for your time so much! , but how can I see particle index? 
And the the any positive value affect the effect of result?

the particle index runs from 0 (first particle in the actor) to the number of particles in the actor. So depending on which particle you want to fix/unfix, you have to use a different index. How to get it depends on what you need to do at runtime: do you pick particles with mouse, or in response to a collision? do you simply want to unfix all fixed particles?

The inverse mass is, as the name implies, 1/mass of the particle. So high inverse masses will cause the particle to be lighter. Low values will make it progressively heavier, until you reach 0 and the particle is infinitely heavy (fixed).
Reply
#16
(14-02-2019, 11:25 AM)josemendez Wrote: the particle index runs from 0 (first particle in the actor) to the number of particles in the actor. So depending on which particle you want to fix/unfix, you have to use a different index. How to get it depends on what you need to do at runtime: do you pick particles with mouse, or in response to a collision? do you simply want to unfix all fixed particles?

The inverse mass is, as the name implies, 1/mass of the particle. So high inverse masses will cause the particle to be lighter. Low values will make it progressively heavier, until you reach 0 and the particle is infinitely heavy (fixed).

I would like to unfix all fixed particles.
Reply
#17
(14-02-2019, 11:37 AM)Richard Wrote: I would like to unfix all fixed particles.

Then iterate over all particles, and set their inverse mass:

Code:
float invMassPerParticle = 0.01f;
for (int i = 0; i < actor.invMasses.Length; ++i){
     int indexInSolver = actor.particleIndices[i];
     actor.invMasses[i] = solver.invMasses[indexInSolver] = invMassPerParticle;
}

You could of course use a more complicated approach to set the particle masses, such as defining a mass for the whole object and dividing it by the number of particles (to distribute it evenly). Or check for those that are fixed and set a different mass only for them, if desired.
Reply
#18
(14-02-2019, 11:37 AM)Richard Wrote: I would like to unfix all fixed particles.

I want to make vending machine of clothing. When a clothing is displayed, it have to be fixed pose, but once it was bought by someone, it should be normal clothing. Can I do that by same object?
Reply
#19
(14-02-2019, 12:20 PM)Richard Wrote: I want to make vending machine of clothing. When a clothing is displayed, it have to be fixed pose, but once it was bought by someone, it should be normal clothing. Can I do that by same object?

It depends on how you want the cloth to behave when it is "fixed". Does it need to move around, or will it just be static (un-simulated) until someone purchases it?
Reply
#20
(14-02-2019, 12:28 PM)josemendez Wrote: It depends on how you want the cloth to behave when it is "fixed". Does it need to move around, or will it just be static (un-simulated) until someone purchases it?


I want it be static.

I tried code, but many errors happen.


"Assets\InverseParticles.cs(15,33): error CS0029: Cannot implicitly convert type 'string' to 'UnityEngine.GameObject'"

"Assets\InverseParticles.cs(18,40): error CS1061: 'GameObject' does not contain a definition for 'invMasses' and no accessible extension method 'invMasses' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)"

"Assets\InverseParticles.cs(20,44): error CS1061: 'GameObject' does not contain a definition for 'particleIndices' and no accessible extension method 'particleIndices' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)"

"Assets\InverseParticles.cs(21,24): error CS1061: 'GameObject' does not contain a definition for 'invMasses' and no accessible extension method 'invMasses' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)"

"Assets\InverseParticles.cs(21,39): error CS0103: The name 'solver' does not exist in the current context"


I can't solve the problem. I thought "actor" in your code is to get name of  object of mesh. However, string causes error. 
In addition to that, I cannot what to do for "solver", or am I wrong how to think the problems?

(14-02-2019, 12:47 PM)Richard Wrote: I want it be static.

I tried code, but many errors happen.


"Assets\InverseParticles.cs(15,33): error CS0029: Cannot implicitly convert type 'string' to 'UnityEngine.GameObject'"

"Assets\InverseParticles.cs(18,40): error CS1061: 'GameObject' does not contain a definition for 'invMasses' and no accessible extension method 'invMasses' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)"

"Assets\InverseParticles.cs(20,44): error CS1061: 'GameObject' does not contain a definition for 'particleIndices' and no accessible extension method 'particleIndices' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)"

"Assets\InverseParticles.cs(21,24): error CS1061: 'GameObject' does not contain a definition for 'invMasses' and no accessible extension method 'invMasses' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)"

"Assets\InverseParticles.cs(21,39): error CS0103: The name 'solver' does not exist in the current context"


I can't solve the problem. I thought "actor" in your code is to get name of  object of mesh. However, string causes error. 
In addition to that, I cannot what to do for "solver", or am I wrong how to think the problems?

The code is the image.
Reply