osrviewport.adoc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. = osrviewport
  2. :revnumber: 2.0
  3. :revdate: 2020/07/25
  4. == OSRViewPort
  5. The OSRViewPort allows you to create a movable, resizable ViewPort with the ability to control the camera's rotation and zoom features via mouse input.
  6. To initialize the OSRViewPort you can call one of the 3 standard constructors as shown in the xref:gui/tonegodgui/quickstart.adoc[Quick Start Guide].
  7. *Constructor 1:*
  8. [source,java]
  9. ----
  10. /** Parameters:
  11. * Screen screen,
  12. * String UID,
  13. * Vector2f position
  14. */
  15. OSRViewPort vp = new OSRViewPort(screen, "vp", new Vector2f(15, 15));
  16. ----
  17. *Constructor 2:*
  18. [source,java]
  19. ----
  20. /** Additional Parameter:
  21. * Vector2f dimensions */
  22. OSRViewPort vp = new OSRViewPort(screen, "vp", new Vector2f(15, 15),
  23. new Vector2f(150, 150)
  24. );
  25. ----
  26. *Constructor 3:*
  27. [source,java]
  28. ----
  29. /** Additional Parameters:
  30. * Vector4f resizeBorders,
  31. * String defaultImg
  32. */
  33. OSRViewPort vp = new OSRViewPort(screen, "vp", new Vector2f(15, 15), new Vector2f(150, 150),
  34. new Vector4f(0,0,0,0),
  35. "imagePathToOverlayImage"
  36. );
  37. ----
  38. Once initialized, you will want to active the OSRBridge for off-screen rendering of your new scene:
  39. [source,java]
  40. ----
  41. vp.setOSRBridge(Node newScene, int renderWidth, int renderHeight);
  42. ----
  43. === The ViewPort’s Camera control methods:
  44. [source,java]
  45. ----
  46. vp.setUseCameraControlRotate(boolean rotateEnabled); // enable/disable rotation control
  47. vp.setUseCameraControlZoom(boolean zoomEnabled); // enable/disable zoom control
  48. vp.setCameraDistance(float distance);
  49. vp.setCameraHorizonalRotation(float angleInRads);
  50. vp.setCameraVerticalRotation(float angleInRads);
  51. vp.setCameraMinDistance(float distance);
  52. vp.setCameraMaxDistance(float distance);
  53. vp.setCameraMinVerticalRotation(float angleInRads);
  54. vp.setCameraMaxVerticalRotation(float angleInRads);
  55. ----
  56. === Other methods:
  57. [source,java]
  58. ----
  59. vp.setBackgroundColor(ColorRGBA color); // ViewPort is transparent by default
  60. ----