It is currently 23 Apr 2014, 18:56

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Python - ShaderDef + Dictionary
PostPosted: 02 Jul 2012, 01:38 
Offline
User avatar

Joined: 06 Jun 2011, 16:00
Posts: 315
Need some help with Python.

I've coded some ShaderDef's manually according to the Object model API for Python. But, I'd like to put that information into a dictionary and then declare the ShaderDef's by reading the information from the dictionary. But I dont know how to do that in Python.

So I want to do something like...

Code:
bsdfPlugins = {
    "diffuse" : {
        "reflectance" : [SpectrumType, TextureType ]
    },

    "roughplastic" : {
        "distribution" : [ EnumerationType(["beckmann", "ggx", "phong"]) ],
        "alpha" : [FloatType ],
        "intIOR" : [ FloatType, EnumerationType(iorPresetNames) ],
        "extIOR" : [ FloatType, EnumerationType(iorPresetNames) ],
        "diffuseReflectance" : [SpectrumType, TextureType ],
        "specularReflectance" : [SpectrumType, TextureType ]
    },

    ...(one entry for every BSDF)...
}


...then read each entry and turn it into the required callbacks for a ShaderDef

Code:
def diffuse_1_0_DefineInfo() {}
def diffuse_1_0_Define() {}
def roughplastic_1_0_DefineInfo() {}
def roughplastic_1_0_Define() {}
etc...


-TS-


Top
 Profile  
 
 Post subject: Re: Python - ShaderDef + Dictionary
PostPosted: 02 Jul 2012, 16:59 
Offline
User avatar

Joined: 06 Jun 2011, 16:00
Posts: 315
If anyone else is trying something like this...the answer is the "exec" statement, which supports dynamic execution of Python code.

Example:

Code:
exec """def fun():
  print 'bbb'
"""


The exec statement will process your string as Python code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: milesc and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group