RevoluteJoint / Spring problem

Hello,

I can't get something to work and i was really hoping you guys could help.

What am i trying to do?

I want to create a tree that can wiggle, build from small boxes. So its basically like a vertical stack of 10 boxes all connected by joints.

How am i doing it?

I'm using the RevoluteJoint which i extended with 2 vars a 'springConstant' and a 'springDamping'.
And on a update i run this script:

Code:
         var Joint:b2Joint = m_world.GetJointList();
         for (Joint; Joint; Joint = Joint.GetNext())
         {
            if(Joint is b2RevoluteJoint){
               var rj:b2RevoluteJoint = Joint as b2RevoluteJoint
               if(rj.IsMotorEnabled()){
                  var rja:Number = rj.GetJointAngle()
                  rj.SetMaxMotorTorque(Math.abs((rja * rj.GetSpringConstant()) + (rj.GetJointSpeed() * rj.GetSpringDamping())));
                  rj.SetMotorSpeed(rja > 0 ? -100000 : +100000);
               }
            }
         }


This does work only the spring is to soft which causes the tree to collapse. Im using a springConstant of 150 and a springDamping of 2.
When i increase the springConstant the bodies start to randomly wiggle really weird.

Did i start of wrong using the revolute joint? Any idea's?

Thanks!

Erik
**FIXED**

Connect boxes with 2 distance joints. far - left and far - right of a box ( not to far, keeping space from the edges). Meaning 10 boxes = 20 Distance joints. see attached picture
Also set 'collideConected' to true.

Is there any solution with even better performance? ( less joints? this works like a charm tho)

Also another question;

Is there any way to find the 'stress' on a joint? Like when there is much wind and the tree starts falling to the left, it would be cool to 'snap' some joints. ( i didn't look in the forum yet, this question just popped my mind)

Thanks!

Original thread: https://box2d.org/forum/viewtopic.php?t=7534