/usr/src/castle-game-engine-5.2.0/x3d/x3d_geometry3d.inc is in castle-game-engine-src 5.2.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 | {
Copyright 2002-2014 Michalis Kamburelis.
This file is part of "Castle Game Engine".
"Castle Game Engine" is free software; see the file COPYING.txt,
included in this distribution, for details about the copyright.
"Castle Game Engine" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
----------------------------------------------------------------------------
}
{$ifdef read_interface}
{ }
TBoxNode = class(TAbstractX3DGeometryNode)
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
private FFdSize: TSFVec3f;
public property FdSize: TSFVec3f read FFdSize;
private FFdSolid: TSFBool;
public property FdSolid: TSFBool read FFdSolid;
private FFdTexCoord: TSFNode;
public property FdTexCoord: TSFNode read FFdTexCoord;
function TexCoordField: TSFNode; override;
function SolidField: TSFBool; override;
function Proxy(var State: TX3DGraphTraverseState;
const OverTriangulate: boolean): TAbstractGeometryNode; override;
function BoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function LocalBoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function TrianglesCount(State: TX3DGraphTraverseState; OverTriangulate: boolean;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
function AutoGenerate3DTexCoords: boolean; override;
end;
TConeNode = class(TAbstractX3DGeometryNode)
protected
procedure DirectEnumerateActive(Func: TEnumerateChildrenFunction); override;
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
private FFdBottom: TSFBool;
public property FdBottom: TSFBool read FFdBottom;
private FFdBottomRadius: TSFFloat;
public property FdBottomRadius: TSFFloat read FFdBottomRadius;
private FFdHeight: TSFFloat;
public property FdHeight: TSFFloat read FFdHeight;
private FFdSide: TSFBool;
public property FdSide: TSFBool read FFdSide;
private FFdSolid: TSFBool;
public property FdSolid: TSFBool read FFdSolid;
class function ForVRMLVersion(const Version: TX3DVersion): boolean;
override;
private FFdTexCoord: TSFNode;
public property FdTexCoord: TSFNode read FFdTexCoord;
function TexCoordField: TSFNode; override;
function SolidField: TSFBool; override;
function Proxy(var State: TX3DGraphTraverseState;
const OverTriangulate: boolean): TAbstractGeometryNode; override;
function BoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function LocalBoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function TrianglesCount(State: TX3DGraphTraverseState; OverTriangulate: boolean;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
function AutoGenerate3DTexCoords: boolean; override;
end;
TConeNode_2 = TConeNode;
TCylinderNode = class(TAbstractX3DGeometryNode)
protected
procedure DirectEnumerateActive(Func: TEnumerateChildrenFunction); override;
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
private FFdBottom: TSFBool;
public property FdBottom: TSFBool read FFdBottom;
private FFdHeight: TSFFloat;
public property FdHeight: TSFFloat read FFdHeight;
private FFdRadius: TSFFloat;
public property FdRadius: TSFFloat read FFdRadius;
private FFdSide: TSFBool;
public property FdSide: TSFBool read FFdSide;
private FFdSolid: TSFBool;
public property FdSolid: TSFBool read FFdSolid;
private FFdTop: TSFBool;
public property FdTop: TSFBool read FFdTop;
class function ForVRMLVersion(const Version: TX3DVersion): boolean;
override;
function Proxy(var State: TX3DGraphTraverseState;
const OverTriangulate: boolean): TAbstractGeometryNode; override;
private FFdTexCoord: TSFNode;
public property FdTexCoord: TSFNode read FFdTexCoord;
function TexCoordField: TSFNode; override;
function SolidField: TSFBool; override;
function BoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function LocalBoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function TrianglesCount(State: TX3DGraphTraverseState; OverTriangulate: boolean;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
function AutoGenerate3DTexCoords: boolean; override;
end;
TCylinderNode_2 = TCylinderNode;
TElevationGridNode = class(TAbstractX3DGeometryNode)
private
procedure EventSet_HeightReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
{ Event in } { }
private FEventSet_height: TMFFloatEvent;
public property EventSet_height: TMFFloatEvent read FEventSet_height;
private FFdAttrib: TMFNode;
public property FdAttrib: TMFNode read FFdAttrib;
private FFdColor: TSFNode;
public property FdColor: TSFNode read FFdColor;
private FFdFogCoord: TSFNode;
public property FdFogCoord: TSFNode read FFdFogCoord;
private FFdNormal: TSFNode;
public property FdNormal: TSFNode read FFdNormal;
private FFdTexCoord: TSFNode;
public property FdTexCoord: TSFNode read FFdTexCoord;
private FFdCcw: TSFBool;
public property FdCcw: TSFBool read FFdCcw;
private FFdColorPerVertex: TSFBool;
public property FdColorPerVertex: TSFBool read FFdColorPerVertex;
private FFdCreaseAngle: TSFFloat;
public property FdCreaseAngle: TSFFloat read FFdCreaseAngle;
private FFdHeight: TMFFloat;
public property FdHeight: TMFFloat read FFdHeight;
private FFdNormalPerVertex: TSFBool;
public property FdNormalPerVertex: TSFBool read FFdNormalPerVertex;
private FFdSolid: TSFBool;
public property FdSolid: TSFBool read FFdSolid;
private FFdXDimension: TSFInt32;
public property FdXDimension: TSFInt32 read FFdXDimension;
private FFdXSpacing: TSFFloat;
public property FdXSpacing: TSFFloat read FFdXSpacing;
private FFdZDimension: TSFInt32;
public property FdZDimension: TSFInt32 read FFdZDimension;
private FFdZSpacing: TSFFloat;
public property FdZSpacing: TSFFloat read FFdZSpacing;
{ This checks whether xDimension and zDimension are >= 2,
xSpacing and zSpacing are > 0 and height has at least the
required number of values. If this returns @false then
it is understood that ElevationGrid is not rendered, doesn't
have any vertices/triangles etc. }
function IsNotEmpty: boolean;
function ColorField: TSFNode; override;
function FogCoord: TMFFloat; override;
function Attrib: TMFNode; override;
function SolidField: TSFBool; override;
function Proxy(var State: TX3DGraphTraverseState;
const OverTriangulate: boolean): TAbstractGeometryNode; override;
function ProxyUsesOverTriangulate: boolean; override;
function LocalBoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function VerticesCount(State: TX3DGraphTraverseState; OverTriangulate: boolean;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
function TrianglesCount(State: TX3DGraphTraverseState; OverTriangulate: boolean;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
end;
TExtrusionNode = class(TAbstractX3DGeometryNode)
protected
procedure DirectEnumerateActive(Func: TEnumerateChildrenFunction); override;
private
procedure Eventset_crossSectionReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
procedure Eventset_orientationReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
procedure Eventset_scaleReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
procedure Eventset_spineReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
{ Event in } { }
private FEventSet_crossSection: TMFVec2fEvent;
public property EventSet_crossSection: TMFVec2fEvent read FEventSet_crossSection;
{ Event in } { }
private FEventSet_orientation: TMFRotationEvent;
public property EventSet_orientation: TMFRotationEvent read FEventSet_orientation;
{ Event in } { }
private FEventSet_scale: TMFVec2fEvent;
public property EventSet_scale: TMFVec2fEvent read FEventSet_scale;
{ Event in } { }
private FEventSet_spine: TMFVec3fEvent;
public property EventSet_spine: TMFVec3fEvent read FEventSet_spine;
private FFdBeginCap: TSFBool;
public property FdBeginCap: TSFBool read FFdBeginCap;
private FFdCcw: TSFBool;
public property FdCcw: TSFBool read FFdCcw;
private FFdConvex: TSFBool;
public property FdConvex: TSFBool read FFdConvex;
private FFdCreaseAngle: TSFFloat;
public property FdCreaseAngle: TSFFloat read FFdCreaseAngle;
private FFdCrossSection: TMFVec2f;
public property FdCrossSection: TMFVec2f read FFdCrossSection;
private FFdEndCap: TSFBool;
public property FdEndCap: TSFBool read FFdEndCap;
private FFdOrientation: TMFRotation;
public property FdOrientation: TMFRotation read FFdOrientation;
private FFdScale: TMFVec2f;
public property FdScale: TMFVec2f read FFdScale;
private FFdSolid: TSFBool;
public property FdSolid: TSFBool read FFdSolid;
private FFdSpine: TMFVec3f;
public property FdSpine: TMFVec3f read FFdSpine;
private FFdTexCoord: TSFNode;
public property FdTexCoord: TSFNode read FFdTexCoord;
function TexCoordField: TSFNode; override;
function SolidField: TSFBool; override;
function ConvexField: TSFBool; override;
{ For given Index, return appropriate FdCrossIndex item as 3D vertex.
That is, uses FdCrossIndex values as X, Z of 3D vertex and sets Y = 0
(that's how Extrusion is defined in VRML / X3D). }
function CrossSection3D(Index: integer): TVector3Single;
{ Check is spine closed. This happens when "spine" field is non-empty
and it's first and last points are equal. }
function SpineClosed: boolean;
{ Check is crossSection closed. This happens when "crossSection"
field is non-empty and it's first and last points are equal. }
function CrossSectionClosed: boolean;
function Proxy(var State: TX3DGraphTraverseState;
const OverTriangulate: boolean): TAbstractGeometryNode; override;
function ProxyUsesOverTriangulate: boolean; override;
function LocalBoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function BoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function TrianglesCount(State: TX3DGraphTraverseState; OverTriangulate: boolean;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
function AutoGenerate3DTexCoords: boolean; override;
end;
TIndexedFaceSetNode = class(TAbstractComposedGeometryNode)
private
procedure Eventset_colorIndexReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
procedure Eventset_coordIndexReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
procedure Eventset_normalIndexReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
procedure Eventset_texCoordIndexReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
{ Event in } { }
private FEventSet_colorIndex: TMFInt32Event;
public property EventSet_colorIndex: TMFInt32Event read FEventSet_colorIndex;
{ Event in } { }
private FEventSet_coordIndex: TMFInt32Event;
public property EventSet_coordIndex: TMFInt32Event read FEventSet_coordIndex;
{ Event in } { }
private FEventSet_normalIndex: TMFInt32Event;
public property EventSet_normalIndex: TMFInt32Event read FEventSet_normalIndex;
{ Event in } { }
private FEventSet_texCoordIndex: TMFInt32Event;
public property EventSet_texCoordIndex: TMFInt32Event read FEventSet_texCoordIndex;
private FFdColorIndex: TMFInt32;
public property FdColorIndex: TMFInt32 read FFdColorIndex;
private FFdConvex: TSFBool;
public property FdConvex: TSFBool read FFdConvex;
function ConvexField: TSFBool; override;
private FFdCoordIndex: TMFInt32;
public property FdCoordIndex: TMFInt32 read FFdCoordIndex;
private FFdCreaseAngle: TSFFloat;
public property FdCreaseAngle: TSFFloat read FFdCreaseAngle;
private FFdNormalIndex: TMFInt32;
public property FdNormalIndex: TMFInt32 read FFdNormalIndex;
private FFdTexCoordIndex: TMFInt32;
public property FdTexCoordIndex: TMFInt32 read FFdTexCoordIndex;
class function ForVRMLVersion(const Version: TX3DVersion): boolean;
override;
function CoordIndex: TMFLong; override;
procedure CoordPolygons(
State: TX3DGraphTraverseState;
PolygonHandler: TIndexedPolygonHandler); override;
function TrianglesCount(State: TX3DGraphTraverseState; OverTriangulate: boolean;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
end;
TIndexedFaceSetNode_2 = TIndexedFaceSetNode;
TSphereNode = class(TAbstractX3DGeometryNode)
public
procedure CreateNode; override;
class function ClassNodeTypeName: string; override;
class function URNMatching(const URN: string): boolean; override;
private FFdRadius: TSFFloat;
public property FdRadius: TSFFloat read FFdRadius;
private FFdSolid: TSFBool;
public property FdSolid: TSFBool read FFdSolid;
class function ForVRMLVersion(const Version: TX3DVersion): boolean;
override;
private FFdTexCoord: TSFNode;
public property FdTexCoord: TSFNode read FFdTexCoord;
function TexCoordField: TSFNode; override;
function SolidField: TSFBool; override;
function Proxy(var State: TX3DGraphTraverseState;
const OverTriangulate: boolean): TAbstractGeometryNode; override;
function BoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function LocalBoundingBox(State: TX3DGraphTraverseState;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): TBox3D; override;
function TrianglesCount(State: TX3DGraphTraverseState; OverTriangulate: boolean;
ProxyGeometry: TAbstractGeometryNode; ProxyState: TX3DGraphTraverseState): Cardinal; override;
function AutoGenerate3DTexCoords: boolean; override;
end;
TSphereNode_2 = TSphereNode;
{$endif read_interface}
{$ifdef read_implementation}
procedure TBoxNode.CreateNode;
begin
inherited;
FFdSize := TSFVec3f.Create(Self, 'size', Vector3Single(2, 2, 2));
FdSize.Exposed := false;
FdSize.ChangesAlways := [chGeometry];
Fields.Add(FFdSize);
{ X3D specification comment: (0,Inf) }
FFdSolid := TSFBool.Create(Self, 'solid', true);
FdSolid.Exposed := false;
FdSolid.ChangesAlways := [chGeometry];
Fields.Add(FFdSolid);
FFdTexCoord := TSFNode.Create(Self, 'texCoord', [TTextureCoordinateGeneratorNode, TProjectedTextureCoordinateNode, TMultiTextureCoordinateNode]);
FdTexCoord.ChangesAlways := [chGeometry];
Fields.Add(FFdTexCoord);
end;
class function TBoxNode.ClassNodeTypeName: string;
begin
Result := 'Box';
end;
class function TBoxNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
function TBoxNode.TexCoordField: TSFNode;
begin
Result := FdTexCoord;
end;
function TBoxNode.AutoGenerate3DTexCoords: boolean;
begin
Result := (FdTexCoord.Value = nil) or not FdTexCoord.CurrentChildAllowed;
end;
function TBoxNode.SolidField: TSFBool;
begin
Result := FdSolid;
end;
{ TConeNode ------------------------------------------------------------------ }
procedure TConeNode.CreateNode;
begin
inherited;
FFdBottom := TSFBool.Create(Self, 'bottom', true);
FdBottom.Exposed := false;
FdBottom.ChangesAlways := [chGeometry];
Fields.Add(FFdBottom);
FFdBottomRadius := TSFFloat.Create(Self, 'bottomRadius', 1);
FdBottomRadius.Exposed := false;
FdBottomRadius.ChangesAlways := [chGeometry];
Fields.Add(FFdBottomRadius);
{ X3D specification comment: (0,Inf) }
FFdHeight := TSFFloat.Create(Self, 'height', 2);
FdHeight.Exposed := false;
FdHeight.ChangesAlways := [chGeometry];
Fields.Add(FFdHeight);
{ X3D specification comment: (0,Inf) }
FFdSide := TSFBool.Create(Self, 'side', true);
FdSide.Exposed := false;
FdSide.ChangesAlways := [chGeometry];
Fields.Add(FFdSide);
FFdSolid := TSFBool.Create(Self, 'solid', true);
FdSolid.Exposed := false;
FdSolid.ChangesAlways := [chGeometry];
Fields.Add(FFdSolid);
FFdTexCoord := TSFNode.Create(Self, 'texCoord', [TTextureCoordinateGeneratorNode, TProjectedTextureCoordinateNode, TMultiTextureCoordinateNode]);
FdTexCoord.ChangesAlways := [chGeometry];
Fields.Add(FFdTexCoord);
end;
class function TConeNode.ClassNodeTypeName: string;
begin
Result := 'Cone';
end;
class function TConeNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
class function TConeNode.ForVRMLVersion(const Version: TX3DVersion): boolean;
begin
Result := Version.Major >= 2;
end;
procedure TConeNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction);
begin
inherited;
FdtexCoord.EnumerateValid(Func);
end;
function TConeNode.TexCoordField: TSFNode;
begin
Result := FdTexCoord;
end;
function TConeNode.AutoGenerate3DTexCoords: boolean;
begin
Result := (FdTexCoord.Value = nil) or not FdTexCoord.CurrentChildAllowed;
end;
function TConeNode.SolidField: TSFBool;
begin
Result := FdSolid;
end;
{ TCylinderNode -------------------------------------------------------------- }
procedure TCylinderNode.CreateNode;
begin
inherited;
FFdBottom := TSFBool.Create(Self, 'bottom', true);
FdBottom.Exposed := false;
FdBottom.ChangesAlways := [chGeometry];
Fields.Add(FFdBottom);
FFdHeight := TSFFloat.Create(Self, 'height', 2);
FdHeight.Exposed := false;
FdHeight.ChangesAlways := [chGeometry];
Fields.Add(FFdHeight);
{ X3D specification comment: (0,Inf) }
FFdRadius := TSFFloat.Create(Self, 'radius', 1);
FdRadius.Exposed := false;
FdRadius.ChangesAlways := [chGeometry];
Fields.Add(FFdRadius);
{ X3D specification comment: (0,Inf) }
FFdSide := TSFBool.Create(Self, 'side', true);
FdSide.Exposed := false;
FdSide.ChangesAlways := [chGeometry];
Fields.Add(FFdSide);
FFdSolid := TSFBool.Create(Self, 'solid', true);
FdSolid.Exposed := false;
FdSolid.ChangesAlways := [chGeometry];
Fields.Add(FFdSolid);
FFdTop := TSFBool.Create(Self, 'top', true);
FdTop.Exposed := false;
FdTop.ChangesAlways := [chGeometry];
Fields.Add(FFdTop);
FFdTexCoord := TSFNode.Create(Self, 'texCoord', [TTextureCoordinateGeneratorNode, TProjectedTextureCoordinateNode, TMultiTextureCoordinateNode]);
FdTexCoord.ChangesAlways := [chGeometry];
Fields.Add(FFdTexCoord);
end;
class function TCylinderNode.ClassNodeTypeName: string;
begin
Result := 'Cylinder';
end;
class function TCylinderNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
class function TCylinderNode.ForVRMLVersion(const Version: TX3DVersion): boolean;
begin
Result := Version.Major >= 2;
end;
procedure TCylinderNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction);
begin
inherited;
FdtexCoord.EnumerateValid(Func);
end;
function TCylinderNode.TexCoordField: TSFNode;
begin
Result := FdTexCoord;
end;
function TCylinderNode.AutoGenerate3DTexCoords: boolean;
begin
Result := (FdTexCoord.Value = nil) or not FdTexCoord.CurrentChildAllowed;
end;
function TCylinderNode.SolidField: TSFBool;
begin
Result := FdSolid;
end;
{ TElevationGridNode --------------------------------------------------------- }
procedure TElevationGridNode.CreateNode;
begin
inherited;
FEventSet_height := TMFFloatEvent.Create(Self, 'set_height', true);
Events.Add(FEventSet_height);
Eventset_height.OnReceive.Add(@EventSet_HeightReceive);
FFdAttrib := TMFNode.Create(Self, 'attrib', [TAbstractVertexAttributeNode]);
FdAttrib.ChangesAlways := [chGeometry];
Fields.Add(FFdAttrib);
FFdColor := TSFNode.Create(Self, 'color', [TAbstractColorNode]);
FdColor.ChangesAlways := [chGeometry];
Fields.Add(FFdColor);
FFdFogCoord := TSFNode.Create(Self, 'fogCoord', [TFogCoordinateNode]);
FdFogCoord.ChangesAlways := [chGeometry];
Fields.Add(FFdFogCoord);
FFdNormal := TSFNode.Create(Self, 'normal', [TAbstractNormalNode]);
FdNormal.ChangesAlways := [chGeometry];
Fields.Add(FFdNormal);
FFdTexCoord := TSFNode.Create(Self, 'texCoord', [TAbstractTextureCoordinateNode]);
FdTexCoord.ChangesAlways := [chGeometry];
Fields.Add(FFdTexCoord);
FFdCcw := TSFBool.Create(Self, 'ccw', true);
FdCcw.Exposed := false;
FdCcw.ChangesAlways := [chGeometry];
Fields.Add(FFdCcw);
FFdColorPerVertex := TSFBool.Create(Self, 'colorPerVertex', true);
FdColorPerVertex.Exposed := false;
FdColorPerVertex.ChangesAlways := [chGeometry];
Fields.Add(FFdColorPerVertex);
FFdCreaseAngle := TSFFloat.Create(Self, 'creaseAngle', 0);
FdCreaseAngle.Angle := true;
FdCreaseAngle.Exposed := false;
FdCreaseAngle.ChangesAlways := [chGeometry];
Fields.Add(FFdCreaseAngle);
{ X3D specification comment: [0,Inf) }
FFdHeight := TMFFloat.Create(Self, 'height', []);
FdHeight.Exposed := false;
FdHeight.ChangesAlways := [chGeometry];
Fields.Add(FFdHeight);
{ X3D specification comment: (-Inf,Inf) }
FFdNormalPerVertex := TSFBool.Create(Self, 'normalPerVertex', true);
FdNormalPerVertex.Exposed := false;
FdNormalPerVertex.ChangesAlways := [chGeometry];
Fields.Add(FFdNormalPerVertex);
FFdSolid := TSFBool.Create(Self, 'solid', true);
FdSolid.Exposed := false;
FdSolid.ChangesAlways := [chGeometry];
Fields.Add(FFdSolid);
FFdXDimension := TSFInt32.Create(Self, 'xDimension', 0);
FdXDimension.Exposed := false;
FdXDimension.ChangesAlways := [chGeometry];
Fields.Add(FFdXDimension);
{ X3D specification comment: [0,Inf) }
FFdXSpacing := TSFFloat.Create(Self, 'xSpacing', 1.0);
FdXSpacing.Exposed := false;
FdXSpacing.ChangesAlways := [chGeometry];
Fields.Add(FFdXSpacing);
{ X3D specification comment: (0,Inf) }
FFdZDimension := TSFInt32.Create(Self, 'zDimension', 0);
FdZDimension.Exposed := false;
FdZDimension.ChangesAlways := [chGeometry];
Fields.Add(FFdZDimension);
{ X3D specification comment: [0,Inf) }
FFdZSpacing := TSFFloat.Create(Self, 'zSpacing', 1.0);
FdZSpacing.Exposed := false;
FdZSpacing.ChangesAlways := [chGeometry];
Fields.Add(FFdZSpacing);
{ X3D specification comment: (0,Inf) }
end;
class function TElevationGridNode.ClassNodeTypeName: string;
begin
Result := 'ElevationGrid';
end;
class function TElevationGridNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
function TElevationGridNode.IsNotEmpty: boolean;
begin
Result :=
(FdXDimension.Value >= 2) and
(FdZDimension.Value >= 2) and
{ VRML spec says that xSpacing and ySpacing shall be > 0.
So I understand that when they are = 0 (or < 0) nothing
should be rendered. }
(FdXSpacing.Value > 0) and
(FdZSpacing.Value > 0) and
(FdHeight.Count >= FdXDimension.Value * FdZDimension.Value);
end;
function TElevationGridNode.ColorField: TSFNode;
begin
Result := FdColor;
end;
function TElevationGridNode.FogCoord: TMFFloat;
begin
if (FdFogCoord.Value <> nil) and
(FdFogCoord.Value is TFogCoordinateNode) then
Result := TFogCoordinateNode(FdFogCoord.Value).FdDepth else
Result := nil;
end;
function TElevationGridNode.Attrib: TMFNode;
begin
Result := FdAttrib;
end;
procedure TElevationGridNode.EventSet_HeightReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
FdHeight.Assign(Value);
FdHeight.Changed;
end;
function TElevationGridNode.SolidField: TSFBool;
begin
Result := FdSolid;
end;
{ TExtrusionNode ------------------------------------------------------------- }
procedure TExtrusionNode.CreateNode;
begin
inherited;
FEventSet_crossSection := TMFVec2fEvent.Create(Self, 'set_crossSection', true);
Events.Add(FEventSet_crossSection);
Eventset_crossSection.OnReceive.Add(@EventSet_crossSectionReceive);
FEventSet_orientation := TMFRotationEvent.Create(Self, 'set_orientation', true);
Events.Add(FEventSet_orientation);
Eventset_orientation.OnReceive.Add(@EventSet_orientationReceive);
FEventSet_scale := TMFVec2fEvent.Create(Self, 'set_scale', true);
Events.Add(FEventSet_scale);
Eventset_scale.OnReceive.Add(@EventSet_scaleReceive);
FEventSet_spine := TMFVec3fEvent.Create(Self, 'set_spine', true);
Events.Add(FEventSet_spine);
Eventset_spine.OnReceive.Add(@EventSet_spineReceive);
FFdBeginCap := TSFBool.Create(Self, 'beginCap', true);
FdBeginCap.Exposed := false;
FdBeginCap.ChangesAlways := [chGeometry];
Fields.Add(FFdBeginCap);
FFdCcw := TSFBool.Create(Self, 'ccw', true);
FdCcw.Exposed := false;
FdCcw.ChangesAlways := [chGeometry];
Fields.Add(FFdCcw);
FFdConvex := TSFBool.Create(Self, 'convex', true);
FdConvex.Exposed := false;
FdConvex.ChangesAlways := [chGeometry];
Fields.Add(FFdConvex);
FFdCreaseAngle := TSFFloat.Create(Self, 'creaseAngle', 0);
FdCreaseAngle.Angle := true;
FdCreaseAngle.Exposed := false;
FdCreaseAngle.ChangesAlways := [chGeometry];
Fields.Add(FFdCreaseAngle);
{ X3D specification comment: [0,Inf) }
FFdCrossSection := TMFVec2f.Create(Self, 'crossSection', [ Vector2Single(1, 1), Vector2Single(1, -1), Vector2Single(-1, -1), Vector2Single(-1, 1), Vector2Single(1, 1) ]);
FdCrossSection.Exposed := false;
FdCrossSection.ChangesAlways := [chGeometry];
Fields.Add(FFdCrossSection);
{ X3D specification comment: (-Inf,Inf) }
FFdEndCap := TSFBool.Create(Self, 'endCap', true);
FdEndCap.Exposed := false;
FdEndCap.ChangesAlways := [chGeometry];
Fields.Add(FFdEndCap);
FFdOrientation := TMFRotation.Create(Self, 'orientation', [ Vector4Single(0, 0, 1, 0) ]);
FdOrientation.Exposed := false;
FdOrientation.ChangesAlways := [chGeometry];
Fields.Add(FFdOrientation);
{ X3D specification comment: [-1,1] or (-Inf,Inf) }
FFdScale := TMFVec2f.Create(Self, 'scale', Vector2Single(1, 1));
FdScale.Exposed := false;
FdScale.ChangesAlways := [chGeometry];
Fields.Add(FFdScale);
{ X3D specification comment: (0,Inf) }
FFdSolid := TSFBool.Create(Self, 'solid', true);
FdSolid.Exposed := false;
FdSolid.ChangesAlways := [chGeometry];
Fields.Add(FFdSolid);
FFdSpine := TMFVec3f.Create(Self, 'spine', [ Vector3Single(0, 0, 0), Vector3Single(0, 1, 0) ]);
FdSpine.Exposed := false;
FdSpine.ChangesAlways := [chGeometry];
Fields.Add(FFdSpine);
{ X3D specification comment: (-Inf,Inf) }
FFdTexCoord := TSFNode.Create(Self, 'texCoord', [TTextureCoordinateGeneratorNode, TProjectedTextureCoordinateNode, TMultiTextureCoordinateNode]);
FdTexCoord.ChangesAlways := [chGeometry];
Fields.Add(FFdTexCoord);
end;
class function TExtrusionNode.ClassNodeTypeName: string;
begin
Result := 'Extrusion';
end;
class function TExtrusionNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
function TExtrusionNode.CrossSection3D(Index: integer): TVector3Single;
begin
Result[0] := FdCrossSection.Items.L[Index][0];
Result[1] := 0;
Result[2] := FdCrossSection.Items.L[Index][1];
end;
function TExtrusionNode.SpineClosed: boolean;
var
SpinePoints: TVector3SingleList;
begin
SpinePoints := FdSpine.Items;
Result := (SpinePoints.Count <> 0) and
VectorsPerfectlyEqual(SpinePoints.Last,
SpinePoints.First);
end;
function TExtrusionNode.CrossSectionClosed: boolean;
var
CrossSectionPoints: TVector2SingleList;
begin
CrossSectionPoints := FdCrossSection.Items;
Result := (CrossSectionPoints.Count <> 0) and
VectorsPerfectlyEqual(CrossSectionPoints.Last,
CrossSectionPoints.First);
end;
function TExtrusionNode.Proxy(var State: TX3DGraphTraverseState;
const OverTriangulate: boolean): TAbstractGeometryNode;
{ Some of the things that are non-optimal when you will render
Extrusion using this Proxy instead of directly rendering node:
- In specialized Extrusion rendering, you now that sides are
composed of quads, and so you can use QUAD_STRIP to render them.
This allows vertices sharing. IndexedFaceSet uses vertex arrays,
that also provides sharing but may be slightly worse.
- In specialized Extrusion rendering, you know that sides' quads
are convex. There's never any need to triangulate them carefully.
For IndexedFaceSet, when caps may be non-convex, you have to set
convex field to false, so sides will be unnecessarily triangulated
with the slower algorithm.
You gain:
- creaseAngle support, which is really the crucial point why
I'm implementing this. I already have a specialized Extrusion
rendering, but adding there creaseAngle support is a major pain.
You would have to calculate all coordinates first, and then calculate
their normal vectors using a specialized routine like CreateNormals
that knows about Extrusion connectivity. This is painful to implement,
and naive implementation would even suffer from a slowdown not present
in Proxy approach: calculating all coordinates two times (before
calculating normals, and later for actual rendering). Sure, smarter
approach would remember these coordinates. Proxy approach provides
this automatically, saving coordinates inside Coordinate node,
for both normals calculation and rendering.
- A little ease of implementation: 230 lines of Proxy approach
versus 390 lines of TExtrusionRenderer. And remember that
actually handling creaseAngle would complicate TExtrusionRenderer
even more (that's why I didn't dare to do it...), and that
Proxy approach could also be used to implement things like
bounding box and triangulate eventually (although for now we use
our optimized methods).
}
var
IFS: TIndexedFaceSetNode absolute Result;
Index: Integer;
E: TVRMLExtrusion;
TexCoords: TVector2SingleList;
procedure NextIndex(SpineIndex, CrossSectionIndex: Integer;
SpecialTex: boolean; SpecialTexIndex: Integer);
begin
if TexCoords <> nil then
begin
if SpecialTex then
IFS.FdTexCoordIndex.Items.L[Index] := SpecialTexIndex else
IFS.FdTexCoordIndex.Items.L[Index] :=
SpineIndex * FdCrossSection.Count + CrossSectionIndex;
end;
{ For closed spine and/or crossSection, specify the same indexes.
For coordIndex (for texCoordIndex, this is not correct, texture
may have a seam there).
This will allow the correct smoothing between spine/crossSection
edges when calculating normal vectors. }
if (SpineIndex = FdSpine.Items.Count - 1) and
E.BeginEndCapsMatching then
SpineIndex := 0;
if (CrossSectionIndex = FdCrossSection.Items.Count - 1) and
E.CrossSectionClosed then
CrossSectionIndex := 0;
IFS.FdCoordIndex.Items.L[Index] :=
SpineIndex * FdCrossSection.Count + CrossSectionIndex;
Inc(Index);
end;
procedure NextIndexFaceDelimiter;
begin
IFS.FdCoordIndex.Items.L[Index] := -1;
if TexCoords <> nil then
IFS.FdTexCoordIndex.Items.L[Index] := -1;
Inc(Index);
end;
function SideTexCoord(SpineIndex, CrossSectionIndex: Integer): TVector2Single;
begin
{ Check ranges, to avoid dividing by zero (eventually the
corresponding coord is set to a predictable zero :) ). }
if FdCrossSection.Count > 1 then
Result[0] := CrossSectionIndex / (FdCrossSection.Count - 1) else
Result[0] := 0;
if E.High > 0 then
Result[1] := SpineIndex / E.High else
Result[1] := 0;
end;
var
CoordNode: TCoordinateNode;
TexCoordNode: TTextureCoordinateNode;
Transform: TMatrix4Single;
I, J, Len, SidesCount: Integer;
LastY, LastZ: TVector3Single;
TexCapsMin, TexCapsMax: TVector2Single;
TexCapsTranslation, TexCapsScale: Single;
begin
IFS := TIndexedFaceSetNode.Create(NodeName, BaseUrl);
try
E := TVRMLExtrusion.Create;
try
E.Node := Self;
{ calculate SidesCount = number of verts on sides, often used number }
SidesCount := (E.High + 1) * FdCrossSection.Count;
{ Fill CoordNode }
CoordNode := TCoordinateNode.Create('', BaseUrl);
IFS.FdCoord.Value := CoordNode;
CoordNode.FdPoint.Items.Count := SidesCount;
for I := 0 to E.High do
begin
E.SpineTransformTo1st(I, LastY, LastZ, Transform);
for J := 0 to FdCrossSection.Count - 1 do
begin
CoordNode.FdPoint.Items.L[I * FdCrossSection.Count + J] :=
MatrixMultPoint(Transform, CrossSection3D(J));
end;
end;
{ Fill TexCoordNode }
if (FdTexCoord.Value <> nil) and FdTexCoord.CurrentChildAllowed then
begin
{ No need for to create tex coords. }
IFS.FdTexCoord.Value := FdTexCoord.Value;
TexCoords := nil;
end else
begin
TexCoordNode := TTextureCoordinateNode.Create('', BaseUrl);
IFS.FdTexCoord.Value := TexCoordNode;
TexCoords := TexCoordNode.FdPoint.Items;
end;
if TexCoords <> nil then
begin
Len := SidesCount;
if FdBeginCap.Value or FdEndCap.Value then
Len += FdCrossSection.Count;
TexCoords.Count := Len;
for I := 0 to E.High do
for J := 0 to FdCrossSection.Count - 1 do
TexCoords.L[I * FdCrossSection.Count + J] := SideTexCoord(I, J);
{ calculate TexCapsTranslation, TexCapsScale }
if FdBeginCap.Value or FdEndCap.Value then
begin
TexCapsTranslation := 0;
TexCapsScale := 1;
if FdCrossSection.Items.MinMax(TexCapsMin, TexCapsMax) then
begin
if TexCapsMax[0] - TexCapsMin[0] >=
TexCapsMax[1] - TexCapsMin[1] then
begin
if not Zero(TexCapsMax[0] - TexCapsMin[0]) then
begin
{ scale such that U is along the X of cap.
Coord calculation will go like
u := (x - TexCapsMin[0]) / (TexCapsMax[0] - TexCapsMin[0]) }
TexCapsTranslation := -TexCapsMin[0];
TexCapsScale := 1 / (TexCapsMax[0] - TexCapsMin[0]);
end;
end else
begin
if not Zero(TexCapsMax[1] - TexCapsMin[1]) then
begin
TexCapsTranslation := -TexCapsMin[1];
TexCapsScale := 1 / (TexCapsMax[1] - TexCapsMin[1]);
end;
end;
end;
for I := 0 to FdCrossSection.Count - 1 do
begin
TexCoordNode.FdPoint.Items.L[
SidesCount + I] :=
VectorScale(VectorAdd(
FdCrossSection.Items.L[I],
Vector2Single(TexCapsTranslation, TexCapsTranslation)),
TexCapsScale);
end;
end;
end;
{ Fill CoordIndex and TexCoordIndex }
if E.High > 0 then
Len := 5 * E.High * (FdCrossSection.Count - 1) else
Len := 0; { E.High may be -1, then Len should remain 0 }
if FdBeginCap.Value then
Len += FdCrossSection.Count + 1 - E.CrossSectionOmit;
if FdEndCap.Value then
Len += FdCrossSection.Count + 1 - E.CrossSectionOmit;
IFS.FdCoordIndex.Items.Count := Len;
if TexCoords <> nil then
IFS.FdTexCoordIndex.Items.Count := Len;
Index := 0;
for I := 1 to E.High do
begin
for J := 1 to FdCrossSection.Count - 1 do
begin
{ The VRML / X3D specifications say that ordering of sides
should be
spine[0](crossSection[0], crossSection[1])
spine[1](crossSection[1], crossSection[0])
This is important, because we want faces to be ordered just
like the specification requires. This makes using "ccw"
and "solid" fields predictable for VRML author, since he
knows which side will be CCW and which CW.
So below we produce the same order. }
NextIndex(I - 1, J - 1, false, 0);
NextIndex(I - 1, J , false, 0);
NextIndex(I , J , false, 0);
NextIndex(I , J - 1, false, 0);
NextIndexFaceDelimiter;
end;
end;
if FdBeginCap.Value then
begin
{ "downto" order, to match the ordering of sides, this makes
things such a "solid TRUE" work Ok. }
for J := FdCrossSection.Count - 1 downto E.CrossSectionOmit do
NextIndex(0, J, true, SidesCount + J);
NextIndexFaceDelimiter;
end;
if FdEndCap.Value then
begin
for J := E.CrossSectionOmit to FdCrossSection.Count - 1 do
NextIndex(E.High, J, true, SidesCount + J);
NextIndexFaceDelimiter;
end;
{ Check that we actually filled all indexes we planned }
Assert(Index = IFS.FdCoordIndex.Items.Count);
finally FreeAndNil(E) end;
IFS.FdSolid.Value := FdSolid.Value;
IFS.FdCcw.Value := FdCcw.Value;
IFS.FdCreaseAngle.Value := FdCreaseAngle.Value;
IFS.FdConvex.Value := FdConvex.Value;
except FreeAndNil(Result); raise end;
end;
function TExtrusionNode.ProxyUsesOverTriangulate: boolean;
begin
Result := false;
end;
procedure TExtrusionNode.DirectEnumerateActive(Func: TEnumerateChildrenFunction);
begin
inherited;
FdtexCoord.EnumerateValid(Func);
end;
function TExtrusionNode.TexCoordField: TSFNode;
begin
Result := FdTexCoord;
end;
function TExtrusionNode.AutoGenerate3DTexCoords: boolean;
begin
Result := (FdTexCoord.Value = nil) or not FdTexCoord.CurrentChildAllowed;
end;
procedure TExtrusionNode.EventSet_crossSectionReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
FdcrossSection.Assign(Value);
FdcrossSection.Changed;
end;
procedure TExtrusionNode.EventSet_orientationReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
Fdorientation.Assign(Value);
Fdorientation.Changed;
end;
procedure TExtrusionNode.EventSet_scaleReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
Fdscale.Assign(Value);
Fdscale.Changed;
end;
procedure TExtrusionNode.EventSet_spineReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
Fdspine.Assign(Value);
Fdspine.Changed;
end;
function TExtrusionNode.ConvexField: TSFBool;
begin
Result := FdConvex;
end;
function TExtrusionNode.SolidField: TSFBool;
begin
Result := FdSolid;
end;
{ TIndexedFaceSetNode -------------------------------------------------------- }
procedure TIndexedFaceSetNode.CreateNode;
begin
inherited;
FEventSet_colorIndex := TMFInt32Event.Create(Self, 'set_colorIndex', true);
Events.Add(FEventSet_colorIndex);
Eventset_colorIndex.OnReceive.Add(@EventSet_colorIndexReceive);
FEventSet_coordIndex := TMFInt32Event.Create(Self, 'set_coordIndex', true);
Events.Add(FEventSet_coordIndex);
Eventset_coordIndex.OnReceive.Add(@EventSet_coordIndexReceive);
FEventSet_normalIndex := TMFInt32Event.Create(Self, 'set_normalIndex', true);
Events.Add(FEventSet_normalIndex);
Eventset_normalIndex.OnReceive.Add(@EventSet_normalIndexReceive);
FEventSet_texCoordIndex := TMFInt32Event.Create(Self, 'set_texCoordIndex', true);
Events.Add(FEventSet_texCoordIndex);
Eventset_texCoordIndex.OnReceive.Add(@EventSet_texCoordIndexReceive);
FFdColorIndex := TMFInt32.Create(Self, 'colorIndex', []);
FdColorIndex.SaveToStreamLineUptoNegative := true;
FdColorIndex.Exposed := false;
FdColorIndex.ChangesAlways := [chGeometry];
Fields.Add(FFdColorIndex);
{ X3D specification comment: [0,Inf) or -1 }
FFdConvex := TSFBool.Create(Self, 'convex', true);
FdConvex.Exposed := false;
FdConvex.ChangesAlways := [chGeometry];
Fields.Add(FFdConvex);
FFdCoordIndex := TMFInt32.Create(Self, 'coordIndex', []);
FdCoordIndex.SaveToStreamLineUptoNegative := true;
FdCoordIndex.Exposed := false;
FdCoordIndex.ChangesAlways := [chGeometry];
Fields.Add(FFdCoordIndex);
{ X3D specification comment: [0,Inf) or -1 }
FFdCreaseAngle := TSFFloat.Create(Self, 'creaseAngle', 0);
FdCreaseAngle.Angle := true;
FdCreaseAngle.Exposed := false;
FdCreaseAngle.ChangesAlways := [chGeometry];
Fields.Add(FFdCreaseAngle);
{ X3D specification comment: [0,Inf) }
FFdNormalIndex := TMFInt32.Create(Self, 'normalIndex', []);
FdNormalIndex.SaveToStreamLineUptoNegative := true;
FdNormalIndex.Exposed := false;
FdNormalIndex.ChangesAlways := [chGeometry];
Fields.Add(FFdNormalIndex);
{ X3D specification comment: [0,Inf) or -1 }
FFdTexCoordIndex := TMFInt32.Create(Self, 'texCoordIndex', []);
FdTexCoordIndex.SaveToStreamLineUptoNegative := true;
FdTexCoordIndex.Exposed := false;
FdTexCoordIndex.ChangesAlways := [chGeometry];
Fields.Add(FFdTexCoordIndex);
{ X3D specification comment: [-1,Inf) }
end;
class function TIndexedFaceSetNode.ClassNodeTypeName: string;
begin
Result := 'IndexedFaceSet';
end;
class function TIndexedFaceSetNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
class function TIndexedFaceSetNode.ForVRMLVersion(const Version: TX3DVersion): boolean;
begin
Result := Version.Major >= 2;
end;
function TIndexedFaceSetNode.CoordIndex: TMFLong;
begin
Result := FdCoordIndex;
end;
procedure TIndexedFaceSetNode.EventSet_colorIndexReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
FdcolorIndex.Assign(Value);
FdcolorIndex.Changed;
end;
procedure TIndexedFaceSetNode.EventSet_coordIndexReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
FdcoordIndex.Assign(Value);
FdcoordIndex.Changed;
end;
procedure TIndexedFaceSetNode.EventSet_normalIndexReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
FdnormalIndex.Assign(Value);
FdnormalIndex.Changed;
end;
procedure TIndexedFaceSetNode.EventSet_texCoordIndexReceive(
Event: TX3DEvent; Value: TX3DField; const Time: TX3DTime);
begin
FdtexCoordIndex.Assign(Value);
FdtexCoordIndex.Changed;
end;
function TIndexedFaceSetNode.ConvexField: TSFBool;
begin
Result := FdConvex;
end;
procedure TSphereNode.CreateNode;
begin
inherited;
FFdRadius := TSFFloat.Create(Self, 'radius', 1);
FdRadius.Exposed := false;
FdRadius.ChangesAlways := [chGeometry];
Fields.Add(FFdRadius);
{ X3D specification comment: (0,Inf) }
FFdSolid := TSFBool.Create(Self, 'solid', true);
FdSolid.Exposed := false;
FdSolid.ChangesAlways := [chGeometry];
Fields.Add(FFdSolid);
FFdTexCoord := TSFNode.Create(Self, 'texCoord', [TTextureCoordinateGeneratorNode, TProjectedTextureCoordinateNode, TMultiTextureCoordinateNode]);
FdTexCoord.ChangesAlways := [chGeometry];
Fields.Add(FFdTexCoord);
end;
class function TSphereNode.ClassNodeTypeName: string;
begin
Result := 'Sphere';
end;
class function TSphereNode.URNMatching(const URN: string): boolean;
begin
Result := (inherited URNMatching(URN)) or
(URN = URNVRML97Nodes + ClassNodeTypeName) or
(URN = URNX3DNodes + ClassNodeTypeName);
end;
class function TSphereNode.ForVRMLVersion(const Version: TX3DVersion): boolean;
begin
Result := Version.Major >= 2;
end;
function TSphereNode.TexCoordField: TSFNode;
begin
Result := FdTexCoord;
end;
function TSphereNode.AutoGenerate3DTexCoords: boolean;
begin
Result := (FdTexCoord.Value = nil) or not FdTexCoord.CurrentChildAllowed;
end;
function TSphereNode.SolidField: TSFBool;
begin
Result := FdSolid;
end;
{ routines ------------------------------------------------------------------- }
procedure RegisterGeometry3DNodes;
begin
NodesManager.RegisterNodeClasses([
TBoxNode,
TConeNode,
TCylinderNode,
TElevationGridNode,
TExtrusionNode,
TIndexedFaceSetNode,
TSphereNode
]);
end;
{$endif read_implementation}
|