Skip to content
Snippets Groups Projects
__init__.py 183 KiB
Newer Older
# ##### BEGIN GPL LICENSE BLOCK #####
Luca Bonavita's avatar
Luca Bonavita committed
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

Maurice Raybaud's avatar
Maurice Raybaud committed
"""Import, export and render to POV engines.

These engines can be POV-Ray or Uberpov but others too, since POV is a
Maurice Raybaud's avatar
Maurice Raybaud committed
Scene Description Language. The script has been split in as few files
Maurice Raybaud's avatar
Maurice Raybaud committed
as possible :

___init__.py :
    Initialize properties
Maurice Raybaud's avatar
Maurice Raybaud committed
update_files.py
    Update new variables to values from older API. This file needs an update
Maurice Raybaud's avatar
Maurice Raybaud committed
ui.py :
    Provide property buttons for the user to set up the variables
Maurice Raybaud's avatar
Maurice Raybaud committed
primitives.py :
    Display some POV native primitives in 3D view for input and output
Maurice Raybaud's avatar
Maurice Raybaud committed

shading.py
Maurice Raybaud's avatar
Maurice Raybaud committed
    Translate shading properties to declared textures at the top of a pov file
Maurice Raybaud's avatar
Maurice Raybaud committed

nodes.py
    Translate node trees to the pov file
Maurice Raybaud's avatar
Maurice Raybaud committed
df3.py
    Render smoke to *.df3 files
Maurice Raybaud's avatar
Maurice Raybaud committed
render.py :
    Translate geometry and UI properties (Blender and POV native) to the POV file
Maurice Raybaud's avatar
Maurice Raybaud committed

Along these essential files also coexist a few additional libraries to help make
Blender stand up to other POV IDEs such as povwin or QTPOV
Maurice Raybaud's avatar
Maurice Raybaud committed
    presets :
        Material (sss)
Maurice Raybaud's avatar
Maurice Raybaud committed
            apple.py ; chicken.py ; cream.py ; Ketchup.py ; marble.py ;
Maurice Raybaud's avatar
Maurice Raybaud committed
            potato.py ; skim_milk.py ; skin1.py ; skin2.py ; whole_milk.py
        Radiosity
Maurice Raybaud's avatar
Maurice Raybaud committed
            01_Debug.py ; 02_Fast.py ; 03_Normal.py ; 04_Two_Bounces.py ;
Maurice Raybaud's avatar
Maurice Raybaud committed
            05_Final.py ; 06_Outdoor_Low_Quality.py ; 07_Outdoor_High_Quality.py ;
            08_Outdoor(Sun)Light.py ; 09_Indoor_Low_Quality.py ;
            10_Indoor_High_Quality.py ;
        World
            01_Clear_Blue_Sky.py ; 02_Partly_Hazy_Sky.py ; 03_Overcast_Sky.py ;
            04_Cartoony_Sky.py ; 05_Under_Water.py ;
        Light
            01_(4800K)_Direct_Sun.py ;
            02_(5400K)_High_Noon_Sun.py ;
Maurice Raybaud's avatar
Maurice Raybaud committed
            03_(6000K)_Daylight_Window.py ;
            04_(6000K)_2500W_HMI_(Halogen_Metal_Iodide).py ;
            05_(4000K)_100W_Metal_Halide.py ;
            06_(3200K)_100W_Quartz_Halogen.py ;
            07_(2850K)_100w_Tungsten.py ;
            08_(2600K)_40w_Tungsten.py ;
Maurice Raybaud's avatar
Maurice Raybaud committed
            09_(5000K)_75W_Full_Spectrum_Fluorescent_T12.py ;
            10_(4300K)_40W_Vintage_Fluorescent_T12.py ;
            11_(5000K)_18W_Standard_Fluorescent_T8 ;
            12_(4200K)_18W_Cool_White_Fluorescent_T8.py ;
Maurice Raybaud's avatar
Maurice Raybaud committed
            13_(3000K)_18W_Warm_Fluorescent_T8.py ;
Maurice Raybaud's avatar
Maurice Raybaud committed
            14_(6500K)_54W_Grow_Light_Fluorescent_T5-HO.py ;
            15_(3200K)_40W_Induction_Fluorescent.py ;
            16_(2100K)_150W_High_Pressure_Sodium.py ;
            17_(1700K)_135W_Low_Pressure_Sodium.py ;
            18_(6800K)_175W_Mercury_Vapor.py ;
            19_(5200K)_700W_Carbon_Arc.py ;
            20_(6500K)_15W_LED_Spot.py ;
            21_(2700K)_7W_OLED_Panel.py ;
Maurice Raybaud's avatar
Maurice Raybaud committed
            22_(30000K)_40W_Black_Light_Fluorescent.py ;
            23_(30000K)_40W_Black_Light_Bulb.py;
            24_(1850K)_Candle.py
Maurice Raybaud's avatar
Maurice Raybaud committed
    templates:
        abyss.pov ; biscuit.pov ; bsp_Tango.pov ; chess2.pov ;
        cornell.pov ; diffract.pov ; diffuse_back.pov ; float5 ;
        gamma_showcase.pov ; grenadine.pov ; isocacti.pov ;
        mediasky.pov ; patio-radio.pov ; subsurface.pov ; wallstucco.pov
"""


    "name": "Persistence of Vision",
    "author": "Campbell Barton, "
Maurice Raybaud's avatar
Maurice Raybaud committed
    "Maurice Raybaud, "
    "Leonid Desyatkov, "
    "Bastien Montagne, "
    "Constantin Rahn, "
    "Silvio Falcinelli",
    "version": (0, 1, 1),
    "blender": (2, 81, 0),
    "location": "Render Properties > Render Engine > Persistence of Vision",
    "description": "Persistence of Vision integration for blender",
    "doc_url": "{BLENDER_MANUAL_URL}/addons/render/povray.html",
    "warning": "Under active development, seeking co-maintainer(s)",
Luca Bonavita's avatar
Luca Bonavita committed

if "bpy" in locals():
    importlib.reload(ui)
    importlib.reload(nodes)
    importlib.reload(render)
    importlib.reload(shading)
    importlib.reload(primitives)
    importlib.reload(update_files)
    from bpy.utils import register_class, unregister_class
Maurice Raybaud's avatar
Maurice Raybaud committed
    # import addon_utils  # To use some other addons
    import nodeitems_utils  # for Nodes
    from nodeitems_utils import NodeCategory, NodeItem  # for Nodes
    from bl_operators.presets import AddPresetBase
    from bpy.types import (
        AddonPreferences,
        PropertyGroup,
        NodeSocket,
    )

    from bpy.props import (
        FloatVectorProperty,
Maurice Raybaud's avatar
Maurice Raybaud committed
        StringProperty,
        BoolProperty,
        IntProperty,
        FloatProperty,
        EnumProperty,
        PointerProperty,
        CollectionProperty,
    )
    from . import ui, render, update_files

def string_strip_hyphen(name):
    """Remove hyphen characters from a string to avoid POV errors"""
    return name.replace("-", "")
def pov_context_tex_datablock(context):
    """Texture context type recreated as deprecated in blender 2.8"""

    idblock = context.brush
    if idblock and context.scene.texture_context == 'OTHER':
        return idblock

    # idblock = bpy.context.active_object.active_material
    idblock = context.view_layer.objects.active.active_material
    if idblock and context.scene.texture_context == 'MATERIAL':
        return idblock

    idblock = context.world
    if idblock and context.scene.texture_context == 'WORLD':
        return idblock

    idblock = context.light
    if idblock and context.scene.texture_context == 'LIGHT':
        return idblock

    if context.particle_system and context.scene.texture_context == 'PARTICLES':
        idblock = context.particle_system.settings

    return idblock

    idblock = context.line_style
    if idblock and context.scene.texture_context == 'LINESTYLE':
        return idblock

def brush_texture_update(self, context):

    """Brush texture rolldown must show active slot texture props"""
    idblock = pov_context_tex_datablock(context)
    if idblock is not None:
        #mat = context.view_layer.objects.active.active_material
        idblock = pov_context_tex_datablock(context)
        slot = idblock.pov_texture_slots[idblock.pov.active_texture_index]
        tex = slot.texture

        if tex:
            # Switch paint brush to active texture so slot and settings remain contextual
            bpy.context.tool_settings.image_paint.brush.texture = bpy.data.textures[tex]
            bpy.context.tool_settings.image_paint.brush.mask_texture = bpy.data.textures[tex]
Loading
Loading full blame...