Simple as that - I'm trying to work with clipping planes and such for a certain effect, but...
entities/ent_barrier/cl_init.lua:29: attempt to call global 'Plane' (a nil value)
Here be the code:
[lua]include('shared.lua')
require( 'renderx' )
function ENT:Draw()
local build = self.Entity:GetNWInt("BuildTime")
if build > 0 then
local p = Plane(self:GetForward(),self:GetPos())
// render with clip plane enabled
render.EnableClipping( true );
end
self:DrawModel()
end[/lua]
I thought RenderX was included in Gmod, but I was getting this error so I put the dll in my lua/includes/modules as usual, but I still got the error. Any clue why this happens? (render.EnableClipping does not return an error, by the way).
My only thought would be it's because I'm using the beta. Not sure why that'd be it though.
[lua]
render.EnableClipping(true)
render.PushCustomClipPlane(normal, distance)
self:DrawModel()
render.PopCustomClipPlane()
render.EnableClipping(false)
[/lua]
That's how you use it. Note the you can do render.PushCustomClipPlane as many times you like, just be sure to add a render.PopCustomClipPlane() after you've drawed the model for each plane you made.
[QUOTE=Dave_Parker;19258665]Yup, for some reason it got left out of renderx. Maybe garry will implement it into the next update.[/QUOTE]
I didn't give it to him for the simple fact, it's redundant. There is absolutely no reason to create a new table to contain normal/distance when you can calculate it yourself without creating as much garbage.
[lua]local normal = Vector( 0, 0, 1 );
local distance = normal:Dot( point );
[/lua]
Where normal is the plane normal and point is any point on the plane.
[editline]04:39PM[/editline]
[QUOTE=ralle105;19261174][lua]
render.EnableClipping(true)
render.PushCustomClipPlane(normal, distance)
self:DrawModel()
render.PopCustomClipPlane()
render.EnableClipping(false)
[/lua]
That's how you use it. Note the you can do render.PushCustomClipPlane as many times you like, just be sure to add a render.PopCustomClipPlane() after you've drawed the model for each plane you made.[/QUOTE]
There is a limit to the amount of user clip planes you have active at any given moment. On my current hardware, Radeon HD 5770, the max user clip planes is six.
To see just how many your hardware supports, open the console, type mat_info. Then look for the following.
[quote]
m_MaxUserClipPlanes: 6
[/quote]
It should be near the bottom.
[QUOTE=iRzilla;19257648]I asked this question a month back. Use this:
[lua]
function Plane( normal, point ) return { Normal = normal, Distance = normal:Dot( point ) } end
[/lua]
By the way you don't need to require renderx. The module is included in gmod by default ;P[/QUOTE]
what do i do with that , where do i put it, and call it?
just a question because i have the same problem and am a lua newbie.
any help would be useful:)
Holy bump :monocle:
If you read, it goes in cl_init
[QUOTE=LuckyLuke;22562181]Holy bump :monocle:
If you read, it goes in cl_init[/QUOTE]
Well where in cl_init, remember in my last post,
i have never done lua before,
Doesn't matter apparantly, as long as it is in cl_init
[QUOTE=LuckyLuke;22562829]Doesn't matter apparantly, as long as it is in cl_init[/QUOTE]
ok thanks for the help, i put it in and its worked!!! :):):):):)
Sorry, you need to Log In to post a reply to this thread.