Vertlet Vertex Help

Blitz3D Forums/Blitz3D Programming/Vertlet Vertex Help

LostCargo(Posted 2003) [#1]
I am trying to write a simple car / truck physics engine for my a game, and am having some difficulty figuring out how to get the wheels aligning to the car propperly when a curb is hit, etc. Basicly, i need to learn a bit more about vertex/vertlet style collisions.

can anyone provide a good example (or tutorial) that is a bit less complicated than sswifts demo? Im not looking to reproduce real physics, i just want get mesh to mesh physics happening so i can drive up hills , roll the car and hit things, without the wheels comming off or getting skewed (wheels are children of the car mesh).


dmc(Posted 2003) [#2]
use a pivot for the collision entity that will be tied to each point mass (or verlet) in your structure. give your pivot a collision radius that is exactly the same as the radius of your tire model. then load in the tire model mesh and parent it to that pivot. to align the tire use align to vector. to get the two axis needed for align to vector pick two sets of two point masses (or verlets) and store off there coords in a variable. send those variables as the arguments to you align to vector call.

as the pivot collides with your ground objects it will react to the collided surface when you call update world. since the tire mesh is parented to the pivot it will follow its position. so the align to vector is called last so it orients properly after collision has been handled.

does this answer your question?


LostCargo(Posted 2003) [#3]
dmc,
It answers my question on how to keep the car level. Yes.
But im having difficulty keeping the tires under the car. Ie
Lets say the car drives towards a sidewalk. the tires hit the sidewalk (or short wall) and stop. The body moves forwards. Now the tires are no longer aligned to the places that they need to be.

I guess my problem is more on how to get an object with children to be effected or rotate when the children hit something. sswifts solution uses vertlet collisions well. But im looking for something a bit more dumbed down that i can use as an example of how vertlets work .


dmc(Posted 2003) [#4]
no it wont. since the pivot that hit the curb is being held against the curb by the blitz collision response and the car is still travelling a forward a little until the springs can push back enough to bring it to a halt the tire will continue to appear to be pushed back.

a simple way to control this is to first record the tires position relative to a master pivot that is tied to the verlet structures center position. then have a routine that allows the tire to bounce up and down (its got a suspension so thats what we want) but to not allow it to move forward or back from the recorded position relative to the master pivot.

in much simpler terms, dont allow the tire to move forward/back or left/right. only allow it to move up and down.


dmc(Posted 2003) [#5]
btw the code your thinking swift wrote was actually written by me. he helped clean it up and hosted it since i didnt have any web hosting.


dmc(Posted 2003) [#6]
i think i see what is confusing you. boy this is gonna be tough to explain... ill give it a shot.

ok the biggest thing that caused me grief when making the car project was how do we derive and orientation and position from a structure that has no clue about its orientation. also since its made of nothing more than point masses and simple springs it does not have a central mass we can easily call its center of gravity.

so the center of gravity part is the easiest to solve. we use a point mass where we want the center of gravity for the object to be and store that off in a user type that defines it as our vehicles CG. all position calculation such as speed are derived from the position of this point mass. ok so now we got position handled. we know where our vehicle is in the world. but we still dont have a clue about its orientation. nor do we know much about the other point masses other than they are connected to the center.

so to solve orientation we use the align to vector trick that was mentioned earlier. it sounds like you understand part. but that still doesnt help us make good decisions on how to handle all the other "parts" of the vehicle. so the trick is to get two measurement systems running parralell to each other. one will be our global coordinates, and the other will be coordinates that are relative to the CG of the vehicle. you can easily swap between them with the functions transform vector, transformpoint etc. use the master pivot as the local axis system. this is easily done if we have aligned it properly before we swap axis systems.

so anyways ive prolly lost you by now =). but the goal of all this is so we can position things properly so they make sense visually. dont think of it as a parent child relationship. think of it as two axis systems and youll be on track to figuring it out.

also here is where i got my start from
http://www.blitzbasic.com/codearcs/codearcs.php?code=688
miracle took an article from the web and wrote up a blitz version. thats a great place to start since the code isnt as long or as specialized and mine.


LostCargo(Posted 2003) [#7]
thanks dmc. Your explaination was good. and i understood it. I was using terrainY in my landscape / car program to keep the wheels vertically under the vehicle.

Ill rethink my approach using what you have suggested. I think i am just mucking up where i am calling the update to the actual car.

I liked the car physics project btw. its pretty cool!