Skip to content

Commit fced270

Browse files
authored
(feat): adds scaleObject and GetSizeFactor helper functions (#348)
1 parent 68b2adf commit fced270

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

pyrep/backend/sim.py

+9
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,15 @@ def simSetShapeColor(shapeHandle, colorName, colorComponent, rgbData):
745745
_check_return(res)
746746

747747

748+
def simScaleObject(shapeHandle, scale_x, scale_y, scale_z):
749+
ret = lib.simScaleObject(shapeHandle, scale_x, scale_y, scale_z, 0)
750+
_check_return(ret)
751+
752+
753+
def simGetObjectSizeFactor(shapeHandle):
754+
return lib.simGetObjectSizeFactor(shapeHandle)
755+
756+
748757
def simReorientShapeBoundingBox(shapeHandle, relativeToHandle):
749758
ret = lib.simReorientShapeBoundingBox(shapeHandle, relativeToHandle, 0)
750759
_check_return(ret)

pyrep/objects/object.py

+21
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,27 @@ def set_name(self, name: str) -> None:
120120
"""
121121
sim.simSetObjectName(self._handle, name)
122122

123+
def scale_object(self, scale_x: float, scale_y: float, scale_z: float) -> None:
124+
"""Scales the object by the given amounts in the x, y, z axes
125+
126+
Note that this function apply the given scale to the object, it doesn't
127+
set the scale factors. This means that if you apply two calls to this
128+
function with factors of 2.0, this results in the object being scaled
129+
by a factor of 4 in total (it doesn't set an internal scale factor!)
130+
131+
:param scale_x: The scaling factor along the object's x axis
132+
:param scale_y: The scaling factor along the object's y axis
133+
:param scale_z: The scaling factor along the object's z axis
134+
"""
135+
sim.simScaleObject(self._handle, scale_x, scale_y, scale_z)
136+
137+
def get_size_factor(self) -> float:
138+
"""Gets the object size factor (for scaling purposes)
139+
140+
:return: The object's size factor
141+
"""
142+
return sim.simGetObjectSizeFactor(self._handle)
143+
123144
def get_position(self, relative_to=None) -> np.ndarray:
124145
"""Gets the position of this object.
125146

0 commit comments

Comments
 (0)