Jump to content
MisterGravity

Is it possible to have a camera screen be a texture?

Recommended Posts

I know there's a camera object, so it is possible to point the camera somewhere, then have a side of a brush be the output of what that camera sees?

 

Think "security cameras".

Share this post


Link to post

To be fair Shadmar made that script smile.png

 

Do you think Shadmar or anyone has an example project I could download on this? The script is a little vague on the first three variables.

 

Well wait a minute now, I've been playing with it and I what I've done is point a camera straight down over an area, and then display that on a screen. Unfortunately, I can't see my first person camera anymore. I just see my hands carrying a gun around from a top down view, which is a little weird.

 

How can I still see what I need to see first person, but the camera view be the one I've setup?

Share this post


Link to post

For the tracking pivot variable, just place a pivot in your scene. The pivot has a position and direction (you can rotate it). The position & direction the pivot is pointing, will be where the camera gets placed so it's what the camera will see. You'll probably have to play around and trial and error get get the perfect direction it's pointing at.

 

The main camera is the camera. Place a camera in your scene and drag it to this parameter

 

RenderToMaterial can be any material. I believe whatever is used in the material as the texture gets overwritten anyway.

Share this post


Link to post

For the tracking pivot variable, just place a pivot in your scene. The pivot has a position and direction (you can rotate it). The position & direction the pivot is pointing, will be where the camera gets placed so it's what the camera will see. You'll probably have to play around and trial and error get get the perfect direction it's pointing at.

 

The main camera is the camera. Place a camera in your scene and drag it to this parameter

 

RenderToMaterial can be any material. I believe whatever is used in the material as the texture gets overwritten anyway.

 

I got that far, but the thing is, when I bring a new Misc / Camera into the scene, it becomes what I see all the time when I run the game. I lost my first-person-camera eyes when I walk around. How do I get that back, but keep the rest of it working? (The camera I placed IS displaying what it sees on the screen I setup, I just lost my own first person viewpoint.)

Share this post


Link to post

You only want 1 camera ever in your scene (for the most part). This script will take your camera, move it to the pivot, take a "snapshot", then restore where it was all before you know it even did it.

Share this post


Link to post

You only want 1 camera ever in your scene (for the most part). This script will take your camera, move it to the pivot, take a "snapshot", then restore where it was all before you know it even did it.

 

Okay, I'm soooo almost there. I replaced the camera I placed in the scene with a 2nd pivot, and when I run it, I see what "I see", as in my first person camera on the screen. How can I point the camera/pivot if it doesn't have a cone like lights and cameras do?

Share this post


Link to post

Trial and error with the rotation :)

 

Also, are you using the same material you passed to the script on some csg or something? That will be what the "security camera" sees.

Share this post


Link to post

Trial and error with the rotation smile.png

 

Also, are you using the same material you passed to the script on some csg or something? That will be what the "security camera" sees.

 

You say trial and error, but I'm not even seeing directions to point to. It's just a pivot, like a waypoint with no cone that you would send Moving Platforms to. See, take a look:

 

tumblr_mzbc6cwOBc1qk5t55o1_1280.jpg

 

 

tumblr_mzbci7TCQE1qk5t55o1_1280.jpg

Share this post


Link to post

Here's the deal. If you are using the base FPSPlayer script this won't work because that creates a camera in itself. (This is why I don't like that script). You don't need a pivot to replace the camera. What you need to do if look at my teleport tutorial and pay attention to the beginning where I change teh FPSPlayer script to accept a camera as a parameter instead of making one in itself. This allows you to drag a camera entity in your scene as the main camera that you can drag into the FPSPlayer script (after you make the change in my tutorial) AND drag it to this script as well.

 

The FPSPlayer script is great for a quick drop and drag and it just works, but with it making it's own camera, it sort of screws up other scripts that need to use a Camera. This is why I changed the script in my tutorial.

Share this post


Link to post

This is a really good idea for a new example map for us to add.

 

It might be necessary to add an extra commands to make it easier, like set a texture for a camera to automatically always render to. It's certainly possible right now through the API we have, but if we had an official example I could use that to figure out how to make it *really* easy to set up.

Share this post


Link to post

We got it figured out. The concept of the pivot being a placeholder to where the camera will move to and take a picture and then move back to the player can be confusing to people new to Leadwerks/game development.

Share this post


Link to post

I'd be interested in seeing your implementation.

 

I'll make a video and or write out exactly what we did. Rick is a brilliant, brilliant guy. Josh, now might be a good time to BEG you for a "point to" feature. As in, this light should point to that spot. Or that pivot should point to that spot. A simple static point to would be fantastic. A dynamic following pointer would be the bee's knees. All this guess work on in a three-dimensional plane is exasperating.

 

You know, now that I think about it, is there a way to get the x,y,z coordinates of a location, like where your mouse pointer is, and then put that in a "point to x,y,z" of a light or pivot? Is there already an easier way than the rotate buttons, test, try again, test, try again...etc.?

Share this post


Link to post

Here you go. Start.map. You'll see the backside of the middle csg (orange) on the monitor.

Share this post


Link to post

Le2 framework has its listener bound to the main camera which made it difficult iirc - you don't get any sound issues with positional audio ? biggrin.png

Share this post


Link to post

The script relys on a camera you can link in. FPSplayer, creates a camera which should be disabled and linked in via Script.Camara instead.

The pivot is like you said the position/rortation (matrix) where maincamera will be moved and snapshot into the buffer and back again.

Share this post


Link to post

 --Fetch CCTV material

mat=Material:Load(self.RenderToMaterial)

self.entity:SetMaterial(mat)

 

should really be in Start() not in Loop()

Share this post


Link to post

Well, that might was poorly worded - rick suggests pure object orientation with the camera being an object, the "only" other option would be self aware/containing objects ( with a own camera using disable old/ enable new ). Now, in le2 framework I "must" use the later because the ears ( listener ) are at the main cameras position "always" - fobaring positional audio e.g. light humming etc ...

 

that's was what I wanted to point out - if you want to have it extensible ... or as a base etc.

 

for beginner : sorry'bout all the "" ... le2 programmer know ( or should remember ) all the little issues we had ... and still have tbh.

Share this post


Link to post

There is actually one last issue I'm having with this that I can't seem to overcome. If my player has a Weapon equipped, like "autopistol.pfb", then the security screen display also shows my hand holding that pistol. Is it possible to draw the camera without it also seeing that?

Share this post


Link to post

Yes, in the script link in your gun/hand and add before and after render() .., something like this :

 

gun:Hide()
App.world:Render() -- render to buffer your pivots matrix
gun:Show()

Share this post


Link to post

Yes, in the script link in your gun/hand and add before and after render() .., something like this :

 

gun:Hide()
App.world:Render() -- render to buffer your pivots matrix
gun:Show()

 

Yep, I bet that is going to do it. Before you give me any answers on how to link in my gun/hand, let me try to figure that out on my own. I'm getting better at Lua by the minute. :)

Share this post


Link to post

This script is capable of having multiple security cameras, right? I've created 2 different securityCameraTextures, put them on two different surfaces, created two different pivots and pointed them were I want them to be, and I'm still amazingly seeing the same screen on both of them which should absolutely not be possible since the textures they're going to are completely different from each other.

 

tumblr_mzi40zuuLm1qk5t55o1_1280.jpg

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...