Skip to content

Commit

Permalink
Added no render option and fixed colors. (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Vin authored Aug 25, 2024
1 parent e6b5f26 commit 0abbbcd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/scenic/core/object_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,7 @@ class Object(OrientedPoint):
"occluding": True,
"showVisibleRegion": False,
"color": None,
"render": True,
"velocity": PropertyDefault((), {"dynamic"}, lambda self: Vector(0, 0, 0)),
"speed": PropertyDefault((), {"dynamic"}, lambda self: 0),
"angularVelocity": PropertyDefault((), {"dynamic"}, lambda self: Vector(0, 0, 0)),
Expand Down Expand Up @@ -1550,6 +1551,9 @@ def show3D(self, viewer, highlight=False):
if needsSampling(self):
raise RuntimeError("tried to show() symbolic Object")

if not self.render:
return

# Render the object
object_mesh = self.occupiedSpace.mesh.copy()

Expand All @@ -1564,7 +1568,12 @@ def show3D(self, viewer, highlight=False):
else:
assert False

object_mesh.visual.face_colors = [255 * r, 255 * g, 255 * b, 255 * a]
object_mesh.visual.face_colors = [
int(255 * r),
int(255 * g),
int(255 * b),
int(255 * a),
]

viewer.add_geometry(object_mesh)

Expand Down
2 changes: 1 addition & 1 deletion src/scenic/simulators/webots/model.scenic
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class Hill(Terrain):

height: 1
spread: 0.25
color: (0,0,0,0)
render: False

def heightAtOffset(self, offset):
dx, dy, _ = offset
Expand Down

0 comments on commit 0abbbcd

Please sign in to comment.