Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Need Transform of Cloth or Particle Group
#1
Hi,

I need to track the the transform of cloth particles or specially 2 individual corner particles who I have assigned Particle Group named lets say "Left Corner Particle" and "Right Corner Particle".

Is there is any way I can fetch the transform using Particle Group?
Reply
#2
(28-02-2025, 06:47 AM)vrtraining Wrote: Hi,

I need to track the the transform of cloth particles or specially 2 individual corner particles who I have assigned Particle Group named lets say "Left Corner Particle" and "Right Corner Particle".

Is there is any way I can fetch the transform using Particle Group?

Hi,

Particles don't have transforms in the literal sense of the word (4x4 matrices). They have separate position, orientation and radii values stored in the solver's data arrays. You can access those using the particles API.

kind regards,
Reply
#3
(28-02-2025, 09:18 AM)josemendez Wrote: Hi,

Particles don't have transforms in the literal sense of the word (4x4 matrices). They have separate position, orientation and radii values stored in the solver's data arrays. You can access those using the particles API.

kind regards,

Hi,

I have only one actor in cloth dedicated solver.

I was able to get the index of particle group through blue print.

Code:
int particleIndex = actor.blueprint.groups[0].particleIndices[0]

I also verified it by giving a unique color to that particle in particle group and checking it through

Code:
actor.blueprint.GetParticleColor(particleIndex)

Now my question is should I'm using this Index in solver to get the position but I'm getting some Local position. How do I get global position?
Reply
#4
(03-03-2025, 04:18 AM)vrtraining Wrote: I was able to get the index of particle group through blue print.

Code:
int particleIndex = actor.blueprint.groups[0].particleIndices[0]

I also verified it by giving a unique color to that particle in particle group and checking it through

Code:
actor.blueprint.GetParticleColor(particleIndex)

Hi!

Blueprints store particle data at rest. If you want to get simulation data, you need to access the solver's arrays instead as explained here.

Quote:Each ObiSolver has a list for each one of these properties (solver.positions, solver.principalRadii, solver.velocities, solver.colors and so on), that stores the particle data for all actors currently being simulated by the solver. All spatial properties (positions, orientations, velocities, vorticities, etc) are expressed in the solver's local space.

(03-03-2025, 04:18 AM)vrtraining Wrote: Now my question is should I'm using this Index in solver to get the position

That index is the index of the particle in the blueprint. You should get its index in the solver first:

Code:
// get index of the particle in the solver:
int indexInSolver = actor.solverIndices[particleIndex];

// retrieve its position (expressed in the solver's local space):
Vector3 localPos = actor.solver.positions[indexInSolver];

(03-03-2025, 04:18 AM)vrtraining Wrote: but I'm getting some Local position. How do I get global position?

All simulation data in Obi is expressed in the solver's local space. Unity has a lot of functions to convert positions/directions/vectors between local/world (global) space and vice-versa, such as transform.TransformPoint.

Code:
Vector3 worldPos = solver.transform.TransformPoint(localPos);

Lots of systems in Unity work this way, for instance meshes: when you retrieve the position of a vertex in a mesh, you get a value expressed in the object's local space. If you want to express it in world space, you need to transform it using TransformPoint. Conversely, if you have a world space position and you need to express it in an object's local space you should use InverseTransformPoint.

kind regards,
Reply
#5
Thanks. I canĀ get the positions easily now.
Reply