Physics in Alternativa3D

This little experiment explores possibilities of Alternativa3D engine to simulate physics.

This is probably the simplest thing one could do – bouncing ball. Also, I have added previously developed custom sprite and light materials – you’re going to need them in case you plan to mess with sources.

The gist of this simulation can be seen in Ball class step() method code:

velocity.add (acceleration);
_collider.calculateDestination (position, velocity, _newPosition);
if (_collider.getCollision (position, velocity, _collision)) {
	// deflect the speed
	_doubleVelocityProjection.copy (_collision.normal);
	_doubleVelocityProjection.multiply (2 * Point3D.dot (
		_doubleVelocityProjection, velocity));
	velocity.subtract (_doubleVelocityProjection);
	// slow down
	velocity.multiply (damping);
}
position.copy (_newPosition);

This uses engine’s EllipsoidCollider class to resolve collisions with 3D objects in scene, and just a little bit of math to simulate massless gravity force and bouncing.

0 Responses to “Physics in Alternativa3D”



  1. Leave a Comment

Ask a Question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Old stuff

October 2008
M T W T F S S
    Nov »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Oh, btw…


%d bloggers like this: