Freezing Y axis

Pakaffy

20-09-2009 15:44:07

Hey thar

Using 1.5.5 BloodyMess. Have a rope of cubes joined with spherical joints, moving the bottom link with set linear velocity, and fixing the y at the top makes it appear to drag along correctly. However the cubes then start colliding with eachother, and everything just kind of goes to hell. So I tried also freezing the y position on the bottom cube, which really..doesn't work at all. Applying the velocity seems to make the whole thing spin in a small radius around the y axis. Very confused? Is there a reason that wouldn't work?

betajaen

20-09-2009 16:00:45

Hello thar,

What about disabling collisions between the actors?

joint_description.mJointFlags = 0;

That would stop them going to hell when you start moving the top one around?

Pakaffy

21-09-2009 00:43:32

hih betajaen!

I hadn't done that, and it seems to make it freak out less than disabling collision in the body description, but collisions still occur up the chain. It seems to not be affecting the outcome?

betajaen

21-09-2009 10:28:41

Sounds wave-like behavior the smallest disturbance at the bottom cube, increases in amplitude up the chain.

I have two ideas;

- Increase the linear damping of the cubes in the chain, this will dampen the cubes movement. But will make the cubes seem heavier.
- Play around with the springs of the joints; making them looser.

I'd try the first one first, and if that doesn't work. I'll help you out with the second. I've also re-read your first post and noticed your setting the movement via linear direction. What about forces? Have you tried pushing/pulling the bottom cube with a force - the simulation may be more stable then.

Also; any chance I can have some source code? ;)

Pakaffy

22-09-2009 02:00:10

Hey again Betajaen. Your first suggestion helped out alot, has stopped the joints from freaking out. Now my only problem remains with locking the y position of the first object as well as the last. Whenever I do this, the rope will freak out, come to a rest, and lock itself along the same axis as the last body. Using freexe y position or just doing it in code has the same result.

I used linear veloc cos it gives me what I want aesthetically. Looks alot smoother. I am simulating marionette strings.

The code I use to render the segments and joints;
if the segment being rendered is the first or last, it should have the body description that fixes the y axis
works fine when it's just the last one. It's like it will only let me lock the y position along one point



for(int i = 0 ; i< nbSegments;i++)
{
if(i==(nbSegments-1)||i==0)
{
ropeSegs[i] = mRenderSystem->createBody(new NxOgre::Box(size.x, size.y, size.z), pos+ NxOgre::Vec3(0,(i+1),0), "Capsule01.mesh",v);
ropeSegs[i]->getEntity()->getParentNode()->setScale(Ogre::Vector3(0.2,0.2,0.2));
}
else if((i<(nbSegments)))
{
ropeSegs[i] = mRenderSystem->createBody(new NxOgre::Box(size.x, size.y, size.z), pos+ NxOgre::Vec3(0,(i+1),0), "Capsule01.mesh",d);
ropeSegs[i]->getEntity()->getParentNode()->setScale(Ogre::Vector3(0.2,0.2,0.2));
}
}
for(int i=0 ; i<nbSegments - 1;i++)
{
ropeLinks[i] = mScene->createSphericalJoint(ropeSegs[i], ropeSegs[i+1], desc);
}




If I render the string again with only the first object locked to this axis, it will render the rope up from where the last node was placed when I lock that, instead of up from the point I specified. wut?

betajaen

22-09-2009 10:23:40

Alright. I'll have a play with your code and see if I can get it more stable.

Few questions;

1. Why are you using boxes instead of capsules even though your Ogre Mesh is a capsule? Capsules are perfect for long pieces of string/rope.

2. Your Global Axis of the joints doesn't seem to be given. It should be the intersection point between the two actors - this could be source of your problems.

3. Have you considered using cloth? It isn't difficult and you can generate the cloth all in code.

Pakaffy

23-09-2009 11:36:11

1. Mainly cos I just added the capsule mesh just then, created by one of the animators I'm working with. There isn't really a reason and i'll prolly update it when I come to writing collision code, but thanks for pointing it out, I prolly would've forgotten about and let it cause more problems =P

2. I set the local anchor heeere. I was under the impression that'd be sufficient?;
NxOgre::SphericalJointDescription desc;
desc.mSwingAxis.set(0,0,1);
desc.mJointFlags = 0;
desc.mSphericalJointFlags = 0;
desc.mLocalAnchor[0].set(0, (10),0);
desc.mLocalAnchor[1].set(0,-(10),0);



3. No I haven't? Do you think that would be better? I haven't even really had a look at the code regarding cloth, are there any tutes about? It is for a uni project, and it needs to be implemented..very soon, so anything you could recommend would be great. Thanks for your help so far.

betajaen

23-09-2009 12:53:11

1. It would be more stable, and you would have less of a chance of the capsules touching each other (unless you swung them around like a madman). You can even relax on the linear damping if you want it to be a bit lighter.

2. Try the GlobalAxis, and change them for each time you add a joint. So it's the half-way vertical point between the first and second capsules of the joint - basically where the tips of each capsule meet each other.

3. Stick with Capsules/Joints then if your pressed for time.