The RTT (Render-to-Texture) camera feature used in the previous tutorial can be exploited in numerous ways to create interesting devices for the realXtend platform. The good news for OpenSim fans is that that the realXtend functionality will soon be merged into OpenSim as an optional regionmodule which can be activated on a per region basis.
Today’s tutorial involves the construction of a realistic working overhead projector. It’s realistic to a point, but it doesn’t project the slides onto your avatar if you step between the projector and the screen! Here’s a video to give you a sense of what it’s like.
I’m going to assume that you can build or find a suitable projector and screen using the techniques described in the tutorial on the streamlined tool chain. I chose this one by Jeff and colored it with my own textures after assigning the mesh to a cubic prim. The screen is just a pair of thin rectangular prims. For this exercise I didn’t bother with a tripod or other mounting hardware. Further, I’ll assume you can create a slide and place it on you projector, much like this:
Create a small cube to hold the RTT camera and position it above the slide near the mirror and lens. The projector I’ve chosen has an offset mirror & lens so I place the RTT camera directly above the slide where the mirror and lens should be. Dimensions of 0.05m cubed should be fine.
Drag a texture on the blank screen and record its UUID. Modify the samplertt.py script in the following ways and save it as overheadrtt.py. The key five lines in my script are:
pos = self.llGetPos()
lookAt = pos + Vector3(0, 0, -0.340)
cameraName = “overhead_cam”
textureId = “303a8c94-e879-4215-a3a9-43f0cf77caa7″ #slide_texture
textureWidth = 512
textureHeight = 512
The script is assigned to the cube by setting the class name to overheadrtt.RttCam (case-sensitive.) The first line gets the position of the cube. The second line tells the camera to look at a point .34m below. You should determine this value by calculating the difference between the center of the cube and the top surface of your slide. (It won’t matter if you use the Z-coordinate of your slide since the slide is very thin.)
After you save the script and restart the Python interpreter, you’ll see an inverted image which may be rotated if you rotated the slide object or the screen object while positioning them. Remove all rotations by setting the angles to zero and try to compensate by rotating and flipping textures. You can also decide whether you want conventional overhead projector behavior where the presenter faces the audience and the slide is oriented the correct way for the presenter, or whether you want the slide oriented towards the audience as it is in my example.
Before we finish, we have to deal with the plywood block. You can shrink it to .001m cubed, change the color and even make it almost transparent. Before you do any of this, link the projector to the cube and edit linked parts to select the cube. It can be very difficult to find a completely transparent cube! A better solution would be to implement a command in the script to toggle its transparency between 0 and 100%. You can combine this action with the existing logic that turns the RTT camera on and off.
If you have a collection of slides in a textures folder, you can drag the textures at will onto the top surface of the slide. You can amuse your audience by moving the slide around with your mouse. (You don’t have to edit the slide prim to do this.)
I leave it as an exercise for the reader to organize a slide flipper and a nice animation for the presenter to flip the slides.