本文整理汇总了Python中UM.Math.Vector.Vector.scale方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.scale方法的具体用法?Python Vector.scale怎么用?Python Vector.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Math.Vector.Vector
的用法示例。
在下文中一共展示了Vector.scale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multiply
# 需要导入模块: from UM.Math.Vector import Vector [as 别名]
# 或者: from UM.Math.Vector.Vector import scale [as 别名]
def test_multiply(self):
vector = Vector(2, 2, 2)
vector2 = Vector(2, 2, 2)
assert vector * vector2 == Vector(4, 4, 4)
assert vector * 2 == Vector(4, 4, 4)
assert vector.scale(vector2) == Vector(4, 4, 4)
vector *= vector2
assert vector == Vector(4, 4, 4)
示例2: SceneNode
# 需要导入模块: from UM.Math.Vector import Vector [as 别名]
# 或者: from UM.Math.Vector.Vector import scale [as 别名]
class SceneNode(SignalEmitter):
class TransformSpace:
Local = 1
Parent = 2
World = 3
def __init__(self, parent = None, name = ""):
super().__init__() # Call super to make multiple inheritence work.
self._children = []
self._mesh_data = None
self._position = Vector()
self._scale = Vector(1.0, 1.0, 1.0)
self._mirror = Vector(1.0, 1.0, 1.0)
self._orientation = Quaternion()
self._transformation = None
self._world_transformation = None
self._derived_position = None
self._derived_orientation = None
self._derived_scale = None
self._inherit_orientation = True
self._inherit_scale = True
self._parent = parent
self._enabled = True
self._selectable = False
self._calculate_aabb = True
self._aabb = None
self._aabb_job = None
self._visible = True
self._name = name
self._decorators = []
self._bounding_box_mesh = None
self.boundingBoxChanged.connect(self.calculateBoundingBoxMesh)
self.parentChanged.connect(self._onParentChanged)
if parent:
parent.addChild(self)
def __deepcopy__(self, memo):
copy = SceneNode()
copy.translate(self.getPosition())
copy.setOrientation(self.getOrientation())
copy.setScale(self.getScale())
copy.setMeshData(deepcopy(self._mesh_data, memo))
copy.setVisible(deepcopy(self._visible, memo))
copy._selectable = deepcopy(self._selectable, memo)
for decorator in self._decorators:
copy.addDecorator(deepcopy(decorator, memo))
for child in self._children:
copy.addChild(deepcopy(child, memo))
self.calculateBoundingBoxMesh()
return copy
def setCenterPosition(self, center):
if self._mesh_data:
m = Matrix()
m.setByTranslation(-center)
self._mesh_data = self._mesh_data.getTransformed(m)
self._mesh_data.setCenterPosition(center)
for child in self._children:
child.setCenterPosition(center)
## \brief Get the parent of this node. If the node has no parent, it is the root node.
# \returns SceneNode if it has a parent and None if it's the root node.
def getParent(self):
return self._parent
def getBoundingBoxMesh(self):
return self._bounding_box_mesh
def calculateBoundingBoxMesh(self):
if self._aabb:
self._bounding_box_mesh = MeshData()
rtf = self._aabb.maximum
lbb = self._aabb.minimum
self._bounding_box_mesh.addVertex(rtf.x, rtf.y, rtf.z) #Right - Top - Front
self._bounding_box_mesh.addVertex(lbb.x, rtf.y, rtf.z) #Left - Top - Front
self._bounding_box_mesh.addVertex(lbb.x, rtf.y, rtf.z) #Left - Top - Front
self._bounding_box_mesh.addVertex(lbb.x, lbb.y, rtf.z) #Left - Bottom - Front
self._bounding_box_mesh.addVertex(lbb.x, lbb.y, rtf.z) #Left - Bottom - Front
self._bounding_box_mesh.addVertex(rtf.x, lbb.y, rtf.z) #Right - Bottom - Front
self._bounding_box_mesh.addVertex(rtf.x, lbb.y, rtf.z) #Right - Bottom - Front
self._bounding_box_mesh.addVertex(rtf.x, rtf.y, rtf.z) #Right - Top - Front
self._bounding_box_mesh.addVertex(rtf.x, rtf.y, lbb.z) #Right - Top - Back
self._bounding_box_mesh.addVertex(lbb.x, rtf.y, lbb.z) #Left - Top - Back
self._bounding_box_mesh.addVertex(lbb.x, rtf.y, lbb.z) #Left - Top - Back
self._bounding_box_mesh.addVertex(lbb.x, lbb.y, lbb.z) #Left - Bottom - Back
#.........这里部分代码省略.........
示例3: SceneNode
# 需要导入模块: from UM.Math.Vector import Vector [as 别名]
# 或者: from UM.Math.Vector.Vector import scale [as 别名]
class SceneNode(SignalEmitter):
class TransformSpace:
Local = 1
Parent = 2
World = 3
def __init__(self, parent = None):
super().__init__() # Call super to make multiple inheritence work.
self._children = []
self._mesh_data = None
self._position = Vector()
self._scale = Vector(1.0, 1.0, 1.0)
self._orientation = Quaternion()
self._transformation = None
self._world_transformation = None
self._derived_position = None
self._derived_orientation = None
self._derived_scale = None
self._inherit_orientation = True
self._inherit_scale = True
self._parent = parent
self._enabled = True
self._selectable = False
self._calculate_aabb = True
self._aabb = None
self._aabb_job = None
self._visible = True
self._name = ""
if parent:
parent.addChild(self)
## \brief Get the parent of this node. If the node has no parent, it is the root node.
# \returns SceneNode if it has a parent and None if it's the root node.
def getParent(self):
return self._parent
def getName(self):
return self._name
def setName(self, name):
self._name = name
## How many nodes is this node removed from the root
def getDepth(self):
if self._parent is None: return 0
return self._parent.getDepth() + 1
## \brief Set the parent of this object
# \param scene_node SceneNode that is the parent of this object.
def setParent(self, scene_node):
if self._parent:
self._parent.removeChild(self)
self._parent = scene_node
if scene_node:
scene_node.addChild(self)
## Emitted whenever the parent changes.
parentChanged = Signal()
## \brief Get the visibility of this node. The parents visibility overrides the visibility.
# TODO: Let renderer actually use the visibility to decide wether to render or not.
def isVisible(self):
if self._parent != None and self._visible:
return self._parent.isVisible()
else:
return self._visible
def setVisible(self, visible):
self._visible = visible
## \brief Get the (original) mesh data from the scene node/object.
# \returns MeshData
def getMeshData(self):
return self._mesh_data
## \brief Get the transformed mesh data from the scene node/object, based on the transformation of scene nodes wrt root.
# \returns MeshData
def getMeshDataTransformed(self):
transformed_mesh = deepcopy(self._mesh_data)
transformed_mesh.transform(self.getWorldTransformation())
return transformed_mesh
## \brief Set the mesh of this node/object
# \param mesh_data MeshData object
def setMeshData(self, mesh_data):
if self._mesh_data:
self._mesh_data.dataChanged.disconnect(self.meshDataChanged)
self._mesh_data = mesh_data
if self._mesh_data is not None:
self._mesh_data.dataChanged.connect(self.meshDataChanged)
self._resetAABB()
self.meshDataChanged.emit(self)
#.........这里部分代码省略.........