Hello Saturba,
English is not my native language so I am not entirely sure what you were asking but I will try to answear what I think you were asking
🙂I have no idea what "shocker" or "shockers" meen in this context (I tried to look it up but it doesn´t make any sense to me) but if I am correct you are asking how I built the car (?)
The car has three bodies: The Right wheel, left wheel and the body. Each wheel are connected to the body using three joints. The distance joint to make for a nice suspension, the prismatic joint to keep the wheels in place and a revolute joint so the wheels can spin.
Now if you know Box2d you will know the prismatic joint prevents any relative rotation and this is solved by adding two other bodys for each wheel that you will connect the prismatic and the distance joint to and then connect that part to a revolute joint that is connected to the wheel.
Now again, if you know Box2d or just try what I said, you will notice that the revolute joint quickly becomes unstable when large forces is put on to it so each frame I have to place the wheels on the same position as the helperbody I was just explaining.
Now for concave shapes: All bodys with concave shapes are constucted from many convex shapes (obviesly). This is done by a tesselation algorithm. Here it is in pseode code: Basicly you just have a list with all the vertieces in clockwise order:
Code:
Array<Vector2> OriginalPolygon
/*
This is the Array of Vertices, specified in clockwise order, that specifies a polygon.
This is the original polygon that may be concave and/or have more Vertices than 8 (the maximum alowed number of vertices per shape in Box2d
*/
Array<Array<Vector2> > ReturnPolygon
/*
This is the polygon splitted into a number of convex polygons that the function will return.
*/
int Index = 0; // Start at the first Vertex
while(OriginalPolygon consists of more than 2 vertices AND // As long as the OriginalPolygon consists of more than 2 vertices there will be more polygons to add to ReturnPolygon
Index < OriginalPolygons size) // If Index becomes larger than the OriginalPolygons size the function has failed (this means probably that you have specified the Vertices is CCW order or that The polygons lines may be overlapping each other)
{
Array<Vector2> TempPolygon // A temporary polygon we will fill with vertices and maybe add this array to the ReturnPolygon
int TempIndex = Index;
/*
Add the first three Vertices from Original Polygon
*/
TempPolygon.AddVertex(OriginalPolygon[TempIndex ]);
TempIndex++;
TempPolygon.AddVertex(OriginalPolygon[TempIndex]);
TempIndex++;
TempPolygon.AddVertex(OriginalPolygon[TempIndex ]);
TempIndex++;
if(TempPolygon is Convex AND TempPolygons Vertices is specified in CW order AND TempPolygon doesn´t contain any of the OriginalPolygons vertices)
{
foreach more Vertex in OriginalPolygon do
{
if(TempPolygons size < 8) // maximum number of vertices per shape in Box2d
break;
else
{
Add Vertex to TempPolygon;
if((TempPolygon is Convex AND TempPolygons Vertices is specified in CW order AND TempPolygon doesn´t contain any of the OriginalPolygons vertices) == FALSE)
{
Remove Vertex From TempPolygon;
break;
}
}
}
Add TempPolygon to ReturnPolygon;
Keep TempPolygons first and last Vertex but remove all the rest from Original Polygon;
Index = 0;
}
else
{
Index++; //The TempPolygon was invalid so we trie with the next vertices
}
}
360 degree movement:
Use "ApplyTorque" instead.