Movie Projector

http://img8.imageshack.us/img8/5273/gmconstruct0110m.jpg

I’m working on a Movie Projector SENT. I starting it quite some time ago and decided to begin work on it again. It’s still got quite a ways to go so I figured I could use some help.

Questions/Answers:

Q: What does it do?
A: This SENT will feature a few different modes.
[ul]
[li]Still Frame:[/li]Projects a single image onto a wall.
[li]Slide Show:[/li]A set of images that are switched between by the player who spawned the SENT. These could either be a bunch of different materials, or one animated material.
[li]Web:[/li]This mode can be used to show what you’re doing on the web. Primary use would be to display a Youtube page.
[li]Animation:[/li]Shows an animated material while it plays a corresponding sound file.
[/ul]
Basically it projects stuff onto walls while it plays a corresponding sound clip. I am adding youtube capabilities as well.

Q: How does it work?
A: This SENT utilizes the Material library, which means in animation mode it can control what frame is shown whenever it needs to. It makes a new instance of the material for each SENT, which means you can have more than one of these in your map playing the same clips at different intervals in time!

Q: Can I place these in my map?
A: Yes, and I plan to make an FGD for it in case you want to manipulate it within a role play map or something.

Q: So what do you need help with?
A: Right now I need help with a few things. Below is my list of bugs/problems.

[ul]
[li]I am trying to make this work with Valve’s env_projectedtexture entity. This will allow me to project this stuff onto walls while bending like real light![/li]I intend to rout it through an RT texture and then use that as the texture projected onto the wall. That way I can make a realistic projection of just about anything!
Since it currently uses DrawQuadEasy to put stuff on walls, it always stays in a perfect square, and is restricted to one axis. This means it could be showing in places I don’t want it to show.
If I can get env_projectedtexture to work with this, any images (including youtube videos) could bend like real light around multiple axes, and wouldn’t leave the area I want them in. Unfortunately, my RT code is not working, and even the default RT texture (“pp/rt”) crashes my game when I use it on DrawQuadEasy. Furthermore, it shows up as the pink/black checkered texture when put through env_projectedtexture. This could very well be due to not setting up RT code correctly. Still, env_projectedtexture seems very limited. Perhaps a binary module could change that?
If anyone wants to work with me on that, I would very much appreciate it.
[/ul]

I plan on adding a control menu for this to play, pause, fast forward, and rewind the clips. For further customization, I plan to make a txt file that acts as a playlist of sorts. It would include the materials along with their corresponding sounds so that the user could simply select a clip name from a list and it would automatically throw it together for your viewing pleasure.

Help would be appreciated. Suggestions would be nice too.

Also, if anyone wants to submit their own animated texture/material along with a sound clip, I would be happy to include it in the release. All I have is an example texture which is just a bunch of my old avatars put together into an animation.

Ooo, sounds intresting.

This could be awesome :open_mouth:

Cool.:aaa:

I’m considering giving it the ability to play youtube vids, but that may be too much. I could implement Avon’s 3d vgui stuff. That way I could use something like an avi/swf/whatever and have it opened with internet explorer.

Well, some ideas here:

To fix the material being shared between projectors, you might be able to create a new instance of the material instead of tagging it on as a general setting.

EG, in ENT:Init( ) clientside, create the material there instead.

To do the warping and possibly fix the orientation, you will need to use a different render function. I think render.DrawQuad is the one that accepts four vectors?

Regardless, you can do four traces in a sort of pyramid shape from wherever you desire the front to be, and then using their hit positions as the corners.

The only issue with that is it could get really strange projecting on edges or props, which would bend the picture physically.

The visibility could be solved by altering the projectors render bounds to extend to wherever the image is being drawn.

Just my ideas.

How do I create a new instance of the material? DrawQuad uses the vmt file which can’t be recreated (right?).
Here’s my init on client.
[lua]
function ENT:Initialize()

local mov = Material("movies/"..self.Movie)
local frame = mov:GetMaterialInt( "$frame" )
local rate = 1/self.FrameRate
timer.Create("frameadvance_"..self:EntIndex(), rate, 0, mov:SetMaterialInt( "$frame", frame+1))

timer.Stop("frameadvance_"..self:EntIndex())

end
[/lua]
The materials play at the same time when I have 2 out at once.
Next, I think the morphing would be too complicated. Too many possibilities.
Also, the visibility wouldn’t be good with renderbounds, since I already have it so it won’t draw if the trace is past a certain distance. What I need is for the alpha on the quad to fade as it gets farther away.

Didn’t know you were already creating instances of it on init, nevermind that then. I was thinking that you had something like this in your code:

[lua]
ENT.Mat = Material( “whatever” )
[/lua]

But that’s not the case, nor issue.


For render.DrawQuad, I believe you would do this:

[lua]
function ENT:Initialize( )
–other code
self.Material = mov
end

function ENT:Draw( )
render.SetMaterial( self.Material )
render.DrawQuad( a, b, c, d ) --Points
end
[/lua]

But it’s been a while since I’ve used DrawQuad so it might not work like that, I’m not sure.

Drawquad is working for me(aside from it being upside down and playing at the same time), but the issue is the alpha value for it. Is there some kind of algorithm I could use to decrease the alpha value as distance increases?

Although it would suffer the same problem as the multi-projector issue, you could probably do this:

[lua]
self.Material:SetMaterialInt( “$alpha”, desired_number )
[/lua]

Although I might have the key wrong, I think that flag exists.

Alpha should be set on the quad.
[lua]render.DrawQuadEasy(
tr.HitPos,
tr.HitNormal,
size,
size,
Color( 255, 255, 255, alpha )
)[/lua]

What I need is an algorithm. I’m terrible with those.
I tried math.Approach but it didn’t work.
[lua]
local dist = Vector1:Distance(tr.HitPos)
local fadedist = 50
local alpha = 255 or alpha

if dist > fadedist then
alpha = math.Approach(alpha, 0, 1)
end[/lua]

I mean with using DrawQuad, not DrawQuadEasy.

Maybe something like:

[lua]
math.EaseInOut( dist / maxdist, fadein, fadeout )
[/lua]

Where fadein could be 1 and fadeout a number like .7? Play around and see what you get, might be the entirely wrong tree, though.

DrawQuadEasy would be fine for now since the morphing thing isn’t necessary.

Also, why is it upside down?

Try flipping the z on the hit normal.

How can I flip the normal?
EaseInOut also doesn’t work.

tr.HitNormal.z = -tr.HitNormal.z

Might also need x/y flipping

Could you pop in a movie dynamically?

Flipping the normal didn’t work. I tried various combinations, but the most it did was flip around and face the opposite direction. When I flip z, it will face the opposite direction. When I flip x, it will face the opposite direction on x axis walls, and the same thing with y but on y facing walls.

I think it might be the trace. Has anyone looked at that code yet? When I rotate the SENT, the trace line does not always go where I want it do. For instance, when I try to rotate it to face downward, the line will spin around the x/y axis instead of the z axis like it should. Is it because I’m using OBBCenter in the trace?

It is possible, but would take a lot of work and may not even be worth it since download times would be horrendous.

What happens if you use a negative vertical size?

You don’t need to have the OBBCenter included in the tr.endpos, because you’ve set the filter to self, so it goes right through itself. I don’t think if this affects anything through.