(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,