Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / [DB classic] Cylinder code question

Author
Message
JoshW
18
Years of Service
User Offline
Joined: 13th Feb 2007
Location:
Posted: 13th Feb 2007 11:49
I'm trying to model a cylinder that rolls/bounces down a matrix. (I don't need a general physics model as I don't need to roll anything other than cylinders.) I've tried searching the boards & the code snippets. I've got the example code for sliding objects & am trying to modify that, but was wondering if anyone else has already solved this problem.

Thanks for any help

Josh
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Feb 2007 08:23 Edited at: 14th Feb 2007 09:49
Hello JoshW,

Now I haven't tried this idea out, it just came to me after I read your post.

If you are only worried about a matrix as the ground and a cylinder, you wouldn't necessarily need sliding collision. You could basically use GET GROUND HEIGHT (of the matrix) to determine what happens between the cylinder and the matrix.

The theory is something like this:

You need to know the size of the cylinder. You should make an invisible cone that the cylinder sits on top of dead center of the cylinder. The matrix should be larger that the cylinder, but it doesn't have to be.

With me so far? Ok, if the matrix is bumpy, it will have varying heights (y values) at different locations. The key is to use GET GROUND HEIGHT for whereever the cylinder is at any given time, and based on the height from the center of the cylinder or at either end, rotate the cylinder more the higher the ground is at a specific end, and if it's higher in the middle, raise the cylinder up on the y axis. It would be helpful to position or rather attach the cylinder on top of an invisible cone that serves as the pivot point.

You move the cone down the matrix (with the cylinder attached to it) and pivot (rotate) the cylinder either end as the ground height changes. Then if the ground height goes up directly under the center of the cylinder (the cone) you raise the whole apparatus.

I mentioned you need to know the size of the cylinder - that is so you can calculate the ground height from the center (the cone) of the cylinder to either end.

Does this make any sense?

Now that I've written this, maybe I'll throw together a demo of what I'm talking about.

[EIDT]
Ok, I've created the demo. I didn't use the pivot cone, I didn't actually need it for this demo. This example pretty much fits the bill of what I was talking about. You can make it more complex to suit your needs - account for the cylinder changing angles, changing slopes and speeds, etc.



Enjoy your day.

Login to post a reply

Server time is: 2025-05-26 03:18:14
Your offset time is: 2025-05-26 03:18:14