AddEntityShape
Adds another shape to a physics body.
AddEntityShape entity,shape[,x#][,y#][,z#][,offset_x#][,offset_y#][,offset_z#][,pitch#][,yaw#][,roll#]
Parameters
- entity
- entity handle
- shape
- 0: automatic, 1: box, 2: sphere, 3: capsule, 4: cylinder, 5: hull, 6: mesh
- x#, y#, z# (optional)
- size of the shape; see below. Leave them out to fit the shape around the entity's mesh.
- offset_x#, offset_y#, offset_z# (optional)
- where the shape sits, relative to the entity, in the entity's own units
- pitch#, yaw#, roll# (optional)
- how the shape is turned, relative to the entity
Description
Adds another shape to an entity's physics body, so one body can be made of several: a table from a top and four legs, a dumbbell from two spheres and a cylinder, a car from a body and wheels. The parameters are as for EntityShape.
Shapes added to a body still using its automatic shape keep the automatic one as well. To build a body only from shapes you choose, set the first with EntityShape and add the rest.
Shapes with a size of their own are the ones to place with offsets and turn; a fitted shape already sits around the mesh. PhysicsDebug shows where every shape is.
Example
; Physics shapes example (an ArcBasic extension); A table made of five boxes, and a ball that rolls under it. D shows the shapesGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,4,-9TurnEntity camera,20,0,0light=CreateLight()RotateEntity light,50,30,0ground=CreatePlane()EntityColor ground,80,120,80EntityPhysics ground,1; the table is a pivot with a top and four legs as children, for looks...table=CreatePivot()top=CreateCube(table) : ScaleEntity top,2,.1,1 : PositionEntity top,0,2,0For x=-1 To 1 Step 2 For z=-1 To 1 Step 2 leg=CreateCube(table) : ScaleEntity leg,.1,1,.1 : PositionEntity leg,x*1.8,1,z*.8 NextNextEntityColor top,160,110,60PositionEntity table,0,3,0TurnEntity table,0,20,8; ...and one body built from five boxes, so there is room underneathEntityPhysics table,2,5EntityShape table,1,4,.2,2,0,2,0For x=-1 To 1 Step 2 For z=-1 To 1 Step 2 AddEntityShape table,1,.2,2,.2,x*1.8,1,z*.8 NextNextball=CreateSphere(12)ScaleEntity ball,.4,.4,.4PositionEntity ball,-6,.4,0EntityColor ball,250,200,60EntityPhysics ball,2debug=FalseWhile Not KeyHit(1) If KeyHit(57) Then SetEntityVelocity ball,6,0,0 If KeyHit(32) debug=Not debug PhysicsDebug debug EndIf UpdateWorld RenderWorld Text 0,0,"Space: roll the ball D: show the physics shapes" FlipWendEnd
