Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How to Save / Load Obi Actors in 5.0
#6
Saw this out of the corner of my eye before leaving the thread:

Quote:I also got to realize that I need to save the raw data, not the blueprint since I can't serialize a runtime-created blueprint: how can I modify all the arrays of data manually?

You can get/set per-particle data manually quite easily:
http://obi.virtualmethodstudio.com/tutor...icles.html

The solver contains all currently loaded particle data in its arrays. solver.positions and solver.velocities are probably the ones you're most interested in.

When an actor is loaded in a solver, the solver allocates space for the particles in a greedy way: for each actor particle, it finds the first empty slot in the data arrays, and places it there.  The actor knows where each particle is placed in the solver because the solver fills in the actor's solverIndices array with the index for each particle.

So, to modify the velocity of the first particle in the actor:
Code:
solver.velocities[actor.solverIndices[0]] = new Vector4(1,0,0,0);

Same to retrieve it. Note: The fourth member (x,y,z,w) in positions/velocities is simply there for nicer memory alignment, should be 0 always.
Reply


Messages In This Thread
RE: How to Save / Load Obi Actors in 5.0 - by josemendez - 26-11-2019, 05:37 PM