Two *simple* questions in one complicated thread!

Blitz3D Forums/Blitz3D Beginners Area/Two *simple* questions in one complicated thread!

Buggy(Posted 2006) [#1]
Hey again. I know I ask a lot of questions here, and I know that in the past I've asked a ton of questions about ball physics for complete idiots and received tremendous support - to no avail. My skull just seems to thick to grasp your suggestions. In other words, I am a beginner programmer and I am stupid.

Anyway, I'm at it again, hopelessly trying to comprehend basic ball physics.

1. I have forward/backwards physics down (with an inertia variable that is added to the ball every frame), and I could probably figure out side-to-side physics on my own if the need arises. But I'm completely stumped with up 'n' down physics!

How does the computer increase the ball's speed when going off a ramp, but keep it rolling down (I suppose with a gravity# variable), and how on earth does the computer detect the difference between the ball rolling into a wall or building and - say - a slight hill that it can roll over?

My second question is much simpler.

2. What would be a good, FREE modellor to use to make both character models and terrains and levels? Would Blender be good?


H&K(Posted 2006) [#2]
http://www.physicsclassroom.com/Class/vectors/U3L2a.html

But My main advice would be to get one of the Physics wrappers/Mods, and use them


Buggy(Posted 2006) [#3]
Thanks H&K, but that physics lesson only works with projectiles. I can do that fine; I simply have trouble with the part where the sphere detects how to go off of a ramp, or bounce when it hits the ground.

I also want to figure out my own physics.


Dreamora(Posted 2006) [#4]
1. That all bases on the collision normal. The normal tells in which direction the surface of the collision is pointing ...

2. I don't know many modelers that create usefull terrains at all. Normally using a terrain editor is the much better choice (if Free then FLE / CLE if still available or create an own one but I would really suggest T.ED as it has superb functionality and a quite low price)


H&K(Posted 2006) [#5]
When the sphere leaves the ramp it IS a projectile. But now I see that you dont mean explain the physic, you mean explain how to program the physic.


Stevie G(Posted 2006) [#6]
Buggy,

There is code in the archives which will give you a start. In particular the bouncing code.

This ..

http://www.blitzbasic.com/codearcs/codearcs.php?code=856

An this ..

http://www.blitzbasic.com/codearcs/codearcs.php?code=670

Stevie


Buggy(Posted 2006) [#7]
Know, I know the physics and could program them if I only understood, say, how a ball can go off of a ramp and continue going up before it goes down again. That sort of thing. Thanks, Stevie, but Jeppe Nielson's code is way over my head.

Thanks anyway you guys.


Stevie G(Posted 2006) [#8]
Buggy,

I can knock something up for you if you want .. won't be until the weekend though?

Stevie


skidracer(Posted 2006) [#9]
It's called inertia. When an object is moving in a certain direction at a certain speed it will continue to do so until other forces are applied.

When the ball is rolling up the ramp at its current speed gravity continously pulls it down and the ramp surface pushes it away.

When the ball leaves the ramp say at 5 metres per second west and 2 metres per second up the force of the ramp stops having any impact and the force of gravity continues, increasing the balls vertical speed downwards at the rate of 10 meters per second per second, so the balls speed changes from upwards to downwards over time and its position describes an arc.

It's not that simple as it took a guy called Newton in the 1700's to figure out the basic laws of motion.

The trick programattically is to have variables both for the balls position and it's speed for each axis of direction (x,y and z), add the speed to the position every frame and then apply the forces as described to the balls speed variables.


Buggy(Posted 2006) [#10]
Thanks skidracer, but I understand the concept. What I don't understand is how to know how much to increase its upwards inertia by as it goes up the ramp. It has to be a value specific to that ramp so that different ramps will have different values respective to their size.

I suppose I could have the x position in one frame and the x position of another frame and find the difference for the inertia, but this seems tedious, as I would have to do it every frame. I would then only apply the inertia when it's not on the ramp anymore. However, it seems like if I did that, and the ball fell off the side of the ramp, it would keep going up for a while.

Hmmph.


GfK(Posted 2006) [#11]
However, it seems like if I did that, and the ball fell off the side of the ramp, it would keep going up for a while.
...which would of course be completely correct.

I think you need to read up on kinetic energy, gravity and friction. You need to understand clearly how these apply in the real world before you start trying to accurately simulate it.


Buggy(Posted 2006) [#12]
Yes, Gfk, you're right... I wasn't thinking.

Still, guys, I just need to know how the computer can determine how much to increase the ball's upward inertia.

Could I somehow determine the slope of the ramp by getting it's "normal"? I don't know much about normals, but I think this might work.

And as for question two, is there a quality, FREE, 3D modellor that I could use for creating static and animated models and save in something that works well with blitz like .B3D? Sorry if that limits things a bit.

Is DeleD a good one?


Buggy(Posted 2006) [#13]
I know I'm being annoying, but if I understand this, I won't be asking questions for a while!

Still, guys, I just need to know how the computer can determine how much to increase the ball's upward inertia.

Could I somehow determine the slope of the ramp by getting it's "normal"? I don't know much about normals, but I think this might work.



Damien Sturdy(Posted 2006) [#14]
Buggy, Some hints:

I use blitz collisions to prevent the ball from going underneith a floor, the difference in the height of the ball (between the last frame and the current frame) should be added to the Y inertia, along with gravity.

So,

Yspeed=(NewY-OldY)-0.98
Y=Y+Yspeed


This solves your height/ramp problem.

Now, for the bounce:

If the ball has collided, Yspeed=-(Yspeed*0.5) which causes the ball to rebound back up in the opposide Y direction.

Check out blitz collisions :)


Buggy(Posted 2006) [#15]
That sounds as if it might work, however, take the example that the ball is rolling up a ramp. The y speed is 1. Now, since it is touching the ramp, it tries to bounce, and everything is messed up. I guess I could do a "if it wasn't touching last frame, but is touching this frame, then bounce" thing, but that seems inefficient.

Thanks for the help, though.


Damien Sturdy(Posted 2006) [#16]
Well, you will need to play with it to get it working properly, You'll need to use blitz collision information to tell where the ball actually hit- a ceiling? A wall? A floor? The collision information will enable you to make it bounce in the right direction :)

If you understood my last post, you're on your way! :)


Buggy(Posted 2006) [#17]
I think I do! What, however, exactly do you mean by "blitz collision information"?

Anyway, thanks for listening.


Damien Sturdy(Posted 2006) [#18]
Blitz collisions allow you to know the exact point of collision;

CollisionX, Collision Y and Collision Z.

CollisionNX, collisionNY and collisionNZ also exist, these give you the direction the surface the ball hit faces...

Use this info to make the ball bounce in the right direction.

(sorry if this seems rushed!)