SG_ParentRelation.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
  19. * All rights reserved.
  20. *
  21. * The Original Code is: all of this file.
  22. *
  23. * Contributor(s): none yet.
  24. *
  25. * ***** END GPL LICENSE BLOCK *****
  26. *
  27. */
  28. /** \file SG_ParentRelation.h
  29. * \ingroup bgesg
  30. * \page SG_ParentRelationPage SG_ParentRelation
  31. *
  32. * \section SG_ParentRelationSection SG_ParentRelation
  33. *
  34. * This is an abstract interface class to the Scene Graph library.
  35. * It allows you to specify how child nodes react to parent nodes.
  36. * Normally a child will use it's parent's transforms to compute
  37. * it's own global transforms. How this is performed depends on
  38. * the type of relation. For example if the parent is a vertex
  39. * parent to this child then the child should not inherit any
  40. * rotation information from the parent. Or if the parent is a
  41. * 'slow parent' to this child then the child should react
  42. * slowly to changes in the parent's position. The exact relation
  43. * is left for you to implement by filling out this interface
  44. * with concrete examples.
  45. *
  46. * There is exactly one SG_ParentRelation per SG_Node. Subclasses
  47. * should not be value types and should be allocated on the heap.
  48. *
  49. */
  50. #ifndef __SG_PARENTRELATION_H__
  51. #define __SG_PARENTRELATION_H__
  52. class SG_Spatial;
  53. class SG_ParentRelation {
  54. public :
  55. /**
  56. * Update the childs local and global coordinates
  57. * based upon the parents global coordinates.
  58. * You must also handle the case when this node has no
  59. * parent (parent == NULL). Usually you should just
  60. * copy the local coordinates of the child to the
  61. * world coordinates.
  62. */
  63. virtual
  64. bool
  65. UpdateChildCoordinates(
  66. SG_Spatial * child,
  67. const SG_Spatial * parent,
  68. bool& parentUpdated
  69. ) = 0;
  70. virtual
  71. ~SG_ParentRelation(
  72. ) {};
  73. /**
  74. * You must provide a way of duplicating an
  75. * instance of an SG_ParentRelation. This should
  76. * return a pointer to a new duplicate allocated
  77. * on the heap. Responsibility for deleting the
  78. * duplicate resides with the caller of this method.
  79. */
  80. virtual
  81. SG_ParentRelation *
  82. NewCopy(
  83. ) = 0;
  84. /**
  85. * Vertex Parent Relation are special: they don't propagate rotation
  86. */
  87. virtual
  88. bool
  89. IsVertexRelation(
  90. ) {
  91. return false;
  92. }
  93. /**
  94. * Need this to see if we are able to adjust time-offset from the python api
  95. */
  96. virtual
  97. bool
  98. IsSlowRelation(
  99. ) {
  100. return false;
  101. }
  102. protected :
  103. /**
  104. * Protected constructors
  105. * this class is not meant to be instantiated.
  106. */
  107. SG_ParentRelation(
  108. ) {
  109. };
  110. /**
  111. * Copy construction should not be implemented
  112. */
  113. SG_ParentRelation(
  114. const SG_ParentRelation &
  115. );
  116. #ifdef WITH_CXX_GUARDEDALLOC
  117. MEM_CXX_CLASS_ALLOC_FUNCS("GE:SG_ParentRelation")
  118. #endif
  119. };
  120. #endif