Skip to content

Commit

Permalink
(feat): adds scaleObject and GetSizeFactor helper functions (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpumacay authored Sep 28, 2023
1 parent 68b2adf commit fced270
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pyrep/backend/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,15 @@ def simSetShapeColor(shapeHandle, colorName, colorComponent, rgbData):
_check_return(res)


def simScaleObject(shapeHandle, scale_x, scale_y, scale_z):
ret = lib.simScaleObject(shapeHandle, scale_x, scale_y, scale_z, 0)
_check_return(ret)


def simGetObjectSizeFactor(shapeHandle):
return lib.simGetObjectSizeFactor(shapeHandle)


def simReorientShapeBoundingBox(shapeHandle, relativeToHandle):
ret = lib.simReorientShapeBoundingBox(shapeHandle, relativeToHandle, 0)
_check_return(ret)
Expand Down
21 changes: 21 additions & 0 deletions pyrep/objects/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,27 @@ def set_name(self, name: str) -> None:
"""
sim.simSetObjectName(self._handle, name)

def scale_object(self, scale_x: float, scale_y: float, scale_z: float) -> None:
"""Scales the object by the given amounts in the x, y, z axes
Note that this function apply the given scale to the object, it doesn't
set the scale factors. This means that if you apply two calls to this
function with factors of 2.0, this results in the object being scaled
by a factor of 4 in total (it doesn't set an internal scale factor!)
:param scale_x: The scaling factor along the object's x axis
:param scale_y: The scaling factor along the object's y axis
:param scale_z: The scaling factor along the object's z axis
"""
sim.simScaleObject(self._handle, scale_x, scale_y, scale_z)

def get_size_factor(self) -> float:
"""Gets the object size factor (for scaling purposes)
:return: The object's size factor
"""
return sim.simGetObjectSizeFactor(self._handle)

def get_position(self, relative_to=None) -> np.ndarray:
"""Gets the position of this object.
Expand Down

0 comments on commit fced270

Please sign in to comment.