Alright, the first two projectors I spawn have a white material. All proceeding projectors have the material I want, but play at the same time(even though they have different material names).
[QUOTE=grea$emonkey;15025822]All proceeding projectors have the material I want, but play at the same time(even though they have different material names).[/QUOTE]
I once made an XBox360 with a animated RRoD and had the same problem. :(
There's a good thing about that bug Greasemonkey, you could make a television SENT that plays different channels set by the server owner! (EG: You could apply a short portal clip to Channel 1 and have a short Half Life 2 clip on channel 2, and they both play in the same timescale like a normal TV would.)
[lua]local maxdist = 1024; -- You can't see it anymore when past this distance
local maxalpha = 255; -- The alpha when it's right next to the trace hitpos
local alpha = maxalpha * math.Clamp(1 - self.Entity:GetPos():Distance(tr.HitPos) / maxdist, 0, 1);
print(alpha);[/lua]
Just figured that this might work as an algorithm for the alpha, in-case you haven't solved it yet.
[QUOTE=DireAvenger;15043018]There's a good thing about that bug Greasemonkey, you could make a television SENT that plays different channels set by the server owner! (EG: You could apply a short portal clip to Channel 1 and have a short Half Life 2 clip on channel 2, and they both play in the same timescale like a normal TV would.)[/QUOTE]
Then it's a television, not a projector. ;)
[QUOTE=DarKSunrise;15047123][lua]local maxdist = 1024; -- You can't see it anymore when past this distance
local maxalpha = 255; -- The alpha when it's right next to the trace hitpos
local alpha = maxalpha * math.Clamp(1 - self.Entity:GetPos():Distance(tr.HitPos) / maxdist, 0, 1);
print(alpha);[/lua]
Just figured that this might work as an algorithm for the alpha, in-case you haven't solved it yet.[/QUOTE]
Thanks! I'll try that out!
Well, alpha doesn't work. I think it is related to DrawQuadEasy, because it has worked in other scripts of mine. I guess the whole color parameter just isn't working.
I did some tinkering with CreateMaterial, and I tried accessing it using Material(). I named it "movie_"..self.Entity:EntIndex()+2 (The +2 is there because for some reason the material shows that way. Don't ask why, I have no idea.)
Anyways, when I printed it it returned as "___error" and the material draw draws as the pink/black checkers.
Does CreateMaterial only work within one function? In which case, I would have to create it in the draw function and I'd be creating it almost as much as Think. I am going to assume that would lag.
In other news, I'm still trying to get that trace to work right with aiming it. I'm strongly considering adding some kind of player based aiming. Does anyone know how to make a concrete trace where the trace goes exactly according the objects angles?
To make it entity-specific frame, could you try adding the EntityRandom proxy to the material?
[QUOTE=Levybreak;15052444]To make it entity-specific frame, could you try adding the EntityRandom proxy to the material?[/QUOTE]
Oops, thought you meant in the code! But, EntityRandomProxy is with the assumption that it is being applied to an entity. In this case, it is a quad, but this just gave me a wonderful idea.
Anyways, I think that CreateMaterial is a dead end. It must be non-functional, because it is apparently making an invalid material. I think I will stick to my old method of there being only one per material in a map. At least that one works.
Xyxen and I collaborated for a while and we finally got this damn thing to work.
Here's some eye-candy for your nonbelievers.
[URL=http://img8.imageshack.us/my.php?image=gmconstruct0104.jpg][IMG]http://img8.imageshack.us/img8/5598/gmconstruct0104.th.jpg[/IMG][/URL]
[URL=http://img8.imageshack.us/my.php?image=gmconstruct0102.jpg][IMG]http://img8.imageshack.us/img8/9142/gmconstruct0102.th.jpg[/IMG][/URL]
[URL=http://img223.imageshack.us/my.php?image=gmconstruct0103.jpg][IMG]http://img223.imageshack.us/img223/6766/gmconstruct0103.th.jpg[/IMG][/URL]
One flaw, it needs to know how many fames there are total in the VTF so it can tell when to start the frame incrementation over. Only way I can think of is storing it in a txt file or a table with their corresponding materials. If anyone knows another way, please tell me.
[QUOTE=grea$emonkey;15061917]One flaw, it needs to know how many fames there are total in the VTF so it can tell when to start the frame incrementation over. Only way I can think of is storing it in a txt file or a table with their corresponding materials. If anyone knows another way, please tell me.[/QUOTE]
Isn't that stored in the VMT? Just guessing here.
[QUOTE=Xera;15094775]Isn't that stored in the VMT? Just guessing here.[/QUOTE]
Nope. Doesn't seem so. But I've got this thing a lot more realistic looking. I got the alpha to work!
Could someone show me how to make the rotation of the quad match the rotation of the ent? Is it the pitch or roll I should be using, and if so, how do I manipulate that so it works? Right now when I exceed 180 or 270 in different directions, it will begin to rotate back the way it came.
I'm trying to make it customizable so that people can add their own movies via text file. I'm terrible with that sorta stuff so could someone help me out?
Here's the code I've written so far. It's currently stored in tables. I wrote this up quickly so it's probably messy.
[lua]
Movies = {}
function AddMovie( name, material, frames, rate, sound )
local info = {
Name = name,
Material = material,
Frames = frames,
Rate = rate,
Sound = sound
}
table.insert( Movies, info )
end
function GetMovie( name )
end
//AddMovie( "Name of my Movie", "material_path", <total number of frames in the texture>, <number of frames to play per second>, "sound_path" )
AddMovie( "Example Film", "movies/example", 5, 1, "example.wav" )
AddMovie( "Example Film 2", "movies/example2", 10, 2, "example2.wav" )
[/lua]
If someone could show me how to translate that into a text file, and then back to code while pulling out each of the values and returning them in GetMovie(), that would be great!
--nvm--
[lua]
local roll = 180 + self.Entity:GetAngles().r;
if(roll > 360) then roll = roll - 360; end
local rotation = Vector(0, 0, roll);
[/lua]
For the rotation, that should work, or atleast give a direction how to do it.
[lua]Movies = {}
function AddMovie( name, material, frames, rate, sound )
local info = {
Name = name,
Material = material,
Frames = frames,
Rate = rate,
Sound = sound
}
table.insert( Movies, info )
end
function GetMovie( name )
for k,v in pairs(Movies) do
if v.Name == name then
return Movies[k]
end
end
end
//AddMovie( "Name of my Movie", "material_path", <total number of frames in the texture>, <number of frames to play per second>, "sound_path" )
AddMovie( "Example Film", "movies/example", 5, 1, "example.wav" )
AddMovie( "Example Film 2", "movies/example2", 10, 2, "example2.wav" )[/lua]
cool :D
about reading/writing to file
[lua]
local readstring = file.Read("file")
data = util.KeyValuesToTable(readstring)
for k,v in pairs(data) do
.....
end
local tabledata = util.TableToKeyValues(table)
datafile = file.Write( "file", tabledata )
[/lua]
[QUOTE=Megalan;15108090]about reading/writing to file
[lua]
local readstring = file.Read("file")
data = util.KeyValuesToTable(readstring)
for k,v in pairs(data) do
.....
end
local tabledata = util.TableToKeyValues(table)
datafile = file.Write( "file", tabledata )
[/lua][/QUOTE]
What would be a good way to format the data so that I can easily pull each of the values out?
Oh, also, should I be writing a new text file for each movie, or have it in one big text file?
you know, VTF is uncompressed format o_O, how big will be a size of standard movie...
[QUOTE=RavMahov;15110541]you know, VTF is uncompressed format o_O, how big will be a size of standard movie...[/QUOTE]
I'm aware that it would be rather large files if someone wanted it to be big. That's why I'm considering using Avon's 3d VGUI script. Then I could potentially play videos from youtube on this.
[QUOTE=grea$emonkey;15110581]I'm aware that it would be rather large files if someone wanted it to be big. That's why I'm considering using Avon's 3d VGUI script. Then I could potentially play videos from youtube on this.[/QUOTE]
If you got this to work with 3D 2D, I could make a digital projector that projects the screens from PCMod 2 onto a wall.
[lua]
function AddMovie( name, material, frames, rate, sound )
local info = {
Name = name,
Material = material,
Frames = frames,
Rate = rate,
Sound = sound
}
local tabledata = util.TableToKeyValues(info)
local filename = string.Replace(name, " ", "_")
file.Write( "movie_projector/"..filename, tabledata )
end
function GetMovie( name )
local filename = string.Replace(name, " ", "_")
local readstring = file.Read("movie_projector/"..filename)
print(readstring)
local data = util.KeyValuesToTable(readstring)
PrintTable(data)
end
GetMovie("Example Film")
[/lua]
Not working. What's wrong here?
[QUOTE=grea$emonkey;15110672][lua]
function AddMovie( name, material, frames, rate, sound )
local info = {
Name = name,
Material = material,
Frames = frames,
Rate = rate,
Sound = sound
}
local tabledata = util.TableToKeyValues(info)
local filename = string.Replace(name, " ", "_")
file.Write( "movie_projector/"..filename, tabledata )
end
function GetMovie( name )
local filename = string.Replace(name, " ", "_")
local readstring = file.Read("movie_projector/"..filename)
print(readstring)
local data = util.KeyValuesToTable(readstring)
PrintTable(data)
end
GetMovie("Example Film")
[/lua]
Not working. What's wrong here?[/QUOTE]
If I recall, and don't hold me to this, but if I recall correct, file.Write and file.Read get pissy if you don't add the file extensions.
So try adding ".txt" to both your file.Read and file.Write filepaths. If that's not the case, then you'll need to write your own system for storing those variables.
[QUOTE=grea$emonkey;15110581]I'm aware that it would be rather large files if someone wanted it to be big. That's why I'm considering using Avon's 3d VGUI script. Then I could potentially play videos from youtube on this.[/QUOTE]
If you want a REALLY simple way to display VGUI in 3D, I figured this out a while back:
[lua]
include( "shared.lua" )
ENT.RenderGroup = RENDERGROUP_OPAQUE
function ENT:Initialize( )
self.Panel = vgui.Create( "DFrame" )
self.Panel:SetSize( 50, 50 )
self.Panel:MakePopup( )
self.Panel:SetVisible( true )
self.Panel:SetKeyboardInputEnabled( false )
self.Panel:SetMouseInputEnabled( false )
self.Panel:SetTitle( "" )
self.Label = vgui.Create( "DLabel", self.Panel )
self.Label:SetText( "DONGS" )
self.Label:StretchToParent( )
self.Panel:SetPaintedManually( true )
self:SetRenderBounds( Vector( -3000, -3000, -3000 ), Vector( 3000, 3000, 3000 ) )
end
function ENT:OnRemove( )
self.Panel:Remove( )
end
function ENT:Draw( )
self.Entity:DrawModel( )
// adjust this stuff for your model/position/whatever
local pos = self:GetPos( ) + ( self:GetForward( ) * 5 ) + ( self:GetUp( ) * 105 ) + ( self:GetRight( ) * 40 )
local ang = self:GetAngles( )
ang:RotateAroundAxis( ang:Right( ), -90 )
ang:RotateAroundAxis( ang:Up( ), 90 )
self.Panel:SetPaintedManually( false )
cam.Start3D2D( pos, ang, 100 ) // change the scale
self.Panel:PaintManual( )
cam.End3D2D( )
self.Panel:SetPaintedManually( true )
end
function ENT:IsTranslucent( )
return true
end
[/lua]
I've never seen avon's version so I don't know how simple his is.
[QUOTE=Gmod4ever;15110788]If I recall, and don't hold me to this, but if I recall correct, file.Write and file.Read get pissy if you don't add the file extensions.
So try adding ".txt" to both your file.Read and file.Write filepaths. If that's not the case, then you'll need to write your own system for storing those variables.[/QUOTE]
How silly of me, you're right.
[QUOTE=DarKSunrise;15106315][lua]
local roll = 180 + self.Entity:GetAngles().r;
if(roll > 360) then roll = roll - 360; end
local rotation = Vector(0, 0, roll);
[/lua]
For the rotation, that should work, or atleast give a direction how to do it.[/QUOTE]
This works great, except it will rotate when I try to aim it up and down. That is a problem.
[QUOTE=Xera;15110842]If you want a REALLY simple way to display VGUI in 3D, I figured this out a while back:
[lua]
include( "shared.lua" )
ENT.RenderGroup = RENDERGROUP_OPAQUE
function ENT:Initialize( )
self.Panel = vgui.Create( "DFrame" )
self.Panel:SetSize( 50, 50 )
self.Panel:MakePopup( )
self.Panel:SetVisible( true )
self.Panel:SetKeyboardInputEnabled( false )
self.Panel:SetMouseInputEnabled( false )
self.Panel:SetTitle( "" )
self.Label = vgui.Create( "DLabel", self.Panel )
self.Label:SetText( "DONGS" )
self.Label:StretchToParent( )
self.Panel:SetPaintedManually( true )
self:SetRenderBounds( Vector( -3000, -3000, -3000 ), Vector( 3000, 3000, 3000 ) )
end
function ENT:OnRemove( )
self.Panel:Remove( )
end
function ENT:Draw( )
self.Entity:DrawModel( )
// adjust this stuff for your model/position/whatever
local pos = self:GetPos( ) + ( self:GetForward( ) * 5 ) + ( self:GetUp( ) * 105 ) + ( self:GetRight( ) * 40 )
local ang = self:GetAngles( )
ang:RotateAroundAxis( ang:Right( ), -90 )
ang:RotateAroundAxis( ang:Up( ), 90 )
self.Panel:SetPaintedManually( false )
cam.Start3D2D( pos, ang, 100 ) // change the scale
self.Panel:PaintManual( )
cam.End3D2D( )
self.Panel:SetPaintedManually( true )
end
function ENT:IsTranslucent( )
return true
end
[/lua]
I've never seen avon's version so I don't know how simple his is.[/QUOTE]
Thanks! I'll try this out later. First I need to get these text files figured out.
I got text files working too!
[editline]01:01PM[/editline]
I got the panel implemented. I'm having issues positioning it though.
This is my trace/drawquad code:
[lua]
local trace = {}
trace.start = self:LocalToWorld( self:OBBCenter() ) + Vector(0,0,1) + self:GetForward()*1.1 + self:GetRight()*11
trace.endpos = self:LocalToWorld( self:OBBCenter() ) + Vector(0,0,90) + self:GetRight()*maxdist
trace.filter = self
tr = util.TraceLine( trace )
render.DrawQuadEasy( tr.HitPos+tr.HitNormal*1.1, tr.HitNormal, size, size, color_white, roll )
[/lua]
Could someone help me translate this to the panel positioning?
Don't try to implement input onto the 3D 2D vgui. Believe me, it's not worth the bother.
And have you tried to position it so its positioned at 0,0 and sized to size,size?
I'm going to leave the vgui out for the moment, but it would be awesome if I got it to work.
[editline]01:49PM[/editline]
Oh, and does anyone have any ideas of how I could add a nice looking projector beam and some dustmotes for a realistic effect?
[QUOTE=grea$emonkey;15110844]I got the panel implemented. I'm having issues positioning it though.
This is my trace/drawquad code:
[lua]
local trace = {}
trace.start = self:LocalToWorld( self:OBBCenter() ) + Vector(0,0,1) + self:GetForward()*1.1 + self:GetRight()*11
trace.endpos = self:LocalToWorld( self:OBBCenter() ) + Vector(0,0,90) + self:GetRight()*maxdist
trace.filter = self
tr = util.TraceLine( trace )
render.DrawQuadEasy( tr.HitPos+tr.HitNormal*1.1, tr.HitNormal, size, size, color_white, roll )
[/lua]
Could someone help me translate this to the panel positioning?[/QUOTE]
tr.HitPos + tr.HitNormal * 1.1
The rotation will be a bit more complex, just use trial and error until it works.
I was looking for something like this before.
Hope this gets finished.
[QUOTE=grea$emonkey;15111924]
Oh, and does anyone have any ideas of how I could add a nice looking projector beam and some dustmotes for a realistic effect?[/QUOTE]
Maybe something like cs_office projector? or projector from portal?
Sorry, you need to Log In to post a reply to this thread.