entityvisible.bmx 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ' entityvisible.bmx
  2. ' from minib3d examples
  3. Strict
  4. Framework b3d.b3dglgraphics
  5. Local width%=800,height%=600,depth%=0,Mode%=2
  6. Graphics3D width,height,depth,Mode
  7. Local light:TLight=CreateLight(1)
  8. RotateEntity light,90,0,0
  9. Local cam:TCamera=CreateCamera()
  10. PositionEntity cam,0,10,-10
  11. Local sphere1:TMesh=CreateSphere()
  12. PositionEntity sphere1,0,0,-2
  13. EntityColor sphere1,255,0,0
  14. Local box:TMesh=CreateCube()
  15. ScaleMesh box,2,1.5,0.5
  16. EntityPickMode box,2,True
  17. Local sphere2:TMesh=CreateSphere()
  18. PositionEntity sphere2,0,0,2
  19. EntityColor sphere2,0,255,0
  20. PointEntity cam,sphere2
  21. While Not KeyHit(KEY_ESCAPE)
  22. If KeyDown(KEY_LEFT) Then MoveEntity box,-0.1,0,0
  23. If KeyDown(KEY_RIGHT) Then MoveEntity box,0.1,0,0
  24. Local visible%=EntityVisible(sphere1,sphere2)
  25. RenderWorld
  26. Text 0,0,"Use left/right cursor keys to move block"
  27. If visible=True
  28. Text 0,20,"Balls can see each other"
  29. Else
  30. Text 0,20,"Balls can't see each other"
  31. EndIf
  32. Flip
  33. Wend
  34. End