class_portal.rst 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Portal.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Portal:
  6. Portal
  7. ======
  8. **Inherits:** :ref:`Spatial<class_Spatial>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Portal nodes are used to enable visibility between :ref:`Room<class_Room>`\ s.
  10. Description
  11. -----------
  12. ``Portal``\ s are a special type of :ref:`MeshInstance<class_MeshInstance>` that allow the portal culling system to 'see' from one room to the next. They often correspond to doors and windows in level geometry. By only allowing :ref:`Camera<class_Camera>`\ s to see through portals, this allows the system to cull out all the objects in rooms that cannot be seen through portals. This is a form of **occlusion culling**, and can greatly increase performance.
  13. There are some limitations to the form of portals:
  14. They must be single sided convex polygons, and usually you would orientate their front faces **outward** from the :ref:`Room<class_Room>` they are placed in. The vertices should be positioned on a single plane (although their positioning does not have to be perfect).
  15. There is no need to place an opposite portal in an adjacent room, links are made two-way automatically.
  16. Properties
  17. ----------
  18. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  19. | :ref:`NodePath<class_NodePath>` | :ref:`linked_room<class_Portal_property_linked_room>` | ``NodePath("")`` |
  20. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  21. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`points<class_Portal_property_points>` | ``PoolVector2Array( 1, -1, 1, 1, -1, 1, -1, -1 )`` |
  22. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`portal_active<class_Portal_property_portal_active>` | ``true`` |
  24. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  25. | :ref:`float<class_float>` | :ref:`portal_margin<class_Portal_property_portal_margin>` | ``1.0`` |
  26. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`two_way<class_Portal_property_two_way>` | ``true`` |
  28. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`use_default_margin<class_Portal_property_use_default_margin>` | ``true`` |
  30. +-------------------------------------------------+---------------------------------------------------------------------+----------------------------------------------------+
  31. Methods
  32. -------
  33. +------+---------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_point<class_Portal_method_set_point>` **(** :ref:`int<class_int>` index, :ref:`Vector2<class_Vector2>` position **)** |
  35. +------+---------------------------------------------------------------------------------------------------------------------------------+
  36. Property Descriptions
  37. ---------------------
  38. .. _class_Portal_property_linked_room:
  39. - :ref:`NodePath<class_NodePath>` **linked_room**
  40. +-----------+------------------------+
  41. | *Default* | ``NodePath("")`` |
  42. +-----------+------------------------+
  43. | *Setter* | set_linked_room(value) |
  44. +-----------+------------------------+
  45. | *Getter* | get_linked_room() |
  46. +-----------+------------------------+
  47. This is a shortcut for setting the linked :ref:`Room<class_Room>` in the name of the ``Portal`` (the name is used during conversion).
  48. ----
  49. .. _class_Portal_property_points:
  50. - :ref:`PoolVector2Array<class_PoolVector2Array>` **points**
  51. +-----------+----------------------------------------------------+
  52. | *Default* | ``PoolVector2Array( 1, -1, 1, 1, -1, 1, -1, -1 )`` |
  53. +-----------+----------------------------------------------------+
  54. | *Setter* | set_points(value) |
  55. +-----------+----------------------------------------------------+
  56. | *Getter* | get_points() |
  57. +-----------+----------------------------------------------------+
  58. The points defining the shape of the ``Portal`` polygon (which should be convex).
  59. These are defined in 2D, with ``0,0`` being the origin of the ``Portal`` node's :ref:`Spatial.global_transform<class_Spatial_property_global_transform>`.
  60. **Note:** These raw points are sanitized for winding order internally.
  61. ----
  62. .. _class_Portal_property_portal_active:
  63. - :ref:`bool<class_bool>` **portal_active**
  64. +-----------+--------------------------+
  65. | *Default* | ``true`` |
  66. +-----------+--------------------------+
  67. | *Setter* | set_portal_active(value) |
  68. +-----------+--------------------------+
  69. | *Getter* | get_portal_active() |
  70. +-----------+--------------------------+
  71. Visibility through ``Portal``\ s can be turned on and off at runtime - this is useful for having closable doors.
  72. ----
  73. .. _class_Portal_property_portal_margin:
  74. - :ref:`float<class_float>` **portal_margin**
  75. +-----------+--------------------------+
  76. | *Default* | ``1.0`` |
  77. +-----------+--------------------------+
  78. | *Setter* | set_portal_margin(value) |
  79. +-----------+--------------------------+
  80. | *Getter* | get_portal_margin() |
  81. +-----------+--------------------------+
  82. Some objects are so big that they may be present in more than one :ref:`Room<class_Room>` ('sprawling'). As we often don't want objects that \*just\* breach the edges to be assigned to neighbouring rooms, you can assign an extra margin through the ``Portal`` to allow objects to breach without sprawling.
  83. ----
  84. .. _class_Portal_property_two_way:
  85. - :ref:`bool<class_bool>` **two_way**
  86. +-----------+--------------------+
  87. | *Default* | ``true`` |
  88. +-----------+--------------------+
  89. | *Setter* | set_two_way(value) |
  90. +-----------+--------------------+
  91. | *Getter* | is_two_way() |
  92. +-----------+--------------------+
  93. Portals default to being two way - see through in both directions, however you can make them one way, visible from the source room only.
  94. ----
  95. .. _class_Portal_property_use_default_margin:
  96. - :ref:`bool<class_bool>` **use_default_margin**
  97. +-----------+-------------------------------+
  98. | *Default* | ``true`` |
  99. +-----------+-------------------------------+
  100. | *Setter* | set_use_default_margin(value) |
  101. +-----------+-------------------------------+
  102. | *Getter* | get_use_default_margin() |
  103. +-----------+-------------------------------+
  104. In most cases you will want to use the default ``Portal`` margin in your portals (this is set in the :ref:`RoomManager<class_RoomManager>`).
  105. If you want to override this default, set this value to ``false``, and the local :ref:`portal_margin<class_Portal_property_portal_margin>` will take effect.
  106. Method Descriptions
  107. -------------------
  108. .. _class_Portal_method_set_point:
  109. - void **set_point** **(** :ref:`int<class_int>` index, :ref:`Vector2<class_Vector2>` position **)**
  110. Sets individual points. Primarily for use by the editor.
  111. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  112. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  113. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`