1 /* 2 Copyright (c) 2015 Starbreeze 3 4 This file is part of COLLADAMaya. 5 6 Portions of the code are: 7 Copyright (c) 2005-2007 Feeling Software Inc. 8 Copyright (c) 2005-2007 Sony Computer Entertainment America 9 Copyright (c) 2004-2005 Alias Systems Corp. 10 11 Licensed under the MIT Open Source License, 12 for details please see LICENSE file or the website 13 http://www.opensource.org/licenses/mit-license.php 14 */ 15 16 #pragma once 17 18 #include "COLLADAMayaPrerequisites.h" 19 #include "COLLADASWStreamWriter.h" 20 21 #include <libxml/parser.h> 22 23 #if defined(_MSC_VER) && _MSC_VER < 1600 24 // int64_t only available since Visual Studio 2010 25 typedef __int64 int64_t; 26 typedef unsigned __int64 uint64_t; 27 #else 28 #include <stdint.h> 29 #endif 30 31 namespace COLLADAMaya 32 { 33 template<typename E> 34 class Flags 35 { 36 public: Flags()37 Flags() 38 : mBitfield(0) 39 {} 40 Flags(int bitfield)41 Flags(int bitfield) 42 : mBitfield(bitfield) 43 {} 44 clear()45 void clear() 46 { 47 mBitfield = 0; 48 } 49 50 Flags operator & (E flag) const 51 { 52 return mBitfield & static_cast<int>(flag); 53 } 54 isSet(E flag)55 bool isSet(E flag) const 56 { 57 return (mBitfield & static_cast<int>(flag)) != 0; 58 } 59 60 void operator |= (E flag) 61 { 62 mBitfield |= static_cast<int>(flag); 63 } 64 65 operator bool() const 66 { 67 return mBitfield != 0; 68 } 69 70 operator int() const 71 { 72 return mBitfield; 73 } 74 75 bool operator == (const Flags & other) const 76 { 77 return mBitfield == other.mBitfield; 78 } 79 80 bool operator != (const Flags & other) const 81 { 82 return mBitfield != other.mBitfield; 83 } 84 85 private: 86 int mBitfield; 87 }; 88 89 namespace PhysXXML 90 { 91 struct UpVector 92 { 93 UpVector(xmlNode* node); 94 void exportElement(COLLADASW::StreamWriter& sw) const; 95 MVector upVector; 96 }; 97 98 struct Length 99 { 100 Length(xmlNode* node); 101 void exportElement(COLLADASW::StreamWriter& sw) const; 102 double length; 103 }; 104 105 struct Mass 106 { 107 Mass(xmlNode* node); 108 void exportElement(COLLADASW::StreamWriter& sw) const; 109 double mass; 110 }; 111 112 struct Speed 113 { 114 Speed(xmlNode* node); 115 void exportElement(COLLADASW::StreamWriter& sw) const; 116 double speed; 117 }; 118 119 struct LengthMassSpeedScale 120 { 121 LengthMassSpeedScale(xmlNode* node); 122 void exportElement(COLLADASW::StreamWriter& sw) const; 123 Length length; 124 Mass mass; 125 Speed speed; 126 }; 127 128 struct Id 129 { 130 Id(xmlNode* node); 131 void exportElement(COLLADASW::StreamWriter& sw) const; 132 uint64_t id; 133 }; 134 135 struct Point 136 { 137 Point(); 138 139 double x; 140 double y; 141 double z; 142 }; 143 144 struct Points 145 { 146 Points(xmlNode* node); 147 void exportElement(COLLADASW::StreamWriter& sw) const; 148 std::vector<Point> points; 149 }; 150 151 struct PxConvexMesh 152 { 153 PxConvexMesh(xmlNode* node); 154 void exportElement(COLLADASW::StreamWriter& sw) const; 155 Id id; 156 Points points; 157 }; 158 159 struct Triangle 160 { 161 Triangle(); 162 163 int point0; 164 int point1; 165 int point2; 166 }; 167 168 struct Triangles 169 { 170 Triangles(xmlNode* node); 171 void exportElement(COLLADASW::StreamWriter& sw) const; 172 std::vector<Triangle> triangles; 173 }; 174 175 struct PxTriangleMesh 176 { 177 PxTriangleMesh(xmlNode* node); 178 void exportElement(COLLADASW::StreamWriter& sw) const; 179 Id id; 180 Points points; 181 Triangles triangles; 182 }; 183 184 struct DynamicFriction 185 { 186 DynamicFriction(xmlNode* node); 187 void exportElement(COLLADASW::StreamWriter& sw) const; 188 double dynamicFriction; 189 }; 190 191 struct StaticFriction 192 { 193 StaticFriction(xmlNode* node); 194 void exportElement(COLLADASW::StreamWriter& sw) const; 195 double staticFriction; 196 }; 197 198 struct Restitution 199 { 200 Restitution(xmlNode* node); 201 void exportElement(COLLADASW::StreamWriter& sw) const; 202 double restitution; 203 }; 204 205 struct CombineMode 206 { 207 enum FlagEnum 208 { 209 Average = 1, 210 Min = 2, 211 Multiply = 4, 212 Max = 8 213 }; 214 215 static const std::map<String, FlagEnum> & GetStringToFlagMap(); 216 static const std::map<FlagEnum, String> & GetFlagToStringMap(); 217 218 private: 219 static std::map<String, FlagEnum> mStringToFlagMap; 220 static std::map<FlagEnum, String> mFlagToStringMap; 221 static std::map<String, FlagEnum> InitializeStringToFlagMap(); 222 static std::map<FlagEnum, String> InitializeFlagToStringMap(); 223 }; 224 225 struct FrictionCombineMode 226 { 227 FrictionCombineMode(xmlNode* node); 228 void exportElement(COLLADASW::StreamWriter& sw) const; 229 CombineMode::FlagEnum frictionCombineMode; 230 }; 231 232 struct RestitutionCombineMode 233 { 234 RestitutionCombineMode(xmlNode* node); 235 void exportElement(COLLADASW::StreamWriter& sw) const; 236 CombineMode::FlagEnum restitutionCombineMode; 237 }; 238 239 struct PxMaterial 240 { 241 PxMaterial(xmlNode* node); 242 void exportElement(COLLADASW::StreamWriter& sw) const; 243 Id id; 244 DynamicFriction dynamicFriction; 245 StaticFriction staticFriction; 246 Restitution restitution; 247 FrictionCombineMode frictionCombineMode; 248 RestitutionCombineMode restitutionCombineMode; 249 }; 250 251 struct Name 252 { 253 Name(xmlNode* node); 254 void exportElement(COLLADASW::StreamWriter& sw) const; 255 String name; 256 }; 257 258 struct ActorFlags 259 { 260 enum FlagEnum 261 { 262 Visualization = 1, 263 DisableGravity = 2, 264 SendSleepNotifies = 4, 265 DisableSimulation = 8 266 }; 267 268 ActorFlags(xmlNode* node); 269 void exportElement(COLLADASW::StreamWriter& sw) const; 270 Flags<FlagEnum> actorFlags; 271 272 static const std::map<FlagEnum, String> & GetFlagToStringMap(); 273 274 private: 275 static std::map<String, FlagEnum> mStringToFlagMap; 276 static std::map<FlagEnum, String> mFlagToStringMap; 277 static std::map<String, FlagEnum> InitializeStringToFlagMap(); 278 static std::map<FlagEnum, String> InitializeFlagToStringMap(); 279 }; 280 281 struct RigidBodyFlags 282 { 283 enum FlagEnum 284 { 285 Kinematic = 1, 286 UseKinematicTargetForSceneQueries = 2, 287 EnabledCCD = 4, 288 EnabledCCDFriction = 8 289 }; 290 291 RigidBodyFlags(xmlNode* node); 292 void exportElement(COLLADASW::StreamWriter& sw) const; 293 Flags<FlagEnum> rigidBodyFlags; 294 295 static const std::map<FlagEnum, String> & GetFlagToStringMap(); 296 297 private: 298 static std::map<String, FlagEnum> mStringToFlagMap; 299 static std::map<FlagEnum, String> mFlagToStringMap; 300 static std::map<String, FlagEnum> InitializeStringToFlagMap(); 301 static std::map<FlagEnum, String> InitializeFlagToStringMap(); 302 }; 303 304 struct DominanceGroup 305 { 306 DominanceGroup(xmlNode* node); 307 void exportElement(COLLADASW::StreamWriter& sw) const; 308 int dominanceGroup; 309 }; 310 311 struct OwnerClient 312 { 313 OwnerClient(xmlNode* node); 314 void exportElement(COLLADASW::StreamWriter& sw) const; 315 int ownerClient; 316 }; 317 318 struct GlobalPose 319 { 320 GlobalPose(xmlNode* node); 321 void exportElement(COLLADASW::StreamWriter& sw) const; 322 MQuaternion rotation; 323 MVector translation; 324 }; 325 326 struct HalfExtents 327 { 328 HalfExtents(xmlNode* node); 329 void exportElement(COLLADASW::StreamWriter& sw) const; 330 MVector halfExtents; 331 }; 332 333 struct PxBoxGeometry 334 { 335 PxBoxGeometry(xmlNode* node); 336 void exportElement(COLLADASW::StreamWriter& sw) const; 337 HalfExtents halfExtents; 338 }; 339 340 struct Radius 341 { 342 Radius(xmlNode* node); 343 void exportElement(COLLADASW::StreamWriter& sw) const; 344 double radius; 345 }; 346 347 struct HalfHeight 348 { 349 HalfHeight(xmlNode* node); 350 void exportElement(COLLADASW::StreamWriter& sw) const; 351 double halfHeight; 352 }; 353 354 struct PxCapsuleGeometry 355 { 356 PxCapsuleGeometry(xmlNode* node); 357 void exportElement(COLLADASW::StreamWriter& sw) const; 358 Radius radius; 359 HalfHeight halfHeight; 360 }; 361 362 struct Scale 363 { 364 Scale(xmlNode* node); 365 void exportElement(COLLADASW::StreamWriter& sw) const; 366 MVector scale; 367 }; 368 369 struct Rotation 370 { 371 Rotation(xmlNode* node); 372 void exportElement(COLLADASW::StreamWriter& sw) const; 373 MQuaternion rotation; 374 }; 375 376 struct MeshScale 377 { 378 MeshScale(xmlNode* node); 379 void exportElement(COLLADASW::StreamWriter& sw) const; 380 Scale scale; 381 Rotation rotation; 382 }; 383 384 struct ConvexMesh 385 { 386 ConvexMesh(xmlNode* node); 387 void exportElement(COLLADASW::StreamWriter& sw) const; 388 uint64_t convexMesh; 389 }; 390 391 struct PxConvexMeshGeometry 392 { 393 PxConvexMeshGeometry(xmlNode* node); 394 void exportElement(COLLADASW::StreamWriter& sw) const; 395 MeshScale scale; 396 ConvexMesh convexMesh; 397 }; 398 399 struct PxPlaneGeometry 400 { 401 PxPlaneGeometry(xmlNode* node); 402 void exportElement(COLLADASW::StreamWriter& sw) const; 403 }; 404 405 struct PxSphereGeometry 406 { 407 PxSphereGeometry(xmlNode* node); 408 void exportElement(COLLADASW::StreamWriter& sw) const; 409 Radius radius; 410 }; 411 412 struct TriangleMesh 413 { 414 TriangleMesh(xmlNode* node); 415 void exportElement(COLLADASW::StreamWriter& sw) const; 416 uint64_t triangleMesh; 417 }; 418 419 struct PxTriangleMeshGeometry 420 { 421 PxTriangleMeshGeometry(xmlNode* node); 422 void exportElement(COLLADASW::StreamWriter& sw) const; 423 MeshScale scale; 424 TriangleMesh triangleMesh; 425 }; 426 427 struct Geometry 428 { 429 Geometry(xmlNode* node); 430 void exportElement(COLLADASW::StreamWriter& sw) const; 431 432 enum Type { 433 Box, 434 Capsule, 435 ConvexMesh, 436 Plane, 437 Sphere, 438 TriangleMesh 439 }; 440 441 Type type; 442 PxBoxGeometry boxGeometry; 443 PxCapsuleGeometry capsuleGeometry; 444 PxConvexMeshGeometry convexMeshGeometry; 445 PxPlaneGeometry planeGeometry; 446 PxSphereGeometry sphereGeometry; 447 PxTriangleMeshGeometry triangleMeshGeometry; 448 }; 449 450 struct LocalPose 451 { 452 LocalPose(xmlNode* node); 453 void exportElement(COLLADASW::StreamWriter& sw) const; 454 MQuaternion rotation; 455 MVector translation; 456 }; 457 458 struct SimulationFilterData 459 { 460 SimulationFilterData(xmlNode* node); 461 void exportElement(COLLADASW::StreamWriter& sw) const; 462 int filter0; 463 int filter1; 464 int filter2; 465 int filter3; 466 }; 467 468 struct QueryFilterData 469 { 470 QueryFilterData(xmlNode* node); 471 void exportElement(COLLADASW::StreamWriter& sw) const; 472 int filter0; 473 int filter1; 474 int filter2; 475 int filter3; 476 }; 477 478 struct PxMaterialRef 479 { 480 PxMaterialRef(xmlNode* node); 481 void exportElement(COLLADASW::StreamWriter& sw) const; 482 uint64_t materialRef; 483 }; 484 485 struct Materials 486 { 487 Materials(xmlNode* node); 488 void exportElement(COLLADASW::StreamWriter& sw) const; 489 PxMaterialRef materialRef; 490 }; 491 492 struct ContactOffset 493 { 494 ContactOffset(xmlNode* node); 495 void exportElement(COLLADASW::StreamWriter& sw) const; 496 double contactOffset; 497 }; 498 499 struct RestOffset 500 { 501 RestOffset(xmlNode* node); 502 void exportElement(COLLADASW::StreamWriter& sw) const; 503 double restOffset; 504 }; 505 506 struct ShapeFlags 507 { 508 enum FlagEnum 509 { 510 SimulationShape = 1, 511 SceneQueryShape = 2, 512 TriggerShape = 4, 513 Visualization = 8, 514 ParticleDrain = 16 515 }; 516 517 ShapeFlags(xmlNode* node); 518 void exportElement(COLLADASW::StreamWriter& sw) const; 519 Flags<FlagEnum> flags; 520 521 static const std::map<FlagEnum, String> & GetFlagToStringMap(); 522 523 private: 524 static std::map<String, FlagEnum> mStringToFlagMap; 525 static std::map<FlagEnum, String> mFlagToStringMap; 526 static std::map<String, FlagEnum> InitializeStringToFlagMap(); 527 static std::map<FlagEnum, String> InitializeFlagToStringMap(); 528 }; 529 530 struct PxShape 531 { 532 PxShape(xmlNode* node); 533 void exportElement(COLLADASW::StreamWriter& sw) const; 534 535 Geometry geometry; 536 LocalPose localPose; 537 SimulationFilterData simulationFilterData; 538 QueryFilterData queryFilterData; 539 Materials materials; 540 ContactOffset contactOffset; 541 RestOffset restOffset; 542 ShapeFlags flags; 543 Name name; 544 }; 545 546 struct Shapes 547 { 548 Shapes(xmlNode* node); 549 void exportElement(COLLADASW::StreamWriter& sw) const; 550 std::vector<PxShape> shapes; 551 }; 552 553 struct PxRigidBody 554 { 555 enum Type 556 { 557 Static, 558 Dynamic 559 }; 560 561 PxRigidBody(xmlNode* node); 562 PxShape* findShape(const String& shapeName); 563 virtual void exportElement(COLLADASW::StreamWriter& sw) const = 0; 564 virtual Type getType() const = 0; 565 Id id; 566 Name name; 567 ActorFlags actorFlags; 568 DominanceGroup dominanceGroup; 569 OwnerClient ownerClient; 570 GlobalPose globalPose; 571 Shapes shapes; 572 }; 573 574 struct PxRigidStatic : public PxRigidBody 575 { 576 PxRigidStatic(xmlNode* node); 577 virtual void exportElement(COLLADASW::StreamWriter& sw) const override; 578 virtual Type getType() const override; 579 }; 580 581 struct CMassLocalPose 582 { 583 CMassLocalPose(xmlNode* node); 584 void exportElement(COLLADASW::StreamWriter& sw) const; 585 MQuaternion rotation; 586 MVector translation; 587 }; 588 589 struct MassSpaceInertiaTensor 590 { 591 MassSpaceInertiaTensor(xmlNode* node); 592 void exportElement(COLLADASW::StreamWriter& sw) const; 593 MVector massSpaceInertiaTensor; 594 }; 595 596 struct LinearVelocity 597 { 598 LinearVelocity(xmlNode* node); 599 void exportElement(COLLADASW::StreamWriter& sw) const; 600 MVector linearVelocity; 601 }; 602 603 struct AngularVelocity 604 { 605 AngularVelocity(xmlNode* node); 606 void exportElement(COLLADASW::StreamWriter& sw) const; 607 MVector angularVelocity; 608 }; 609 610 struct MinCCDAdvanceCoefficient 611 { 612 MinCCDAdvanceCoefficient(xmlNode* node); 613 void exportElement(COLLADASW::StreamWriter& sw) const; 614 double minCCDAdvanceCoefficient; 615 }; 616 617 struct MaxDepenetrationVelocity 618 { 619 MaxDepenetrationVelocity(xmlNode* node); 620 void exportElement(COLLADASW::StreamWriter& sw) const; 621 double maxDepenetrationVelocity; 622 }; 623 624 struct LinearDamping 625 { 626 LinearDamping(xmlNode* node); 627 void exportElement(COLLADASW::StreamWriter& sw) const; 628 double linearDamping; 629 }; 630 631 struct AngularDamping 632 { 633 AngularDamping(xmlNode* node); 634 void exportElement(COLLADASW::StreamWriter& sw) const; 635 double angularDamping; 636 }; 637 638 struct MaxAngularVelocity 639 { 640 MaxAngularVelocity(xmlNode* node); 641 void exportElement(COLLADASW::StreamWriter& sw) const; 642 double maxAngularVelocity; 643 }; 644 645 struct SleepThreshold 646 { 647 SleepThreshold(xmlNode* node); 648 void exportElement(COLLADASW::StreamWriter& sw) const; 649 double sleepThreshold; 650 }; 651 652 struct StabilizationThreshold 653 { 654 StabilizationThreshold(xmlNode* node); 655 void exportElement(COLLADASW::StreamWriter& sw) const; 656 double stabilizationThreshold; 657 }; 658 659 struct WakeCounter 660 { 661 WakeCounter(xmlNode* node); 662 void exportElement(COLLADASW::StreamWriter& sw) const; 663 double wakeCounter; 664 }; 665 666 struct MinPositionIters 667 { 668 MinPositionIters(xmlNode* node); 669 void exportElement(COLLADASW::StreamWriter& sw) const; 670 int minPositionIters; 671 }; 672 673 struct MinVelocityIters 674 { 675 MinVelocityIters(xmlNode* node); 676 void exportElement(COLLADASW::StreamWriter& sw) const; 677 int minVelocityIters; 678 }; 679 680 struct SolverIterationCounts 681 { 682 SolverIterationCounts(xmlNode* node); 683 void exportElement(COLLADASW::StreamWriter& sw) const; 684 MinPositionIters minPositionIters; 685 MinVelocityIters minVelocityIters; 686 }; 687 688 struct ContactReportThreshold 689 { 690 ContactReportThreshold(xmlNode* node); 691 void exportElement(COLLADASW::StreamWriter& sw) const; 692 double contactReportThreshold; 693 }; 694 695 struct PxRigidDynamic : public PxRigidBody 696 { 697 PxRigidDynamic(xmlNode* node); 698 virtual void exportElement(COLLADASW::StreamWriter& sw) const override; 699 virtual Type getType() const override; 700 CMassLocalPose cMassLocalPose; 701 Mass mass; 702 MassSpaceInertiaTensor massSpaceInertiaTensor; 703 LinearVelocity linearVelocity; 704 AngularVelocity angularVelocity; 705 RigidBodyFlags rigidBodyFlags; 706 MinCCDAdvanceCoefficient minCCDAdvanceCoefficient; 707 MaxDepenetrationVelocity maxDepenetrationVelocity; 708 LinearDamping linearDamping; 709 AngularDamping angularDamping; 710 MaxAngularVelocity maxAngularVelocity; 711 SleepThreshold sleepThreshold; 712 StabilizationThreshold stabilizationThreshold; 713 WakeCounter wakeCounter; 714 SolverIterationCounts solverIterationCounts; 715 ContactReportThreshold contactReportThreshold; 716 }; 717 718 struct Actor0 719 { 720 Actor0(xmlNode* node); 721 void exportElement(COLLADASW::StreamWriter& sw) const; 722 uint64_t actor0; 723 }; 724 725 struct Actor1 726 { 727 Actor1(xmlNode* node); 728 void exportElement(COLLADASW::StreamWriter& sw) const; 729 uint64_t actor1; 730 }; 731 732 struct Actors 733 { 734 Actors(xmlNode* node); 735 void exportElement(COLLADASW::StreamWriter& sw) const; 736 Actor0 actor0; 737 Actor1 actor1; 738 }; 739 740 struct EActor0 741 { 742 EActor0(xmlNode* node); 743 void exportElement(COLLADASW::StreamWriter& sw) const; 744 MQuaternion rotation; 745 MVector translation; 746 }; 747 748 struct EActor1 749 { 750 EActor1(xmlNode* node); 751 void exportElement(COLLADASW::StreamWriter& sw) const; 752 MQuaternion rotation; 753 MVector translation; 754 }; 755 756 struct ActorLocalPose 757 { 758 ActorLocalPose(xmlNode* node); 759 void exportElement(COLLADASW::StreamWriter& sw) const; 760 EActor0 eActor0; 761 EActor1 eActor1; 762 }; 763 764 struct Force 765 { 766 Force(xmlNode* node); 767 void exportElement(COLLADASW::StreamWriter& sw) const; 768 double force; 769 }; 770 771 struct Torque 772 { 773 Torque(xmlNode* node); 774 void exportElement(COLLADASW::StreamWriter& sw) const; 775 double torque; 776 }; 777 778 struct BreakForce 779 { 780 BreakForce(xmlNode* node); 781 void exportElement(COLLADASW::StreamWriter& sw) const; 782 Force force; 783 Torque torque; 784 }; 785 786 struct ConstraintFlags 787 { 788 enum FlagEnum 789 { 790 Broken = 1, 791 ProjectToActor0 = 2, 792 ProjectToActor1 = 4, 793 Projection = 8, 794 CollisionEnabled = 16, 795 Reporting = 32, 796 Visualization = 64, 797 DriveLimitsAreForces = 128, 798 ImprovedSlerp = 256 799 }; 800 801 ConstraintFlags(xmlNode* node); 802 void exportElement(COLLADASW::StreamWriter& sw) const; 803 Flags<FlagEnum> flags; 804 805 static const std::map<FlagEnum, String> & GetFlagToStringMap(); 806 807 private: 808 static std::map<String, FlagEnum> mStringToFlagMap; 809 static std::map<FlagEnum, String> mFlagToStringMap; 810 static std::map<String, FlagEnum> InitializeStringToFlagMap(); 811 static std::map<FlagEnum, String> InitializeFlagToStringMap(); 812 }; 813 814 struct InvMassScale0 815 { 816 InvMassScale0(xmlNode* node); 817 void exportElement(COLLADASW::StreamWriter& sw) const; 818 double invMassScale0; 819 }; 820 821 struct InvMassScale1 822 { 823 InvMassScale1(xmlNode* node); 824 void exportElement(COLLADASW::StreamWriter& sw) const; 825 double invMassScale1; 826 }; 827 828 struct InvInertiaScale0 829 { 830 InvInertiaScale0(xmlNode* node); 831 void exportElement(COLLADASW::StreamWriter& sw) const; 832 double invInertiaScale0; 833 }; 834 835 struct InvInertiaScale1 836 { 837 InvInertiaScale1(xmlNode* node); 838 void exportElement(COLLADASW::StreamWriter& sw) const; 839 double invInertiaScale1; 840 }; 841 842 struct MotionFlags 843 { 844 enum FlagEnum 845 { 846 Locked = 1, 847 Limited = 2, 848 Free = 4 849 }; 850 851 static const std::map<String, FlagEnum> & GetStringToFlagMap(); 852 static const std::map<FlagEnum, String> & GetFlagToStringMap(); 853 854 private: 855 static std::map<String, FlagEnum> mStringToFlagMap; 856 static std::map<FlagEnum, String> mFlagToStringMap; 857 static std::map<String, FlagEnum> InitializeStringToFlagMap(); 858 static std::map<FlagEnum, String> InitializeFlagToStringMap(); 859 }; 860 861 struct MotionX 862 { 863 MotionX(xmlNode* node); 864 void exportElement(COLLADASW::StreamWriter& sw) const; 865 MotionFlags::FlagEnum eX; 866 }; 867 868 struct MotionY 869 { 870 MotionY(xmlNode* node); 871 void exportElement(COLLADASW::StreamWriter& sw) const; 872 MotionFlags::FlagEnum eY; 873 }; 874 875 struct MotionZ 876 { 877 MotionZ(xmlNode* node); 878 void exportElement(COLLADASW::StreamWriter& sw) const; 879 MotionFlags::FlagEnum eZ; 880 }; 881 882 struct MotionTwist 883 { 884 MotionTwist(xmlNode* node); 885 void exportElement(COLLADASW::StreamWriter& sw) const; 886 MotionFlags::FlagEnum eTwist; 887 }; 888 889 struct MotionSwing1 890 { 891 MotionSwing1(xmlNode* node); 892 void exportElement(COLLADASW::StreamWriter& sw) const; 893 MotionFlags::FlagEnum eSwing1; 894 }; 895 896 struct MotionSwing2 897 { 898 MotionSwing2(xmlNode* node); 899 void exportElement(COLLADASW::StreamWriter& sw) const; 900 MotionFlags::FlagEnum eSwing2; 901 }; 902 903 struct Motion 904 { 905 Motion(xmlNode* node); 906 void exportElement(COLLADASW::StreamWriter& sw) const; 907 MotionX eX; 908 MotionY eY; 909 MotionZ eZ; 910 MotionTwist eTwist; 911 MotionSwing1 eSwing1; 912 MotionSwing2 eSwing2; 913 }; 914 915 struct BounceThreshold 916 { 917 BounceThreshold(xmlNode* node); 918 void exportElement(COLLADASW::StreamWriter& sw) const; 919 double bounceThreshold; 920 }; 921 922 struct Stiffness 923 { 924 Stiffness(xmlNode* node); 925 void exportElement(COLLADASW::StreamWriter& sw) const; 926 double stiffness; 927 }; 928 929 struct Damping 930 { 931 Damping(xmlNode* node); 932 void exportElement(COLLADASW::StreamWriter& sw) const; 933 double damping; 934 }; 935 936 struct ContactDistance 937 { 938 ContactDistance(xmlNode* node); 939 void exportElement(COLLADASW::StreamWriter& sw) const; 940 double contactDistance; 941 }; 942 943 struct Value 944 { 945 Value(xmlNode* node); 946 void exportElement(COLLADASW::StreamWriter& sw) const; 947 double value; 948 }; 949 950 struct LinearLimit 951 { 952 LinearLimit(xmlNode* node); 953 void exportElement(COLLADASW::StreamWriter& sw) const; 954 Restitution restitution; 955 BounceThreshold bounceThreshold; 956 Stiffness stiffness; 957 Damping damping; 958 ContactDistance contactDistance; 959 Value value; 960 }; 961 962 struct Upper 963 { 964 Upper(xmlNode* node); 965 void exportElement(COLLADASW::StreamWriter& sw) const; 966 double upper; 967 }; 968 969 struct Lower 970 { 971 Lower(xmlNode* node); 972 void exportElement(COLLADASW::StreamWriter& sw) const; 973 double lower; 974 }; 975 976 struct TwistLimit 977 { 978 TwistLimit(xmlNode* node); 979 void exportElement(COLLADASW::StreamWriter& sw) const; 980 Restitution restitution; 981 BounceThreshold bounceThreshold; 982 Stiffness stiffness; 983 Damping damping; 984 ContactDistance contactDistance; 985 Upper upper; 986 Lower lower; 987 }; 988 989 struct YAngle 990 { 991 YAngle(xmlNode* node); 992 void exportElement(COLLADASW::StreamWriter& sw) const; 993 double yAngle; 994 }; 995 996 struct ZAngle 997 { 998 ZAngle(xmlNode* node); 999 void exportElement(COLLADASW::StreamWriter& sw) const; 1000 double zAngle; 1001 }; 1002 1003 struct SwingLimit 1004 { 1005 SwingLimit(xmlNode* node); 1006 void exportElement(COLLADASW::StreamWriter& sw) const; 1007 Restitution restitution; 1008 BounceThreshold bounceThreshold; 1009 Stiffness stiffness; 1010 Damping damping; 1011 ContactDistance contactDistance; 1012 YAngle yAngle; 1013 ZAngle zAngle; 1014 }; 1015 1016 struct ForceLimit 1017 { 1018 ForceLimit(xmlNode* node); 1019 void exportElement(COLLADASW::StreamWriter& sw) const; 1020 double forceLimit; 1021 }; 1022 1023 struct DriveFlags 1024 { 1025 enum FlagEnum 1026 { 1027 Acceleration = 1 1028 }; 1029 1030 DriveFlags(xmlNode* node); 1031 void exportElement(COLLADASW::StreamWriter& sw) const; 1032 Flags<FlagEnum> flags; 1033 1034 static const std::map<FlagEnum, String> & GetFlagToStringMap(); 1035 1036 private: 1037 static std::map<String, FlagEnum> mStringToFlagMap; 1038 static std::map<FlagEnum, String> mFlagToStringMap; 1039 static std::map<String, FlagEnum> InitializeStringToFlagMap(); 1040 static std::map<FlagEnum, String> InitializeFlagToStringMap(); 1041 }; 1042 1043 struct DriveX 1044 { 1045 DriveX(xmlNode* node); 1046 void exportElement(COLLADASW::StreamWriter& sw) const; 1047 Stiffness stiffness; 1048 Damping damping; 1049 ForceLimit forceLimit; 1050 DriveFlags flags; 1051 }; 1052 1053 struct DriveY 1054 { 1055 DriveY(xmlNode* node); 1056 void exportElement(COLLADASW::StreamWriter& sw) const; 1057 Stiffness stiffness; 1058 Damping damping; 1059 ForceLimit forceLimit; 1060 DriveFlags flags; 1061 }; 1062 1063 struct DriveZ 1064 { 1065 DriveZ(xmlNode* node); 1066 void exportElement(COLLADASW::StreamWriter& sw) const; 1067 Stiffness stiffness; 1068 Damping damping; 1069 ForceLimit forceLimit; 1070 DriveFlags flags; 1071 }; 1072 1073 struct DriveSwing 1074 { 1075 DriveSwing(xmlNode* node); 1076 void exportElement(COLLADASW::StreamWriter& sw) const; 1077 Stiffness stiffness; 1078 Damping damping; 1079 ForceLimit forceLimit; 1080 DriveFlags flags; 1081 }; 1082 1083 struct DriveTwist 1084 { 1085 DriveTwist(xmlNode* node); 1086 void exportElement(COLLADASW::StreamWriter& sw) const; 1087 Stiffness stiffness; 1088 Damping damping; 1089 ForceLimit forceLimit; 1090 DriveFlags flags; 1091 }; 1092 1093 struct DriveSlerp 1094 { 1095 DriveSlerp(xmlNode* node); 1096 void exportElement(COLLADASW::StreamWriter& sw) const; 1097 Stiffness stiffness; 1098 Damping damping; 1099 ForceLimit forceLimit; 1100 DriveFlags flags; 1101 }; 1102 1103 struct Drive 1104 { 1105 Drive(xmlNode* node); 1106 void exportElement(COLLADASW::StreamWriter& sw) const; 1107 DriveX driveX; 1108 DriveY driveY; 1109 DriveZ driveZ; 1110 DriveSwing driveSwing; 1111 DriveTwist driveTwist; 1112 DriveSlerp driveSlerp; 1113 }; 1114 1115 struct DrivePosition 1116 { 1117 DrivePosition(xmlNode* node); 1118 void exportElement(COLLADASW::StreamWriter& sw) const; 1119 MQuaternion rotation; 1120 MVector translation; 1121 }; 1122 1123 struct Linear 1124 { 1125 Linear(xmlNode* node); 1126 void exportElement(COLLADASW::StreamWriter& sw) const; 1127 MVector linear; 1128 }; 1129 1130 struct Angular 1131 { 1132 Angular(xmlNode* node); 1133 void exportElement(COLLADASW::StreamWriter& sw) const; 1134 MVector angular; 1135 }; 1136 1137 struct DriveVelocity 1138 { 1139 DriveVelocity(xmlNode* node); 1140 void exportElement(COLLADASW::StreamWriter& sw) const; 1141 Linear linear; 1142 Angular angular; 1143 }; 1144 1145 struct ProjectionLinearTolerance 1146 { 1147 ProjectionLinearTolerance(xmlNode* node); 1148 void exportElement(COLLADASW::StreamWriter& sw) const; 1149 double projectionLinearTolerance; 1150 }; 1151 1152 struct ProjectionAngularTolerance 1153 { 1154 ProjectionAngularTolerance(xmlNode* node); 1155 void exportElement(COLLADASW::StreamWriter& sw) const; 1156 double projectionAngularTolerance; 1157 }; 1158 1159 struct PxD6Joint 1160 { 1161 PxD6Joint(xmlNode* node); 1162 void exportElement(COLLADASW::StreamWriter& sw) const; 1163 Id id; 1164 Actors actors; 1165 ActorLocalPose localPose; 1166 BreakForce breakForce; 1167 ConstraintFlags constraintFlags; 1168 InvMassScale0 invMassScale0; 1169 InvInertiaScale0 invInertiaScale0; 1170 InvMassScale1 invMassScale1; 1171 InvInertiaScale1 invInertiaScale1; 1172 Name name; 1173 Motion motion; 1174 LinearLimit linearLimit; 1175 TwistLimit twistLimit; 1176 SwingLimit swingLimit; 1177 Drive drive; 1178 DrivePosition drivePosition; 1179 DriveVelocity driveVelocity; 1180 ProjectionLinearTolerance projectionLinearTolerance; 1181 ProjectionAngularTolerance projectionAngularTolerance; 1182 }; 1183 1184 struct PhysX30Collection 1185 { 1186 PhysX30Collection(xmlNode* node); 1187 void exportElement(COLLADASW::StreamWriter& sw) const; 1188 UpVector upVector; 1189 LengthMassSpeedScale scale; 1190 std::vector<PxConvexMesh> convexMeshes; 1191 std::vector<PxTriangleMesh> triangleMeshes; 1192 std::vector<PxMaterial> materials; 1193 std::vector<PxRigidStatic> rigidStatics; 1194 std::vector<PxRigidDynamic> rigidDynamics; 1195 std::vector<PxD6Joint> D6Joints; 1196 }; 1197 1198 struct PhysXDoc 1199 { 1200 PhysXDoc(xmlDocPtr xml); 1201 PhysX30Collection physX30Collection; 1202 bool validate(); 1203 1204 PxConvexMesh* findConvexMesh(uint64_t id); 1205 PxTriangleMesh* findTriangleMesh(uint64_t id); 1206 PxMaterial* findMaterial(uint64_t ref); 1207 PxMaterial* findMaterial(const String& shapeName); 1208 PxShape* findShape(const String & shapeName); 1209 PxRigidBody* findRigidBody(const String & bodyName); 1210 PxRigidBody* findRigidBody(uint64_t id); 1211 PxRigidStatic* findRigidStatic(uint64_t id); 1212 PxRigidStatic* findRigidStatic(const String& bodyName); 1213 PxRigidDynamic* findRigidDynamic(uint64_t id); 1214 PxRigidDynamic* findRigidDynamic(const String& bodyName); 1215 PxD6Joint* findD6Joint(const String& jointName); 1216 }; 1217 1218 class PhysXDocPtr 1219 { 1220 public: 1221 PhysXDocPtr(); 1222 PhysXDocPtr(xmlDocPtr xml); 1223 ~PhysXDocPtr(); 1224 1225 const PhysXDocPtr& operator = (xmlDocPtr xml); 1226 1227 PhysXDoc* operator -> () const; 1228 1229 operator bool() const; 1230 1231 private: 1232 PhysXDoc* mPhysXDoc; 1233 }; 1234 } 1235 }