verlets......for beginners.

Blitz3D Forums/Blitz3D Programming/verlets......for beginners.

Hello. This topic is dedicated to all of those who said..."this is tooooooo hard!!!! I'm just going to GIVE UP!!!" I'll tell ya. I was on the verge of giving up. Inspired by all of the people who need/needed help... I've started working on a verlet tutorial. It has many parts to it. It starts of REALLY easy then works its way up to Intermediate, then Hard. I reacently just discovered the Verlet Integration Theory, but through hours of hard work, I have cracked the Verlet Integration Theory. I would like to thank all of the people on the blitz website that talked about verlets and gave examples. For without them, I wouldn't have made it this far.

As soon as I am done with a part of the tutorial, I will post it here, in a code box. "Why would you put it in a code box?" You might ask, well, I don't want to go through the process of uploading it. I don't know how. So here you go.



Part I:

This text file is dedicated to all of those who want to learn verlets but could not figure out all of the hard examples out there.

----------------------------------------------------------------------------------------------------------------------------------

Verlet:

Think of a verlet as a "dot". Whenever I refer to a verlet, I want you to think of a "dot" (in 3D space or in 2D space;it doesn't matter what dimension).

Verlet Cage:

A verlet cage is simply an abstract shape of verlets ("dots", remember). A verlet cage is used to orient an object. Usually verlet cages are assigned to RigidBodies.

Rigid Bodies:

Rigid Bodies are a collection of verlets. They are usually made up of one verlet cage (again: a "dot" cage). The use of a  rigid body is to parent it to an entity.
An example of a Rigid Body's parent would be a vehicle. Here is an explanation:


I want a car. Not just any car, I want a car that will tilt and react to a suface. To do that I would: setup a Rigid Body (filled with verlets, that make a verlet cage),
then parent that Rigid Body to my car. The verlets on the rigid body would have constant gravity pulling down on them. With the verlets parented to the Rigid
Body, and the Rigid Body parented to the car, whenever my verlets go down, my car would also go down. In order for my car to tilt with my Rigid Body, I would
probably use AlignToVector to do that. The reason for that is because an entity (my car) can not have more than one parent (without messing something up).
So, parenting an entity to other entities is a bad idea. Instead we would probably use AlignToVector to do that. I will show you that momentarily.

Constraints:

You might be wondering...If a verlet collides with something, how does it not get "out-of-whack". Well, it does, but that is what a constraint is for :)
Constraints are for binding verlets together so they stay the same distance between eachother. A tactic I've learned through reaserch is that it is a good
idea to have a central verlet.  You will understand later.

Review:

So let's review: Verlets are held together by Constraints, mulitple verlets,binded together into one abstract stucture is called a Verlet Cage, a verlet cage
is binded to a Rigid Body, and the Rigid Body is parented to the car.

Reviel:

Whenever I said "...and the Rigid Body is parented to the car", well I lied. A Rigid Body is a structure that holds a verlet cage, BUT...it is the object
you made the verlets for. Sorry I'm confusing you. So a Rigid Body would be my car I talked about. Another example would be:

I wanted a monster truck. I need verlets to add physics to it. I would setup a verlet cage (dot cage), and parent that verlet cage to my rigid body. So
in this case my Rigid Body would be my moster truck.

Summery:

You now know what's a: verlet,constraint,verlet cage, and a rigid body. If you don't then you should go back and review. Becuase in my next tutorial I will
be getting deeper into the Verlet Integration Theory (which is what you are learning about right now).

Closing:

Seeeeyyyaaa.





Part II:

In this part, we will cover how to setup everything.
We will be making a verlet physics engine. Here is how we will do it.

Setting Up Verlets:

Ok, so you know all of the terms that will be used in this part. Let's dive into verlets.

For our verlets, let's have a Type for them. (Their fields will be explained shortly)

Type Verlet_Type

	Field x#,y#,z#
	Field ox#,oy#,oz#
	Field xv#,yv#,zv#
	Field ent

End Type

Ok, I'll explain the fields:

x,y,z: The 3d positioning of the verlet
ox,oy,oz: The old 3d positioning values of the verlet
xv,yv,zv: The 3d velocities of the verlet
ent: The entity of the verlet

Setting Up Constraints:

Now let's cover constraints.

Here is our Type for a constraint:

Type Constraint_Type

	Field v1.Verlet_Type
	Field v2.Verlet_Type
	Field length#

End Type

Fields:

v1.Verlet_Type: The first verlet to be constrained
v2.Verlet_Type: The second verlet to be constrained
length: the length of the constraint

Setting Up Rigid Bodies:

Here is the tricky one: a rigid body.

Note that in our verlet cages we will have many verlets.
Some with special uses too.

Here is the Type for our rigid body.

Type RigidBody_Type

	Field v1.Verlet_Type,v2.Verlet_Type,v3.Verlet_Type,v4.Verlet_Type
	Field cv.Verlet_Type
	Field x#,y#,z#
	Field ox#,oy#,oz#
	Field xv#,yv#,zv#
	Field ent,parent

End Type

Fields:

All of the verlets (v1,v2...etc) are the verlets of the verlet cage of the rigid body.
cv.Verlet_Type: central verlet (will help with constraining the verlets
x#,y#,z#: 3d position of the rigid body
ox#,oy#,oz#: old 3d position of the rigid body
xv#,yv#,zv#: 3d velocities of the rigid body
ent,parent: the entity and parent of the rigid body

Review:

O.K. So know you know how to setup: verlets,constraints, and rigid bodies.

Summery:

Woah. That's alot of stuff we just covered. Study-Up before proceeding to the next part. In my next part I will be talking about how to create everything.
Wheras, in this part, we coverd: how to setup everything.

Seeeyyyyaaa.


You could perhaps also put it in the code archives so that it doesn't get lost in the forum history over time...

There's a tutorials section you could put this in.

Also, use a spell checker and perhaps include some diagrams so that people can visualise what our talking about.

And you shouldn't explain everything in a codebox, keep the explanations out of the code and show snippets, when your done post some working code.

Good Idea. But I'm not actually explaining everything in the code. I just add code with my explanation. As for the spelling, I'm doing it in notepad.