SetCameraToTexture

From ZDoom Wiki

Jump to: navigation, search
void setcameratotexture(int cameratid, str texturename, int fov); 

Usage

Binds the named texture to the specified camera (which doesn't have to be an actual camera thing). From this point on, whatever the camera sees in the specified FOV will be drawn onto the specified texture every frame. AFAIK, there is no way to 'unbind' the texture, but you can assign it a different camera.

Camera textures are only recalculated when they are viewed. Therefore you may make liberal use of camera textures, as long as there aren't several on-screen at once *.

Note that the texture used must be defined as a "cameratexture" in the ANIMDEFS lump.

Examples

I have a ANIMDEFS lump in my WAD with the following contents:

 cameratexture TCAMTEX1 128 64 fit 80 56

This will give me a texture called 'TCAMTEX1', 80 pixels wide and 56 high (but with a slightly higher, horizontally-compressed resolution), that I can apply to any wall or set of walls in my map. Next I put a camera thing in an interesting spot in the map, give it a TID (let's say 7), and put the following text in the map's ACS script:

 script 1 OPEN {
   SetCameraToTexture( 7, "TCAMTEX1", 90 );
 }

Now, all surfaces with TCAMTEX1 on them will be video screens showing what the camera sees. If I wanted, I could re-assign the texture to a different camera with a trigger somewhere in the level:

 script 2( int camera_tid, int fov ) {
   SetCameraToTexture( camera_tid, "TCAMTEX1", fov );
 }

Triggered by walk-over lines, this would allow me to re-use the same camera texture over and over again at different points in the level, possibly saving a bit of memory and lines in ANIMDEFS. Another use is to have a script that periodically changes the screen's view:

 script 3 OPEN {
   int inter_delay = 70; // 2 seconds between switching
   while( 1 ) {
     SetCameraToTexture( 7, "TCAMTEX1", 90 );
     Delay( inter_delay );
     SetCameraToTexture( 12, "TCAMTEX1", 90 );
     Delay( inter_delay );
     SetCameraToTexture( 15, "TCAMTEX1", 40 ); // this one's zoomed in!
     Delay( inter_delay );
   }
 }
Personal tools