Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Marquee tool
#7
(10-06-2019, 03:44 PM)josemendez Wrote: Projecting a position is not related to Obi, since a position is a position regardless of where it came from. Obi gives you access to all per-particle properties (positions, velocities, masses, etc), and the documentation explains how to get/set them, but what you do with them is up to you, and largely not related to the engine itself.

Simply iterate over all particles projecting their current position, like this:

Code:
for (int i = 0; i < actor.positions.Length; ++i){
            int indexInSolver = actor.particleIndices[i];
            Vector3 projectedPos = camera.WorldToScreenPoint(solver.positions[indexInSolver]);
        }

After that I should write code below to make handle?


Code:
// Create the handle:
                GameObject c = new GameObject("Obi Handle");
                Undo.RegisterCreatedObjectUndo(c,"Create Obi Particle Handle");
                ObiParticleHandle handle = c.AddComponent<ObiParticleHandle>();
                handle.Actor = actor;

                // Calculate position of handle from average of particle positions:
                Vector3 average = Vector3.zero;
                for(int i = 0; i < selectionStatus.Length; i++){
                    if (selectionStatus[i]){
                        average += wsPositions[i];
                    }
                }

                c.transform.position = average / selectedCount;

                // Add the selected particles to the handle:
                for(int i = 0; i < selectionStatus.Length; i++){
                    if (selectionStatus[i]){
                        handle.AddParticle(i,wsPositions[i],actor.invMasses[i]);
                    }
                }
Reply


Messages In This Thread
Marquee tool - by Richard - 09-06-2019, 05:06 PM
RE: Marquee tool - by josemendez - 10-06-2019, 08:32 AM
RE: Marquee tool - by Richard - 10-06-2019, 09:21 AM
RE: Marquee tool - by josemendez - 10-06-2019, 02:19 PM
RE: Marquee tool - by Richard - 10-06-2019, 02:37 PM
RE: Marquee tool - by josemendez - 10-06-2019, 03:44 PM
RE: Marquee tool - by Richard - 10-06-2019, 04:14 PM
RE: Marquee tool - by josemendez - 10-06-2019, 07:21 PM
RE: Marquee tool - by Richard - 11-06-2019, 08:38 AM
RE: Marquee tool - by josemendez - 11-06-2019, 09:04 AM
RE: Marquee tool - by Richard - 11-06-2019, 09:14 AM
RE: Marquee tool - by josemendez - 11-06-2019, 11:06 AM
RE: Marquee tool - by Richard - 11-06-2019, 11:38 AM
RE: Marquee tool - by josemendez - 11-06-2019, 12:02 PM
RE: Marquee tool - by Richard - 11-06-2019, 04:21 PM
RE: Marquee tool - by josemendez - 12-06-2019, 07:13 AM
RE: Marquee tool - by Richard - 12-06-2019, 11:10 AM
RE: Marquee tool - by josemendez - 12-06-2019, 12:23 PM
RE: Marquee tool - by Richard - 12-06-2019, 12:49 PM