gamecreator Posted March 3, 2014 Share Posted March 3, 2014 Simple question: why does a ball not fall when set up like this? ballmodel=Model::Load("Models/ball.mdl"); shape=Shape::Load("Models/ball.phy"); ballmodel->SetShape(shape); ballmodel->SetPosition(0,3,0); ballmodel->SetMass(1); ballmodel->SetCollisionType(1); If I get rid of the two shape lines it does fall (but then it also falls through my floor). I've tried generating the shape as both Convex Hull and Polymesh. By the way, why use one instead of the other? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted March 3, 2014 Share Posted March 3, 2014 A model already takes the phy file in to account and does not have to be se manually. (as far as I know) How did you set up the floor? Have you set a collision type in the editor via code? Convex hulls have no inward vertices and represent a simple shape to enclose the object (not the same as AABB). I believe polymeshes are the same thing as concave meshes. Convex hulls are easier for the physics engine to handle or concave meshes require a more complex calculation by the physics engine. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted March 3, 2014 Author Share Posted March 3, 2014 I figured the shape would be loaded automatically (like it did in LE2) so I'm happy to get rid of those lines if that's the way to go. The ground is set up exactly the same way. I'm sure the collision works fine as when I create a box dynamically using your code, here http://www.leadwerks.com/werkspace/page/tutorials/_/introduction-to-android-r40 it works and bounces off the ground. But the ground also does the same thing: if I don't load the shape manually it falls, whether or not I set SetMass(0); And your explanation on Convex Hulls makes sense. Thank you. My ground has columns to bump against and the collision only worked properly with Polymesh. I'll upload my project when I'm home if there's no solution to this but there's gotta be something simple I'm missing. Quote Link to comment Share on other sites More sharing options...
beo6 Posted March 3, 2014 Share Posted March 3, 2014 You forgot to set the PhysicsMode. I think you can also release the shape after setting it to save a bit memory. ballmodel=Model::Load("Models/ball.mdl"); ballmodel->SetPosition(0,3,0); ballmodel->SetPhysicsMode(Entity::RigidBodyPhysics); ballmodel->SetMass(1); ballmodel->SetCollisionType(1); shape=Shape::Load("Models/ball.phy"); ballmodel->SetShape(shape); shape->Release(); Hope that helps. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted March 3, 2014 Author Share Posted March 3, 2014 Thanks. Will try it. Odd though that Aggror's tutorial (linked above) didn't need that line. Maybe it's different with loaded models versus ones generated on the fly? Quote Link to comment Share on other sites More sharing options...
gamecreator Posted March 4, 2014 Author Share Posted March 4, 2014 So good thought but the SetPhysicsMode wasn't necessary. What was necessary was to set the ball to ConvexHull, not Polymesh (seems like I said I tried this in the original post but apparently not). Otherwise it wouldn't fall. It also seems that loading the PHY files yourself is also necessary (though the documentation doesn't do it here). Here's the project: https://www.mediafire.com/?ifbf4eyeee3obg1 If you press the spacebar it will dynamically generate a falling sphere without loading a model (mostly copied from Aggror's code). Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 4, 2014 Share Posted March 4, 2014 I create bullets that collides at runtime : they work and are prefabs. They are simple 3D model spheres without no physhape : i just put in collision tab panel : shape = sphere type = prop mass = 0.2 If you do like that and make it a prefab and load it it will work. Perhaps it's a bug with Physhape loading ? Quote Stop toying and make games Link to comment Share on other sites More sharing options...
beo6 Posted March 4, 2014 Share Posted March 4, 2014 That is definitely odd. I guess rigidBodyPhysics is the default so it makes sense that it is not required. However that it does not work with a polymesh is odd. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted March 4, 2014 Author Share Posted March 4, 2014 Next step was to rotate the floor but I can't figure that out either. It seems like if I set the mass to 0 so the floor won't move then it also won't rotate. If I set it to 1 then it falls. Ok, so I use PhysicsSetPosition to keep it in place. But then I have to set the mass to some large number so ball won't just push it around. Fair enough. Then I try to use the following code: if(window->KeyDown(Key:)) levelmodel->PhysicsSetRotation(-1000,0,0,0.1f); if(window->KeyDown(Key:)) levelmodel->PhysicsSetRotation(1000,0,0,0.1f); But that doesn't seem to work on Polymeshes, only Convex Hulls (which isn't what I need). I need to use a Polymesh because my model has columns so it's not convex. Thoughts? Screenshot to better give you an idea of what I'm working with: Quote Link to comment Share on other sites More sharing options...
YouGroove Posted March 4, 2014 Share Posted March 4, 2014 I even tried that style of game in LE3 for someone also trying t do this game type and we had also some issues (old thread) You should keep level as static no rotation, no move. And fake level rotation or move, by rotating camera only and applying forces to the ball function of camera angles. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
gamecreator Posted March 4, 2014 Author Share Posted March 4, 2014 This is either a bug or my lack of understanding on how things work. I'd love for Josh to weigh in on which it is. If it's a bug, I'm happy to put a clearer, thorough report in the bug forum. In either case, both Convex and Poly should be able to be controlled with the very basics: moved or not moved and rotated. Quote Link to comment Share on other sites More sharing options...
Michael_J Posted March 4, 2014 Share Posted March 4, 2014 PolyMesh is for non-moving meshes only (eg static level geometry). ConvexHull should work, but obviously you won't have any concave elements. What needs to happen (and I believe Josh said he would be re-implementing it) is to be able to use Convex Decomposition. What this does is take a concave mesh, break it apart into multiple optimized convex elements, and then use those pieces with Newton's ability to combine multiple shapes for one object. For now, I THINK, you'd have to break your column elements into separate objects and link them to the parent floor... Quote --"There is no spoon" Link to comment Share on other sites More sharing options...
gamecreator Posted March 4, 2014 Author Share Posted March 4, 2014 Thank you Michael. I was slowly coming to the same conclusion. There really needs to be a "movable PolyMesh" solution. Interesting to note that the PolyMesh documentation suggests using Shape::ConvexDecomposition() but there's no documentation for that function yet. 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.