DModelPanel/SetDirectionalLight

From Garry's Mod
Jump to: navigation, search
 DModelPanel:SetDirectionalLight( )

Contents

DescriptionPanelFunc

Sets the directional lighting used on the rendered entity.

Arguments

number direction

The light direction, see BOX_ Enums.

Arguments

table color

The color of the directional lighting.

Examples

Example

Displays a model panel with no directional lighting. Dr. Kleiner is only lit by the ambient light set by DModelPanel:SetAmbientLight.

-- Black background panel
BGPanel = vgui.Create("DPanel")
BGPanel:SetPos(20, 20)
BGPanel:SetSize(400, 400)
BGPanel:SetBackgroundColor(Color(0, 0, 0, 255))

local mdl = vgui.Create("DModelPanel", BGPanel)
mdl:SetSize(BGPanel:GetSize())
	
-- Setup model and camera
mdl:SetModel("models/kleiner.mdl")
mdl:SetCamPos(Vector(20, 20, 60))
mdl:SetLookAt(Vector(0, 0, 60))

-- Make Kleiner pace
mdl:GetEntity():SetSequence(mdl:GetEntity():LookupSequence("pace_all"))

-- Disable directional lighting
mdl:SetDirectionalLight(BOX_TOP, Color(0, 0, 0))
mdl:SetDirectionalLight(BOX_FRONT, Color(0, 0, 0))

-- Spin around faster and play animation
function mdl:LayoutEntity(ent)
	ent:SetAngles(Angle( 0, self.LastPaint*60,  0))
	self:RunAnimation()
end

Output:



DModelPanel SetDirectionalLight example1.jpg
Personal tools
Navigation