//now add springs between adjacent boxes hkpStiffSpringConstraintData* spring = new hkpStiffSpringConstraintData(); hkpStiffSpringConstraintData* spring2 = new hkpStiffSpringConstraintData(); for(size_t i=0;i<boxes.size()-1;i++) { hkTransform b1 = boxes[i]->getTransform(); hkTransform b2 = boxes[i+1]->getTransform(); hkVector4f t1 = b1.getTranslation(); hkVector4f t2 = b2.getTranslation(); t1.add(hkVector4f(-0.5,0.5,0)); t2.add(hkVector4f(-0.5,-0.5,0)); spring->setInWorldSpace(b1,b2, t1, t2); { hkpConstraintInstance* constraint = new hkpConstraintInstance(boxes[i], boxes[i+1], spring ); g_pWorld->addConstraint(constraint); constraint->removeReference(); } t1.add(hkVector4f(1,0,0)); t2.add(hkVector4f(1,0,0)); spring2->setInWorldSpace(b1,b2, t1, t2); { hkpConstraintInstance* constraint = new hkpConstraintInstance(boxes[i], boxes[i+1], spring2 ); g_pWorld->addConstraint(constraint); constraint->removeReference(); } } spring->removeReference(); spring2->removeReference(); }