本文整理汇总了Python中UM.Scene.SceneNode.SceneNode.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Python SceneNode.getPosition方法的具体用法?Python SceneNode.getPosition怎么用?Python SceneNode.getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Scene.SceneNode.SceneNode
的用法示例。
在下文中一共展示了SceneNode.getPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_setPosition
# 需要导入模块: from UM.Scene.SceneNode import SceneNode [as 别名]
# 或者: from UM.Scene.SceneNode.SceneNode import getPosition [as 别名]
def test_setPosition(self):
node = SceneNode()
self.assertEqual(node.getPosition(), Vector(0, 0, 0))
node.setPosition(Vector(0, 0, 10))
self.assertEqual(node.getPosition(), Vector(0, 0, 10))
node.setPosition(Vector(0, 0, 10))
self.assertEqual(node.getPosition(), Vector(0, 0, 10))
示例2: test_translate
# 需要导入模块: from UM.Scene.SceneNode import SceneNode [as 别名]
# 或者: from UM.Scene.SceneNode.SceneNode import getPosition [as 别名]
def test_translate(self):
node = SceneNode()
self.assertEqual(node.getPosition(), Vector(0, 0, 0))
node.translate(Vector(0, 0, 10))
self.assertEqual(node.getPosition(), Vector(0, 0, 10))
node.translate(Vector(0, 0, 10))
self.assertEqual(node.getPosition(), Vector(0, 0, 20))
示例3: test_applyOperation
# 需要导入模块: from UM.Scene.SceneNode import SceneNode [as 别名]
# 或者: from UM.Scene.SceneNode.SceneNode import getPosition [as 别名]
def test_applyOperation(self):
# If there is no selection, nothing should happen
assert Selection.applyOperation(TranslateOperation) is None
node_1 = SceneNode()
Selection.add(node_1)
Selection.applyOperation(TranslateOperation, Vector(10, 20, 30))
assert node_1.getPosition() == Vector(10, 20, 30)
node_2 = SceneNode()
Selection.add(node_2)
assert len(Selection.applyOperation(TranslateOperation, Vector(10, 20, 30))) == 2
# Node 1 got moved twice
assert node_1.getPosition() == Vector(20, 40, 60)
# And node 2 only once
assert node_2.getPosition() == Vector(10, 20, 30)
示例4: test_translateWorld
# 需要导入模块: from UM.Scene.SceneNode import SceneNode [as 别名]
# 或者: from UM.Scene.SceneNode.SceneNode import getPosition [as 别名]
def test_translateWorld(self):
node1 = SceneNode()
node2 = SceneNode(node1)
self.assertEqual(node2.getWorldPosition(), Vector(0, 0, 0))
node1.translate(Vector(0, 0, 10))
self.assertEqual(node1.getWorldPosition(), Vector(0, 0, 10))
self.assertEqual(node2.getWorldPosition(), Vector(0, 0, 10))
node2.translate(Vector(0, 0, 10))
self.assertEqual(node1.getWorldPosition(), Vector(0, 0, 10))
self.assertEqual(node2.getWorldPosition(), Vector(0, 0, 20))
node1.rotate(Quaternion.fromAngleAxis(math.pi / 2, Vector.Unit_Y))
self.assertEqual(node1.getWorldPosition(), Vector(0, 0, 10))
self.assertEqual(node2.getWorldPosition(), Vector(10, 0, 10))
node2.translate(Vector(0, 0, 10))
# Local translation on Z with a parent rotated 90 degrees results in movement on X axis
pos = node2.getWorldPosition()
#Using fuzzyCompare due to accumulation of floating point error
self.assertTrue(Float.fuzzyCompare(pos.x, 20, 1e-5), "{0} does not equal {1}".format(pos, Vector(20, 0, 10)))
self.assertTrue(Float.fuzzyCompare(pos.y, 0, 1e-5), "{0} does not equal {1}".format(pos, Vector(20, 0, 10)))
self.assertTrue(Float.fuzzyCompare(pos.z, 10, 1e-5), "{0} does not equal {1}".format(pos, Vector(20, 0, 10)))
node2.translate(Vector(0, 0, 10), SceneNode.TransformSpace.World)
# World translation on Z with a parent rotated 90 degrees results in movement on Z axis
pos = node2.getWorldPosition()
self.assertTrue(Float.fuzzyCompare(pos.x, 20, 1e-5), "{0} does not equal {1}".format(pos, Vector(20, 0, 20)))
self.assertTrue(Float.fuzzyCompare(pos.y, 0, 1e-5), "{0} does not equal {1}".format(pos, Vector(20, 0, 20)))
self.assertTrue(Float.fuzzyCompare(pos.z, 20, 1e-5), "{0} does not equal {1}".format(pos, Vector(20, 0, 20)))
node1.translate(Vector(0, 0, 10))
self.assertEqual(node1.getWorldPosition(), Vector(10, 0, 10))
pos = node2.getWorldPosition()
self.assertTrue(Float.fuzzyCompare(pos.x, 30, 1e-5), "{0} does not equal {1}".format(pos, Vector(30, 0, 20)))
self.assertTrue(Float.fuzzyCompare(pos.y, 0, 1e-5), "{0} does not equal {1}".format(pos, Vector(30, 0, 20)))
self.assertTrue(Float.fuzzyCompare(pos.z, 20, 1e-5), "{0} does not equal {1}".format(pos, Vector(30, 0, 20)))
node1.scale(Vector(2, 2, 2))
pos = node2.getWorldPosition()
self.assertTrue(Float.fuzzyCompare(pos.x, 50, 1e-4), "{0} does not equal {1}".format(pos, Vector(50, 0, 30)))
self.assertTrue(Float.fuzzyCompare(pos.y, 0, 1e-4), "{0} does not equal {1}".format(pos, Vector(50, 0, 30)))
self.assertTrue(Float.fuzzyCompare(pos.z, 30, 1e-4), "{0} does not equal {1}".format(pos, Vector(50, 0, 30)))
node2.translate(Vector(0, 0, 10))
pos = node2.getWorldPosition()
self.assertTrue(Float.fuzzyCompare(pos.x, 70, 1e-4), "{0} does not equal {1}".format(pos, Vector(70, 0, 30)))
self.assertTrue(Float.fuzzyCompare(pos.y, 0, 1e-4), "{0} does not equal {1}".format(pos, Vector(70, 0, 30)))
self.assertTrue(Float.fuzzyCompare(pos.z, 30, 1e-4), "{0} does not equal {1}".format(pos, Vector(70, 0, 30)))
# World space set position
node1 = SceneNode()
node2 = SceneNode(node1)
node1.setPosition(Vector(15,15,15))
node2.setPosition(Vector(10,10,10))
self.assertEqual(node2.getWorldPosition(), Vector(25, 25, 25))
node2.setPosition(Vector(15,15,15), SceneNode.TransformSpace.World)
self.assertEqual(node2.getWorldPosition(), Vector(15, 15, 15))
self.assertEqual(node2.getPosition(), Vector(0,0,0))
node1.setPosition(Vector(15,15,15))
node2.setPosition(Vector(0,0,0))
node2.rotate(Quaternion.fromAngleAxis(-math.pi / 2, Vector.Unit_Y))
node2.translate(Vector(10,0,0))
self.assertEqual(node2.getWorldPosition(), Vector(15,15,25))
node2.setPosition(Vector(15,15,25), SceneNode.TransformSpace.World)
self.assertEqual(node2.getWorldPosition(), Vector(15,15,25))
self.assertEqual(node2.getPosition(), Vector(0,0,10))