AggrorJorn Posted May 3, 2013 Share Posted May 3, 2013 I have slider joints successfully working but I am left with a problem. Right now my object can move beautifully across the x axis. But now lets say that both the parent (a pivot) and the child (a box) are rotated 30 degrees. The code for the joint is this: slidingDoorJoint = Joint::Slider(0,0,0, 1,0,0, slidingDoor,slidingDoorPivot But what if I my object is rotated 30 degrees? I tried setting the rotation of the joint itself but that doesn't work. try it yourself: #include "App.h" using namespace Leadwerks;App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {} App::~App() { delete world; delete window; }//sliding Door Pivot* slidingDoorPivot; Model* slidingDoor; Joint* slidingDoorJoint; bool App::Start() { //Create a window window = Window::Create("_12_Joints");//Create a context context = Context::Create(window); //Create a world world = World::Create();//Create a camera camera = Camera::Create(); camera->Move(0, 1, -4); camera->SetRotation(0,0,0); Light* light = DirectionalLight::Create(); light->SetRotation(45,45,0); //Sliding door Shape* slideDoorShape = Shape::Box(0,0,0 ,0,0,0, 2,4,0.2); slidingDoorPivot = Pivot::Create(); slidingDoorPivot->SetPosition(-2,0,0); slidingDoorPivot->SetRotation(0,30,0); slidingDoor = Model::Box(2,4,0.2); slidingDoor->SetShape(slideDoorShape); slidingDoor->SetMass(1); slidingDoor->SetPosition(-2,0,0); slidingDoor->SetRotation(0,30,0); slidingDoorJoint = Joint::Slider(0,0,0, 1,0,0, slidingDoor,slidingDoorPivot,-2, 2); slideDoorShape->Release();return true; } bool App::Loop() { //Close the window to end the program if (window->Closed()) return false; float sliderForce = window->KeyDown(Key::E) - window->KeyDown(Key::Q); slidingDoor->AddForce(sliderForce* Time::GetSpeed() * 2,0,0); Time::Update(); world->Update(); world->Render(); context->Sync(false);return true; } Quote Link to comment Share on other sites More sharing options...
Mumbles Posted May 3, 2013 Share Posted May 3, 2013 I would have thought you just attach the joint to the door (both totally unrotated), and then rotate the door. Would that not automatically rotate the joint -with- the door? Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 3, 2013 Author Share Posted May 3, 2013 The joint creation requires a child and parent object. The joint itself is not an entity. Quote Link to comment Share on other sites More sharing options...
Mumbles Posted May 3, 2013 Share Posted May 3, 2013 Oh, I've been using newton for too long, I'm so used to using the custom 6DOF joint that I totally forget that the normal joints need parents. But in Newton 2 (I know Newton 3 is out, but I'm still using 2), even if you do create a joint with a parent, you can call NewtonBodySetMatrixRecursive (which sounds like the SetMatrix function in Leadwerks with the recursive flag set to true) on the 'parent', and it will move all children too, and rotates all the joint pins on the parent to match. I don't know if Leadwerks allows this or not, or if you have to call EntityParent first - or whatever that function is called in the new version, so that the door is parented to the pivot. But in my mind though, I'm still sure that moving and rotating only the pivot (the parent), after they have been joined together is the way you're supposed to do it. That's certainly how you do it in Newton 2. Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 3, 2013 Author Share Posted May 3, 2013 I found that function you are talking about.however it requires a newton body, which I can't access, and a float matrix. I also don't think this is the way Josh intends users to work like. But I could be wrong. Quote Link to comment Share on other sites More sharing options...
YouGroove Posted May 6, 2013 Share Posted May 6, 2013 I'm lot more interested on attaching objects to some bone of animated model with some offsets. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 14, 2013 Author Share Posted May 14, 2013 I am still stuck with this. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 20, 2013 Author Share Posted May 20, 2013 I don't know what else to try here. I made a lot of different combinations but it just doesn't work slidingDoorJoint->SetRotation(0,30,0); slidingDoorPivot->SetRotation(0,30,0); slidingDoorJoint->SetRotation(0,30,0, 1); slidingDoorPivot->SetRotation(0,30,0, 0); slidingDoorJoint->SetRotation(0,30,0, 0); slidingDoorPivot->SetRotation(0,30,0, 1); slidingDoor->SetRotation(0,30,0, 1); slidingDoor->SetRotation(0,30,0, 0); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.