Hpl3:Game:scripting:camera textures

From Frictional Wiki
Jump to navigation Jump to search

Camera Textures

It's possible to render a texture captured from an in-game camera to use on a GUI texture - for example, for showing images on security monitors etc.

Setup

First of all you create a camera texture and give it a name. For best results the size (avSize below) should match the size of the texture you want to draw on-screen. Method:

void Gui_CreateCameraTexture(tString asName, cVector2l avSize, uint alFrameRate, float afFOV, float afNearPlane, float afFarPlane);

and then attach the camera texture to a particular entity. This entity's position and rotation will be the viewpoint the camera is rendered from. Don't point this towards the terminal showing the image! Method:

void Gui_AttachCameraTextureToEntity(tString asName, tString asEntity);

For example:

<file> Gui_CreateCameraTexture("DunbatCamera", cVector2l(768, 613), 10, 60.0f, 0.1, 10); Gui_AttachCameraTextureToEntity("DunbatCamera", "DunbatCameraArea"); </file>

Rendering

In your OnGui function, you just render (as if it were any kind of texture) an image texture with the same name as the camera texture and the argument eImGuiGfx_Special.

For example:

<file> cImGuiGfx gfx("DunbatCamera", eImGuiGfx_Special); ImGui_DrawGfx(gfx, cVector3f(0,0,5.0f), ImGui_GetSize(), cColor(1, 1)); </file>