Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.6 KiB

  1. import vs
  2. import vs.dmeutils
  3. from vs import dmeutils
  4. animUtils = dmeutils.CDmAnimUtils
  5. DagList = dmeutils.DagList
  6. def AreVectorsEqual( vectorA, vectorB ):
  7. if ( vectorA.x != vectorB.y ):
  8. return False
  9. if ( vectorA.y != vectorB.y ):
  10. return False
  11. if ( vectorA.z != vectorB.z ):
  12. return False
  13. return True
  14. root = vs.g_pDataModel.RestoreFromFile( "./test.dmx" )
  15. print root
  16. # Get the cube and sphere dag nodes from the scene
  17. cubeDag = root.model.children[ 0 ]
  18. print cubeDag
  19. sphereDag = root.model.children[ 1 ]
  20. print sphereDag
  21. # Test getting the position and rotatation of a dag
  22. cubePos = animUtils.GetDagPosition( DagList( cubeDag ), vs.TS_WORLD_SPACE )
  23. cubeRot = animUtils.GetDagRotation( DagList( cubeDag ), vs.TS_WORLD_SPACE )
  24. print cubePos
  25. print cubeRot
  26. # Create a test dag
  27. testDag = animUtils.CreateDag( "testDag", vs.vec3_origin, vs.quat_identity )
  28. print testDag
  29. # Test creating a dag list with multiple dag nodes
  30. dagList = vs.DagList( cubeDag, sphereDag, testDag )
  31. # Move the test dag
  32. animUtils.TransformDagNodes( vs.Vector( 5, 5, 5 ), vs.quat_identity, DagList( testDag ), False, vs.dmeutils.TS_WORLD_SPACE )
  33. testPos = animUtils.GetDagPosition( DagList( testDag ), vs.TS_WORLD_SPACE )
  34. print testPos
  35. # Constrain the test dag, this should overwrite the position of the test dag
  36. testConstraint = animUtils.CreatePointConstraint( "testConstraint", testDag, DagList( cubeDag ), False, 1.0 )
  37. print testConstraint
  38. testPos = animUtils.GetDagPosition( DagList( testDag ), vs.TS_WORLD_SPACE )
  39. print testPos
  40. # Generate log samples for the test dag evaluating the constraint
  41. animUtils.GenerateLogSamples( testDag, None, True, True )
  42. # Make the sphere a cild of the cube, but keep its world space
  43. # position, so the position should not change with this operation
  44. print "Re-parent with maintain world space, following position should be the same."
  45. spherePos = vs.CDmAnimUtils_GetDagPosition( vs.DagList( sphereDag ), vs.TS_WORLD_SPACE )
  46. print spherePos
  47. vs.dmeutils.CDmAnimUtils_ReParentDagNode( sphereDag, cubeDag, True, vs.REPARENT_LOGS_MAINTAIN_WORLD )
  48. spherePos = vs.CDmAnimUtils_GetDagPosition( vs.DagList( sphereDag ), vs.TS_WORLD_SPACE )
  49. print spherePos
  50. # Now move the cube, this should change the position of both the cube
  51. # and the sphere since the sphere should now be a child of the cube.
  52. print "Now the world space position of the sphere should have changed since its parent position changed"
  53. vs.dmeutils.CDmAnimUtils_MoveDagNodes( vs.Vector( 0, 0, 10 ), vs.DagList( cubeDag ), True, vs.dmeutils.TS_WORLD_SPACE )
  54. spherePos = vs.CDmAnimUtils_GetDagPosition( vs.DagList( sphereDag ), vs.TS_WORLD_SPACE )
  55. print spherePos