Jump to content
WtymonrW

How i can project camera image like a entity texture or like simple image in real time?

Recommended Posts

So, i wanna project image that "see" camera at other place.

How i can do that?

I think, it have function simple fo this goal

Share this post


Link to post

What function call scripts in code? What value return this script?

So, anyway, i can rewrite this at C++ class:D

 

--This is where security cam will render
Script.TrackingPivot=""--entity
--This should be your main camera where you are, like your FPSCam
Script.MainCamera=""--entity
--This can be any material with any diffuse shader, paint your CCTV with this
Script.RenderToMaterial=""--path
function Script:Start()
   --Create Buffer and texture so we have a rendertarget to render to.
   camerabuffer=Buffer:Create(256,256,1,0);
   tex = Texture:Create(App.context:GetWidth(),App.context:GetHeight())
   camerabuffer:SetColorTexture(tex)
   camerabuffer:Disable();
   --Fetch CCTV material
   mat=Material:Load(self.RenderToMaterial)
   self.entity:SetMaterial(mat)
end
function Script:UpdateWorld()
   camerabuffer:Enable()
   save=self.MainCamera:GetMatrix() --save your cam matrix
   self.MainCamera:SetMatrix(self.TrackingPivot:GetMatrix())
   App.world:Render() -- render to buffer your pivots matrix
   self.MainCamera:SetMatrix(save) --restore matrix
   camerabuffer:Disable()
   --Ok now do backbuffer in mainloop (App.lua)
   Context:SetCurrent(App.context)
   --Set buffer output and send it to the shader as texture0
   buffertex = camerabuffer:GetColorTexture()
   mat:SetTexture(buffertex,0)
end

 

it set's the camera's view as a texture and then sends it off to send that texture image as texture0 for it to render on to the surface, and updates it constantly in the update world.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...