Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Finding last point of rope
#1
Hi,

I need to find the last point of rope in script, not the particles(because when moving the rope, particles seems to be bit late to reach the rope rendered position.

I know this is basic ques, I have searched everywhere, I couldnt get what i need.
Reply
#2
(15-11-2021, 07:36 AM)srid96 Wrote: Hi,

I need to find the last point of rope in script, not the particles(because when moving the rope, particles seems to be bit late to reach the rope rendered position.

I know this is basic ques, I have searched everywhere, I couldnt get what i need.

Hi!

This is explained in the "scripting particles" section manual:
http://obi.virtualmethodstudio.com/manua...icles.html

Quote:The solver will also generate renderable particle positions and orientations at the end of every frame. You can access them like this:

Vector3 pos = solver.renderablePositions[actor.solverIndices[0]];

If the solver's interpolation mode is set to "interpolate", solver.renderablePositions will contain temporally smoothed-out positions that won´t coincide with the actual particle positions at the end of the simulation step. That's why they are called "renderable": they are only used for smooth rendering, but they aren't fed back into the simulation.

let me know if you need further help. cheers!
Reply
#3
(15-11-2021, 08:40 AM)josemendez Wrote: Hi!

This is explained in the "scripting particles" section manual:
http://obi.virtualmethodstudio.com/manua...icles.html


let me know if you need further help. cheers!
can you help me on how to get the last point on rope?
Reply
#4
(15-11-2021, 09:08 AM)srid96 Wrote: can you help me on how to get the last point on rope?

The manual explains how to get the position of any particle in the actor. The last one (or the first one, the 3rd one) is no different from any other. Instead of iterating trough all particles in the actor.solverIndices array, get the last one:

Code:
var lastPos = solver.renderablePositions[actor.solverIndices[actor.solverIndices.Length-1]];

Keep in mind that if you're tearing or resizing your rope at runtime, you will need to use rope elements to consistently get the last particle (as it will change at runtime). See the API docs for more info.
Reply
#5
(15-11-2021, 09:21 AM)josemendez Wrote: The manual explains how to get the position of any particle in the actor. The last one (or the first one, the 3rd one) is no different from any other. Instead of iterating trough all particles in the actor.solverIndices array, get the last one:

Code:
var lastPos = solver.renderablePositions[actor.solverIndices[actor.solverIndices.Length-1]];

Keep in mind that if you're tearing or resizing your rope at runtime, you will need to use rope elements to consistently get the last particle (as it will change at runtime). See the API docs for more info.
I did this, but my position seems to be somewhere other than end of the rope. I have attached for your reference. Let me know how to fix this.
Thank you.
Reply
#6
(15-11-2021, 03:35 PM)srid96 Wrote: I did this, but my position seems to be somewhere other than end of the rope. I have attached for your reference. Let me know how to fix this.
Thank you.

Hi,

Can't see any attached code/file to your post.
Reply
#7
(15-11-2021, 03:39 PM)josemendez Wrote: Hi,

Can't see any attached code/file to your post.
Sorry, i didnt know what happened.

(15-11-2021, 03:42 PM)srid96 Wrote: Sorry, i didnt know what happened.


Attached Files Thumbnail(s)
                       
Reply
#8
Positions (and all other particle data) in Obi are expressed in solver space:
http://obi.virtualmethodstudio.com/manua...icles.html

Quote:All spatial properties (positions, orientations, velocities, vorticities, etc) are expressed in the solver's local space.

However you're assigning your position to transform.position, which is expressed in world space. If you want to use it this way, you need to convert the particle position to world space first, using Unity's TransformPoint(): https://docs.unity3d.com/ScriptReference...Point.html
Reply
#9
[attachment=1171 Wrote:     josemendez pid='11140' dateline='1636987641']Positions (and all other particle data) in Obi are expressed in solver space:
http://obi.virtualmethodstudio.com/manua...icles.html


However you're assigning your position to transform.position, which is expressed in world space. If you want to use it this way, you need to convert the particle position to world space first, using Unity's TransformPoint(): https://docs.unity3d.com/ScriptReference...Point.html
Hi, transforming to world space did not put the object to the last point on rope. Is there anything else am I missing from the attachments? 

 I also tried particle attachment of an object at the end of the rope (like in chains demo), i'm curious how that chainball moves smoothly and having mass of 5 units didnt jitter/dance where in my case i have to bring the mass to the lowest value to stop jittering and when moving rope , object is not moving smoothly like the chainball.
See the imgs below for particle attachments


Attached Files Thumbnail(s)
   
Reply
#10
(16-11-2021, 08:30 AM)srid96 Wrote: Hi, transforming to world space did not put the object to the last point on rope. Is there anything else am I missing from the attachments? 

It should. That's all there is to it, transforming from solver to world space will give you the particle position in world space. Can you share the code you wrote to do this?

(16-11-2021, 08:30 AM)srid96 Wrote:  I also tried particle attachment of an object at the end of the rope (like in chains demo), i'm curious how that chainball moves smoothly and having mass of 5 units didnt jitter/dance where in my case i have to bring the mass to the lowest value to stop jittering and when moving rope , object is not moving smoothly like the chainball.

Mass is not the issue here, Obi is unconditionally stable so any jittering indicates a setup problem: probably your object is colliding with the rope. The object cannot be simultaneously inside and outside the rope (which is what the attachment and collisions want, respectively) so it "dances" between both configurations. If the rope needs to be attached inside of or very close to the object, simply disable collisions between the end of the rope and the collider. You can use filters for this.

This issue along with the solution is explained in the manual, at the end of the "pin constraints" section referenced from dynamic attachments:
http://obi.virtualmethodstudio.com/manua...aints.html
Reply