|
|
How to Code Thickness? |
Posted by: Renman3000 - 19-08-2023, 01:08 PM - Forum: Obi Rope
- Replies (1)
|
 |
Hi,
I was looking in Docs but I see no reference to ScaleThickness.
I do see something in the ObiRopeBlueprintBase called thickness, but attmepts to access are not going well.
How can i code the thickness?
Thanks
|
|
|
Creating and Removing Pin Constraints from ObiPinConstraintsBatch |
Posted by: sebjf - 15-08-2023, 09:59 PM - Forum: Obi Cloth
- Replies (6)
|
 |
Hi,
I am trying to use ObiCloth to make an adhesive pad in VR, which the user can place on a surface, and pull away.
The way I am approaching this, is to use the collision callback to detect when particles are within a given distance of the target surface, and at the end of the frame create new Pin Constraints for all those that are not already adhered. At the end of each step, the breaking threshold is used to remove the constraints based on ObiParticleAttachment::BreakDynamicAttachment().
To avoid adding particles multiple times, I keep a list of particles that have been added to the ObiPinConstraintsBatch, and remove them from this list when they are removed in my version of BreakDynamicAttachment. However, this step often attempts to remove particles that don't exist in the list, and it appears others remain in the list even though there don't appear to be any active attachments affecting the cloth.
I have tried approaches using RemoveConstraint and DeactivateConstraint. I have successfully used a procedural ObiPinConstraintsBatch to facilitate grasping of the cloth, but in this case I can clear the ObiPinConstraintsBatch each time I need to update it.
I suspect therefore my approach to adding and removing particles from the ObiPinConstraintsBatch is wrong.
What is the best way to handle creating and destroying a small number of Pin Constraints for this purpose?
Would it be better, for example, to create an ObiPinConstraintsBatch with a single constraint for each particle at startup, then update/Activate/Deactivate these as they come into and out of contact?
Or perhaps I am getting the index for a broken constraint the wrong way - is this code correct?
Code: // The particlesToStick is populated in the collision callback, with solver indices
private void UpdateAdhesionConstraintsBatch()
{
if (particlesToStick.Count > 0)
{
var bindMatrix = Dummy.transform.worldToLocalMatrix * actor.solver.transform.localToWorldMatrix;
if(adhesionBatch == null)
{
adhesionBatch = new ObiPinConstraintsBatch();
}
foreach (var solverIndex in particlesToStick)
{
var positionOffset = bindMatrix.MultiplyPoint3x4(actor.solver.positions[solverIndex]);
var orientationOffset = bindMatrix.rotation * actor.solver.orientations[solverIndex];
adhesionBatch.AddConstraint(
solverIndex,
Dummy,
positionOffset,
orientationOffset,
0,
0,
0.1f
);
//q: why is this needed?
adhesionBatch.activeConstraintCount++;
stuck.Add(solverIndex);
actor.SetConstraintsDirty(Oni.ConstraintType.Pin);
}
particlesToStick.Clear();
UpdateAdhesion(); [color=#333333][size=small][font=Monaco, Consolas, Courier, monospace]// This adds or removes the batch depending on whether there are any active constraints, and tells the solver to rebuild the pins[/font][/size][/color]
}
}
// And to break the constraints, at the end of each step
private void BreakDynamicAttachment(float stepTime)
{
if (actor.isLoaded)
{
var actorConstraints = actor.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
var solverConstraints = actor.solver.GetConstraintsByType(Oni.ConstraintType.Pin) as ObiConstraints<ObiPinConstraintsBatch>;
if (actorConstraints != null && adhesionBatch != null)
{
int batchIndex = actorConstraints.batches.IndexOf(adhesionBatch);
if (batchIndex >= 0 && batchIndex < actor.solverBatchOffsets[(int)Oni.ConstraintType.Pin].Count)
{
int offset = actor.solverBatchOffsets[(int)Oni.ConstraintType.Pin][batchIndex];
var solverBatch = solverConstraints.batches[batchIndex];
float sqrTime = stepTime * stepTime;
for (int i = 0; i < adhesionBatch.constraintCount; i++)
{
// in case the constraint has been broken:
var b = -solverBatch.lambdas[(offset + i) * 4 + 3] / sqrTime;
if (b > adhesionBatch.breakThresholds[i])
{
var solverIndex = adhesionBatch.particleIndices[i];
if (!stuck.Remove(solverIndex))
{
Debug.Log("Error");
}
adhesionBatch.RemoveConstraint(i);
}
}
}
UpdateAdhesion(); // This adds or removes the batch depending on whether there are any active constraints, and tells the solver to rebuild the pins
}
}
}
|
|
|
Save and restore the state of the rops in the scene. |
Posted by: murathan - 15-08-2023, 05:56 PM - Forum: Obi Rope
- Replies (1)
|
 |
In the same scene, there are multiple Obi Ropes. After moving them differently within the game, is it possible to save their current positions to a text file or something similar, and then, at a different time, load them back to the same positions and shapes?
|
|
|
Problem with detecting collisions between different ropes |
Posted by: murathan - 14-08-2023, 09:23 PM - Forum: Obi Rope
- Replies (2)
|
 |
I'm trying to detect collisions between multiple ropes with the code below. However, even if the colliding ropes are different, both pa.actor.gameObject and po.actor.gameObject point to the same object. Both bodyA and bodyB show the same rope. I want to detect different colliding ropes. I looked into the forum and believe that detection should be done with this method. However, I wonder if I'm making a mistake when creating the Rope or Solver.
solver.OnParticleCollision += Solver_OnCollision;
void Solver_OnCollision(object sender, Obi.ObiSolver.ObiCollisionEventArgs e)
{
foreach (Oni.Contact contact in e.contacts)
{
// this one is an actual collision:
if (contact.distance < 0.01)
{
ObiSolver.ParticleInActor pa = solver.particleToActor[solver.simplices[contact.bodyA]];
ObiSolver.ParticleInActor po = solver.particleToActor[solver.simplices[contact.bodyB]];
if (pa.actor.gameObject != po.actor.gameObject)
{
Debug.Log("rope collides: " + pa.actor.blueprint.name + " " + po.actor.blueprint.name, pa.actor.gameObject);
}
}
}
}
|
|
|
issues with blueprint generation |
Posted by: bs-techart - 14-08-2023, 02:11 PM - Forum: Obi Softbody
- Replies (1)
|
 |
Hi,
I'm having issues with blueprint regeneration. I'm playing around with DeformationGradient sample. Whenever I change prism blueprint settings to generate a new one, the resulting Blueprint seems to make mesh wild in runtime. is there a fix for this, as I can't seem to find anything in documentation. Please check attachment.
Also, if I regenerate new blueprint with original prism blueprint settings, the resulting particle looks totally different. It almost looks like the values that were used to generate prism blueprint do not resemble the values that are shown on the asset. I have imported the package multiple times, just to revert back to original state.
Thanks!
|
|
|
Beta invite |
Posted by: 7Dev.io - 13-08-2023, 01:44 AM - Forum: General
- No Replies
|
 |
Are you guys still inviting for the betas? I sent an email a while ago with my invoices but never got a reply.
|
|
|
Problem with rods in moving objects |
Posted by: 1234567398 - 08-08-2023, 09:41 PM - Forum: Obi Rope
- Replies (1)
|
 |
Hi,
I've recently encountered a problem while working with Obi Rope rods. I created a rod with attachments on both ends, and everything seemed to be working fine. However, when the parent object containing this entire setup (the rod and both attachment transforms) started moving, the rod became very unstable and jagged, it was bouncing back and forth very quickly. This parent object was inside object with Obi Solver component, which was stationairy all the time, and this object was moving relatively to it. I've also checked and the same issue appears when a rope instead of rod was used.
Is there a way for a rod to somehow ignore the movement of parent objects and use local position for calculations, instead of world position? This would be really helpful, because I need to create many objects with rods, where the objects are moving, but the rods inside them are stationairy in relation to their parent.
Thank you for your help
|
|
|
|