View topic - Shuvro Sarker : Blender 2.5 Integration with yafray

Shuvro Sarker : Blender 2.5 Integration with yafray

This forum hosts proposals sent to YafaRay, discussions about GSOC 2010 accepted projects and their betatesting.

Shuvro Sarker : Blender 2.5 Integration with yafray

Post Tue Mar 23, 2010 2:35 am

Hi,

I am shuvro Sarker ,a final year CSE student of computer science in Bangladesh university of science and technology.I am interested in integrating Blender 2.5 with yafray.

Previous I have done projects in platforms like C,C++,python,java,PHP and javascript.I have done works with game and game AI.But what is most important in this regard that I have worked with Blender and Blender game engine and written scripts for blender.I have three submitted patches for blender 2.5 also.

my thought about this project:

The main cause before the necessity of this exporter is the vast change of python API from blender 2.49 to 2.50 as it works with python 3.1 rather than 2.6.x . And the main problematic fact is that blender 2.5 is not fully documented yet.

So,the basic workflow should be like that -

0.acquaintance with blender python api (which I already have)
1.collect the data from blender scene with the blender python api
2.Do any data conversion according to the input specification of yafaray.
3.format all data according to the desired format.
4.feed this formatted information to the yafaray python interpreter.

What I have done so far:

1. Building yafaray from source.
2. Analyze the previous exporter script.
3. analyze the povray script for blender 2.5
4. read about the desire XML format about yafaray.
5. worked with blender python api.

So,I think I can do the project with proper accuracy if I get the chance.If anyone has suggestions or advices for me please feel free to tell.
thanks.

Shuvro

And this the link of my blog -
http://somenewcolors.blogspot.com/
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

Re: Shuvro Sarker : Blender 2.5 Integration with yafray

Post Tue Mar 23, 2010 9:29 am

hi shuvro Sarker,

Welcome to our community. There are other people proposing the same topic. Try to differenciate your proposal by focusing it on a particular subject, like using yafaray nodes withing blender, or memory performace in complex scenes. For instance, currently there are some memory problems and unexpected crashes in Windows with complex scenes, investigate and propose a solution for them if possible.

Don't hesitate to post your questions here or in the chat room. Thank you for your interest in us. Best regards.
User avatar
Samo
 
Posts: 3097
Joined: Tue Dec 20, 2005 10:39 am
Location: Spain

Re: Shuvro Sarker : Blender 2.5 Integration with yafray

Post Wed Mar 24, 2010 10:34 am

Samo,

Thanks for your reply.

Currently I am trying to analyze the yafaray 2.49 python exporter scripts and trying to have an idea when and why the functions of the yafarayinterface.i is needed to be called.I also studied about SWIG to have a clear understanding about yafaray system.

When I complete all this I will be able to make the proposal more specific.

Shuvro
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

A small step in Yafaray integration with blender 2.5

Post Sat Apr 03, 2010 5:14 pm

First part of the integration process is to remove those panels from UI that contains some properties that are not needed or does not contain some properties that is needed for Yafaray and draw a new panel with the required options of Yafaray and add custom data types corresponding to these options by adding the property in the RNA module .

This example demonstrates that.It removes the lamp panel.Draws it with light options,color chooser and power property.The power property is not a native property of lamp class.So it is needed to add that in RNA of the class.Thats all.Attached code and images will clarify this more.To run this,save the code to a file,say properties_yfa.py copy it to the .blender/scripts/ui folder and restart blender.

The script is already loaded.To see what it does - select lamp from 3d view and go to Object data section.You will see the edited menu.The image will make it more clear.

Code: Select all
import bpy
from properties_data_lamp import DATA_PT_lamp



FloatProperty = bpy.types.Lamp.FloatProperty
IntProperty = bpy.types.Lamp.IntProperty
BoolProperty = bpy.types.Lamp.BoolProperty


#add new property in the RNA of bpy.types.Lamp
FloatProperty(attr="yaf_power",name="Power",description="Power",min=0, max=500.0, default=1.0)

class YafDataButtonsPanel(bpy.types.Panel):
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "data"

    def poll(self, context):
        return context.lamp


class DATA_PT_lamp_yaf(YafDataButtonsPanel):
    bl_label = "Lamp"

   

    def draw(self, context):
        layout = self.layout
           
        lamp = context.lamp
        layout.prop(lamp, "type", expand=True)
           
        split = layout.split()
        col = split.column()
        sub = col.column()
        sub.prop(lamp, "color", text="")
           
        sub = col.column()
        sub.prop(lamp, "yaf_power", text="light power")
       
        classes = [DATA_PT_lamp]
     
        try:
            for ins in classes:
                bpy.types.unregister(ins)
        except SystemError:
            #do nothing
            pass
       
           
           



classes = [
        DATA_PT_lamp_yaf
    ]


def register():
    register = bpy.types.register
    for cls in classes:
        register(cls)


def unregister():
    unregister = bpy.types.unregister
    for cls in classes:
        unregister(cls)

if __name__ == "__main__":
    register()


See the attached images.My semester final exam in going on.After the exam I will try to add more properties on it and also try to work on other aspects of this integration process.
Attachments
previous.png
This is the normal lamp menu
ui_update.png
this is updated UI for lamp
Last edited by shuvro on Thu Apr 08, 2010 2:59 am, edited 1 time in total.
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

A very simple(yet executable) blender integration script

Post Wed Apr 07, 2010 11:01 am

This is a very simple script that shows how to add an external renderer with blender python api and how to draw UI and add data component. I wanted to collect some data from python scene (like mesh data) and write it to the yafarayinterface also.But in doing that I found python wrapper of yafaray exporter module is prepared for python 2.6 and as blender python api uses python 3.1 ; importing yafaray python wrapper in blender causes some syntax conflict (for the change of python version).Compiling yafarayinterface.i for python 3.1 with SWIG may solve this problem but there is very little document along there for doing that.Adding -py3 option (suggested in the link http://www.swig.org/Doc1.3/Python.html#Python_python3support) didn't work for me.I have swig 1.3 installed.

Btw,I am including a screenshot also . The arrow pointed areas show the point of the sctipt.

Code: Select all
import bpy
import random
import time

class DummyRenderEngine(bpy.types.RenderEngine):
     
   bl_idname = 'MY_RENDER'
   bl_label = "NewRenderer"
       
   # callback to render scene
   def render(self, scene):
      print("rendering has started")
      #collect all the scene data here and write it to yafray interface
         


class RENDER_PT_dummy(bpy.types.Panel):
       
   bl_space_type = 'PROPERTIES'
   bl_region_type = 'WINDOW'
   bl_context = "render"
   bl_label = "My Renderer"
       
   COMPAT_ENGINES = { "MY_RENDER" }

   def poll(self, context):
      rd = context.scene.render
      print(rd.engine)
      print(rd.engine == 'MY_RENDER')
      return (rd.engine == 'MY_RENDER')

   def draw(self, context):
      layout = self.layout
      scene = context.scene
      layout.prop(scene, "yaf_power", text="light power")



VAR = 'MY_RENDER'
# Use some of the existing buttons.
   
import properties_render

properties_render.RENDER_PT_render.COMPAT_ENGINES.add(VAR)
properties_render.RENDER_PT_dimensions.COMPAT_ENGINES.add(VAR)
properties_render.RENDER_PT_antialiasing.COMPAT_ENGINES.add(VAR)
properties_render.RENDER_PT_output.COMPAT_ENGINES.add(VAR)
del properties_render

# Use only a subset of the world panels
import properties_world
properties_world.WORLD_PT_preview.COMPAT_ENGINES.add(VAR)
properties_world.WORLD_PT_context_world.COMPAT_ENGINES.add(VAR)
properties_world.WORLD_PT_world.COMPAT_ENGINES.add(VAR)
properties_world.WORLD_PT_mist.COMPAT_ENGINES.add(VAR)
del properties_world

# Example of wrapping every class 'as is'
import properties_material
for member in dir(properties_material):
   subclass = getattr(properties_material, member)
   try:
      subclass.COMPAT_ENGINES.add(VAR)
   except:
            pass
del properties_material
   

# extend scene with new property
scene = bpy.types.Scene
scene.BoolProperty(attr="yaf_power", name="YafPower", description="", default=True)


# register engine and panel
def register():
   bpy.types.register(DummyRenderEngine)
   bpy.types.register(RENDER_PT_dummy)
       
def unregister():
   print("command for unregistering")


and the print function included in the poll function prints the following lines in shell (which helped me to understand what is happening).
Code: Select all
BLENDER_RENDER
False
MY_RENDER
True
MY_RENDER
True
MY_RENDER
True


when I pressed the image button under render panel,it prints the line.
Code: Select all
rendering has started


Ok,too much talk.Here is the screenshot -
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

Importing yafarayinterface to python 3.1

Post Fri Apr 09, 2010 4:10 am

Now I have solved the problem of importing yafarayinterface module into python 3.1 .Though I have spent a lot time in finding the proper approach, the right workflow is simple.To do this,you need to have swig installed in your pc (vesion 1.3.37 or later).I downloaded the latest source(version 1.3.40) from this link - http://sourceforge.net/projects/swig/files/swig/swig-1.3.40/swig-1.3.40.tar.gz/download

Then I compiled and installed it.After that I copied yafaray/config/linux2-config.py file of yafaray source to the yafaray/ folder and renamed it as user-config.py .After that I enabled and changed some of the parameters of the file.The changes are listed below -
Code: Select all
# Python
YF_PYTHON = '/usr'
YF_PYTHON_VERSION = '3.1'
YF_PYTHON_INC = '${YF_PYTHON}/include/python${YF_PYTHON_VERSION}'
YF_PYTHON_LIBPATH = '${YF_PYTHON}/lib/python${YF_PYTHON_VERSION}'


Next I typed this command from shell -
Code: Select all
sudo scons swig


That generated the python binding for yafaray and the files are created under yafaray/build/bindings folder.There were 4 files in this folder - yafrayinterface.py _yafrayinterface.so yafrayinterface_wrap.cc and yafrayinterface_wrap.cc .And if you look at the syntax of yafrayinterface.py file you will notice that it is the syntax of python3.1 . To test whether it is compatible to python3.1 go to yafray/build/binding folder from shell and type 'python3.1' from the shell.This will open the python3.1 console.Now type -

Code: Select all
import yafrayinterface


It should smoothly import the yafrayinterface module without showing any error messages.Now you can play with the functions of the module.

To include it in Blender,just change the first two variables of the following script according to your blender and yafaray source location,then execute this script from linux shell -

Code: Select all
YAFDIR="/home/shuvro/codes/gsoc/yafaray/"
BLENDDIR="/home/shuvro/Desktop/Blender/"
ADD="install/linux2/.blender/scripts/io/"
ADDYAF="build/bindings/"
DIRNAME="yafaray"


mkdir $BLENDDIR$ADD$DIRNAME
cp $YAFDIR$ADDYAF* $BLENDDIR$ADD$DIRNAME
echo -e "from yafrayinterface import *\n\ndef register():\n\tpass\n\ndef unregister():\n\tpass\n" > $BLENDDIR$ADD$DIRNAME/__init__.py


Then run blender,open its script console and simply write -
Code: Select all
import yafaray
dir(yafaray)


This will print the elements of the yafarayinterface.


That's it.Thanks.
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

Re: Shuvro Sarker : Blender 2.5 Integration with yafray

Post Tue Apr 13, 2010 6:03 am

A script to determine the UI components

It is only needed to mention a panel name, its propperties and their data type .This script then searches blender source tree for this panel, extracts the properties associated with the panel and their data type.It then compares these data with the given input and returns a list of all the properties and their data types for this panel to fit with yafaray. It also returns a list about the properties that are not present in that blender panel and need to be added .If we have to draw a new panel, we can draw this with the first list returned(which keeps track of the values of the common properties)

This script also demonstrates about what properties (at least) should be passed from the yafaray plugin to take proper decision about the exporter interface.This is the code.It can be easily run from the text editor.The pasted output will clarify the thing more.

Code: Select all
import re

def properties_in_panel(panel):
    panel    = getattr(bpy.types, panel)
    filename = panel.draw.__code__.co_filename
    file     = open(filename)
    lines    = file.readlines()
    file.close()
   
    lines       =  lines[panel.draw.__code__.co_firstlineno:]
    regex       = re.compile(r'<class\s+\'(str|float|bool|int)\'>$')
    properties  = []
    var_names   = []
    vars        = []
    for l in lines:
        if l[0] not in [" ", "#", "\n"]:
            break
        else:
            element = []
            if l.find("=") > -1:
                v = l.split("=")
                var_names.append(v[0].strip())
                vars.append(v[1].strip())
            p = l.find(".prop(")
            if p > -1:
                data = l.split(",")[0].split("(")[-1]
                var_index = var_names.index(data)
               
                var = "bpy."+vars[var_index]
                v = eval("bpy."+vars[var_index])
                s = l.split(",")[1].strip(')\n" ')
               
                typeS = "type(" + var + "." + s + ")"
                #print("type string " + typeS)
                prop_data = eval(typeS)
               
                property = regex.findall(str(prop_data))
                if property:
                    property = property[0]
                else:
                    property = prop_data
               
                #print(property)
           
                #mytype = eval()
                p = getattr(v, s)
               
                element.append(s)
                element.append(property)
                element.append(p)
               
               
                #print(p)
                properties.append(element)
    return(properties)
   

def suggest_new_layout(panel_name,property_list):
   
    blender_prop_list = properties_in_panel(panel_name)
    print("blender props         : " + str(blender_prop_list))
    output = []
    add    = []
    alter  = []
   
   
    for yaf_prop in property_list :
        flag = 1
        for blend_prop in blender_prop_list:
            #only check for the data types
            if yaf_prop == blend_prop :
                flag = 0
                output.append(blend_prop)
                #remove the property from blender property list
                blender_prop_list.remove(blend_prop)
                break
        if flag :
            output.append(yaf_prop)
            add.append(yaf_prop)
   
    #for i in range(len(output)):
    #    if output[i] != property_list[i]:
    #        alter.append(output[i])
    #
    #for item in add:
    #    if item in alter:
    #        alter.remove(item)
   
    return output,add

#[['system', 'str', 'NONE'], ['scale_length', 'float', 1.0], ['use_separate', 'bool', False], ['rotation_units', 'str', 'DEGREES']]
panel_name    = "SCENE_PT_unit"
yaf_property  = [['system', 'str', 'NONE'], ['scale_length', 'int', 1], ['use_separate', 'bool', False], ['rotation', 'str', 'DEGREES']]

all_props,new_props = suggest_new_layout(panel_name,yaf_property)

print("props needed             :" + str(yaf_property))
print("suggested  props         :" + str(all_props))
print("new props                :" + str(new_props))
#print("props need to be altered :" + str(alter))


and this is the corresponding output -
Code: Select all
blender props : [['system', 'str', 'NONE'], ['scale_length', 'float', 1.0], ['use_separate', 'bool', False], ['rotation_units', 'str', 'DEGREES']]
props needed             :[['system', 'str', 'NONE'], ['scale_length', 'int', 1], ['use_separate', 'bool', False], ['rotation', 'str', 'DEGREES']]
suggested  props         :[['system', 'str', 'NONE'], ['scale_length', 'int', 1], ['use_separate', 'bool', False], ['rotation', 'str', 'DEGREES']]
new props                :[['scale_length', 'int', 1], ['rotation', 'str', 'DEGREES']]


Cheers!
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

Re: Shuvro Sarker : Blender 2.5 Integration with yafray

Post Wed Apr 14, 2010 12:51 am

Simple Demo: Working with functions of yafrayinterface inside Blender 2.5

I wanted to see the functions of yafarayinterface working inside blender 2.5.To make it importable I added the yafrayinterface.py,_yafrayinterface.so,yafrayinterface_wrap.cc and yafrayinterface_wrap.os in .blender/python/lib/python3.1/site-packages folder.Then I added this path into sys.path.The thing was done.After that I call some functions of yafrayinterface to test whether it is working or not.

Corresponding codes are given below -

Code: Select all
import sys

#This is the address where I copied the mentioned files.
PATH_TO_ADD = '/home/shuvro/Desktop/Blender/install/linux2/.blender/python/lib/python3.1/site-packages'
sys.path.append(PATH_TO_ADD)
import yafrayinterface


And to see that it's really working I called the following functions of yafrayinterface from the blender 2.5 console -

Code: Select all
YAF_LIB_PATH = '/usr/local/lib/yafaray'
t = yafrayinterface.yafrayInterface_t()
print(t.getVersion())
t.loadPlugins(YAF_LIB_PATH)


The output corresponding to the commands are -
Code: Select all
#output of print(t.getVersion())
543

#output of t.loadPlugins(YAF_LIB_PATH)
INFO:  [Environment] Loading plugins ...
INFO:  [Environment] Registered Integrator type 'photonmapping'
INFO:  [Environment] Registered Light type 'arealight'
INFO:  [Environment] Registered Light type 'bgPortalLight'
INFO:  [Environment] Registered Light type 'meshlight'
INFO:  [Environment] Registered Integrator type 'DebugIntegrator'
INFO:  [Environment] Registered Material type 'blend_mat'
INFO:  [Environment] Registered Light type 'spherelight'
INFO:  [Environment] Registered Material type 'light_mat'
INFO:  [Environment] Registered Material type 'mask_mat'
INFO:  [Environment] Registered Light type 'sunlight'
INFO:  [Environment] Registered Background type 'sunsky'
INFO:  [Environment] Registered Integrator type 'directlighting'
INFO:  [Environment] Registered Material type 'shinydiffusemat'
INFO:  [Environment] Registered VolumeRegion type 'GridVolume'
INFO:  [Environment] Registered Integrator type 'SkyIntegrator'
INFO:  [Environment] Registered Light type 'spotlight'
INFO:  [Environment] Registered Camera type 'orthographic'
INFO:  [Environment] Registered Integrator type 'EmissionIntegrator'
INFO:  [Environment] Registered Integrator type 'pathtracing'
INFO:  [Environment] Registered Material type 'glass'
INFO:  [Environment] Registered Material type 'mirror'
INFO:  [Environment] Registered Material type 'null'
INFO:  [Environment] Registered Material type 'rough_glass'
INFO:  [Environment] Registered Integrator type 'bidirectional'
INFO:  [Environment] Registered Light type 'directional'
INFO:  [Environment] Registered Integrator type 'SingleScatterIntegrator'
INFO:  [Environment] Registered Background type 'gradientback'
INFO:  [Environment] Registered VolumeRegion type 'SkyVolume'
INFO:  [Environment] Registered Light type 'pointlight'
INFO:  [Environment] Registered Material type 'coated_glossy'
INFO:  [Environment] Registered VolumeRegion type 'UniformVolume'
INFO:  [Environment] Registered Texture type 'blend'
INFO:  [Environment] Registered Texture type 'clouds'
INFO:  [Environment] Registered Texture type 'marble'
INFO:  [Environment] Registered Texture type 'wood'
INFO:  [Environment] Registered Texture type 'voronoi'
INFO:  [Environment] Registered Texture type 'musgrave'
INFO:  [Environment] Registered Texture type 'distorted_noise'
INFO:  [Environment] Registered Texture type 'rgb_cube'
INFO:  [Environment] Registered Texture type 'image'
INFO:  [Environment] Registered Background type 'darksky'
INFO:  [Environment] Registered Camera type 'angular'
INFO:  [Environment] Registered VolumeRegion type 'NoiseVolume'
INFO:  [Environment] Registered ShaderNode type 'texture_mapper'
INFO:  [Environment] Registered ShaderNode type 'value'
INFO:  [Environment] Registered ShaderNode type 'mix'
INFO:  [Environment] Registered ShaderNode type 'layer'
INFO:  [Environment] Registered ShaderNode type 'vcolor'
INFO:  [Environment] Registered Material type 'glossy'
INFO:  [Environment] Registered Integrator type 'none'
INFO:  [Environment] Registered VolumetricHandler type 'beer'
INFO:  [Environment] Registered VolumetricHandler type 'sss'
INFO:  [Environment] Registered VolumeRegion type 'ExpDensityVolume'
INFO:  [Environment] Registered Camera type 'perspective'
INFO:  [Environment] Registered Camera type 'architect'
INFO:  [Environment] Registered Background type 'textureback'
INFO:  [Environment] Registered Background type 'constant'
INFO:  [Environment] Registered Light type 'ieslight'


That was enough for me to be sure that it is working properly insider blender 2.5.Thanks.
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

Re: Shuvro Sarker : Blender 2.5 Integration with yafray

Post Sat Apr 17, 2010 2:27 am

Script: Layout specification and auto code generation for layout

Apart from the data that each plugin should supply, some layout data should also be provided to specify the layout. So, a system is needed to express the layout in a simple manner and to generate code with the given layout settings. The script below shows a way of doing that. With this, layout structure can be easily expressed and blender UI generation code is automatically produced from the layout structure, that is what we need.

First we can have a look how this script can be used in specifying layout data.

Suppose we want a layout similar to this -

Code: Select all
   
    -----------------------
    |    a     |    b      |
    -----------------------
    |          c           |
    -----------------------
    |          d           |
    ------------------------


We can do this with these simple statements.

Code: Select all
    panel_code.add_column('a_label')
    column = panel_code.add_column('b_label')
    panel_code.add_row(column)
   
    panel_code.empty_column()
    column = panel_code.add_column('c_label')
    panel_code.add_row(column)
   
   
    panel_code.empty_column()
    column = panel_code.add_column('d_label')
    panel_code.add_row(column)


Now, here is the code that do the stuffs -

Code: Select all
class PanelDraw:
    '''Generates a panel generating code with user settings'''
   
    def __init__(self,panel,space_type = '',region_type = '',context_name = ''):
        self.panel_name = panel
        #self.classN     = class_name
        self.space      = space_type
        self.region     = region_type
        self.context    = context_name
        self.row        = []
        self.column     = []
        self.properties = []
        self.COMPAT_ENGINES = ['YAF_RENDERER','ABUL_RENDERER']
   
    def add_row(self,new_row):
        self.row.append(new_row)
   
    def add_column(self,new_column):
        self.column.append(new_column)
        return self.column
   
    def add_properties(self,list_properties):
        self.properties = list_properties
   
    def empty_column(self):
        self.column = []
   
    def generate_code(self):
        file = open('code.py','w')
       
        string  = 'class YAF_PT_' + self.panel_name +'(bpy.types.Panel):\n\tbl_space_type = \'' + self.space + '\'\n'
        string += '\tbl_region_type = \'' + self.region + '\'\n'
        string += '\tbl_context = \'' + self.context + '\'\n'
       
        string += '\n\n'
       
        '''poll function started '''
        string += '\tdef poll(self, context):\n\n\t\tengine = context.scene.render.engine\n\t\treturn engine in ' + str([engine for engine in self.COMPAT_ENGINES]) + '\n'
       
        '''draw method started '''
        string += '\n\n\tdef draw(self, context):\n\n\t\tlayout = self.layout\n\t\tobj = context.object\n\n'
       
        for item in self.row:
            string += '\t\trow = layout.row()\n'
            if len(item) == 1:
                tmp = self.properties.pop(0)
                string += '\t\trow.prop(obj,\''+ tmp + '\')\n'
                string += '\t\trow.label(text=\'' + str(item[0]) + '\',icon=\'\')\n'
            else:
                for column in item:
                    string += '\n'
                    tmp = self.properties.pop(0)
                    string += '\t\tcolumn= row.column()\n'
                    string += '\t\tcolumn.prop(obj,\''+ tmp + '\')\n'
                    string +=  '\t\tcolumn.label(text=\'' + str(column) + '\',icon=\'\')\n'
                   
            string += '\n\n'
       
        '''code for registering the panel'''
        string += '\n\nbpy.types.register(YAF_PT_' + self.panel_name + ')\n\n\n'
        file.write(string)
        file.close()
       

if __name__ == "__main__":
   
    #init info for panels
   
    panel_code = PanelDraw('preview','PROPERTIES','WINDOW','data')
    panel_code.add_properties(['a','b','c','d'])
   
    #layout info
    '''
    Suppose we want a layout similar to this -
   
    -----------------------
    |    a     |    b      |
    -----------------------
    |          c           |
    -----------------------
    |          d           |
    ------------------------
   
    We can do this with these simple statements.
   
    '''
   
    panel_code.add_column('a_label')
    column = panel_code.add_column('b_label')
    panel_code.add_row(column)
   
    panel_code.empty_column()
    column = panel_code.add_column('c_label')
    panel_code.add_row(column)
   
   
    panel_code.empty_column()
    column = panel_code.add_column('d_label')
    panel_code.add_row(column)
   
    #add
    panel_code.generate_code()


And when this code is executed a file named code.py is generated automatically in the current folder that contains valid UI code for Blender panel with the given layout specification. Here is the code.py for the above layout setting -

Code: Select all
class YAF_PT_preview(bpy.types.Panel):
   bl_space_type = 'PROPERTIES'
   bl_region_type = 'WINDOW'
   bl_context = 'data'


   def poll(self, context):

      engine = context.scene.render.engine
      return engine in ['YAF_RENDERER', 'ABUL_RENDERER']


   def draw(self, context):

      layout = self.layout
      obj = context.object

      row = layout.row()

      column= row.column()
      column.prop(obj,'a')
      column.label(text='a_label',icon='')

      column= row.column()
      column.prop(obj,'b')
      column.label(text='b_label',icon='')


      row = layout.row()
      row.prop(obj,'c')
      row.label(text='c_label',icon='')


      row = layout.row()
      row.prop(obj,'d')
      row.label(text='d_label',icon='')




bpy.types.register(YAF_PT_preview)


I think this will be helpful for this project. Thanks.
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

Re: Shuvro Sarker : Blender 2.5 Integration with yafray

Post Tue Jun 29, 2010 4:58 am

Some screenshots of what I have done so far:
Attachments
layout_lamp.png
UI for lamp settings
render_sun_lamp.png
Rendered using sun light
render_sun_lamp.png (7.55 KiB) Viewed 17172 times
sphere_light.png
Rendered using sphere light
panel_camera.png
UI for camera settings
panel_camera_2.png
UI for camera settings - 2
camera_orthographic.png
Orthographic camera
camera_orthographic.png (6.54 KiB) Viewed 17172 times
camera_perspective.png
Perspective camera
camera_perspective.png (4.35 KiB) Viewed 17172 times
yafaray_bg.png
UI for background settings
ibl.png
A scene with image as background and image based lighting as lighting technique
ibl_settings.png
UI settings for texture background
shuvro
 
Posts: 26
Joined: Mon Mar 22, 2010 1:02 am

Re: Shuvro Sarker : Blender 2.5 Integration with yafray

Post Tue Jun 29, 2010 2:47 pm

You've done much progress, that's great. I'm curious to see the materials panels.
User avatar
bupla
 
Posts: 164
Joined: Thu Oct 23, 2008 7:06 am

Re: Shuvro Sarker : Blender 2.5 Integration with yafray

Post Tue Jul 27, 2010 12:19 am

Hi Shuvro,
I have been searching for code snippet for drop down list. I found a few in this thread, but its not working in B2.53(beta), could you please able to show me how to achieve this, it will be really helpful.( I am looking for internal properties , like that you given for LAMP types drop down menu ).
cheers,
afilash
zerothwonder
 
Posts: 3
Joined: Sun Aug 23, 2009 5:32 am


Return to Google summer of code 2010 - YafaRay Projects



Who is online

Users browsing this forum: No registered users and 1 guest