| 1 |
{%MainUnit x3dfields.pas} |
| 2 |
{ |
| 3 |
Copyright 2002-2024 Michalis Kamburelis. |
| 4 |
|
| 5 |
This file is part of "Castle Game Engine". |
| 6 |
|
| 7 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 8 |
included in this distribution, for details about the copyright. |
| 9 |
|
| 10 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
|
| 14 |
---------------------------------------------------------------------------- |
| 15 |
} |
| 16 |
|
| 17 |
{$ifdef read_interface} |
| 18 |
|
| 19 |
{ For PasDoc: below is a trick to convince PasDoc that EX3DError is a class. |
| 20 |
|
| 21 |
Otherwise, PasDoc doesn't understand it, and places EX3DError in |
| 22 |
the "Class Hierarchy" (since it's an ancestor of some other classes....) |
| 23 |
but in the incorrect place (not descending from Exception, despite |
| 24 |
external_class_hierarchy.txt.) |
| 25 |
That's because original EX3DError is in unparsed by PasDoc (internal) |
| 26 |
CastleInternalX3DLexer unit. } |
| 27 |
{ Any error related to VRML/X3D. } |
| 28 |
{$ifdef PASDOC} |
| 29 |
EX3DError = class(Exception); |
| 30 |
{$else} |
| 31 |
EX3DError = CastleInternalX3DLexer.EX3DError; |
| 32 |
{$endif} |
| 33 |
|
| 34 |
EX3DFieldAssign = class(EX3DError); |
| 35 |
EX3DFieldAssignInvalidClass = class(EX3DFieldAssign); |
| 36 |
{ Raised by various X3D methods searching for X3D items (nodes, fields, |
| 37 |
events and such) when given item cannot be found. } |
| 38 |
EX3DNotFound = class(EX3DError); |
| 39 |
|
| 40 |
EInvalidNurbs = class(EX3DError); |
| 41 |
|
| 42 |
TSaveToXmlMethod = (sxNone, sxAttribute, sxAttributeCustomQuotes, sxChildElement); |
| 43 |
|
| 44 |
{ Possible things that happen when given field is changed. |
| 45 |
Used by @link(TX3DField.ExecuteChange) and @link(TX3DField.ChangeAlways). } |
| 46 |
TX3DChange = ( |
| 47 |
{ This field has no effect on the rendering/behavior of anything. } |
| 48 |
chNone, |
| 49 |
|
| 50 |
{ Something visible in the geometry changed. |
| 51 |
See vcVisibleGeometry. |
| 52 |
This means that VisibleChangeHere with vcVisibleGeometry included should |
| 53 |
be called. |
| 54 |
|
| 55 |
See TVisibleChange for the difference between "geometry" and "non-geometry" |
| 56 |
change. In short, "geometry" change means that shape of something changed, |
| 57 |
so even rendering it with some special shader (e.g. only to depth buffer) |
| 58 |
is affected (makes different result). } |
| 59 |
chVisibleGeometry, |
| 60 |
|
| 61 |
{ Something visible changed, but not geometry. |
| 62 |
See vcVisibleNonGeometry. |
| 63 |
This means that VisibleChangeHere with vcVisibleNonGeometry included should |
| 64 |
be called. } |
| 65 |
chVisibleNonGeometry, |
| 66 |
|
| 67 |
{ Call VisibleChangeHere to redisplay the scene. |
| 68 |
In contrast to chVisibleGeometry or chVisibleNonGeometry, |
| 69 |
this flag should be used if your change requires |
| 70 |
redisplay of the 3D view for some other reason |
| 71 |
(e.g. need to update rendered texture). } |
| 72 |
chRedisplay, |
| 73 |
|
| 74 |
{ Transformation of children of this node changed. } |
| 75 |
chTransform, |
| 76 |
|
| 77 |
{ Coordinate node (both VRML 1.0 and >= 2.0) "point" field changed. } |
| 78 |
chCoordinate, |
| 79 |
|
| 80 |
{ Normal node (both VRML 1.0 and >= 2.0) "vector" field changed. } |
| 81 |
chNormal, |
| 82 |
|
| 83 |
{ Tangent node "vector" field changed. } |
| 84 |
chTangent, |
| 85 |
|
| 86 |
{ Something visible in VRML 1.0 state node (that may be present |
| 87 |
in TX3DGraphTraverseState.VRML1State) changed, but not geometry. |
| 88 |
|
| 89 |
- Do not call this for Coordinate node change |
| 90 |
(this one should go through chCoordinate only, even for VRML 1.0). |
| 91 |
Actually Coordinate node change would be chGeometryVRML1State anyway. |
| 92 |
|
| 93 |
- Do not call this for Normal node change |
| 94 |
(this one should go through chNormal only, even for VRML 1.0). |
| 95 |
|
| 96 |
- Do not call this for changes that don't require recreating Proxy, |
| 97 |
and only require redisplay (chVisibleNonGeometry is enough for them). |
| 98 |
|
| 99 |
This is allowed, and ignored, on nodes that are not part of VRML 1.0 |
| 100 |
state. (This is useful for alphaChannel field, that is declared |
| 101 |
in TAbstractGeometryNode, and so is part of some VRML 1.0 state nodes |
| 102 |
but is also part of VRML >= 2.0 nodes.) } |
| 103 |
chVisibleVRML1State, |
| 104 |
|
| 105 |
{ Some visible geometry changed because of VRML 1.0 state node change. |
| 106 |
This is for VRML 1.0 state node changes, excluding |
| 107 |
- non-geometry changes (these go to chVisibleVRML1State) |
| 108 |
- Coordinate changes (these go to chCoordinate) |
| 109 |
- Normal changes (these go to chNormal, they are non-geometry anyway). } |
| 110 |
chGeometryVRML1State, |
| 111 |
|
| 112 |
{ Light property that is also reflected in TLightInstance structure. |
| 113 |
Only allowed on node's descending from TAbstractLightNode. } |
| 114 |
chLightInstanceProperty, |
| 115 |
|
| 116 |
{ Light's location and/or direction changed. |
| 117 |
Implies also chLightInstanceProperty change. } |
| 118 |
chLightLocationDirection, |
| 119 |
|
| 120 |
{ TCastleSceneCore.InternalMainLightForShadows possibly changed because of this change. } |
| 121 |
chLightForShadowVolumes, |
| 122 |
|
| 123 |
{ Switch.whichChoice changed, for VRML >= 2.0. } |
| 124 |
chSwitch2, |
| 125 |
|
| 126 |
{ X3DColorNode colors changed. } |
| 127 |
chColorNode, |
| 128 |
|
| 129 |
{ X3DTextureCoordinateNode coords changed. } |
| 130 |
chTextureCoordinate, |
| 131 |
|
| 132 |
{ VRML >= 2.0 TextureTransform changed. |
| 133 |
Not for multi-texture node changes, only the simple nodes changes. } |
| 134 |
chTextureTransform, |
| 135 |
|
| 136 |
{ Geometry node visible (or collidable) changed. |
| 137 |
Use for fields of the geometry node. } |
| 138 |
chGeometry, |
| 139 |
|
| 140 |
{ Like chGeometry and in addition font texture changed. Only on TTextNode. } |
| 141 |
chGeometryFontChanged, |
| 142 |
|
| 143 |
{ X3DEnvironmentalSensorNode bounds (size/center) changed. } |
| 144 |
chEnvironmentalSensorBounds, |
| 145 |
|
| 146 |
{ TimeDependent node is start/stop/pause/resume time changed. } |
| 147 |
chTimeStopStart, |
| 148 |
|
| 149 |
{ Viewpoint vectors (position, direction, up, gravity up) changed. } |
| 150 |
chViewpointVectors, |
| 151 |
|
| 152 |
{ Viewpoint projection changed. } |
| 153 |
chViewpointProjection, |
| 154 |
|
| 155 |
{ Texture image (data) needs reloading, because node fields |
| 156 |
that determine it (like ImageTexture.URL or PixelTexture.Image) changed. |
| 157 |
|
| 158 |
This is for fields in TAbstractTextureNode. |
| 159 |
|
| 160 |
We will release previously loaded data (setting IsTextureLoaded:=false) |
| 161 |
and load a new one. We will also update rendering resources, |
| 162 |
just like chTextureRendererProperties. } |
| 163 |
chTextureImage, |
| 164 |
|
| 165 |
{ Texture properties used by the renderer changed. |
| 166 |
No need to reload texture data in CPU (do not change IsTextureLoaded), |
| 167 |
but reload the rendering resources (like OpenGL texture). |
| 168 |
|
| 169 |
This is for fields in TAbstractTextureNode. } |
| 170 |
chTextureRendererProperties, |
| 171 |
|
| 172 |
{ Texture properties inside TextureProperties node changed. } |
| 173 |
chTexturePropertiesNode, |
| 174 |
|
| 175 |
{ What is considered a shadow caster changed. } |
| 176 |
chShadowCasters, |
| 177 |
|
| 178 |
{ Mark the generated texture node (parent of this field) as requiring update |
| 179 |
(assuming it's "update" field value wants it too). } |
| 180 |
chGeneratedTextureUpdateNeeded, |
| 181 |
|
| 182 |
{ VRML 2.0 / X3D FontStyle changed, and it requires recreating TTextNode |
| 183 |
geometry (but not texture). |
| 184 |
The node must be TFontStyleNode. } |
| 185 |
chFontStyle, |
| 186 |
|
| 187 |
{ VRML 2.0 / X3D FontStyle changed, and it requires recreating TTextNode |
| 188 |
geometry and texture (so underlying font changed). |
| 189 |
The node must be TFontStyleNode. } |
| 190 |
chFontStyleFontChanged, |
| 191 |
|
| 192 |
{ HeadLight on status changed. } |
| 193 |
chHeadLightOn, |
| 194 |
|
| 195 |
{ Clip plane visible change (enabled or plane equation). } |
| 196 |
chClipPlane, |
| 197 |
|
| 198 |
{ Enabled field of the pointing-device drag sensor changed. |
| 199 |
Use only for TSFBool fields within TAbstractDragSensorNode. } |
| 200 |
chDragSensorEnabled, |
| 201 |
|
| 202 |
{ NavigationInfo field value used in |
| 203 |
NavigationTypeFromNavigationInfo or |
| 204 |
TCastleSceneCore.InternalUpdateNavigation changed. } |
| 205 |
chNavigationInfo, |
| 206 |
|
| 207 |
{ ScreenEffect.enabled changed. } |
| 208 |
chScreenEffectEnabled, |
| 209 |
|
| 210 |
{ X3DBackgroundNode properties that are stored inside TBackground |
| 211 |
display list have changed. } |
| 212 |
chBackground, |
| 213 |
|
| 214 |
{ Everything changed and needs to be recalculated. |
| 215 |
This is needed for changes on stuff internally cached in |
| 216 |
TCastleSceneCore, TCastleScene, TShape that cannot be expressed |
| 217 |
as one of above flags. |
| 218 |
|
| 219 |
Use only as a last resort, as this is very costly! |
| 220 |
(And in an ideal implementation, should not be needed.) } |
| 221 |
chEverything, |
| 222 |
|
| 223 |
{ Higher-level shadow maps fields changed. |
| 224 |
They have to be processed to lower-level fields by calling |
| 225 |
TCastleSceneCore.ProcessShadowMapsReceivers. } |
| 226 |
chShadowMaps, |
| 227 |
|
| 228 |
{ Shading changed from wireframe to non-wireframe. } |
| 229 |
chWireframe, |
| 230 |
|
| 231 |
{ Children of X3D (or VRML 2) grouping node have been added or removed. } |
| 232 |
chGroupChildren, |
| 233 |
|
| 234 |
{ Children of X3D (or VRML 2) grouping node have been added (but not removed). |
| 235 |
This is special case of chGroupChildren. |
| 236 |
If unsure whether something was removed or not, it is always safe to use chGroupChildren. |
| 237 |
If you are sure that only additions were done, use chGroupChildrenAdd to be more efficient. } |
| 238 |
chGroupChildrenAdd, |
| 239 |
|
| 240 |
{ Shape.bboxCenter/Size changed, so TShape.LocalBoundingBox changed. } |
| 241 |
chBBox |
| 242 |
); |
| 243 |
TX3DChanges = set of TX3DChange; |
| 244 |
|
| 245 |
{$endif read_interface} |
| 246 |
|
| 247 |
{$ifdef read_implementation} |
| 248 |
|
| 249 |
{$endif read_implementation} |