help/commands/3d_examples
JointMotor.abs
67 lines of ArcBasic. Words in colour that are commands link to their help page. To run it, download ArcBasic, open the file and press F5.
; Joint motors, limits and springs example (an ArcBasic extension); A windmill turned by a motor, a lift that goes up and down between its; limits, and a springy platform. Up/Down change the windmill's speedGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,5,-16TurnEntity camera,10,0,0light=CreateLight()RotateEntity light,50,30,0ground=CreatePlane()EntityColor ground,80,80,110EntityPhysics ground,1; the windmill: sails on a hinge facing the camera, driven by a motortower=CreateCube() : ScaleEntity tower,.3,3,.3 : PositionEntity tower,-5,3,1 : EntityPhysics tower,1sails=CreatePivot()PositionEntity sails,-5,6,0For i=0 To 3 blade=CreateCube(sails) ScaleEntity blade,.25,1.6,.05 TurnEntity blade,0,0,i*90 MoveEntity blade,0,1.6,0 EntityColor blade,240,240,250NextEntityPhysics sails,2,2mill=HingeJoint(sails,0,-5,6,0,0,0,1)speed#=60JointMotor mill,speed,400; the lift: a platform on a slider that moves between 0 and 4 units uplift=CreateCube() : ScaleEntity lift,1.2,.1,1.2 : PositionEntity lift,1,.2,0EntityColor lift,255,180,60EntityPhysics lift,2,5shaft=SliderJoint(lift,0,0,1,0)JointLimits shaft,0,4JointMotor shaft,1.5,400crate=CreateCube() : ScaleEntity crate,.4,.4,.4 : PositionEntity crate,1,.8,0 : EntityPhysics crate,2; a springy platform: drop crates on it with Spacepad=CreateCube() : ScaleEntity pad,1.2,.1,1.2 : PositionEntity pad,6,2,0EntityColor pad,90,220,140EntityPhysics pad,2,2bounce=SliderJoint(pad,0,0,1,0)JointSpring bounce,150,2While Not KeyHit(1) If KeyDown(200) Then speed=speed+2 : JointMotor mill,speed,400 If KeyDown(208) Then speed=speed-2 : JointMotor mill,speed,400 ; turn the lift round at the ends of its travel If JointPosition(shaft)>3.95 Then JointMotor shaft,-1.5,400 If JointPosition(shaft)<.05 Then JointMotor shaft,1.5,400 If KeyHit(57) c=CreateCube() : ScaleEntity c,.3,.3,.3 : PositionEntity c,6+Rnd(-.5,.5),6,Rnd(-.3,.3) EntityPhysics c,2 EndIf UpdateWorld RenderWorld Text 0,0,"Up/Down: windmill speed "+Int(speed)+" degrees a second Space: drop a crate on the spring" Text 0,15,"Sails at "+Int(JointPosition(mill))+" degrees, lift at "+JointPosition(shaft) FlipWendEnd
