shadmar Posted September 17, 2013 Share Posted September 17, 2013 If you test ball joints they are wierd According to the docs it should be SetLimits(cone,twist), however cone seems to be set in the last parameter. And twist doesn't seem to work, however setting a high value, seems to break cone.? Test : Copy/paste into any App.lua camera=Camera:Create() camera:SetPosition(0,2,-5) ground = Model:Box(20,1,20) local shape=Shape:Box(0,0,0,0,0,0,20,1,20) ground:SetShape(shape) ground:SetMass(0) box1 = Model:Box() box1:SetPosition(0,1.5,0) box1:SetColor(1,0,0) local shape=Shape:Box() box1:SetShape(shape) box1:SetMass(20) box2=box1:Instance() box2:SetColor(0,1,0) box2:SetPosition(0,3,0) box2:SetMass(1) cone=0 twist=45 joint=Joint:Ball(0,2,0,box1,box2) joint:SetLimits(cone,twist) joint:EnableLimits() box2:AddTorque(200,200,200) HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Admin Posted September 18, 2013 Share Posted September 18, 2013 You're right, that is very strange. I reported it here: http://newtondynamics.com/forum/viewtopic.php?f=12&t=7770 function App:Start() self.angle=45 self.window = Window:Create() self.context = Context:Create(self.window) self.world = World:Create() piv = Pivot:Create() camera=Camera:Create(piv) camera:SetPosition(0,2,-5) camera:SetDebugPhysicsMode(true) ground = Model:Box(20,1,20) local shape=Shape:Box(0,0,0,0,0,0,20,1,20) ground:SetShape(shape) ground:SetMass(0) box1 = Model:Box() box1:SetPosition(0,1.5,0) box1:SetColor(1,0,0) local shape=Shape:Box() box1:SetShape(shape) box1:SetMass(20) box2=box1:Instance() box2:SetColor(0,1,0) box2:SetPosition(0,3,0) box2:SetMass(1) cone=0 twist=45 joint=Joint:Ball(0,2,0,box1,box2) joint:SetLimits(cone,twist) joint:EnableLimits() box2:AddTorque(2000,2000,0) return trueend function App:Loop() if self.window:KeyHit(Key.Escape) then return false endpiv:Turn(0,1,0) Time:Update() self.world:Update() self.world:Render() self.context:Sync() return trueend Link to comment Share on other sites More sharing options...
Josh Posted October 11, 2013 Share Posted October 11, 2013 I see. The ball joint matrix needs to indicate the pin direction. This will work in the update next week: #include "App.h" using namespace Leadwerks; App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; } float angle=25; Joint* joint; bool App::Start() { window = Window::Create(); context = Context::Create(window); world = World::Create(); camera = Camera::Create(); camera->Move(0,0,-4); Light* light = DirectionalLight::Create(); light->SetRotation(35,35,0); Model* ground = Model::Box(20,1,20); Shape* shape=Shape::Box(0,0,0,0,0,0,20,1,20); ground->SetShape(shape); ground->SetMass(0); Model* box1 = Model::Box(); box1->SetPosition(0,1.5,0); box1->SetColor(1,0,0,1); shape=Shape::Box(); box1->SetShape(shape); box1->SetMass(20); Model* box2=(Model*)box1->Instance(); box2->SetColor(0,1,0,1); box2->SetPosition(0,3,0); box2->SetMass(1); float cone=45; float twist=0; joint=Joint::Ball(0,2,0,box1,box2); joint->SetLimits(cone,twist); joint->EnableLimits(); box2->AddTorque(200,200,200); return true; } bool App::Loop() { if (window->Closed() || window->KeyDown(Key::Escape)) return false; if (window->KeyDown(Key::Up)) angle+=1.0; if (window->KeyDown(Key::Down)) angle-=1.0; joint->SetAngle(angle); if (window->KeyHit(Key::Space)) { if (!joint->MotorEnabled()) { joint->EnableMotor(); } else { joint->DisableMotor(); } } Time::Update(); world->Update(); world->Render(); context->Sync(); return true; } My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts