Physics engine

Blitz3D Forums/Blitz3D Beginners Area/Physics engine

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I can't even imagine what a hurricane must be like, but we lost our roof and garage due to a tornado 2 years ago. One of the scariest things I've been through, and we had about 30 seconds of warning.

Anyways, to get back on topic,... I'm building a new verlet cage the uses a cube instead of the pyramid that is in the code above. Those will be my main cages that physics are applied to, since they will fit most objects in some fashion.

For the linking the mesh, you can use the verlet positions. There is an example of this in the blitz samples,... the driver.bb file in the mak directory specifically. In that example, a mesh body is aligned to four wheels. It is the same process to link a mesh body to a verlet cage.

Here is the code section that does the aligning

	;align car to wheels
	zx#=(EntityX( wheels[2],True )+EntityX( wheels[4],True ))/2
	zx=zx-(EntityX( wheels[1],True )+EntityX( wheels[3],True ))/2
	zy#=(EntityY( wheels[2],True )+EntityY( wheels[4],True ))/2
	zy=zy-(EntityY( wheels[1],True )+EntityY( wheels[3],True ))/2
	zz#=(EntityZ( wheels[2],True )+EntityZ( wheels[4],True ))/2
	zz=zz-(EntityZ( wheels[1],True )+EntityZ( wheels[3],True ))/2
	AlignToVector car,zx,zy,zz,1
	
	zx#=(EntityX( wheels[1],True )+EntityX( wheels[2],True ))/2
	zx=zx-(EntityX( wheels[3],True )+EntityX( wheels[4],True ))/2
	zy#=(EntityY( wheels[1],True )+EntityY( wheels[2],True ))/2
	zy=zy-(EntityY( wheels[3],True )+EntityY( wheels[4],True ))/2
	zz#=(EntityZ( wheels[1],True )+EntityZ( wheels[2],True ))/2
	zz=zz-(EntityZ( wheels[3],True )+EntityZ( wheels[4],True ))/2
	AlignToVector car,zx,zy,zz,3


What is happening here is that you need to get a vector along the x axis, align the mesh, and then get a z vector and align it again.