Skip to content
Snippets Groups Projects
__init__.py 176 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 variables
Maurice Raybaud's avatar
Maurice Raybaud committed
update_files.py
Maurice Raybaud's avatar
Maurice Raybaud committed
    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.

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.
    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_(5400K)_Direct_Sun.py ; 02_(5400K)_High_Noon_Sun.py ;
            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 ;
            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 ;
Maurice Raybaud's avatar
Maurice Raybaud committed
            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
    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, 0),
    "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",
Luca Bonavita's avatar
Luca Bonavita committed

if "bpy" in locals():
    importlib.reload(ui)
    importlib.reload(render)
    importlib.reload(shading)
    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
Maurice Raybaud's avatar
Maurice Raybaud committed
    from bpy.types import AddonPreferences, PropertyGroup
    from bpy.props import (
Maurice Raybaud's avatar
Maurice Raybaud committed
        StringProperty,
        BoolProperty,
        IntProperty,
        FloatProperty,
        FloatVectorProperty,
        EnumProperty,
        PointerProperty,
        CollectionProperty,
    )
    from . import ui, render, update_files

def string_strip_hyphen(name):
Maurice Raybaud's avatar
Maurice Raybaud committed
    """Remove hyphen characters from a string to avoid POV errors."""
    return name.replace("-", "")
Maurice Raybaud's avatar
Maurice Raybaud committed

def active_texture_name_from_uilist(self, context):
    mat = context.scene.view_layers["View Layer"].objects.active.active_material
    index = mat.pov.active_texture_index
    name = mat.pov_texture_slots[index].name
    newname = mat.pov_texture_slots[index].texture
    tex = bpy.data.textures[name]
    tex.name = newname
    mat.pov_texture_slots[index].name = newname


Maurice Raybaud's avatar
Maurice Raybaud committed
def active_texture_name_from_search(self, context):
    mat = context.scene.view_layers["View Layer"].objects.active.active_material
    index = mat.pov.active_texture_index
    name = mat.pov_texture_slots[index].texture_search
    try:
        tex = bpy.data.textures[name]
        mat.pov_texture_slots[index].name = name
        mat.pov_texture_slots[index].texture = name
    except:
        pass

###############################################################################
# Scene POV properties.
###############################################################################
class RenderPovSettingsScene(PropertyGroup):
Maurice Raybaud's avatar
Maurice Raybaud committed
    """Declare scene level properties controllable in UI and translated to POV."""
Maurice Raybaud's avatar
Maurice Raybaud committed

    # Linux SDL-window enable
    sdl_window_enable: BoolProperty(
Maurice Raybaud's avatar
Maurice Raybaud committed
        name="Enable SDL window",
        description="Enable the SDL window in Linux OS",
        default=True,
    )
    # File Options
    text_block: StringProperty(
Maurice Raybaud's avatar
Maurice Raybaud committed
        name="Text Scene Name",
        description="Name of POV scene to use. "
        "Set when clicking Run to render current text only",
        maxlen=1024,
    )
    tempfiles_enable: BoolProperty(
Maurice Raybaud's avatar
Maurice Raybaud committed
        name="Enable Tempfiles",
        description="Enable the OS-Tempfiles. Otherwise set the path where"
Maurice Raybaud's avatar
Maurice Raybaud committed
        " to save the files",
Maurice Raybaud's avatar
Maurice Raybaud committed
        default=True,
    )
    pov_editor: BoolProperty(
Maurice Raybaud's avatar
Maurice Raybaud committed
        name="POV editor",
        description="Don't Close POV editor after rendering (Overridden"
Maurice Raybaud's avatar
Maurice Raybaud committed
        " by /EXIT command)",
Maurice Raybaud's avatar
Maurice Raybaud committed
        default=False,
    )
    deletefiles_enable: BoolProperty(
Maurice Raybaud's avatar
Maurice Raybaud committed
        name="Delete files",
Loading
Loading full blame...