gamecreator Posted November 14, 2019 Share Posted November 14, 2019 I have the following scene with a ground and a ball (together in one fbx/mdl but four separate models: ground, ground collision shape, sphere, sphere collision shape) and a code-generated character controller. The ground and the ball have their own collision shapes. If they're both collisionhull, everything is fine. However, if either one is a collisionmesh, the controller falls through the ground, even though the camera physics debug (and the model editor) shows that the collision meshes are there. Below is the code and attached is the Models folder with all of the fbx and mdl files. #include "Leadwerks.h" using namespace Leadwerks; Entity* player = 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->SetRotation(25, 0, 0); camera->Move(0, 0, -16); camera->SetDebugPhysicsMode(true); Light* light = DirectionalLight::Create(); light->SetRotation(35, 35, 0); Model* scene = Model::Load("Models/scene_bothcollisionhull.mdl"); // This works! // Model* scene = Model::Load("Models/scene_bothcollisionmesh.mdl"); // This doesn't work - controller falls through ground // Model* scene = Model::Load("Models/scene_groundcollisionmesh_spherecollisionhull.mdl"); // This doesn't work - controller falls through ground // Model* scene = Model::Load("Models/scene_groundcollisionhull_spherecollisionmesh.mdl"); // This doesn't work - controller falls through ground // The next 3 lines don't seem to be necessary but I tried them anyway // scene->SetMass(0); // scene->SetPhysicsMode(Entity::RigidBodyPhysics); // scene->SetCollisionType(Collision::Scene); //Create a character player = Pivot::Create(); Entity* visiblecapsule = Model::Cylinder(16, player); visiblecapsule->SetScale(1, 2, 1); visiblecapsule->SetPosition(0, 1, 0); player->SetMass(1); player->SetPhysicsMode(Entity::CharacterPhysics); player->SetPosition(0, 1, 0); while(true) { if(window->Closed() || window->KeyDown(Key::Escape)) return false; Leadwerks::Time::Update(); float move = (window->KeyDown(Key::Up) - window->KeyDown(Key::Down)) * 4; float strafe = (window->KeyDown(Key::Right) - window->KeyDown(Key::Left)) * 4; player->SetInput(0, move, strafe); world->Update(); world->Render(); context->Sync(); } return 0; } Comment out one of the Model::Load lines and uncomment another one to load a different combination. Models.zip Quote Link to comment Share on other sites More sharing options...
reepblue Posted November 14, 2019 Share Posted November 14, 2019 Don't have time to look at this right now but it's worth asking if you yourself created the collision or these are editor generated shapes. Are the models collapsed? I have issues with non-collapsed models myself. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
gamecreator Posted November 14, 2019 Author Share Posted November 14, 2019 I should have been more clear that they're four individual models I created in 3DS Max. By collapsing do you mean combining into one? I could certainly combine the ground and the sphere but the idea is to have two separate collision types in one scene and that can't be done with one model (you need at least one named collisionhull and at least one named collisionmesh). Since I use physics debug, I think I could have simplified this by not even having visible models, just the collision meshes. Quote Link to comment Share on other sites More sharing options...
reepblue Posted November 14, 2019 Share Posted November 14, 2019 I mean using the collapse feature in the model editor. It removes all child nodes. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
gamecreator Posted November 14, 2019 Author Share Posted November 14, 2019 Collapsing it combines all of the meshes into 1... and eliminates the physics shapes. ? Quote Link to comment Share on other sites More sharing options...
reepblue Posted November 14, 2019 Share Posted November 14, 2019 Then you build a new one. I can show you how I do my shapes sometime. Shapes without collapsing models for me doesn't produce great results for my purposes. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
gamecreator Posted November 14, 2019 Author Share Posted November 14, 2019 I'm curious about your process and what collapsing models improves. Maybe you could either blog or post elsewhere about it. In the meantime, I think the collisionmesh bug remains. Quote Link to comment Share on other sites More sharing options...
reepblue Posted November 14, 2019 Share Posted November 14, 2019 1 hour ago, gamecreator said: I'm curious about your process and what collapsing models improves. Maybe you could either blog or post elsewhere about it. In the meantime, I think the collisionmesh bug remains. Yeah, I think I will. Keep an eye out for it 1 Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
gamecreator Posted November 14, 2019 Author Share Posted November 14, 2019 I definitely will. 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.