[Closed] Problem extending DirectX material
Hi guys,
I’m trying to create a custom DirectX material by extending “DirectX_9_Shader” class and replacing its UI. The extended material should load my .fx file upon creation, but I cannot make it work.
In the following example I try to load one of the standard .fx files shipped with 3ds Max, but as soon as the material is created I get the error: “>> MAXScript Scripted Plugin Handler Exception: – Type error: Call needs function or class, got: undefined <<” and the “delegate.effectFile” line is highlighted.
I’ve found this article on Gamasutra showing code almost identical to mine too, but I got no luck. What am I doing wrong?
plugin Material Custom
name:"DirectX Custom Shader"
classID:#(0x5345a218, 0x71525337)
extends:DirectX_9_Shader replaceUI:true version:1
(
parameters main rollout:params
(
cDiffuse type:#color default:blue ui:cpDiffuseColor
on cDiffuse set val do delegate.baseColor = val
)
rollout params "Parameters"
(
colorPicker cpDiffuseColor "Diffuse Color: " align:#center
)
on create do
(
-- setup initial material
-- try to load one of the default shaders
delegate.effectFile (getDir #MaxRoot + "maps\fx\HammerTime.fx")
)
)
Thank you for any help
- Enrico
has to be :
delegate.effectFile = (getDir #MaxRoot + "maps\fx\HammerTime.fx")
Thanks Denis,
I can’t believe it was so stupid… And I missed it from the article too. shame on me
- Enrico