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 #include "COLLADAMayaStableHeaders.h" 17 18 #include "COLLADAMayaPhysXXML.h" 19 #include "COLLADASWStreamWriter.h" 20 21 using namespace COLLADASW; 22 23 namespace COLLADAMaya 24 { 25 namespace PhysXXML 26 { 27 namespace Strings 28 { 29 const String actor0 = "actor0"; 30 const String actor1 = "actor1"; 31 const String ActorFlags = "ActorFlags"; 32 const String Actors = "Actors"; 33 const String angular = "angular"; 34 const String AngularDamping = "AngularDamping"; 35 const String AngularVelocity = "AngularVelocity"; 36 const String BounceThreshold = "BounceThreshold"; 37 const String BreakForce = "BreakForce"; 38 const String CMassLocalPose = "CMassLocalPose"; 39 const String ConstraintFlags = "ConstraintFlags"; 40 const String ContactDistance = "ContactDistance"; 41 const String ContactOffset = "ContactOffset"; 42 const String ContactReportThreshold = "ContactReportThreshold"; 43 const String ConvexMesh = "ConvexMesh"; 44 const String Damping = "Damping"; 45 const String DominanceGroup = "DominanceGroup"; 46 const String Drive = "Drive"; 47 const String DrivePosition = "DrivePosition"; 48 const String DriveVelocity = "DriveVelocity"; 49 const String DynamicFriction = "DynamicFriction"; 50 const String eACTOR0 = "eACTOR0"; 51 const String eACTOR1 = "eACTOR1"; 52 const String eSLERP = "eSLERP"; 53 const String eSWING = "eSWING"; 54 const String eSWING1 = "eSWING1"; 55 const String eSWING2 = "eSWING2"; 56 const String eTWIST = "eTWIST"; 57 const String eX = "eX"; 58 const String eY = "eY"; 59 const String eZ = "eZ"; 60 const String Flags = "Flags"; 61 const String force = "force"; 62 const String ForceLimit = "ForceLimit"; 63 const String FrictionCombineMode = "FrictionCombineMode"; 64 const String Id = "Id"; 65 const String InvInertiaScale0 = "InvInertiaScale0"; 66 const String InvInertiaScale1 = "InvInertiaScale1"; 67 const String InvMassScale0 = "InvMassScale0"; 68 const String InvMassScale1 = "InvMassScale1"; 69 const String Geometry = "Geometry"; 70 const String GlobalPose = "GlobalPose"; 71 const String HalfExtents = "HalfExtents"; 72 const String HalfHeight = "HalfHeight"; 73 const String Length = "Length"; 74 const String linear = "linear"; 75 const String LinearDamping = "LinearDamping"; 76 const String LinearLimit = "LinearLimit"; 77 const String LinearVelocity = "LinearVelocity"; 78 const String LocalPose = "LocalPose"; 79 const String Lower = "Lower"; 80 const String Mass = "Mass"; 81 const String MassSpaceInertiaTensor = "MassSpaceInertiaTensor"; 82 const String Materials = "Materials"; 83 const String MaxAngularVelocity = "MaxAngularVelocity"; 84 const String MaxDepenetrationVelocity = "MaxDepenetrationVelocity"; 85 const String MinCCDAdvanceCoefficient = "MinCCDAdvanceCoefficient"; 86 const String minPositionIters = "minPositionIters"; 87 const String minVelocityIters = "minVelocityIters"; 88 const String Motion = "Motion"; 89 const String Name = "Name"; 90 const String OwnerClient = "OwnerClient"; 91 const String PhysX30Collection = "PhysX30Collection"; 92 const String points = "points"; 93 const String ProjectionAngularTolerance = "ProjectionAngularTolerance"; 94 const String ProjectionLinearTolerance = "ProjectionLinearTolerance"; 95 const String PxBoxGeometry = "PxBoxGeometry"; 96 const String PxCapsuleGeometry = "PxCapsuleGeometry"; 97 const String PxConvexMesh = "PxConvexMesh"; 98 const String PxConvexMeshGeometry = "PxConvexMeshGeometry"; 99 const String PxD6Joint = "PxD6Joint"; 100 const String PxMaterial = "PxMaterial"; 101 const String PxMaterialRef = "PxMaterialRef"; 102 const String PxPlaneGeometry = "PxPlaneGeometry"; 103 const String PxRigidDynamic = "PxRigidDynamic"; 104 const String PxRigidStatic = "PxRigidStatic"; 105 const String PxShape = "PxShape"; 106 const String PxSphereGeometry = "PxSphereGeometry"; 107 const String PxTriangleMesh = "PxTriangleMesh"; 108 const String PxTriangleMeshGeometry = "PxTriangleMeshGeometry"; 109 const String QueryFilterData = "QueryFilterData"; 110 const String Radius = "Radius"; 111 const String Restitution = "Restitution"; 112 const String RestitutionCombineMode = "RestitutionCombineMode"; 113 const String RestOffset = "RestOffset"; 114 const String RigidBodyFlags = "RigidBodyFlags"; 115 const String Rotation = "Rotation"; 116 const String Scale = "Scale"; 117 const String Shapes = "Shapes"; 118 const String SimulationFilterData = "SimulationFilterData"; 119 const String SleepThreshold = "SleepThreshold"; 120 const String SolverIterationCounts = "SolverIterationCounts"; 121 const String Speed = "Speed"; 122 const String StabilizationThreshold = "StabilizationThreshold"; 123 const String StaticFriction = "StaticFriction"; 124 const String Stiffness = "Stiffness"; 125 const String SwingLimit = "SwingLimit"; 126 const String text = "text"; 127 const String torque = "torque"; 128 const String TriangleMesh = "TriangleMesh"; 129 const String Triangles = "Triangles"; 130 const String TwistLimit = "TwistLimit"; 131 const String Upper = "Upper"; 132 const String UpVector = "UpVector"; 133 const String Value = "Value"; 134 const String WakeCounter = "WakeCounter"; 135 const String YAngle = "YAngle"; 136 const String ZAngle = "ZAngle"; 137 138 const String eAVERAGE = "eAVERAGE"; 139 const String eMIN = "eMIN"; 140 const String eMULTIPLY = "eMULTIPLY"; 141 const String eMAX = "eMAX"; 142 const String eVISUALIZATION = "eVISUALIZATION"; 143 const String eDISABLE_GRAVITY = "eDISABLE_GRAVITY"; 144 const String eSEND_SLEEP_NOTIFIES = "eSEND_SLEEP_NOTIFIES"; 145 const String eDISABLE_SIMULATION = "eDISABLE_SIMULATION"; 146 const String eKINEMATIC = "eKINEMATIC"; 147 const String eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES = "eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES"; 148 const String eENABLE_CCD = "eENABLE_CCD"; 149 const String eENABLE_CCD_FRICTION = "eENABLE_CCD_FRICTION"; 150 const String eSIMULATION_SHAPE = "eSIMULATION_SHAPE"; 151 const String eSCENE_QUERY_SHAPE = "eSCENE_QUERY_SHAPE"; 152 const String eTRIGGER_SHAPE = "eTRIGGER_SHAPE"; 153 const String ePARTICLE_DRAIN = "ePARTICLE_DRAIN"; 154 const String eBROKEN = "eBROKEN"; 155 const String ePROJECT_TO_ACTOR0 = "ePROJECT_TO_ACTOR0"; 156 const String ePROJECT_TO_ACTOR1 = "ePROJECT_TO_ACTOR1"; 157 const String ePROJECTION = "ePROJECTION"; 158 const String eCOLLISION_ENABLED = "eCOLLISION_ENABLED"; 159 const String eREPORTING = "eREPORTING"; 160 const String eDRIVE_LIMITS_ARE_FORCES = "eDRIVE_LIMITS_ARE_FORCES"; 161 const String eIMPROVED_SLERP = "eIMPROVED_SLERP"; 162 const String eACCELERATION = "eACCELERATION"; 163 const String eLOCKED = "eLOCKED"; 164 const String eLIMITED = "eLIMITED"; 165 const String eFREE = "eFREE"; 166 } 167 168 std::map<String, CombineMode::FlagEnum> CombineMode::mStringToFlagMap = CombineMode::InitializeStringToFlagMap(); InitializeStringToFlagMap()169 std::map<String, CombineMode::FlagEnum> CombineMode::InitializeStringToFlagMap() 170 { 171 std::map<String, FlagEnum> m; 172 m[Strings::eAVERAGE] = Average; 173 m[Strings::eMIN] = Min; 174 m[Strings::eMULTIPLY] = Multiply; 175 m[Strings::eMAX] = Max; 176 return m; 177 } 178 std::map<CombineMode::FlagEnum, String> CombineMode::mFlagToStringMap = CombineMode::InitializeFlagToStringMap(); InitializeFlagToStringMap()179 std::map<CombineMode::FlagEnum, String> CombineMode::InitializeFlagToStringMap() 180 { 181 std::map<FlagEnum, String> m; 182 m[Average] = Strings::eAVERAGE; 183 m[Min] = Strings::eMIN; 184 m[Multiply] = Strings::eMULTIPLY; 185 m[Max] = Strings::eMAX; 186 return m; 187 } GetStringToFlagMap()188 const std::map<String, CombineMode::FlagEnum> & CombineMode::GetStringToFlagMap() 189 { 190 return mStringToFlagMap; 191 } GetFlagToStringMap()192 const std::map<CombineMode::FlagEnum, String> & CombineMode::GetFlagToStringMap() 193 { 194 return mFlagToStringMap; 195 } 196 197 std::map<String, ActorFlags::FlagEnum> ActorFlags::mStringToFlagMap = ActorFlags::InitializeStringToFlagMap(); InitializeStringToFlagMap()198 std::map<String, ActorFlags::FlagEnum> ActorFlags::InitializeStringToFlagMap() 199 { 200 std::map<String, FlagEnum> m; 201 m[Strings::eVISUALIZATION] = Visualization; 202 m[Strings::eDISABLE_GRAVITY] = DisableGravity; 203 m[Strings::eSEND_SLEEP_NOTIFIES] = SendSleepNotifies; 204 m[Strings::eDISABLE_SIMULATION] = DisableSimulation; 205 return m; 206 } 207 std::map<ActorFlags::FlagEnum, String> ActorFlags::mFlagToStringMap = ActorFlags::InitializeFlagToStringMap(); InitializeFlagToStringMap()208 std::map<ActorFlags::FlagEnum, String> ActorFlags::InitializeFlagToStringMap() 209 { 210 std::map<FlagEnum, String> m; 211 m[Visualization] = Strings::eVISUALIZATION; 212 m[DisableGravity] = Strings::eDISABLE_GRAVITY; 213 m[SendSleepNotifies] = Strings::eSEND_SLEEP_NOTIFIES; 214 m[DisableSimulation] = Strings::eDISABLE_SIMULATION; 215 return m; 216 } GetFlagToStringMap()217 const std::map<ActorFlags::FlagEnum, String> & ActorFlags::GetFlagToStringMap() 218 { 219 return mFlagToStringMap; 220 } 221 222 std::map<String, RigidBodyFlags::FlagEnum> RigidBodyFlags::mStringToFlagMap = RigidBodyFlags::InitializeStringToFlagMap(); InitializeStringToFlagMap()223 std::map<String, RigidBodyFlags::FlagEnum> RigidBodyFlags::InitializeStringToFlagMap() 224 { 225 std::map<String, FlagEnum> m; 226 m[Strings::eKINEMATIC] = Kinematic; 227 m[Strings::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES] = UseKinematicTargetForSceneQueries; 228 m[Strings::eENABLE_CCD] = EnabledCCD; 229 m[Strings::eENABLE_CCD_FRICTION] = EnabledCCDFriction; 230 return m; 231 } 232 std::map<RigidBodyFlags::FlagEnum, String> RigidBodyFlags::mFlagToStringMap = RigidBodyFlags::InitializeFlagToStringMap(); InitializeFlagToStringMap()233 std::map<RigidBodyFlags::FlagEnum, String> RigidBodyFlags::InitializeFlagToStringMap() 234 { 235 std::map<FlagEnum, String> m; 236 m[Kinematic] = Strings::eKINEMATIC; 237 m[UseKinematicTargetForSceneQueries] = Strings::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES; 238 m[EnabledCCD] = Strings::eENABLE_CCD; 239 m[EnabledCCDFriction] = Strings::eENABLE_CCD_FRICTION; 240 return m; 241 } GetFlagToStringMap()242 const std::map<RigidBodyFlags::FlagEnum, String> & RigidBodyFlags::GetFlagToStringMap() 243 { 244 return mFlagToStringMap; 245 } 246 247 std::map<String, ShapeFlags::FlagEnum> ShapeFlags::mStringToFlagMap = ShapeFlags::InitializeStringToFlagMap(); InitializeStringToFlagMap()248 std::map<String, ShapeFlags::FlagEnum> ShapeFlags::InitializeStringToFlagMap() 249 { 250 std::map<String, FlagEnum> m; 251 m[Strings::eSIMULATION_SHAPE] = SimulationShape; 252 m[Strings::eSCENE_QUERY_SHAPE] = SceneQueryShape; 253 m[Strings::eTRIGGER_SHAPE] = TriggerShape; 254 m[Strings::eVISUALIZATION] = Visualization; 255 m[Strings::ePARTICLE_DRAIN] = ParticleDrain; 256 return m; 257 } 258 std::map<ShapeFlags::FlagEnum, String> ShapeFlags::mFlagToStringMap = ShapeFlags::InitializeFlagToStringMap(); InitializeFlagToStringMap()259 std::map<ShapeFlags::FlagEnum, String> ShapeFlags::InitializeFlagToStringMap() 260 { 261 std::map<FlagEnum, String> m; 262 m[SimulationShape] = Strings::eSIMULATION_SHAPE; 263 m[SceneQueryShape] = Strings::eSCENE_QUERY_SHAPE; 264 m[TriggerShape] = Strings::eTRIGGER_SHAPE; 265 m[Visualization] = Strings::eVISUALIZATION; 266 m[ParticleDrain] = Strings::ePARTICLE_DRAIN; 267 return m; 268 } GetFlagToStringMap()269 const std::map<ShapeFlags::FlagEnum, String> & ShapeFlags::GetFlagToStringMap() 270 { 271 return mFlagToStringMap; 272 } 273 274 std::map<String, ConstraintFlags::FlagEnum> ConstraintFlags::mStringToFlagMap = ConstraintFlags::InitializeStringToFlagMap(); InitializeStringToFlagMap()275 std::map<String, ConstraintFlags::FlagEnum> ConstraintFlags::InitializeStringToFlagMap() 276 { 277 std::map<String, FlagEnum> m; 278 m[Strings::eBROKEN] = Broken; 279 m[Strings::ePROJECT_TO_ACTOR0] = ProjectToActor0; 280 m[Strings::ePROJECT_TO_ACTOR1] = ProjectToActor1; 281 m[Strings::ePROJECTION] = Projection; 282 m[Strings::eCOLLISION_ENABLED] = CollisionEnabled; 283 m[Strings::eREPORTING] = Reporting; 284 m[Strings::eVISUALIZATION] = Visualization; 285 m[Strings::eDRIVE_LIMITS_ARE_FORCES] = DriveLimitsAreForces; 286 m[Strings::eIMPROVED_SLERP] = ImprovedSlerp; 287 return m; 288 } 289 std::map<ConstraintFlags::FlagEnum, String> ConstraintFlags::mFlagToStringMap = ConstraintFlags::InitializeFlagToStringMap(); InitializeFlagToStringMap()290 std::map<ConstraintFlags::FlagEnum, String> ConstraintFlags::InitializeFlagToStringMap() 291 { 292 std::map<FlagEnum, String> m; 293 m[Broken] = Strings::eBROKEN; 294 m[ProjectToActor0] = Strings::ePROJECT_TO_ACTOR0; 295 m[ProjectToActor1] = Strings::ePROJECT_TO_ACTOR1; 296 m[Projection] = Strings::ePROJECTION; 297 m[CollisionEnabled] = Strings::eCOLLISION_ENABLED; 298 m[Reporting] = Strings::eREPORTING; 299 m[Visualization] = Strings::eVISUALIZATION; 300 m[DriveLimitsAreForces] = Strings::eDRIVE_LIMITS_ARE_FORCES; 301 m[ImprovedSlerp] = Strings::eIMPROVED_SLERP; 302 return m; 303 } GetFlagToStringMap()304 const std::map<ConstraintFlags::FlagEnum, String> & ConstraintFlags::GetFlagToStringMap() 305 { 306 return mFlagToStringMap; 307 } 308 309 std::map<String, DriveFlags::FlagEnum> DriveFlags::mStringToFlagMap = DriveFlags::InitializeStringToFlagMap(); InitializeStringToFlagMap()310 std::map<String, DriveFlags::FlagEnum> DriveFlags::InitializeStringToFlagMap() 311 { 312 std::map<String, FlagEnum> m; 313 m[Strings::eACCELERATION] = Acceleration; 314 return m; 315 } 316 std::map<DriveFlags::FlagEnum, String> DriveFlags::mFlagToStringMap = DriveFlags::InitializeFlagToStringMap(); InitializeFlagToStringMap()317 std::map<DriveFlags::FlagEnum, String> DriveFlags::InitializeFlagToStringMap() 318 { 319 std::map<FlagEnum, String> m; 320 m[Acceleration] = Strings::eACCELERATION; 321 return m; 322 } GetFlagToStringMap()323 const std::map<DriveFlags::FlagEnum, String> & DriveFlags::GetFlagToStringMap() 324 { 325 return mFlagToStringMap; 326 } 327 328 std::map<String, MotionFlags::FlagEnum> MotionFlags::mStringToFlagMap = MotionFlags::InitializeStringToFlagMap(); InitializeStringToFlagMap()329 std::map<String, MotionFlags::FlagEnum> MotionFlags::InitializeStringToFlagMap() 330 { 331 std::map<String, FlagEnum> m; 332 m[Strings::eLOCKED] = Locked; 333 m[Strings::eLIMITED] = Limited; 334 m[Strings::eFREE] = Free; 335 return m; 336 } 337 std::map<MotionFlags::FlagEnum, String> MotionFlags::mFlagToStringMap = MotionFlags::InitializeFlagToStringMap(); InitializeFlagToStringMap()338 std::map<MotionFlags::FlagEnum, String> MotionFlags::InitializeFlagToStringMap() 339 { 340 std::map<FlagEnum, String> m; 341 m[Locked] = Strings::eLOCKED; 342 m[Limited] = Strings::eLIMITED; 343 m[Free] = Strings::eFREE; 344 return m; 345 } GetStringToFlagMap()346 const std::map<String, MotionFlags::FlagEnum> & MotionFlags::GetStringToFlagMap() 347 { 348 return mStringToFlagMap; 349 } GetFlagToStringMap()350 const std::map<MotionFlags::FlagEnum, String> & MotionFlags::GetFlagToStringMap() 351 { 352 return mFlagToStringMap; 353 } 354 355 template<typename E> FlagsToString(const Flags<E> & flags,const std::map<E,String> & flagToStringMap)356 String FlagsToString(const Flags<E> & flags, const std::map<E, String> & flagToStringMap) 357 { 358 String s; 359 for (int i = 0; i < 32; ++i) 360 { 361 E flag = static_cast<E>(1 << i); 362 if (flags & flag) 363 { 364 typename std::map<E, String>::const_iterator it = flagToStringMap.find(flag); 365 if (!s.empty()) 366 s += '|'; 367 s += it->second; 368 } 369 } 370 return s; 371 } 372 equal(xmlNode * node,const String & name)373 bool equal(xmlNode* node, const String& name) 374 { 375 if (!node) { 376 return false; 377 } 378 //return _stricmp(reinterpret_cast<const char*>(node->name), name.c_str()) == 0; 379 return name == reinterpret_cast<const char*>(node->name); 380 } 381 382 template<typename T> FindChild(T node,const String & name)383 xmlNode* FindChild(T node, const String& name) 384 { 385 if (!node) { 386 return NULL; 387 } 388 389 xmlNode* child = node->children; 390 while (child) 391 { 392 if (equal(child, name)) { 393 return child; 394 } 395 child = child->next; 396 } 397 return NULL; 398 } 399 400 template<typename T> FindChildren(T node,const String & name)401 std::vector<xmlNode*> FindChildren(T node, const String& name) 402 { 403 if (!node) { 404 return std::vector<xmlNode*>(); 405 } 406 407 std::vector<xmlNode*> children; 408 xmlNode* child = node->children; 409 while (child) 410 { 411 if (equal(child, name)) { 412 children.push_back(child); 413 } 414 child = child->next; 415 } 416 return children; 417 } 418 419 template<typename E> GetContent(xmlNode * node,Flags<E> & flags,const std::map<String,E> & stringToFlagMap)420 void GetContent(xmlNode* node, Flags<E> & flags, const std::map<String, E> & stringToFlagMap) 421 { 422 if (!node) { 423 return; 424 } 425 426 node = FindChild(node, Strings::text); 427 if (!node) { 428 return; 429 } 430 431 if (!node->content) { 432 return; 433 } 434 435 std::stringstream ss; 436 ss << node->content; 437 438 String str; 439 ss >> str; 440 441 std::vector<String> strFlags; 442 COLLADABU::Utils::split(str, "|", strFlags); 443 flags.clear(); 444 for (size_t i = 0; i < strFlags.size(); ++i) 445 { 446 typename std::map<String, E>::const_iterator it = stringToFlagMap.find(strFlags[i]); 447 if (it != stringToFlagMap.end()) 448 { 449 flags |= it->second; 450 } 451 } 452 } 453 454 template<typename E> GetContent(xmlNode * node,E & flag,const std::map<String,E> & stringToFlagMap)455 void GetContent(xmlNode* node, E & flag, const std::map<String, E> & stringToFlagMap) 456 { 457 if (!node) { 458 return; 459 } 460 461 node = FindChild(node, Strings::text); 462 if (!node) { 463 return; 464 } 465 466 if (!node->content) { 467 return; 468 } 469 470 std::stringstream ss; 471 ss << node->content; 472 473 String str; 474 ss >> str; 475 476 flag = static_cast<E>(0); 477 478 typename std::map<String, E>::const_iterator it = stringToFlagMap.find(str); 479 if (it != stringToFlagMap.end()) 480 { 481 flag = it->second; 482 } 483 } 484 GetContent(xmlNode * node,double & content)485 void GetContent(xmlNode* node, double& content) 486 { 487 if (!node) { 488 return; 489 } 490 491 node = FindChild(node, Strings::text); 492 if (!node) { 493 return; 494 } 495 496 if (!node->content) { 497 return; 498 } 499 500 std::stringstream s; 501 s << node->content; 502 s >> content; 503 } 504 GetContent(xmlNode * node,int & content)505 void GetContent(xmlNode* node, int& content) 506 { 507 if (!node) { 508 return; 509 } 510 511 node = FindChild(node, Strings::text); 512 if (!node) { 513 return; 514 } 515 516 if (!node->content) { 517 return; 518 } 519 520 std::stringstream s; 521 s << node->content; 522 s >> content; 523 } 524 GetContent(xmlNode * node,uint64_t & content)525 void GetContent(xmlNode* node, uint64_t& content) 526 { 527 if (!node) { 528 return; 529 } 530 531 node = FindChild(node, Strings::text); 532 if (!node) { 533 return; 534 } 535 536 if (!node->content) { 537 return; 538 } 539 540 std::stringstream s; 541 s << node->content; 542 s >> content; 543 } 544 GetContent(xmlNode * node,MQuaternion & q,MVector & v)545 void GetContent(xmlNode* node, MQuaternion& q, MVector& v) 546 { 547 if (!node) { 548 return; 549 } 550 551 node = FindChild(node, Strings::text); 552 if (!node) { 553 return; 554 } 555 556 if (!node->content) { 557 return; 558 } 559 560 std::stringstream s; 561 s << node->content; 562 s >> q.x; 563 s >> q.y; 564 s >> q.z; 565 s >> q.w; 566 s >> v.x; 567 s >> v.y; 568 s >> v.z; 569 } 570 GetContent(xmlNode * node,int & a,int & b,int & c,int & d)571 void GetContent(xmlNode* node, int& a, int& b, int& c, int& d) 572 { 573 if (!node) { 574 return; 575 } 576 577 node = FindChild(node, Strings::text); 578 if (!node) { 579 return; 580 } 581 582 if (!node->content) { 583 return; 584 } 585 586 std::stringstream s; 587 s << node->content; 588 s >> a; 589 s >> b; 590 s >> c; 591 s >> d; 592 } 593 GetContent(xmlNode * node,String & content)594 void GetContent(xmlNode* node, String& content) 595 { 596 if (!node) { 597 return; 598 } 599 600 node = FindChild(node, Strings::text); 601 if (!node) { 602 return; 603 } 604 605 if (!node->content) { 606 return; 607 } 608 609 std::stringstream s; 610 s << node->content; 611 s >> content; 612 } 613 ReplaceAll(String & str,const String & what,const String & by)614 void ReplaceAll(String& str, const String& what, const String& by) 615 { 616 const size_t whatLength = what.length(); 617 const size_t byLength = by.length(); 618 for (size_t pos = str.find(what, 0); pos != std::string::npos; pos = str.find(what, pos + byLength)) 619 { 620 str.replace(pos, whatLength, by); 621 } 622 } 623 GetContent(xmlNode * node,std::vector<PhysXXML::Point> & content)624 void GetContent(xmlNode* node, std::vector<PhysXXML::Point>& content) 625 { 626 content.clear(); 627 if (!node) { 628 return; 629 } 630 631 node = FindChild(node, Strings::text); 632 if (!node) { 633 return; 634 } 635 636 if (!node->content) { 637 return; 638 } 639 640 std::string contentStr = reinterpret_cast<const char*>(node->content); 641 642 // Convert all 
 and 	 643 ReplaceAll(contentStr, "
", " "); 644 ReplaceAll(contentStr, "	", ""); 645 646 std::stringstream s(contentStr); 647 648 do { 649 PhysXXML::Point p; 650 s >> p.x; 651 s >> p.y; 652 s >> p.z; 653 content.push_back(p); 654 } while (!s.eof()); 655 } 656 GetContent(xmlNode * node,std::vector<PhysXXML::Triangle> & content)657 void GetContent(xmlNode* node, std::vector<PhysXXML::Triangle>& content) 658 { 659 content.clear(); 660 if (!node) { 661 return; 662 } 663 664 node = FindChild(node, Strings::text); 665 if (!node) { 666 return; 667 } 668 669 if (!node->content) { 670 return; 671 } 672 673 std::string contentStr = reinterpret_cast<const char*>(node->content); 674 675 // Convert all 
 and 	 676 ReplaceAll(contentStr, "
", " "); 677 ReplaceAll(contentStr, "	", ""); 678 679 std::stringstream s(contentStr); 680 681 do { 682 PhysXXML::Triangle t; 683 s >> t.point0; 684 s >> t.point1; 685 s >> t.point2; 686 content.push_back(t); 687 } while (!s.eof()); 688 } 689 GetContent(xmlNode * node,MVector & content)690 void GetContent(xmlNode* node, MVector& content) 691 { 692 if (!node) { 693 return; 694 } 695 696 node = FindChild(node, Strings::text); 697 if (!node) { 698 return; 699 } 700 701 if (!node->content) { 702 return; 703 } 704 705 std::stringstream s; 706 s << node->content; 707 s >> content.x; 708 s >> content.y; 709 s >> content.z; 710 } 711 GetContent(xmlNode * node,MQuaternion & content)712 void GetContent(xmlNode* node, MQuaternion& content) 713 { 714 if (!node) { 715 return; 716 } 717 718 node = FindChild(node, Strings::text); 719 if (!node) { 720 return; 721 } 722 723 if (!node->content) { 724 return; 725 } 726 727 std::stringstream s; 728 s << node->content; 729 s >> content.x; 730 s >> content.y; 731 s >> content.z; 732 s >> content.w; 733 } 734 UpVector(xmlNode * node)735 UpVector::UpVector(xmlNode* node) 736 : upVector(0.0, 0.0, 0.0) 737 { 738 GetContent(node, upVector); 739 } 740 exportElement(StreamWriter & sw) const741 void UpVector::exportElement(StreamWriter& sw) const 742 { 743 sw.openElement(Strings::UpVector); 744 sw.appendValues(upVector.x, upVector.y, upVector.z); 745 sw.closeElement(); 746 } 747 Length(xmlNode * node)748 Length::Length(xmlNode* node) 749 : length(0.0) 750 { 751 GetContent(node, length); 752 } 753 exportElement(StreamWriter & sw) const754 void Length::exportElement(StreamWriter& sw) const 755 { 756 sw.openElement(Strings::Length); 757 sw.appendValues(length); 758 sw.closeElement(); 759 } 760 Mass(xmlNode * node)761 Mass::Mass(xmlNode* node) 762 : mass(0.0) 763 { 764 GetContent(node, mass); 765 } 766 exportElement(StreamWriter & sw) const767 void Mass::exportElement(StreamWriter& sw) const 768 { 769 sw.openElement(Strings::Mass); 770 sw.appendValues(mass); 771 sw.closeElement(); 772 } 773 Speed(xmlNode * node)774 Speed::Speed(xmlNode* node) 775 : speed(0.0) 776 { 777 GetContent(node, speed); 778 } 779 exportElement(StreamWriter & sw) const780 void Speed::exportElement(StreamWriter& sw) const 781 { 782 sw.openElement(Strings::Speed); 783 sw.appendValues(speed); 784 sw.closeElement(); 785 } 786 LengthMassSpeedScale(xmlNode * node)787 LengthMassSpeedScale::LengthMassSpeedScale(xmlNode* node) 788 : length(FindChild(node, Strings::Length)) 789 , mass(FindChild(node, Strings::Mass)) 790 , speed(FindChild(node, Strings::Speed)) 791 {} 792 exportElement(StreamWriter & sw) const793 void LengthMassSpeedScale::exportElement(StreamWriter& sw) const 794 { 795 sw.openElement(Strings::Scale); 796 length.exportElement(sw); 797 mass.exportElement(sw); 798 speed.exportElement(sw); 799 sw.closeElement(); 800 } 801 Id(xmlNode * node)802 Id::Id(xmlNode* node) 803 : id(0) 804 { 805 GetContent(node, id); 806 } 807 exportElement(StreamWriter & sw) const808 void Id::exportElement(StreamWriter& sw) const 809 { 810 sw.openElement(Strings::Id); 811 sw.appendValues(id); 812 sw.closeElement(); 813 } 814 Point()815 Point::Point() 816 : x(0.0) 817 , y(0.0) 818 , z(0.0) 819 {} 820 Points(xmlNode * node)821 Points::Points(xmlNode* node) 822 { 823 GetContent(node, points); 824 } 825 exportElement(StreamWriter & sw) const826 void Points::exportElement(StreamWriter& sw) const 827 { 828 sw.openElement(Strings::points); 829 sw.appendValues(&points[0].x, points.size() * 3); 830 sw.closeElement(); 831 } 832 PxConvexMesh(xmlNode * node)833 PxConvexMesh::PxConvexMesh(xmlNode* node) 834 : id(FindChild(node, Strings::Id)) 835 , points(FindChild(node, Strings::points)) 836 {} 837 exportElement(StreamWriter & sw) const838 void PxConvexMesh::exportElement(StreamWriter& sw) const 839 { 840 sw.openElement(Strings::PxConvexMesh); 841 id.exportElement(sw); 842 points.exportElement(sw); 843 sw.closeElement(); 844 } 845 Triangle()846 Triangle::Triangle() 847 : point0(0) 848 , point1(0) 849 , point2(0) 850 {} 851 Triangles(xmlNode * node)852 Triangles::Triangles(xmlNode* node) 853 { 854 GetContent(node, triangles); 855 } 856 exportElement(StreamWriter & sw) const857 void Triangles::exportElement(StreamWriter& sw) const 858 { 859 sw.openElement(Strings::Triangles); 860 sw.appendValues(&triangles[0].point0, triangles.size() * 3); 861 sw.closeElement(); 862 } 863 PxTriangleMesh(xmlNode * node)864 PxTriangleMesh::PxTriangleMesh(xmlNode* node) 865 : id(FindChild(node, Strings::Id)) 866 , points(FindChild(node, Strings::points)) 867 , triangles(FindChild(node, Strings::Triangles)) 868 {} 869 exportElement(StreamWriter & sw) const870 void PxTriangleMesh::exportElement(StreamWriter& sw) const 871 { 872 sw.openElement(Strings::PxTriangleMesh); 873 id.exportElement(sw); 874 points.exportElement(sw); 875 triangles.exportElement(sw); 876 sw.closeElement(); 877 } 878 DynamicFriction(xmlNode * node)879 DynamicFriction::DynamicFriction(xmlNode* node) 880 : dynamicFriction(0.0) 881 { 882 GetContent(node, dynamicFriction); 883 } 884 exportElement(StreamWriter & sw) const885 void DynamicFriction::exportElement(StreamWriter& sw) const 886 { 887 sw.openElement(Strings::DynamicFriction); 888 sw.appendValues(dynamicFriction); 889 sw.closeElement(); 890 } 891 StaticFriction(xmlNode * node)892 StaticFriction::StaticFriction(xmlNode* node) 893 : staticFriction(0.0) 894 { 895 GetContent(node, staticFriction); 896 } 897 exportElement(StreamWriter & sw) const898 void StaticFriction::exportElement(StreamWriter& sw) const 899 { 900 sw.openElement(Strings::StaticFriction); 901 sw.appendValues(staticFriction); 902 sw.closeElement(); 903 } 904 Restitution(xmlNode * node)905 Restitution::Restitution(xmlNode* node) 906 : restitution(0.0) 907 { 908 GetContent(node, restitution); 909 } 910 exportElement(StreamWriter & sw) const911 void Restitution::exportElement(StreamWriter& sw) const 912 { 913 sw.openElement(Strings::Restitution); 914 sw.appendValues(restitution); 915 sw.closeElement(); 916 } 917 FrictionCombineMode(xmlNode * node)918 FrictionCombineMode::FrictionCombineMode(xmlNode* node) 919 { 920 GetContent(node, frictionCombineMode, CombineMode::GetStringToFlagMap()); 921 } 922 exportElement(StreamWriter & sw) const923 void FrictionCombineMode::exportElement(StreamWriter& sw) const 924 { 925 sw.openElement(Strings::FrictionCombineMode); 926 sw.appendValues(FlagsToString(Flags<CombineMode::FlagEnum>(frictionCombineMode), CombineMode::GetFlagToStringMap())); 927 sw.closeElement(); 928 } 929 RestitutionCombineMode(xmlNode * node)930 RestitutionCombineMode::RestitutionCombineMode(xmlNode* node) 931 { 932 GetContent(node, restitutionCombineMode, CombineMode::GetStringToFlagMap()); 933 } 934 exportElement(StreamWriter & sw) const935 void RestitutionCombineMode::exportElement(StreamWriter& sw) const 936 { 937 sw.openElement(Strings::RestitutionCombineMode); 938 sw.appendValues(FlagsToString(Flags<CombineMode::FlagEnum>(restitutionCombineMode), CombineMode::GetFlagToStringMap())); 939 sw.closeElement(); 940 } 941 PxMaterial(xmlNode * node)942 PxMaterial::PxMaterial(xmlNode* node) 943 : id(FindChild(node, Strings::Id)) 944 , dynamicFriction(FindChild(node, Strings::DynamicFriction)) 945 , staticFriction(FindChild(node, Strings::StaticFriction)) 946 , restitution(FindChild(node, Strings::Restitution)) 947 , frictionCombineMode(FindChild(node, Strings::FrictionCombineMode)) 948 , restitutionCombineMode(FindChild(node, Strings::RestitutionCombineMode)) 949 {} 950 exportElement(StreamWriter & sw) const951 void PxMaterial::exportElement(StreamWriter& sw) const 952 { 953 sw.openElement(Strings::PxMaterial); 954 id.exportElement(sw); 955 dynamicFriction.exportElement(sw); 956 staticFriction.exportElement(sw); 957 restitution.exportElement(sw); 958 frictionCombineMode.exportElement(sw); 959 restitutionCombineMode.exportElement(sw); 960 sw.closeElement(); 961 } 962 Name(xmlNode * node)963 Name::Name(xmlNode* node) 964 { 965 GetContent(node, name); 966 } 967 exportElement(StreamWriter & sw) const968 void Name::exportElement(StreamWriter& sw) const 969 { 970 sw.openElement(Strings::Name); 971 sw.appendValues(name); 972 sw.closeElement(); 973 } 974 ActorFlags(xmlNode * node)975 ActorFlags::ActorFlags(xmlNode* node) 976 { 977 GetContent(node, actorFlags, mStringToFlagMap); 978 } 979 exportElement(StreamWriter & sw) const980 void ActorFlags::exportElement(StreamWriter& sw) const 981 { 982 sw.openElement(Strings::ActorFlags); 983 sw.appendValues(FlagsToString(actorFlags, mFlagToStringMap)); 984 sw.closeElement(); 985 } 986 RigidBodyFlags(xmlNode * node)987 RigidBodyFlags::RigidBodyFlags(xmlNode* node) 988 { 989 GetContent(node, rigidBodyFlags, mStringToFlagMap); 990 } 991 exportElement(StreamWriter & sw) const992 void RigidBodyFlags::exportElement(StreamWriter& sw) const 993 { 994 sw.openElement(Strings::RigidBodyFlags); 995 sw.appendValues(FlagsToString(rigidBodyFlags, mFlagToStringMap)); 996 sw.closeElement(); 997 } 998 DominanceGroup(xmlNode * node)999 DominanceGroup::DominanceGroup(xmlNode* node) 1000 : dominanceGroup(0) 1001 { 1002 GetContent(node, dominanceGroup); 1003 } 1004 exportElement(StreamWriter & sw) const1005 void DominanceGroup::exportElement(StreamWriter& sw) const 1006 { 1007 sw.openElement(Strings::DominanceGroup); 1008 sw.appendValues(dominanceGroup); 1009 sw.closeElement(); 1010 } 1011 OwnerClient(xmlNode * node)1012 OwnerClient::OwnerClient(xmlNode* node) 1013 : ownerClient(0) 1014 { 1015 GetContent(node, ownerClient); 1016 } 1017 exportElement(StreamWriter & sw) const1018 void OwnerClient::exportElement(StreamWriter& sw) const 1019 { 1020 sw.openElement(Strings::OwnerClient); 1021 sw.appendValues(ownerClient); 1022 sw.closeElement(); 1023 } 1024 GlobalPose(xmlNode * node)1025 GlobalPose::GlobalPose(xmlNode* node) 1026 { 1027 GetContent(node, rotation, translation); 1028 } 1029 exportElement(StreamWriter & sw) const1030 void GlobalPose::exportElement(StreamWriter& sw) const 1031 { 1032 sw.openElement(Strings::GlobalPose); 1033 sw.appendValues(&rotation.x, 7); 1034 sw.closeElement(); 1035 } 1036 HalfExtents(xmlNode * node)1037 HalfExtents::HalfExtents(xmlNode* node) 1038 { 1039 GetContent(node, halfExtents); 1040 } 1041 exportElement(StreamWriter & sw) const1042 void HalfExtents::exportElement(StreamWriter& sw) const 1043 { 1044 sw.openElement(Strings::HalfExtents); 1045 sw.appendValues(&halfExtents.x, 3); 1046 sw.closeElement(); 1047 } 1048 PxBoxGeometry(xmlNode * node)1049 PxBoxGeometry::PxBoxGeometry(xmlNode* node) 1050 : halfExtents(FindChild(node, Strings::HalfExtents)) 1051 {} 1052 exportElement(StreamWriter & sw) const1053 void PxBoxGeometry::exportElement(StreamWriter& sw) const 1054 { 1055 sw.openElement(Strings::PxBoxGeometry); 1056 halfExtents.exportElement(sw); 1057 sw.closeElement(); 1058 } 1059 Radius(xmlNode * node)1060 Radius::Radius(xmlNode* node) 1061 : radius(0.0) 1062 { 1063 GetContent(node, radius); 1064 } 1065 exportElement(StreamWriter & sw) const1066 void Radius::exportElement(StreamWriter& sw) const 1067 { 1068 sw.openElement(Strings::Radius); 1069 sw.appendValues(radius); 1070 sw.closeElement(); 1071 } 1072 HalfHeight(xmlNode * node)1073 HalfHeight::HalfHeight(xmlNode* node) 1074 : halfHeight(0.0) 1075 { 1076 GetContent(node, halfHeight); 1077 } 1078 exportElement(StreamWriter & sw) const1079 void HalfHeight::exportElement(StreamWriter& sw) const 1080 { 1081 sw.openElement(Strings::HalfHeight); 1082 sw.appendValues(halfHeight); 1083 sw.closeElement(); 1084 } 1085 PxCapsuleGeometry(xmlNode * node)1086 PxCapsuleGeometry::PxCapsuleGeometry(xmlNode* node) 1087 : radius(FindChild(node, Strings::Radius)) 1088 , halfHeight(FindChild(node, Strings::HalfHeight)) 1089 {} 1090 exportElement(StreamWriter & sw) const1091 void PxCapsuleGeometry::exportElement(StreamWriter& sw) const 1092 { 1093 sw.openElement(Strings::PxCapsuleGeometry); 1094 radius.exportElement(sw); 1095 halfHeight.exportElement(sw); 1096 sw.closeElement(); 1097 } 1098 Scale(xmlNode * node)1099 Scale::Scale(xmlNode* node) 1100 { 1101 GetContent(node, scale); 1102 } 1103 exportElement(StreamWriter & sw) const1104 void Scale::exportElement(StreamWriter& sw) const 1105 { 1106 sw.openElement(Strings::Scale); 1107 sw.appendValues(&scale.x, 3); 1108 sw.closeElement(); 1109 } 1110 Rotation(xmlNode * node)1111 Rotation::Rotation(xmlNode* node) 1112 { 1113 GetContent(node, rotation); 1114 } 1115 exportElement(StreamWriter & sw) const1116 void Rotation::exportElement(StreamWriter& sw) const 1117 { 1118 sw.openElement(Strings::Rotation); 1119 sw.appendValues(rotation.x, rotation.y, rotation.z, rotation.w); 1120 sw.closeElement(); 1121 } 1122 MeshScale(xmlNode * node)1123 MeshScale::MeshScale(xmlNode* node) 1124 : scale(FindChild(node, Strings::Scale)) 1125 , rotation(FindChild(node, Strings::Rotation)) 1126 {} 1127 exportElement(StreamWriter & sw) const1128 void MeshScale::exportElement(StreamWriter& sw) const 1129 { 1130 sw.openElement(Strings::Scale); 1131 scale.exportElement(sw); 1132 rotation.exportElement(sw); 1133 sw.closeElement(); 1134 } 1135 ConvexMesh(xmlNode * node)1136 ConvexMesh::ConvexMesh(xmlNode* node) 1137 : convexMesh(0) 1138 { 1139 GetContent(node, convexMesh); 1140 } 1141 exportElement(StreamWriter & sw) const1142 void ConvexMesh::exportElement(StreamWriter& sw) const 1143 { 1144 sw.openElement(Strings::ConvexMesh); 1145 sw.appendValues(convexMesh); 1146 sw.closeElement(); 1147 } 1148 PxConvexMeshGeometry(xmlNode * node)1149 PxConvexMeshGeometry::PxConvexMeshGeometry(xmlNode* node) 1150 : scale(FindChild(node, Strings::Scale)) 1151 , convexMesh(FindChild(node, Strings::ConvexMesh)) 1152 {} 1153 exportElement(StreamWriter & sw) const1154 void PxConvexMeshGeometry::exportElement(StreamWriter& sw) const 1155 { 1156 sw.openElement(Strings::PxConvexMeshGeometry); 1157 scale.exportElement(sw); 1158 convexMesh.exportElement(sw); 1159 sw.closeElement(); 1160 } 1161 PxPlaneGeometry(xmlNode * node)1162 PxPlaneGeometry::PxPlaneGeometry(xmlNode* node) 1163 {} 1164 exportElement(StreamWriter & sw) const1165 void PxPlaneGeometry::exportElement(StreamWriter& sw) const 1166 { 1167 sw.openElement(Strings::PxPlaneGeometry); 1168 sw.closeElement(); 1169 } 1170 PxSphereGeometry(xmlNode * node)1171 PxSphereGeometry::PxSphereGeometry(xmlNode* node) 1172 : radius(FindChild(node, Strings::Radius)) 1173 {} 1174 exportElement(StreamWriter & sw) const1175 void PxSphereGeometry::exportElement(StreamWriter& sw) const 1176 { 1177 sw.openElement(Strings::PxSphereGeometry); 1178 radius.exportElement(sw); 1179 sw.closeElement(); 1180 } 1181 TriangleMesh(xmlNode * node)1182 TriangleMesh::TriangleMesh(xmlNode* node) 1183 : triangleMesh(0) 1184 { 1185 GetContent(node, triangleMesh); 1186 } 1187 exportElement(StreamWriter & sw) const1188 void TriangleMesh::exportElement(StreamWriter& sw) const 1189 { 1190 sw.openElement(Strings::TriangleMesh); 1191 sw.appendValues(triangleMesh); 1192 sw.closeElement(); 1193 } 1194 PxTriangleMeshGeometry(xmlNode * node)1195 PxTriangleMeshGeometry::PxTriangleMeshGeometry(xmlNode* node) 1196 : scale(FindChild(node, Strings::Scale)) 1197 , triangleMesh(FindChild(node, Strings::TriangleMesh)) 1198 {} 1199 exportElement(StreamWriter & sw) const1200 void PxTriangleMeshGeometry::exportElement(StreamWriter& sw) const 1201 { 1202 sw.openElement(Strings::PxTriangleMeshGeometry); 1203 scale.exportElement(sw); 1204 triangleMesh.exportElement(sw); 1205 sw.closeElement(); 1206 } 1207 Geometry(xmlNode * node)1208 Geometry::Geometry(xmlNode* node) 1209 : type(Sphere) 1210 , boxGeometry(FindChild(node, Strings::PxBoxGeometry)) 1211 , capsuleGeometry(FindChild(node, Strings::PxCapsuleGeometry)) 1212 , convexMeshGeometry(FindChild(node, Strings::PxConvexMeshGeometry)) 1213 , planeGeometry(FindChild(node, Strings::PxPlaneGeometry)) 1214 , sphereGeometry(FindChild(node, Strings::PxSphereGeometry)) 1215 , triangleMeshGeometry(FindChild(node, Strings::PxTriangleMeshGeometry)) 1216 { 1217 if (FindChild(node, Strings::PxBoxGeometry)) { 1218 type = Box; 1219 } 1220 else if (FindChild(node, Strings::PxCapsuleGeometry)) { 1221 type = Capsule; 1222 } 1223 else if (FindChild(node, Strings::PxConvexMeshGeometry)) { 1224 type = ConvexMesh; 1225 } 1226 else if (FindChild(node, Strings::PxPlaneGeometry)) { 1227 type = Plane; 1228 } 1229 else if (FindChild(node, Strings::PxSphereGeometry)) { 1230 type = Sphere; 1231 } 1232 else if (FindChild(node, Strings::PxTriangleMeshGeometry)) { 1233 type = TriangleMesh; 1234 } 1235 } 1236 exportElement(StreamWriter & sw) const1237 void Geometry::exportElement(StreamWriter& sw) const 1238 { 1239 sw.openElement(Strings::Geometry); 1240 switch (type) 1241 { 1242 case Box: 1243 boxGeometry.exportElement(sw); 1244 break; 1245 case Capsule: 1246 capsuleGeometry.exportElement(sw); 1247 break; 1248 case ConvexMesh: 1249 convexMeshGeometry.exportElement(sw); 1250 break; 1251 case Plane: 1252 planeGeometry.exportElement(sw); 1253 break; 1254 case Sphere: 1255 sphereGeometry.exportElement(sw); 1256 break; 1257 case TriangleMesh: 1258 triangleMeshGeometry.exportElement(sw); 1259 break; 1260 } 1261 sw.closeElement(); 1262 } 1263 LocalPose(xmlNode * node)1264 LocalPose::LocalPose(xmlNode* node) 1265 { 1266 GetContent(node, rotation, translation); 1267 } 1268 exportElement(StreamWriter & sw) const1269 void LocalPose::exportElement(StreamWriter& sw) const 1270 { 1271 sw.openElement(Strings::LocalPose); 1272 sw.appendValues(&rotation.x, 7); 1273 sw.closeElement(); 1274 } 1275 SimulationFilterData(xmlNode * node)1276 SimulationFilterData::SimulationFilterData(xmlNode* node) 1277 : filter0(0) 1278 , filter1(0) 1279 , filter2(0) 1280 , filter3(0) 1281 { 1282 GetContent(node, filter0, filter1, filter2, filter3); 1283 } 1284 exportElement(StreamWriter & sw) const1285 void SimulationFilterData::exportElement(StreamWriter& sw) const 1286 { 1287 sw.openElement(Strings::SimulationFilterData); 1288 sw.appendValues(&filter0, 4); 1289 sw.closeElement(); 1290 } 1291 QueryFilterData(xmlNode * node)1292 QueryFilterData::QueryFilterData(xmlNode* node) 1293 : filter0(0) 1294 , filter1(0) 1295 , filter2(0) 1296 , filter3(0) 1297 { 1298 GetContent(node, filter0, filter1, filter2, filter3); 1299 } 1300 exportElement(StreamWriter & sw) const1301 void QueryFilterData::exportElement(StreamWriter& sw) const 1302 { 1303 sw.openElement(Strings::QueryFilterData); 1304 sw.appendValues(&filter0, 4); 1305 sw.closeElement(); 1306 } 1307 PxMaterialRef(xmlNode * node)1308 PxMaterialRef::PxMaterialRef(xmlNode* node) 1309 : materialRef(0) 1310 { 1311 GetContent(node, materialRef); 1312 } 1313 exportElement(StreamWriter & sw) const1314 void PxMaterialRef::exportElement(StreamWriter& sw) const 1315 { 1316 sw.openElement(Strings::PxMaterialRef); 1317 sw.appendValues(materialRef); 1318 sw.closeElement(); 1319 } 1320 Materials(xmlNode * node)1321 Materials::Materials(xmlNode* node) 1322 : materialRef(FindChild(node, Strings::PxMaterialRef)) 1323 {} 1324 exportElement(StreamWriter & sw) const1325 void Materials::exportElement(StreamWriter& sw) const 1326 { 1327 sw.openElement(Strings::Materials); 1328 materialRef.exportElement(sw); 1329 sw.closeElement(); 1330 } 1331 ContactOffset(xmlNode * node)1332 ContactOffset::ContactOffset(xmlNode* node) 1333 : contactOffset(0.0) 1334 { 1335 GetContent(node, contactOffset); 1336 } 1337 exportElement(StreamWriter & sw) const1338 void ContactOffset::exportElement(StreamWriter& sw) const 1339 { 1340 sw.openElement(Strings::ContactOffset); 1341 sw.appendValues(contactOffset); 1342 sw.closeElement(); 1343 } 1344 RestOffset(xmlNode * node)1345 RestOffset::RestOffset(xmlNode* node) 1346 : restOffset(0.0) 1347 { 1348 GetContent(node, restOffset); 1349 } 1350 exportElement(StreamWriter & sw) const1351 void RestOffset::exportElement(StreamWriter& sw) const 1352 { 1353 sw.openElement(Strings::RestOffset); 1354 sw.appendValues(restOffset); 1355 sw.closeElement(); 1356 } 1357 ShapeFlags(xmlNode * node)1358 ShapeFlags::ShapeFlags(xmlNode* node) 1359 { 1360 GetContent(node, flags, mStringToFlagMap); 1361 } 1362 exportElement(StreamWriter & sw) const1363 void ShapeFlags::exportElement(StreamWriter& sw) const 1364 { 1365 sw.openElement(Strings::Flags); 1366 sw.appendValues(FlagsToString(flags, mFlagToStringMap)); 1367 sw.closeElement(); 1368 } 1369 PxShape(xmlNode * node)1370 PxShape::PxShape(xmlNode* node) 1371 : geometry(FindChild(node, Strings::Geometry)) 1372 , localPose(FindChild(node, Strings::LocalPose)) 1373 , simulationFilterData(FindChild(node, Strings::SimulationFilterData)) 1374 , queryFilterData(FindChild(node, Strings::QueryFilterData)) 1375 , materials(FindChild(node, Strings::Materials)) 1376 , contactOffset(FindChild(node, Strings::ContactOffset)) 1377 , restOffset(FindChild(node, Strings::RestOffset)) 1378 , flags(FindChild(node, Strings::Flags)) 1379 , name(FindChild(node, Strings::Name)) 1380 {} 1381 exportElement(StreamWriter & sw) const1382 void PxShape::exportElement(StreamWriter& sw) const 1383 { 1384 sw.openElement(Strings::PxShape); 1385 geometry.exportElement(sw); 1386 localPose.exportElement(sw); 1387 simulationFilterData.exportElement(sw); 1388 queryFilterData.exportElement(sw); 1389 //materials.exportElement(sw); 1390 contactOffset.exportElement(sw); 1391 restOffset.exportElement(sw); 1392 flags.exportElement(sw); 1393 name.exportElement(sw); 1394 sw.closeElement(); 1395 } 1396 Shapes(xmlNode * node)1397 Shapes::Shapes(xmlNode* node) 1398 { 1399 std::vector<xmlNode*> PxShapes = FindChildren(node, Strings::PxShape); 1400 for (size_t i = 0; i < PxShapes.size(); ++i) { 1401 shapes.push_back(PxShape(PxShapes[i])); 1402 } 1403 } 1404 exportElement(StreamWriter & sw) const1405 void Shapes::exportElement(StreamWriter& sw) const 1406 { 1407 sw.openElement(Strings::Shapes); 1408 for (size_t i = 0; i < shapes.size(); ++i) { 1409 shapes[i].exportElement(sw); 1410 } 1411 sw.closeElement(); 1412 } 1413 PxRigidBody(xmlNode * node)1414 PxRigidBody::PxRigidBody(xmlNode* node) 1415 : id(FindChild(node, Strings::Id)) 1416 , name(FindChild(node, Strings::Name)) 1417 , actorFlags(FindChild(node, Strings::ActorFlags)) 1418 , dominanceGroup(FindChild(node, Strings::DominanceGroup)) 1419 , ownerClient(FindChild(node, Strings::OwnerClient)) 1420 , globalPose(FindChild(node, Strings::GlobalPose)) 1421 , shapes(FindChild(node, Strings::Shapes)) 1422 {} 1423 findShape(const String & shapeName)1424 PxShape* PxRigidBody::findShape(const String& shapeName) 1425 { 1426 for (size_t i = 0; i < shapes.shapes.size(); ++i) { 1427 PxShape& shape = shapes.shapes[i]; 1428 if (shape.name.name == shapeName) { 1429 return &shape; 1430 } 1431 } 1432 return NULL; 1433 } 1434 PxRigidStatic(xmlNode * node)1435 PxRigidStatic::PxRigidStatic(xmlNode* node) 1436 : PxRigidBody(node) 1437 {} 1438 exportElement(StreamWriter & sw) const1439 void PxRigidStatic::exportElement(StreamWriter& sw) const 1440 { 1441 sw.openElement(Strings::PxRigidStatic); 1442 id.exportElement(sw); 1443 name.exportElement(sw); 1444 actorFlags.exportElement(sw); 1445 dominanceGroup.exportElement(sw); 1446 ownerClient.exportElement(sw); 1447 globalPose.exportElement(sw); 1448 //shapes.exportElement(sw); 1449 sw.closeElement(); 1450 } 1451 getType() const1452 PxRigidBody::Type PxRigidStatic::getType() const 1453 { 1454 return Static; 1455 } 1456 CMassLocalPose(xmlNode * node)1457 CMassLocalPose::CMassLocalPose(xmlNode* node) 1458 { 1459 GetContent(node, rotation, translation); 1460 } 1461 exportElement(StreamWriter & sw) const1462 void CMassLocalPose::exportElement(StreamWriter& sw) const 1463 { 1464 sw.openElement(Strings::CMassLocalPose); 1465 sw.appendValues(&rotation.x, 7); 1466 sw.closeElement(); 1467 } 1468 MassSpaceInertiaTensor(xmlNode * node)1469 MassSpaceInertiaTensor::MassSpaceInertiaTensor(xmlNode* node) 1470 { 1471 GetContent(node, massSpaceInertiaTensor); 1472 } 1473 exportElement(StreamWriter & sw) const1474 void MassSpaceInertiaTensor::exportElement(StreamWriter& sw) const 1475 { 1476 sw.openElement(Strings::MassSpaceInertiaTensor); 1477 sw.appendValues(&massSpaceInertiaTensor.x, 3); 1478 sw.closeElement(); 1479 } 1480 LinearVelocity(xmlNode * node)1481 LinearVelocity::LinearVelocity(xmlNode* node) 1482 { 1483 GetContent(node, linearVelocity); 1484 } 1485 exportElement(StreamWriter & sw) const1486 void LinearVelocity::exportElement(StreamWriter& sw) const 1487 { 1488 sw.openElement(Strings::LinearVelocity); 1489 sw.appendValues(&linearVelocity.x, 3); 1490 sw.closeElement(); 1491 } 1492 AngularVelocity(xmlNode * node)1493 AngularVelocity::AngularVelocity(xmlNode* node) 1494 { 1495 GetContent(node, angularVelocity); 1496 } 1497 exportElement(StreamWriter & sw) const1498 void AngularVelocity::exportElement(StreamWriter& sw) const 1499 { 1500 sw.openElement(Strings::AngularVelocity); 1501 sw.appendValues(&angularVelocity.x, 3); 1502 sw.closeElement(); 1503 } 1504 MinCCDAdvanceCoefficient(xmlNode * node)1505 MinCCDAdvanceCoefficient::MinCCDAdvanceCoefficient(xmlNode* node) 1506 : minCCDAdvanceCoefficient(0.0) 1507 { 1508 GetContent(node, minCCDAdvanceCoefficient); 1509 } 1510 exportElement(StreamWriter & sw) const1511 void MinCCDAdvanceCoefficient::exportElement(StreamWriter& sw) const 1512 { 1513 sw.openElement(Strings::MinCCDAdvanceCoefficient); 1514 sw.appendValues(minCCDAdvanceCoefficient); 1515 sw.closeElement(); 1516 } 1517 MaxDepenetrationVelocity(xmlNode * node)1518 MaxDepenetrationVelocity::MaxDepenetrationVelocity(xmlNode* node) 1519 : maxDepenetrationVelocity(0.0) 1520 { 1521 GetContent(node, maxDepenetrationVelocity); 1522 } 1523 exportElement(StreamWriter & sw) const1524 void MaxDepenetrationVelocity::exportElement(StreamWriter& sw) const 1525 { 1526 sw.openElement(Strings::MaxDepenetrationVelocity); 1527 sw.appendValues(maxDepenetrationVelocity); 1528 sw.closeElement(); 1529 } 1530 LinearDamping(xmlNode * node)1531 LinearDamping::LinearDamping(xmlNode* node) 1532 : linearDamping(0.0) 1533 { 1534 GetContent(node, linearDamping); 1535 } 1536 exportElement(StreamWriter & sw) const1537 void LinearDamping::exportElement(StreamWriter& sw) const 1538 { 1539 sw.openElement(Strings::LinearDamping); 1540 sw.appendValues(linearDamping); 1541 sw.closeElement(); 1542 } 1543 AngularDamping(xmlNode * node)1544 AngularDamping::AngularDamping(xmlNode* node) 1545 : angularDamping(0.0) 1546 { 1547 GetContent(node, angularDamping); 1548 } 1549 exportElement(StreamWriter & sw) const1550 void AngularDamping::exportElement(StreamWriter& sw) const 1551 { 1552 sw.openElement(Strings::AngularDamping); 1553 sw.appendValues(angularDamping); 1554 sw.closeElement(); 1555 } 1556 MaxAngularVelocity(xmlNode * node)1557 MaxAngularVelocity::MaxAngularVelocity(xmlNode* node) 1558 : maxAngularVelocity(0.0) 1559 { 1560 GetContent(node, maxAngularVelocity); 1561 } 1562 exportElement(StreamWriter & sw) const1563 void MaxAngularVelocity::exportElement(StreamWriter& sw) const 1564 { 1565 sw.openElement(Strings::MaxAngularVelocity); 1566 sw.appendValues(maxAngularVelocity); 1567 sw.closeElement(); 1568 } 1569 SleepThreshold(xmlNode * node)1570 SleepThreshold::SleepThreshold(xmlNode* node) 1571 : sleepThreshold(0.0) 1572 { 1573 GetContent(node, sleepThreshold); 1574 } 1575 exportElement(StreamWriter & sw) const1576 void SleepThreshold::exportElement(StreamWriter& sw) const 1577 { 1578 sw.openElement(Strings::SleepThreshold); 1579 sw.appendValues(sleepThreshold); 1580 sw.closeElement(); 1581 } 1582 StabilizationThreshold(xmlNode * node)1583 StabilizationThreshold::StabilizationThreshold(xmlNode* node) 1584 : stabilizationThreshold(0.0) 1585 { 1586 GetContent(node, stabilizationThreshold); 1587 } 1588 exportElement(StreamWriter & sw) const1589 void StabilizationThreshold::exportElement(StreamWriter& sw) const 1590 { 1591 sw.openElement(Strings::StabilizationThreshold); 1592 sw.appendValues(stabilizationThreshold); 1593 sw.closeElement(); 1594 } 1595 WakeCounter(xmlNode * node)1596 WakeCounter::WakeCounter(xmlNode* node) 1597 : wakeCounter(0.0) 1598 { 1599 GetContent(node, wakeCounter); 1600 } 1601 exportElement(StreamWriter & sw) const1602 void WakeCounter::exportElement(StreamWriter& sw) const 1603 { 1604 sw.openElement(Strings::WakeCounter); 1605 sw.appendValues(wakeCounter); 1606 sw.closeElement(); 1607 } 1608 MinPositionIters(xmlNode * node)1609 MinPositionIters::MinPositionIters(xmlNode* node) 1610 : minPositionIters(0) 1611 { 1612 GetContent(node, minPositionIters); 1613 } 1614 exportElement(StreamWriter & sw) const1615 void MinPositionIters::exportElement(StreamWriter& sw) const 1616 { 1617 sw.openElement(Strings::minPositionIters); 1618 sw.appendValues(minPositionIters); 1619 sw.closeElement(); 1620 } 1621 MinVelocityIters(xmlNode * node)1622 MinVelocityIters::MinVelocityIters(xmlNode* node) 1623 : minVelocityIters(0) 1624 { 1625 GetContent(node, minVelocityIters); 1626 } 1627 exportElement(StreamWriter & sw) const1628 void MinVelocityIters::exportElement(StreamWriter& sw) const 1629 { 1630 sw.openElement(Strings::minVelocityIters); 1631 sw.appendValues(minVelocityIters); 1632 sw.closeElement(); 1633 } 1634 SolverIterationCounts(xmlNode * node)1635 SolverIterationCounts::SolverIterationCounts(xmlNode* node) 1636 : minPositionIters(FindChild(node, Strings::minPositionIters)) 1637 , minVelocityIters(FindChild(node, Strings::minVelocityIters)) 1638 {} 1639 exportElement(StreamWriter & sw) const1640 void SolverIterationCounts::exportElement(StreamWriter& sw) const 1641 { 1642 sw.openElement(Strings::SolverIterationCounts); 1643 minPositionIters.exportElement(sw); 1644 minVelocityIters.exportElement(sw); 1645 sw.closeElement(); 1646 } 1647 ContactReportThreshold(xmlNode * node)1648 ContactReportThreshold::ContactReportThreshold(xmlNode* node) 1649 : contactReportThreshold(0.0) 1650 { 1651 GetContent(node, contactReportThreshold); 1652 } 1653 exportElement(StreamWriter & sw) const1654 void ContactReportThreshold::exportElement(StreamWriter& sw) const 1655 { 1656 sw.openElement(Strings::ContactReportThreshold); 1657 sw.appendValues(contactReportThreshold); 1658 sw.closeElement(); 1659 } 1660 PxRigidDynamic(xmlNode * node)1661 PxRigidDynamic::PxRigidDynamic(xmlNode* node) 1662 : PxRigidBody(node) 1663 , cMassLocalPose(FindChild(node, Strings::CMassLocalPose)) 1664 , mass(FindChild(node, Strings::Mass)) 1665 , massSpaceInertiaTensor(FindChild(node, Strings::MassSpaceInertiaTensor)) 1666 , linearVelocity(FindChild(node, Strings::LinearVelocity)) 1667 , angularVelocity(FindChild(node, Strings::AngularVelocity)) 1668 , minCCDAdvanceCoefficient(FindChild(node, Strings::MinCCDAdvanceCoefficient)) 1669 , maxDepenetrationVelocity(FindChild(node, Strings::MaxDepenetrationVelocity)) 1670 , linearDamping(FindChild(node, Strings::LinearDamping)) 1671 , angularDamping(FindChild(node, Strings::AngularDamping)) 1672 , rigidBodyFlags(FindChild(node, Strings::RigidBodyFlags)) 1673 , maxAngularVelocity(FindChild(node, Strings::MaxAngularVelocity)) 1674 , sleepThreshold(FindChild(node, Strings::SleepThreshold)) 1675 , stabilizationThreshold(FindChild(node, Strings::StabilizationThreshold)) 1676 , wakeCounter(FindChild(node, Strings::WakeCounter)) 1677 , solverIterationCounts(FindChild(node, Strings::SolverIterationCounts)) 1678 , contactReportThreshold(FindChild(node, Strings::ContactReportThreshold)) 1679 {} 1680 exportElement(StreamWriter & sw) const1681 void PxRigidDynamic::exportElement(StreamWriter& sw) const 1682 { 1683 sw.openElement(Strings::PxRigidDynamic); 1684 id.exportElement(sw); 1685 name.exportElement(sw); 1686 actorFlags.exportElement(sw); 1687 dominanceGroup.exportElement(sw); 1688 ownerClient.exportElement(sw); 1689 globalPose.exportElement(sw); 1690 //shapes.exportElement(sw); 1691 cMassLocalPose.exportElement(sw); 1692 mass.exportElement(sw); 1693 massSpaceInertiaTensor.exportElement(sw); 1694 linearVelocity.exportElement(sw); 1695 angularVelocity.exportElement(sw); 1696 rigidBodyFlags.exportElement(sw); 1697 minCCDAdvanceCoefficient.exportElement(sw); 1698 maxDepenetrationVelocity.exportElement(sw); 1699 linearDamping.exportElement(sw); 1700 angularDamping.exportElement(sw); 1701 maxAngularVelocity.exportElement(sw); 1702 sleepThreshold.exportElement(sw); 1703 stabilizationThreshold.exportElement(sw); 1704 wakeCounter.exportElement(sw); 1705 solverIterationCounts.exportElement(sw); 1706 contactReportThreshold.exportElement(sw); 1707 sw.closeElement(); 1708 } 1709 getType() const1710 PxRigidBody::Type PxRigidDynamic::getType() const 1711 { 1712 return Dynamic; 1713 } 1714 Actor0(xmlNode * node)1715 Actor0::Actor0(xmlNode* node) 1716 : actor0(0) 1717 { 1718 GetContent(node, actor0); 1719 } 1720 exportElement(StreamWriter & sw) const1721 void Actor0::exportElement(StreamWriter& sw) const 1722 { 1723 sw.openElement(Strings::actor0); 1724 sw.appendValues(actor0); 1725 sw.closeElement(); 1726 } 1727 Actor1(xmlNode * node)1728 Actor1::Actor1(xmlNode* node) 1729 : actor1(0) 1730 { 1731 GetContent(node, actor1); 1732 } 1733 exportElement(StreamWriter & sw) const1734 void Actor1::exportElement(StreamWriter& sw) const 1735 { 1736 sw.openElement(Strings::actor1); 1737 sw.appendValues(actor1); 1738 sw.closeElement(); 1739 } 1740 Actors(xmlNode * node)1741 Actors::Actors(xmlNode* node) 1742 : actor0(FindChild(node, Strings::actor0)) 1743 , actor1(FindChild(node, Strings::actor1)) 1744 {} 1745 exportElement(StreamWriter & sw) const1746 void Actors::exportElement(StreamWriter& sw) const 1747 { 1748 sw.openElement(Strings::Actors); 1749 actor0.exportElement(sw); 1750 actor1.exportElement(sw); 1751 sw.closeElement(); 1752 } 1753 EActor0(xmlNode * node)1754 EActor0::EActor0(xmlNode* node) 1755 { 1756 GetContent(node, rotation, translation); 1757 } 1758 exportElement(StreamWriter & sw) const1759 void EActor0::exportElement(StreamWriter& sw) const 1760 { 1761 sw.openElement(Strings::eACTOR0); 1762 sw.appendValues(&rotation.x, 7); 1763 sw.closeElement(); 1764 } 1765 EActor1(xmlNode * node)1766 EActor1::EActor1(xmlNode* node) 1767 { 1768 GetContent(node, rotation, translation); 1769 } 1770 exportElement(StreamWriter & sw) const1771 void EActor1::exportElement(StreamWriter& sw) const 1772 { 1773 sw.openElement(Strings::eACTOR1); 1774 sw.appendValues(&rotation.x, 7); 1775 sw.closeElement(); 1776 } 1777 ActorLocalPose(xmlNode * node)1778 ActorLocalPose::ActorLocalPose(xmlNode* node) 1779 : eActor0(FindChild(node, Strings::eACTOR0)) 1780 , eActor1(FindChild(node, Strings::eACTOR1)) 1781 {} 1782 exportElement(StreamWriter & sw) const1783 void ActorLocalPose::exportElement(StreamWriter& sw) const 1784 { 1785 sw.openElement(Strings::LocalPose); 1786 eActor0.exportElement(sw); 1787 eActor1.exportElement(sw); 1788 sw.closeElement(); 1789 } 1790 Force(xmlNode * node)1791 Force::Force(xmlNode* node) 1792 : force(0.0) 1793 { 1794 GetContent(node, force); 1795 } 1796 exportElement(StreamWriter & sw) const1797 void Force::exportElement(StreamWriter& sw) const 1798 { 1799 sw.openElement(Strings::force); 1800 sw.appendValues(force); 1801 sw.closeElement(); 1802 } 1803 Torque(xmlNode * node)1804 Torque::Torque(xmlNode* node) 1805 : torque(0.0) 1806 { 1807 GetContent(node, torque); 1808 } 1809 exportElement(StreamWriter & sw) const1810 void Torque::exportElement(StreamWriter& sw) const 1811 { 1812 sw.openElement(Strings::torque); 1813 sw.appendValues(torque); 1814 sw.closeElement(); 1815 } 1816 BreakForce(xmlNode * node)1817 BreakForce::BreakForce(xmlNode* node) 1818 : force(FindChild(node, Strings::force)) 1819 , torque(FindChild(node, Strings::torque)) 1820 {} 1821 exportElement(StreamWriter & sw) const1822 void BreakForce::exportElement(StreamWriter& sw) const 1823 { 1824 sw.openElement(Strings::BreakForce); 1825 force.exportElement(sw); 1826 torque.exportElement(sw); 1827 sw.closeElement(); 1828 } 1829 ConstraintFlags(xmlNode * node)1830 ConstraintFlags::ConstraintFlags(xmlNode* node) 1831 { 1832 GetContent(node, flags, mStringToFlagMap); 1833 } 1834 exportElement(StreamWriter & sw) const1835 void ConstraintFlags::exportElement(StreamWriter& sw) const 1836 { 1837 sw.openElement(Strings::ConstraintFlags); 1838 sw.appendValues(FlagsToString(flags, mFlagToStringMap)); 1839 sw.closeElement(); 1840 } 1841 InvMassScale0(xmlNode * node)1842 InvMassScale0::InvMassScale0(xmlNode* node) 1843 : invMassScale0(0.0) 1844 { 1845 GetContent(node, invMassScale0); 1846 } 1847 exportElement(StreamWriter & sw) const1848 void InvMassScale0::exportElement(StreamWriter& sw) const 1849 { 1850 sw.openElement(Strings::InvMassScale0); 1851 sw.appendValues(invMassScale0); 1852 sw.closeElement(); 1853 } 1854 InvMassScale1(xmlNode * node)1855 InvMassScale1::InvMassScale1(xmlNode* node) 1856 : invMassScale1(0.0) 1857 { 1858 GetContent(node, invMassScale1); 1859 } 1860 exportElement(StreamWriter & sw) const1861 void InvMassScale1::exportElement(StreamWriter& sw) const 1862 { 1863 sw.openElement(Strings::InvMassScale1); 1864 sw.appendValues(invMassScale1); 1865 sw.closeElement(); 1866 } 1867 InvInertiaScale0(xmlNode * node)1868 InvInertiaScale0::InvInertiaScale0(xmlNode* node) 1869 : invInertiaScale0(0.0) 1870 { 1871 GetContent(node, invInertiaScale0); 1872 } 1873 exportElement(StreamWriter & sw) const1874 void InvInertiaScale0::exportElement(StreamWriter& sw) const 1875 { 1876 sw.openElement(Strings::InvInertiaScale0); 1877 sw.appendValues(invInertiaScale0); 1878 sw.closeElement(); 1879 } 1880 InvInertiaScale1(xmlNode * node)1881 InvInertiaScale1::InvInertiaScale1(xmlNode* node) 1882 : invInertiaScale1(0.0) 1883 { 1884 GetContent(node, invInertiaScale1); 1885 } 1886 exportElement(StreamWriter & sw) const1887 void InvInertiaScale1::exportElement(StreamWriter& sw) const 1888 { 1889 sw.openElement(Strings::InvInertiaScale1); 1890 sw.appendValues(invInertiaScale1); 1891 sw.closeElement(); 1892 } 1893 MotionX(xmlNode * node)1894 MotionX::MotionX(xmlNode* node) 1895 { 1896 GetContent(node, eX, MotionFlags::GetStringToFlagMap()); 1897 } 1898 exportElement(StreamWriter & sw) const1899 void MotionX::exportElement(StreamWriter& sw) const 1900 { 1901 sw.openElement(Strings::eX); 1902 sw.appendValues(FlagsToString(Flags<MotionFlags::FlagEnum>(eX), MotionFlags::GetFlagToStringMap())); 1903 sw.closeElement(); 1904 } 1905 MotionY(xmlNode * node)1906 MotionY::MotionY(xmlNode* node) 1907 { 1908 GetContent(node, eY, MotionFlags::GetStringToFlagMap()); 1909 } 1910 exportElement(StreamWriter & sw) const1911 void MotionY::exportElement(StreamWriter& sw) const 1912 { 1913 sw.openElement(Strings::eY); 1914 sw.appendValues(FlagsToString(Flags<MotionFlags::FlagEnum>(eY), MotionFlags::GetFlagToStringMap())); 1915 sw.closeElement(); 1916 } 1917 MotionZ(xmlNode * node)1918 MotionZ::MotionZ(xmlNode* node) 1919 { 1920 GetContent(node, eZ, MotionFlags::GetStringToFlagMap()); 1921 } 1922 exportElement(StreamWriter & sw) const1923 void MotionZ::exportElement(StreamWriter& sw) const 1924 { 1925 sw.openElement(Strings::eZ); 1926 sw.appendValues(FlagsToString(Flags<MotionFlags::FlagEnum>(eZ), MotionFlags::GetFlagToStringMap())); 1927 sw.closeElement(); 1928 } 1929 MotionTwist(xmlNode * node)1930 MotionTwist::MotionTwist(xmlNode* node) 1931 { 1932 GetContent(node, eTwist, MotionFlags::GetStringToFlagMap()); 1933 } 1934 exportElement(StreamWriter & sw) const1935 void MotionTwist::exportElement(StreamWriter& sw) const 1936 { 1937 sw.openElement(Strings::eTWIST); 1938 sw.appendValues(FlagsToString(Flags<MotionFlags::FlagEnum>(eTwist), MotionFlags::GetFlagToStringMap())); 1939 sw.closeElement(); 1940 } 1941 MotionSwing1(xmlNode * node)1942 MotionSwing1::MotionSwing1(xmlNode* node) 1943 { 1944 GetContent(node, eSwing1, MotionFlags::GetStringToFlagMap()); 1945 } 1946 exportElement(StreamWriter & sw) const1947 void MotionSwing1::exportElement(StreamWriter& sw) const 1948 { 1949 sw.openElement(Strings::eSWING1); 1950 sw.appendValues(FlagsToString(Flags<MotionFlags::FlagEnum>(eSwing1), MotionFlags::GetFlagToStringMap())); 1951 sw.closeElement(); 1952 } 1953 MotionSwing2(xmlNode * node)1954 MotionSwing2::MotionSwing2(xmlNode* node) 1955 { 1956 GetContent(node, eSwing2, MotionFlags::GetStringToFlagMap()); 1957 } 1958 exportElement(StreamWriter & sw) const1959 void MotionSwing2::exportElement(StreamWriter& sw) const 1960 { 1961 sw.openElement(Strings::eSWING2); 1962 sw.appendValues(FlagsToString(Flags<MotionFlags::FlagEnum>(eSwing2), MotionFlags::GetFlagToStringMap())); 1963 sw.closeElement(); 1964 } 1965 Motion(xmlNode * node)1966 Motion::Motion(xmlNode* node) 1967 : eX(FindChild(node, Strings::eX)) 1968 , eY(FindChild(node, Strings::eY)) 1969 , eZ(FindChild(node, Strings::eZ)) 1970 , eTwist(FindChild(node, Strings::eTWIST)) 1971 , eSwing1(FindChild(node, Strings::eSWING1)) 1972 , eSwing2(FindChild(node, Strings::eSWING2)) 1973 {} 1974 exportElement(StreamWriter & sw) const1975 void Motion::exportElement(StreamWriter& sw) const 1976 { 1977 sw.openElement(Strings::Motion); 1978 eX.exportElement(sw); 1979 eY.exportElement(sw); 1980 eZ.exportElement(sw); 1981 eTwist.exportElement(sw); 1982 eSwing1.exportElement(sw); 1983 eSwing2.exportElement(sw); 1984 sw.closeElement(); 1985 } 1986 BounceThreshold(xmlNode * node)1987 BounceThreshold::BounceThreshold(xmlNode* node) 1988 : bounceThreshold(0.0) 1989 { 1990 GetContent(node, bounceThreshold); 1991 } 1992 exportElement(StreamWriter & sw) const1993 void BounceThreshold::exportElement(StreamWriter& sw) const 1994 { 1995 sw.openElement(Strings::BounceThreshold); 1996 sw.appendValues(bounceThreshold); 1997 sw.closeElement(); 1998 } 1999 Stiffness(xmlNode * node)2000 Stiffness::Stiffness(xmlNode* node) 2001 : stiffness(0.0) 2002 { 2003 GetContent(node, stiffness); 2004 } 2005 exportElement(StreamWriter & sw) const2006 void Stiffness::exportElement(StreamWriter& sw) const 2007 { 2008 sw.openElement(Strings::Stiffness); 2009 sw.appendValues(stiffness); 2010 sw.closeElement(); 2011 } 2012 Damping(xmlNode * node)2013 Damping::Damping(xmlNode* node) 2014 : damping(0.0) 2015 { 2016 GetContent(node, damping); 2017 } 2018 exportElement(StreamWriter & sw) const2019 void Damping::exportElement(StreamWriter& sw) const 2020 { 2021 sw.openElement(Strings::Damping); 2022 sw.appendValues(damping); 2023 sw.closeElement(); 2024 } 2025 ContactDistance(xmlNode * node)2026 ContactDistance::ContactDistance(xmlNode* node) 2027 : contactDistance(0.0) 2028 { 2029 GetContent(node, contactDistance); 2030 } 2031 exportElement(StreamWriter & sw) const2032 void ContactDistance::exportElement(StreamWriter& sw) const 2033 { 2034 sw.openElement(Strings::ContactDistance); 2035 sw.appendValues(contactDistance); 2036 sw.closeElement(); 2037 } 2038 Value(xmlNode * node)2039 Value::Value(xmlNode* node) 2040 : value(0.0) 2041 { 2042 GetContent(node, value); 2043 } 2044 exportElement(StreamWriter & sw) const2045 void Value::exportElement(StreamWriter& sw) const 2046 { 2047 sw.openElement(Strings::Value); 2048 sw.appendValues(value); 2049 sw.closeElement(); 2050 } 2051 LinearLimit(xmlNode * node)2052 LinearLimit::LinearLimit(xmlNode* node) 2053 : restitution(FindChild(node, Strings::Restitution)) 2054 , bounceThreshold(FindChild(node, Strings::BounceThreshold)) 2055 , stiffness(FindChild(node, Strings::Stiffness)) 2056 , damping(FindChild(node, Strings::Damping)) 2057 , contactDistance(FindChild(node, Strings::ContactDistance)) 2058 , value(FindChild(node, Strings::Value)) 2059 {} 2060 exportElement(StreamWriter & sw) const2061 void LinearLimit::exportElement(StreamWriter& sw) const 2062 { 2063 sw.openElement(Strings::LinearLimit); 2064 restitution.exportElement(sw); 2065 bounceThreshold.exportElement(sw); 2066 stiffness.exportElement(sw); 2067 damping.exportElement(sw); 2068 contactDistance.exportElement(sw); 2069 value.exportElement(sw); 2070 sw.closeElement(); 2071 } 2072 Upper(xmlNode * node)2073 Upper::Upper(xmlNode* node) 2074 : upper(0.0) 2075 { 2076 GetContent(node, upper); 2077 } 2078 exportElement(StreamWriter & sw) const2079 void Upper::exportElement(StreamWriter& sw) const 2080 { 2081 sw.openElement(Strings::Upper); 2082 sw.appendValues(upper); 2083 sw.closeElement(); 2084 } 2085 Lower(xmlNode * node)2086 Lower::Lower(xmlNode* node) 2087 : lower(0.0) 2088 { 2089 GetContent(node, lower); 2090 } 2091 exportElement(StreamWriter & sw) const2092 void Lower::exportElement(StreamWriter& sw) const 2093 { 2094 sw.openElement(Strings::Lower); 2095 sw.appendValues(lower); 2096 sw.closeElement(); 2097 } 2098 TwistLimit(xmlNode * node)2099 TwistLimit::TwistLimit(xmlNode* node) 2100 : restitution(FindChild(node, Strings::Restitution)) 2101 , bounceThreshold(FindChild(node, Strings::BounceThreshold)) 2102 , stiffness(FindChild(node, Strings::Stiffness)) 2103 , damping(FindChild(node, Strings::Damping)) 2104 , contactDistance(FindChild(node, Strings::ContactDistance)) 2105 , upper(FindChild(node, Strings::Upper)) 2106 , lower(FindChild(node, Strings::Lower)) 2107 {} 2108 exportElement(StreamWriter & sw) const2109 void TwistLimit::exportElement(StreamWriter& sw) const 2110 { 2111 sw.openElement(Strings::TwistLimit); 2112 restitution.exportElement(sw); 2113 bounceThreshold.exportElement(sw); 2114 stiffness.exportElement(sw); 2115 damping.exportElement(sw); 2116 contactDistance.exportElement(sw); 2117 upper.exportElement(sw); 2118 lower.exportElement(sw); 2119 sw.closeElement(); 2120 } 2121 YAngle(xmlNode * node)2122 YAngle::YAngle(xmlNode* node) 2123 : yAngle(0.0) 2124 { 2125 GetContent(node, yAngle); 2126 } 2127 exportElement(StreamWriter & sw) const2128 void YAngle::exportElement(StreamWriter& sw) const 2129 { 2130 sw.openElement(Strings::YAngle); 2131 sw.appendValues(yAngle); 2132 sw.closeElement(); 2133 } 2134 ZAngle(xmlNode * node)2135 ZAngle::ZAngle(xmlNode* node) 2136 : zAngle(0.0) 2137 { 2138 GetContent(node, zAngle); 2139 } 2140 exportElement(StreamWriter & sw) const2141 void ZAngle::exportElement(StreamWriter& sw) const 2142 { 2143 sw.openElement(Strings::ZAngle); 2144 sw.appendValues(zAngle); 2145 sw.closeElement(); 2146 } 2147 SwingLimit(xmlNode * node)2148 SwingLimit::SwingLimit(xmlNode* node) 2149 : restitution(FindChild(node, Strings::Restitution)) 2150 , bounceThreshold(FindChild(node, Strings::BounceThreshold)) 2151 , stiffness(FindChild(node, Strings::Stiffness)) 2152 , damping(FindChild(node, Strings::Damping)) 2153 , contactDistance(FindChild(node, Strings::ContactDistance)) 2154 , yAngle(FindChild(node, Strings::YAngle)) 2155 , zAngle(FindChild(node, Strings::ZAngle)) 2156 {} 2157 exportElement(StreamWriter & sw) const2158 void SwingLimit::exportElement(StreamWriter& sw) const 2159 { 2160 sw.openElement(Strings::SwingLimit); 2161 restitution.exportElement(sw); 2162 bounceThreshold.exportElement(sw); 2163 stiffness.exportElement(sw); 2164 damping.exportElement(sw); 2165 contactDistance.exportElement(sw); 2166 yAngle.exportElement(sw); 2167 zAngle.exportElement(sw); 2168 sw.closeElement(); 2169 } 2170 ForceLimit(xmlNode * node)2171 ForceLimit::ForceLimit(xmlNode* node) 2172 : forceLimit(0.0) 2173 { 2174 GetContent(node, forceLimit); 2175 } 2176 exportElement(StreamWriter & sw) const2177 void ForceLimit::exportElement(StreamWriter& sw) const 2178 { 2179 sw.openElement(Strings::ForceLimit); 2180 sw.appendValues(forceLimit); 2181 sw.closeElement(); 2182 } 2183 DriveFlags(xmlNode * node)2184 DriveFlags::DriveFlags(xmlNode* node) 2185 { 2186 GetContent(node, flags, mStringToFlagMap); 2187 } 2188 exportElement(StreamWriter & sw) const2189 void DriveFlags::exportElement(StreamWriter& sw) const 2190 { 2191 sw.openElement(Strings::Flags); 2192 sw.appendValues(FlagsToString(flags, mFlagToStringMap)); 2193 sw.closeElement(); 2194 } 2195 DriveX(xmlNode * node)2196 DriveX::DriveX(xmlNode* node) 2197 : stiffness(FindChild(node, Strings::Stiffness)) 2198 , damping(FindChild(node, Strings::Damping)) 2199 , forceLimit(FindChild(node, Strings::ForceLimit)) 2200 , flags(FindChild(node, Strings::Flags)) 2201 {} 2202 exportElement(StreamWriter & sw) const2203 void DriveX::exportElement(StreamWriter& sw) const 2204 { 2205 sw.openElement(Strings::eX); 2206 stiffness.exportElement(sw); 2207 damping.exportElement(sw); 2208 forceLimit.exportElement(sw); 2209 flags.exportElement(sw); 2210 sw.closeElement(); 2211 } 2212 DriveY(xmlNode * node)2213 DriveY::DriveY(xmlNode* node) 2214 : stiffness(FindChild(node, Strings::Stiffness)) 2215 , damping(FindChild(node, Strings::Damping)) 2216 , forceLimit(FindChild(node, Strings::ForceLimit)) 2217 , flags(FindChild(node, Strings::Flags)) 2218 {} 2219 exportElement(StreamWriter & sw) const2220 void DriveY::exportElement(StreamWriter& sw) const 2221 { 2222 sw.openElement(Strings::eY); 2223 stiffness.exportElement(sw); 2224 damping.exportElement(sw); 2225 forceLimit.exportElement(sw); 2226 flags.exportElement(sw); 2227 sw.closeElement(); 2228 } 2229 DriveZ(xmlNode * node)2230 DriveZ::DriveZ(xmlNode* node) 2231 : stiffness(FindChild(node, Strings::Stiffness)) 2232 , damping(FindChild(node, Strings::Damping)) 2233 , forceLimit(FindChild(node, Strings::ForceLimit)) 2234 , flags(FindChild(node, Strings::Flags)) 2235 {} 2236 exportElement(StreamWriter & sw) const2237 void DriveZ::exportElement(StreamWriter& sw) const 2238 { 2239 sw.openElement(Strings::eZ); 2240 stiffness.exportElement(sw); 2241 damping.exportElement(sw); 2242 forceLimit.exportElement(sw); 2243 flags.exportElement(sw); 2244 sw.closeElement(); 2245 } 2246 DriveSwing(xmlNode * node)2247 DriveSwing::DriveSwing(xmlNode* node) 2248 : stiffness(FindChild(node, Strings::Stiffness)) 2249 , damping(FindChild(node, Strings::Damping)) 2250 , forceLimit(FindChild(node, Strings::ForceLimit)) 2251 , flags(FindChild(node, Strings::Flags)) 2252 {} 2253 exportElement(StreamWriter & sw) const2254 void DriveSwing::exportElement(StreamWriter& sw) const 2255 { 2256 sw.openElement(Strings::eSWING); 2257 stiffness.exportElement(sw); 2258 damping.exportElement(sw); 2259 forceLimit.exportElement(sw); 2260 flags.exportElement(sw); 2261 sw.closeElement(); 2262 } 2263 DriveTwist(xmlNode * node)2264 DriveTwist::DriveTwist(xmlNode* node) 2265 : stiffness(FindChild(node, Strings::Stiffness)) 2266 , damping(FindChild(node, Strings::Damping)) 2267 , forceLimit(FindChild(node, Strings::ForceLimit)) 2268 , flags(FindChild(node, Strings::Flags)) 2269 {} 2270 exportElement(StreamWriter & sw) const2271 void DriveTwist::exportElement(StreamWriter& sw) const 2272 { 2273 sw.openElement(Strings::eTWIST); 2274 stiffness.exportElement(sw); 2275 damping.exportElement(sw); 2276 forceLimit.exportElement(sw); 2277 flags.exportElement(sw); 2278 sw.closeElement(); 2279 } 2280 DriveSlerp(xmlNode * node)2281 DriveSlerp::DriveSlerp(xmlNode* node) 2282 : stiffness(FindChild(node, Strings::Stiffness)) 2283 , damping(FindChild(node, Strings::Damping)) 2284 , forceLimit(FindChild(node, Strings::ForceLimit)) 2285 , flags(FindChild(node, Strings::Flags)) 2286 {} 2287 exportElement(StreamWriter & sw) const2288 void DriveSlerp::exportElement(StreamWriter& sw) const 2289 { 2290 sw.openElement(Strings::eSLERP); 2291 stiffness.exportElement(sw); 2292 damping.exportElement(sw); 2293 forceLimit.exportElement(sw); 2294 flags.exportElement(sw); 2295 sw.closeElement(); 2296 } 2297 Drive(xmlNode * node)2298 Drive::Drive(xmlNode* node) 2299 : driveX(FindChild(node, Strings::eX)) 2300 , driveY(FindChild(node, Strings::eY)) 2301 , driveZ(FindChild(node, Strings::eZ)) 2302 , driveSwing(FindChild(node, Strings::eSWING)) 2303 , driveTwist(FindChild(node, Strings::eTWIST)) 2304 , driveSlerp(FindChild(node, Strings::eSLERP)) 2305 {} 2306 exportElement(StreamWriter & sw) const2307 void Drive::exportElement(StreamWriter& sw) const 2308 { 2309 sw.openElement(Strings::Drive); 2310 driveX.exportElement(sw); 2311 driveY.exportElement(sw); 2312 driveZ.exportElement(sw); 2313 driveSwing.exportElement(sw); 2314 driveTwist.exportElement(sw); 2315 driveSlerp.exportElement(sw); 2316 sw.closeElement(); 2317 } 2318 DrivePosition(xmlNode * node)2319 DrivePosition::DrivePosition(xmlNode* node) 2320 { 2321 GetContent(node, rotation, translation); 2322 } 2323 exportElement(StreamWriter & sw) const2324 void DrivePosition::exportElement(StreamWriter& sw) const 2325 { 2326 sw.openElement(Strings::DrivePosition); 2327 sw.appendValues(&rotation.x, 7); 2328 sw.closeElement(); 2329 } 2330 Linear(xmlNode * node)2331 Linear::Linear(xmlNode* node) 2332 { 2333 GetContent(node, linear); 2334 } 2335 exportElement(StreamWriter & sw) const2336 void Linear::exportElement(StreamWriter& sw) const 2337 { 2338 sw.openElement(Strings::linear); 2339 sw.appendValues(&linear.x, 3); 2340 sw.closeElement(); 2341 } 2342 Angular(xmlNode * node)2343 Angular::Angular(xmlNode* node) 2344 { 2345 GetContent(node, angular); 2346 } 2347 exportElement(StreamWriter & sw) const2348 void Angular::exportElement(StreamWriter& sw) const 2349 { 2350 sw.openElement(Strings::angular); 2351 sw.appendValues(&angular.x, 3); 2352 sw.closeElement(); 2353 } 2354 DriveVelocity(xmlNode * node)2355 DriveVelocity::DriveVelocity(xmlNode* node) 2356 : linear(FindChild(node, Strings::linear)) 2357 , angular(FindChild(node, Strings::angular)) 2358 {} 2359 exportElement(StreamWriter & sw) const2360 void DriveVelocity::exportElement(StreamWriter& sw) const 2361 { 2362 sw.openElement(Strings::DriveVelocity); 2363 linear.exportElement(sw); 2364 angular.exportElement(sw); 2365 sw.closeElement(); 2366 } 2367 ProjectionLinearTolerance(xmlNode * node)2368 ProjectionLinearTolerance::ProjectionLinearTolerance(xmlNode* node) 2369 : projectionLinearTolerance(0.0) 2370 { 2371 GetContent(node, projectionLinearTolerance); 2372 } 2373 exportElement(StreamWriter & sw) const2374 void ProjectionLinearTolerance::exportElement(StreamWriter& sw) const 2375 { 2376 sw.openElement(Strings::ProjectionLinearTolerance); 2377 sw.appendValues(projectionLinearTolerance); 2378 sw.closeElement(); 2379 } 2380 ProjectionAngularTolerance(xmlNode * node)2381 ProjectionAngularTolerance::ProjectionAngularTolerance(xmlNode* node) 2382 : projectionAngularTolerance(0.0) 2383 { 2384 GetContent(node, projectionAngularTolerance); 2385 } 2386 exportElement(StreamWriter & sw) const2387 void ProjectionAngularTolerance::exportElement(StreamWriter& sw) const 2388 { 2389 sw.openElement(Strings::ProjectionAngularTolerance); 2390 sw.appendValues(projectionAngularTolerance); 2391 sw.closeElement(); 2392 } 2393 PxD6Joint(xmlNode * node)2394 PxD6Joint::PxD6Joint(xmlNode* node) 2395 : id(FindChild(node, Strings::Id)) 2396 , actors(FindChild(node, Strings::Actors)) 2397 , localPose(FindChild(node, Strings::LocalPose)) 2398 , breakForce(FindChild(node, Strings::BreakForce)) 2399 , constraintFlags(FindChild(node, Strings::ConstraintFlags)) 2400 , invMassScale0(FindChild(node, Strings::InvMassScale0)) 2401 , invInertiaScale0(FindChild(node, Strings::InvInertiaScale0)) 2402 , invMassScale1(FindChild(node, Strings::InvMassScale1)) 2403 , invInertiaScale1(FindChild(node, Strings::InvInertiaScale1)) 2404 , name(FindChild(node, Strings::Name)) 2405 , motion(FindChild(node, Strings::Motion)) 2406 , linearLimit(FindChild(node, Strings::LinearLimit)) 2407 , twistLimit(FindChild(node, Strings::TwistLimit)) 2408 , swingLimit(FindChild(node, Strings::SwingLimit)) 2409 , drive(FindChild(node, Strings::Drive)) 2410 , drivePosition(FindChild(node, Strings::DrivePosition)) 2411 , driveVelocity(FindChild(node, Strings::DriveVelocity)) 2412 , projectionLinearTolerance(FindChild(node, Strings::ProjectionLinearTolerance)) 2413 , projectionAngularTolerance(FindChild(node, Strings::ProjectionAngularTolerance)) 2414 {} 2415 exportElement(StreamWriter & sw) const2416 void PxD6Joint::exportElement(StreamWriter& sw) const 2417 { 2418 sw.openElement(Strings::PxD6Joint); 2419 id.exportElement(sw); 2420 actors.exportElement(sw); 2421 localPose.exportElement(sw); 2422 breakForce.exportElement(sw); 2423 constraintFlags.exportElement(sw); 2424 invMassScale0.exportElement(sw); 2425 invInertiaScale0.exportElement(sw); 2426 invMassScale1.exportElement(sw); 2427 invInertiaScale1.exportElement(sw); 2428 name.exportElement(sw); 2429 motion.exportElement(sw); 2430 linearLimit.exportElement(sw); 2431 twistLimit.exportElement(sw); 2432 swingLimit.exportElement(sw); 2433 drive.exportElement(sw); 2434 drivePosition.exportElement(sw); 2435 driveVelocity.exportElement(sw); 2436 projectionLinearTolerance.exportElement(sw); 2437 projectionAngularTolerance.exportElement(sw); 2438 sw.closeElement(); 2439 } 2440 PhysX30Collection(xmlNode * node)2441 PhysX30Collection::PhysX30Collection(xmlNode* node) 2442 : upVector(FindChild(node, Strings::UpVector)) 2443 , scale(FindChild(node, Strings::Scale)) 2444 { 2445 std::vector<xmlNode*> convexMeshNodes = FindChildren(node, Strings::PxConvexMesh); 2446 for (size_t i = 0; i < convexMeshNodes.size(); ++i) { 2447 convexMeshes.push_back(PxConvexMesh(convexMeshNodes[i])); 2448 } 2449 2450 std::vector<xmlNode*> triangleMeshNodes = FindChildren(node, Strings::PxTriangleMesh); 2451 for (size_t i = 0; i < triangleMeshNodes.size(); ++i) { 2452 triangleMeshes.push_back(PxTriangleMesh(triangleMeshNodes[i])); 2453 } 2454 2455 std::vector<xmlNode*> materialNodes = FindChildren(node, Strings::PxMaterial); 2456 for (size_t i = 0; i < materialNodes.size(); ++i) { 2457 materials.push_back(PxMaterial(materialNodes[i])); 2458 } 2459 2460 std::vector<xmlNode*> rigidStaticNodes = FindChildren(node, Strings::PxRigidStatic); 2461 for (size_t i = 0; i < rigidStaticNodes.size(); ++i) { 2462 rigidStatics.push_back(PxRigidStatic(rigidStaticNodes[i])); 2463 } 2464 2465 std::vector<xmlNode*> rigidDynamicNodes = FindChildren(node, Strings::PxRigidDynamic); 2466 for (size_t i = 0; i < rigidDynamicNodes.size(); ++i) { 2467 rigidDynamics.push_back(PxRigidDynamic(rigidDynamicNodes[i])); 2468 } 2469 2470 std::vector<xmlNode*> D6JointNodes = FindChildren(node, Strings::PxD6Joint); 2471 for (size_t i = 0; i < D6JointNodes.size(); ++i) { 2472 D6Joints.push_back(PxD6Joint(D6JointNodes[i])); 2473 } 2474 } 2475 exportElement(StreamWriter & sw) const2476 void PhysX30Collection::exportElement(StreamWriter& sw) const 2477 { 2478 sw.openElement(Strings::PhysX30Collection); 2479 upVector.exportElement(sw); 2480 scale.exportElement(sw); 2481 for (size_t i = 0; i < convexMeshes.size(); ++i) { 2482 convexMeshes[i].exportElement(sw); 2483 } 2484 for (size_t i = 0; i < triangleMeshes.size(); ++i) { 2485 triangleMeshes[i].exportElement(sw); 2486 } 2487 for (size_t i = 0; i < materials.size(); ++i) { 2488 materials[i].exportElement(sw); 2489 } 2490 for (size_t i = 0; i < rigidStatics.size(); ++i) { 2491 rigidStatics[i].exportElement(sw); 2492 } 2493 for (size_t i = 0; i < rigidDynamics.size(); ++i) { 2494 rigidDynamics[i].exportElement(sw); 2495 } 2496 for (size_t i = 0; i < D6Joints.size(); ++i) { 2497 D6Joints[i].exportElement(sw); 2498 } 2499 sw.closeElement(); 2500 } 2501 PhysXDoc(xmlDocPtr xml)2502 PhysXDoc::PhysXDoc(xmlDocPtr xml) 2503 : physX30Collection(FindChild(xml, Strings::PhysX30Collection)) 2504 {} 2505 validate()2506 bool PhysXDoc::validate() 2507 { 2508 // PhysX plugin sets a name to each object based on Maya node name (not full DagPath). 2509 // If 2 nodes have the same name then we can't find corresponding PhysX object in the XML file. 2510 // A fix for this would be to set PhysX object name to node full DagPath (in PhysX plugin source code). 2511 2512 for (size_t i = 0; i < physX30Collection.rigidDynamics.size(); ++i) { 2513 for (size_t j = i + 1; j < physX30Collection.rigidDynamics.size(); ++j) { 2514 if (physX30Collection.rigidDynamics[i].name.name == physX30Collection.rigidDynamics[j].name.name) { 2515 MGlobal::displayError((String("Duplicated dynamic rigid body name: ") + physX30Collection.rigidDynamics[i].name.name).c_str()); 2516 return false; 2517 } 2518 } 2519 2520 // Also check for duplicated shape name 2521 for (size_t si = 0; si < physX30Collection.rigidDynamics[i].shapes.shapes.size(); ++si) { 2522 for (size_t sj = si + 1; sj < physX30Collection.rigidDynamics[i].shapes.shapes.size(); ++sj) { 2523 if (physX30Collection.rigidDynamics[i].shapes.shapes[si].name.name == 2524 physX30Collection.rigidDynamics[i].shapes.shapes[sj].name.name) { 2525 MGlobal::displayError((String("Duplicated shape name: ") + physX30Collection.rigidDynamics[i].shapes.shapes[si].name.name).c_str()); 2526 return false; 2527 } 2528 } 2529 } 2530 } 2531 2532 for (size_t i = 0; i < physX30Collection.rigidStatics.size(); ++i) { 2533 for (size_t j = i + 1; j < physX30Collection.rigidStatics.size(); ++j) { 2534 if (physX30Collection.rigidStatics[i].name.name == physX30Collection.rigidStatics[j].name.name) { 2535 MGlobal::displayError((String("Duplicated static rigid body name: ") + physX30Collection.rigidStatics[i].name.name).c_str()); 2536 return false; 2537 } 2538 } 2539 2540 // Also check for duplicated shape name 2541 for (size_t si = 0; si < physX30Collection.rigidStatics[i].shapes.shapes.size(); ++si) { 2542 for (size_t sj = si + 1; sj < physX30Collection.rigidStatics[i].shapes.shapes.size(); ++sj) { 2543 if (physX30Collection.rigidStatics[i].shapes.shapes[si].name.name == 2544 physX30Collection.rigidStatics[i].shapes.shapes[sj].name.name) { 2545 MGlobal::displayError((String("Duplicated shape name: ") + physX30Collection.rigidStatics[i].shapes.shapes[si].name.name).c_str()); 2546 return false; 2547 } 2548 } 2549 } 2550 } 2551 2552 for (size_t i = 0; i < physX30Collection.D6Joints.size(); ++i) { 2553 for (size_t j = i + 1; j < physX30Collection.D6Joints.size(); ++j) { 2554 if (physX30Collection.D6Joints[i].name.name == physX30Collection.D6Joints[j].name.name) { 2555 MGlobal::displayError((String("Duplicated constraint name: ") + physX30Collection.D6Joints[i].name.name).c_str()); 2556 return false; 2557 } 2558 } 2559 } 2560 2561 return true; 2562 } 2563 findConvexMesh(uint64_t id)2564 PxConvexMesh* PhysXDoc::findConvexMesh(uint64_t id) 2565 { 2566 for (size_t i = 0; i < physX30Collection.convexMeshes.size(); ++i) { 2567 PxConvexMesh& convexMesh = physX30Collection.convexMeshes[i]; 2568 if (convexMesh.id.id == id) 2569 return &convexMesh; 2570 } 2571 return NULL; 2572 } 2573 findTriangleMesh(uint64_t id)2574 PxTriangleMesh* PhysXDoc::findTriangleMesh(uint64_t id) 2575 { 2576 for (size_t i = 0; i < physX30Collection.triangleMeshes.size(); ++i) { 2577 PxTriangleMesh& triangleMesh = physX30Collection.triangleMeshes[i]; 2578 if (triangleMesh.id.id == id) 2579 return &triangleMesh; 2580 } 2581 return NULL; 2582 } 2583 findMaterial(uint64_t ref)2584 PxMaterial* PhysXDoc::findMaterial(uint64_t ref) 2585 { 2586 for (size_t i = 0; i < physX30Collection.materials.size(); ++i) { 2587 PxMaterial& material = physX30Collection.materials[i]; 2588 if (material.id.id == ref) { 2589 return &material; 2590 } 2591 } 2592 return NULL; 2593 } 2594 findMaterial(const String & shapeName)2595 PxMaterial* PhysXDoc::findMaterial(const String& shapeName) 2596 { 2597 PxShape* shape = findShape(shapeName); 2598 if (shape) { 2599 return findMaterial(shape->materials.materialRef.materialRef); 2600 } 2601 return NULL; 2602 } 2603 findShape(const String & shapeName)2604 PxShape* PhysXDoc::findShape(const String& shapeName) 2605 { 2606 for (size_t rb = 0; rb < physX30Collection.rigidStatics.size(); ++rb) { 2607 PxRigidStatic& rigid = physX30Collection.rigidStatics[rb]; 2608 for (size_t sh = 0; sh < rigid.shapes.shapes.size(); ++sh) { 2609 if (rigid.shapes.shapes[sh].name.name == shapeName) { 2610 return &rigid.shapes.shapes[sh]; 2611 } 2612 } 2613 } 2614 for (size_t rb = 0; rb < physX30Collection.rigidDynamics.size(); ++rb) { 2615 PxRigidDynamic& rigid = physX30Collection.rigidDynamics[rb]; 2616 for (size_t sh = 0; sh < rigid.shapes.shapes.size(); ++sh) { 2617 if (rigid.shapes.shapes[sh].name.name == shapeName) { 2618 return &rigid.shapes.shapes[sh]; 2619 } 2620 } 2621 } 2622 return NULL; 2623 } 2624 findRigidBody(const String & bodyName)2625 PxRigidBody* PhysXDoc::findRigidBody(const String & bodyName) 2626 { 2627 if (PxRigidStatic* s = findRigidStatic(bodyName)) { 2628 return s; 2629 } 2630 if (PxRigidDynamic* d = findRigidDynamic(bodyName)) { 2631 return d; 2632 } 2633 return NULL; 2634 } 2635 findRigidBody(uint64_t id)2636 PxRigidBody* PhysXDoc::findRigidBody(uint64_t id) 2637 { 2638 if (PxRigidStatic* s = findRigidStatic(id)) { 2639 return s; 2640 } 2641 if (PxRigidDynamic* d = findRigidDynamic(id)) { 2642 return d; 2643 } 2644 return NULL; 2645 } 2646 findRigidStatic(uint64_t id)2647 PxRigidStatic* PhysXDoc::findRigidStatic(uint64_t id) 2648 { 2649 for (size_t i = 0; i < physX30Collection.rigidStatics.size(); ++i) { 2650 PxRigidStatic& rigid = physX30Collection.rigidStatics[i]; 2651 if (rigid.id.id == id) { 2652 return &rigid; 2653 } 2654 } 2655 return NULL; 2656 } 2657 findRigidStatic(const String & bodyName)2658 PxRigidStatic* PhysXDoc::findRigidStatic(const String& bodyName) 2659 { 2660 for (size_t i = 0; i < physX30Collection.rigidStatics.size(); ++i) { 2661 PxRigidStatic& rigid = physX30Collection.rigidStatics[i]; 2662 if (rigid.name.name == bodyName) { 2663 return &rigid; 2664 } 2665 } 2666 return NULL; 2667 } 2668 findRigidDynamic(uint64_t id)2669 PxRigidDynamic* PhysXDoc::findRigidDynamic(uint64_t id) 2670 { 2671 for (size_t i = 0; i < physX30Collection.rigidDynamics.size(); ++i) { 2672 PxRigidDynamic& rigid = physX30Collection.rigidDynamics[i]; 2673 if (rigid.id.id == id) { 2674 return &rigid; 2675 } 2676 } 2677 return NULL; 2678 } 2679 findRigidDynamic(const String & bodyName)2680 PxRigidDynamic* PhysXDoc::findRigidDynamic(const String& bodyName) 2681 { 2682 for (size_t i = 0; i < physX30Collection.rigidDynamics.size(); ++i) { 2683 PxRigidDynamic& rigid = physX30Collection.rigidDynamics[i]; 2684 if (rigid.name.name == bodyName) { 2685 return &rigid; 2686 } 2687 } 2688 return NULL; 2689 } 2690 findD6Joint(const String & jointName)2691 PxD6Joint* PhysXDoc::findD6Joint(const String& jointName) 2692 { 2693 for (size_t i = 0; i < physX30Collection.D6Joints.size(); ++i) { 2694 PxD6Joint& joint = physX30Collection.D6Joints[i]; 2695 if (joint.name.name == jointName) { 2696 return &joint; 2697 } 2698 } 2699 return NULL; 2700 } 2701 PhysXDocPtr()2702 PhysXDocPtr::PhysXDocPtr() 2703 : mPhysXDoc(NULL) 2704 {} 2705 PhysXDocPtr(xmlDocPtr xml)2706 PhysXDocPtr::PhysXDocPtr(xmlDocPtr xml) 2707 : mPhysXDoc(NULL) 2708 { 2709 if (mPhysXDoc) { 2710 delete mPhysXDoc; 2711 } 2712 mPhysXDoc = new PhysXDoc(xml); 2713 } 2714 ~PhysXDocPtr()2715 PhysXDocPtr::~PhysXDocPtr() 2716 { 2717 if (mPhysXDoc) { 2718 delete mPhysXDoc; 2719 } 2720 } 2721 operator =(xmlDocPtr xml)2722 const PhysXDocPtr& PhysXDocPtr::operator = (xmlDocPtr xml) 2723 { 2724 if (mPhysXDoc) { 2725 delete mPhysXDoc; 2726 } 2727 mPhysXDoc = new PhysXDoc(xml); 2728 return *this; 2729 } 2730 operator ->() const2731 PhysXDoc* PhysXDocPtr::operator -> () const 2732 { 2733 return mPhysXDoc; 2734 } 2735 operator bool() const2736 PhysXDocPtr::operator bool() const 2737 { 2738 return mPhysXDoc != NULL; 2739 } 2740 } 2741 }