ArcBasicDocs
3DPhysics Soft BodiesArcBasic extension

SoftBodyPin

Fixes a soft body's vertex where it is.

SoftBodyPin ( entity,vertex[,pin] )

Parameters

entity
a soft body (see EntitySoftBody)
vertex
the index of the vertex in the first surface
pin (optional)
True (the default) fixes it, False lets it go

Description

Fixes a vertex of a soft body where it is, so cloth can hang from a rail, a flag can fly from a pole or a net can be tied at its corners. Let a pinned vertex go to drop it.

Example

SoftBodyPin.absOpen in editor
; Physics soft bodies example (an ArcBasic extension); A flag of cloth pinned to a pole, a balloon and a blob of jelly.; Space: a gust of wind   B: drop the balloon again   J: squash the jellyGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,4,-11TurnEntity camera,12,0,0light=CreateLight()RotateEntity light,50,30,0ground=CreatePlane()EntityColor ground,70,90,70EntityPhysics ground,1; the flag: a grid of vertices, pinned along the edge at the polepole=CreateCylinder(8)ScaleEntity pole,.08,3,.08PositionEntity pole,-4,3,0EntityPhysics pole,1Const N=12flag=CreateMesh()surf=CreateSurface(flag)For y=0 To N	For x=0 To N		AddVertex surf,-3.9+x*3.0/N,5.8-y*2.0/N,0,x/Float(N),y/Float(N)	NextNextFor y=0 To N-1	For x=0 To N-1		v=y*(N+1)+x		AddTriangle surf,v,v+1,v+N+2		AddTriangle surf,v,v+N+2,v+N+1	NextNextUpdateNormals flagEntityColor flag,230,60,80EntityFX flag,16EntitySoftBody flag,1,.9For y=0 To N	SoftBodyPin flag,y*(N+1)Next; a balloon: a closed mesh with air pressure inside, and a shelf for it to land onshelf=CreateCube()ScaleEntity shelf,.6,.6,.6PositionEntity shelf,1.5,.6,0EntityPhysics shelf,1balloon=CreateSphere(12)PositionEntity balloon,1.5,5,0EntityColor balloon,80,160,255EntitySoftBody balloon,1,.6,3; jelly: a squashed ball, soft and only lightly filled, so it wobbles; (soft bodies bend at their vertices: a plain cube has too few to wobble)jelly=CreateSphere(12)ScaleEntity jelly,1,.6,1PositionEntity jelly,4.5,.6,0EntityColor jelly,120,255,120EntityAlpha jelly,.8EntitySoftBody jelly,1,.4,2.5While Not KeyHit(1)	; a light breeze all the time, and a gust while Space is held	If KeyDown(57) Then ApplyForce flag,0,0,6 Else ApplyForce flag,1,0,.6	If KeyHit(48)		FreeEntity balloon		balloon=CreateSphere(12)		PositionEntity balloon,1.5,5,0		EntityColor balloon,80,160,255		EntitySoftBody balloon,1,.6,3	EndIf	If KeyHit(36) Then ApplyImpulse jelly,0,-8,0	UpdateWorld	RenderWorld	Text 0,0,"Space: gust of wind   B: drop the balloon again   J: squash the jelly"	FlipWendEnd

See also