When applying a projection material to the target asset (sphere) as shown in the GIF below,
I want to move the projector asset (cube) to check how the projected image will appear on the target. Is this possible?
It’s been a while since this question was asked, but in the case anyone still is wondering the same, I’ll leave this here.
Using the example code provided in the guide you linked, I modified a few lines to achieve the effect you wanted:
from pxr import Usd, UsdGeom
from pathlib import Path
import omni.usd
import omni.replicator.core as rep
#Create Light
distance_light = rep.create.light(rotation=(400,-23,-94), intensity=10000, light_type="distant")
stage = omni.usd.get_context().get_stage()
plane = rep.create.plane(position=(0, 0, 0), rotation=(0, 45, 10))
cube = rep.create.cube(visible=True, semantics=[('class', 'cube')], position=(0, 0, 0), rotation=(90, -90, 0), scale=(0.2, 0.2, 0.2))
sem = [('class', 'shape')]
# Create the projection with the plane as the target
with plane:
proj1 = rep.create.projection_material(cube, sem)
# Modify the cube position, and update the projection
with rep.trigger.on_frame():
with proj1:
rep.modify.projection_material(diffuse=Path(rep.example.TEXTURES_DIR).joinpath("smiley_albedo.png").as_posix())
rep.orchestrator.run()
The key to this is that I let replicator run an unlimited amount of frames by not defining the num_frames and then start the orchestrator which will activate your triggers.
You can read more about the different triggers that replicator provide here: Replicator API - Triggers