gamecreator Posted April 19, 2020 Share Posted April 19, 2020 I tried to make a simple gate that lowers when a button is pressed. The gate itself works perfectly; a single bone moves it up or down. However, the problem is that I can't tie the collision mesh to it in any way so that it moves with the gate. I've tried: 1. Skinning the collision mesh as well with the gate bone (Leadwerks converted it into a non-physics model) 2. Skinning the collision mesh with its own bone and moving both bones together (same conversion) 3. Creating a collision mesh in the model editor (did not move with model) Must the collision mesh be moved separately by code or is there a way to make this work? Quote Link to comment Share on other sites More sharing options...
Keith Lannister Posted April 28, 2020 Share Posted April 28, 2020 Hiya Am I correct in asking that the collision box being displayed is to the same height as the door stops opening? Quote Link to comment Share on other sites More sharing options...
gamecreator Posted April 28, 2020 Author Share Posted April 28, 2020 Yes. The collision box in the last picture doesn't move at all. I generated it at animation frame 0 but when I animated the model (in the screenshot it is frame 32) the collision box didn't move down. This makes sense because a model could be complex and anything could be going on, including multiple pieces moving in different directions but I wanted to test to see what would happen. Ideally you could tie a collisionmesh to a bone but Leadwerks doesn't seem to support that. I was mostly just looking for some sort of alternative, short of doing it by code. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted April 28, 2020 Author Share Posted April 28, 2020 This was for the Ludum Dare 46 competition a week ago and I ended up moving the gate with a collision mesh by code. 1 Quote Link to comment Share on other sites More sharing options...
Marcousik Posted May 17, 2020 Share Posted May 17, 2020 Is there a reason why you don't just use the joint possibility as in the examples/tutos for doors opening? Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 17, 2020 Author Share Posted May 17, 2020 Do you have a link to the tutorial page? The ones I found use code to move the doors. That said, I did think of two "workarounds" since then that I haven't tried yet: Joining the shape and the model as a prefab. I figure this should work. Using a single line in the code to parent the door and collision shape together. The point of this thread was to avoid code but it's not the worst to do this during map initialization. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted May 17, 2020 Share Posted May 17, 2020 No sorry I mean the tutorial as you can find one in the examples map Josh made. So you want to avoid loading time by initialising the map am I right? I think in the principle, moving a shaped element and becoming consequences of this has something to do with massed object and that s why joints and no animation will be used. It seems to run as if animations are into the domain of "decoration" while shape, collision, mass more like supporting "behind the scene" ground elements. Sorry not sure if I can express this good. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 18, 2020 Author Share Posted May 18, 2020 It was mostly just curiosity about whether or not I could combine an skinned model with a collision mesh directly in a modeling program but seems not. But there are several ways to easily do this by either code or the above-mentioned methods so it's fine. Quote Link to comment Share on other sites More sharing options...
Solution Rick Posted May 20, 2020 Solution Share Posted May 20, 2020 CSG shape as a child in the editor? Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 20, 2020 Author Share Posted May 20, 2020 1 hour ago, Rick said: CSG shape as a child in the editor? Would this work? How would it know which bone to follow if there's more than one bone? Or imagine if there was a double door in a single mesh (each with a bone). Hmm. I guess a prefab wouldn't work either for this reason. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted May 21, 2020 Share Posted May 21, 2020 On 5/20/2020 at 2:21 AM, Rick said: CSG shape as a child in the editor? I think this is worth a try. The invisible shape CSG shape should be parented to each bone, it is a good idea. (you could seperate the mesh and passing them to each bone simply with blender if necessery) Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 21, 2020 Author Share Posted May 21, 2020 6 hours ago, Marcousik said: The invisible shape CSG shape should be parented to each bone Ah, of course. I think this could work! Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 21, 2020 Author Share Posted May 21, 2020 Tested and it seems to work! I created a box (door) with a bone skinned to it and moved it around and exported it as an animated FBX. Then I created another box (doorcol) with just the collision mesh as another exported FBX. I then parented doorcol to door in a scene and then saved the whole thing as a prefab. Then I used the following code to load and animate the prefab: #include "Leadwerks.h" using namespace Leadwerks; Entity* entity = NULL; int main(int argc, const char *argv[]) { Leadwerks::Window* window = Leadwerks::Window::Create(); Context* context = Context::Create(window); World* world = World::Create(); Camera* camera = Camera::Create(); camera->Turn(0, 15, 0); camera->Move(-1, 1, -4); camera->SetDebugPhysicsMode(true); // Set camera to see physics shapes Light* light = DirectionalLight::Create(); light->SetRotation(35, 35, 0); // Make a sphere Model* sphere = NULL; sphere = Model::Sphere(); sphere->SetColor(1.0, 0.0, 0.0); sphere->SetPosition(0, -1, 0); Entity *model = Prefab::Load("Prefabs/thedoor.pfb"); // Entity *model = Model::Load("Models/door/door.mdl"); // Sanity check while(true) { if(window->Closed() || window->KeyDown(Key::Escape)) return false; model->SetAnimationFrame(Leadwerks::Time::GetCurrent() / 30.0, 1, 0); Leadwerks::Time::Update(); world->Update(); world->Render(); context->Sync(); } return 0; } The result (yes, the animation is sloppy but it was just to test it; and I put the collision off to the side so it's easier to see): Thank you everyone for the help. 2 Quote Link to comment Share on other sites More sharing options...
Marcousik Posted May 27, 2020 Share Posted May 27, 2020 I just worked today on this model and I had to think about this thread ^^ Somehow the same problematic happens now to me and I do not see any solution if not seperate the mesh and use a joint ?? Here the animation is turning the propeller (without shape!), but I need the poly mesh as shape so the player can enter in the building... Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 27, 2020 Author Share Posted May 27, 2020 Leadwerks physics shapes are limited and buggy. It's trial and error to see what works but I suggest having different models and shapes whenever possible. As I reported before, collisionmesh and polymesh don't seem to get along. Quote Link to comment Share on other sites More sharing options...
Marcousik Posted May 28, 2020 Share Posted May 28, 2020 Yes just wanted to add this link to this thematic as following the same theme 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted May 30, 2020 Share Posted May 30, 2020 @Marcousik The turning parts of the windmill should be a separate model. 1 Quote 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
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.