Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mass and Center of Mass? Missing API?
#1
Pregunta 
Has the API Docs been updated for softbody? I may be overlooking it or using an outdated link.

Before I write my own methods, I have a few questions:

I'm replacing my rigidbody with a softbody. Do these methods/fields or something equivalent exist for softbodies.

  1. Rigidbody.GetPointVelocity(Vector3 worldPoint) - returns the pointVelocity .
  2. Rigidbody.AddForceAtPosition(Vector3 force, Vector3 position)
  3. Rigibody.centerOfMass - get and set the center of mass of softbody.
  4. Rigibody.mass - [i]get and set the total mass of softbody.[/i]
  5. Rigibody.velocity - gets the softbody velocity 
I have been working on alternative approaches just in case the above methods/fields don't exist. so far...
for setting mass: I was going to divide the total mass with the particle count and add that value to each particle.
for getting velocity: since each particle has a velocity, I was going to use the first particle as the velocity.
 but does a single particle velocity represent the velocity of the entire softbody? Not sure this will work.


And Lastly - Since you have to initialize a softbody in the editor, It's not possible to create a softbody at runtime, right?

I'm in the dark and guessing without the softbody API documentation (using the source helps, but creates more questions).

 Any help would be greatly appreciated.

Thanks.
Reply
#2
(25-03-2019, 10:09 PM)StudioTatsu Wrote: Has the API Docs been updated for softbody? I may be overlooking it or using an outdated link.

Before I write my own methods, I have a few questions:

I'm replacing my rigidbody with a softbody. Do these methods/fields or something equivalent exist for softbodies.

  1. Rigidbody.AddForceAtPosition(Vector3 force, Vector3 position)
  2. Rigibody.centerOfMass - get and set the center of mass of softbody.
  3. Rigibody.mass - [i]get and set the total mass of softbody.[/i]
  4. Rigibody.velocity - gets the softbody velocity 
I have been working on alternative approaches just in case the above methods/fields don't exist. so far...
for setting mass: I was going to divide the total mass with the particle count and add that value to each particle.
for getting velocity: since each particle has a velocity, I was going to use the first particle as the velocity.
 but does a single particle velocity represent the velocity of the entire softbody? Not sure this will work.


And Lastly - Since you have to initialize a softbody in the editor, It's not possible to create a softbody at runtime, right?

I'm in the dark and guessing without the softbody API documentation (using the source helps, but creates more questions).

 Any help would be greatly appreciated.

Thanks.

Hi there,

[*]Rigidbody.GetPointVelocity(Vector3 worldPoint) - returns the pointVelocity .

In a rigidbody, you can get the velocity at any point in space (even outside of the body's volume), since it is assumed to be rigid. Not the case of a softbody. You could treat the softbody as a rigidbody by calculating its center of mass (more on that later) and its approximate angular and linear velocities. Then you could get the velocity at any point as:





Code:
linear_velocity_at_COM + Cross(angular_velocity_at_COM, point - COM);

[*]


However in practice, it is both easier and more accurate to simply get the velocity of a given particle. See:
http://obi.virtualmethodstudio.com/tutor...icles.html

[*]Rigibody.centerOfMass - get and set the center of mass of softbody.

You cannot directly set the center of mass of a softbody, because its density is not constant over space (unlike a rigidbody). You can indirectly influence it by altering the mass distribution over particles (making some particles heavier than others). Also you can calculate the current center of mass. It is done by performed a weighted sum of all particles's positions, then dividing by the total mass of the body. There's a sample that does this here:
http://obi.virtualmethodstudio.com/tutor...icles.html

[*]Rigibody.mass - [i]get and set the total mass of softbody.[/i]

To get it, simply accumulate the mass of each particle. If you assume homogenous density (same mass and volume for all particles, which is not necessarily true), you could set it by dividing the mass by the amount of particles, then assigning this fraction of the total mass to each particle. Note that particles work with inverse masses (1/mass), instead of mass directly.

[*]Rigibody.velocity - gets the softbody velocity 

Similar to calculating the COM (center of mass). But instead of a weighted sum of positions, a weighted sum of velocities.





Quote:And Lastly - Since you have to initialize a softbody in the editor, It's not possible to create a softbody at runtime, right?







[*]

Yes, it is possible. In fact there's an entire manual page dedicated to it. There's no ObiSoftbody-specific sample in that page though, but since it derives from ObiActor the same workflow applies to it.
http://obi.virtualmethodstudio.com/tutor...ctors.html
Reply
#3
Thanks. That helps a lot. I will try those suggestions.

So, just to be clear there isn't an AddForceAtPosition equivalent method with softbody currently?
And will the API docs be updated to include Softbody?

Thanks again for your help.
Reply