; EntityClass Example ; ------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-8 light=CreateLight() RotateEntity light,45,45,0 ; A little scene holding several different kinds of entity ground=CreatePlane() EntityPickMode ground,2 crate=CreateCube() PositionEntity crate,-2.5,1,0 EntityPickMode crate,2 ball=CreateSphere(16) PositionEntity ball,2.5,1,0 EntityPickMode ball,2 ; Not geometry at all - EntityClass is how you tell these from meshes marker=CreatePivot() PositionEntity marker,0,1,0 While Not KeyDown(1) TurnEntity crate,0,1,0 ; Shoot a pick ray through the mouse pointer, like a click-to-select cursor CameraPick camera,MouseX(),MouseY() ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Point the mouse at the crate, the ball or the floor Arrows: camera Esc: exit" hit=PickedEntity() If hit<>0 ; EntityClass names the kind of entity behind a handle you were handed Text 0,20,"EntityClass(PickedEntity()) = "+Chr$(34)+EntityClass(hit)+Chr$(34) Else Text 0,20,"Nothing under the pointer - EntityClass needs a real handle" EndIf Text 0,40,"camera -> "+EntityClass(camera)+" light -> "+EntityClass(light)+" marker -> "+EntityClass(marker) Text 0,60,"ground -> "+EntityClass(ground)+" crate -> "+EntityClass(crate)+" ball -> "+EntityClass(ball) Flip Wend End