Beispiel #1
0
# All Rights Reserved. V-Ray(R) is a registered trademark of Chaos Software.
#

import os

import bpy

from vb30 import debug
from vb30.lib import ExportUtils
from vb30.lib import PluginUtils
from vb30.lib import PathUtils
from vb30.lib import LibUtils
from vb30.lib import SysUtils


PluginUtils.loadPluginOnModule(globals(), __name__)


def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
    scene  = bus['scene']
    o      = bus['output']
    camera = bus['camera']

    VRayScene = scene.vray
    VRayExporter = VRayScene.Exporter
    BakeView     = VRayScene.BakeView
    img_width  = int(scene.render.resolution_x * scene.render.resolution_percentage * 0.01)
    img_height = int(scene.render.resolution_y * scene.render.resolution_percentage * 0.01)

    # NOTE: Camera could be None when saving a preset, for example
    if camera:
# 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, see <http://www.gnu.org/licenses/>.
#
# All Rights Reserved. V-Ray(R) is a registered trademark of Chaos Software.
#

import bpy

from vb30.lib import ExportUtils
from vb30.lib import PluginUtils

PluginUtils.loadPluginOnModule(globals(), __name__)


def _updateSystemGamma(self, context):
    if self.sync_with_gamma:
        view_settings = context.scene.view_settings
        view_settings.gamma = 1.0 / self.gamma


# Inject update callback
for attrDesc in globals()['PluginParams']:
    if attrDesc['attr'] in {'gamma', 'sync_with_gamma'}:
        attrDesc['update'] = _updateSystemGamma


def writeDatablock(bus, pluginModule, pluginName, propGroup, overrideParams):
Beispiel #3
0
def register():
    global PLUGINS
    global PLUGINS_ID

    PluginUtils.LoadPluginDesc()
    LoadPlugins(PLUGINS, PLUGINS_ID)

    for jsonPluginName in PluginUtils.PLUGINS_DESC:
        if jsonPluginName not in PLUGINS_ID:
            if jsonPluginName in {
                    'MtlMulti',
                    'MtlLayeredBRDF',
                    'MtlSelectRE',
                    'MtlSkp2Sided',
                    'MtlWrapperMaya',
                    'GeomMeshLoader',
                    'GeomMeshLoader1',
                    'GeomMeshTest',
                    'GeomMetaballSystem',
                    'GeomParticleSystem',
                    'GeomStaticNURBS',
                    'Instancer',
                    'Instancer2',
                    'PhxShaderSimGeom',
                    'PhxShaderSimMesh',
            }:
                continue

            jsonPlugin = PluginUtils.PLUGINS_DESC[jsonPluginName]
            if jsonPlugin['TYPE'] in {'MISC'}:
                continue

            DynPluginType = type(
                # Name
                "JSON%s" % jsonPluginName,
                # Inheritance
                (
                    object, ),
                # Attributes
                jsonPlugin)

            PLUGINS[jsonPlugin['TYPE']][jsonPlugin['ID']] = DynPluginType
            PLUGINS_ID[jsonPlugin['ID']] = DynPluginType

    for regClass in GetRegClasses():
        bpy.utils.register_class(regClass)

    bpy.types.ParticleSettings.vray = bpy.props.PointerProperty(
        name="V-Ray Particle Settings",
        type=VRayParticleSettings,
        description="V-Ray Particle settings")

    VRayParticleSettings.VRayFur = bpy.props.PointerProperty(
        name="V-Ray Fur Settings",
        type=VRayFur,
        description="V-Ray Fur settings")

    bpy.types.Texture.vray = bpy.props.PointerProperty(
        name="V-Ray Texture Settings",
        type=VRayTexture,
        description="V-Ray texture settings")

    bpy.types.Scene.vray = bpy.props.PointerProperty(
        name="V-Ray Settings",
        type=VRayScene,
        description="V-Ray Renderer settings")

    bpy.types.Material.vray = bpy.props.PointerProperty(
        name="V-Ray Material Settings",
        type=VRayMaterial,
        description="V-Ray material settings")

    bpy.types.Mesh.vray = bpy.props.PointerProperty(
        name="V-Ray Mesh Settings",
        type=VRayMesh,
        description="V-Ray geometry settings")

    bpy.types.Lamp.vray = bpy.props.PointerProperty(
        name="V-Ray Lamp Settings",
        type=VRayLight,
        description="V-Ray lamp settings")

    bpy.types.Curve.vray = bpy.props.PointerProperty(
        name="V-Ray Curve Settings",
        type=VRayMesh,
        description="V-Ray geometry settings")

    bpy.types.Camera.vray = bpy.props.PointerProperty(
        name="V-Ray Camera Settings",
        type=VRayCamera,
        description="V-Ray Camera / DoF / Motion Blur settings")

    bpy.types.Object.vray = bpy.props.PointerProperty(
        name="V-Ray Object Settings",
        type=VRayObject,
        description="V-Ray Object Settings")

    bpy.types.World.vray = bpy.props.PointerProperty(
        name="V-Ray World Settings",
        type=VRayWorld,
        description="V-Ray world settings")

    VRayScene.VRayDR = bpy.props.PointerProperty(
        name="Distributed rendering",
        type=VRayDR,
        description="Distributed rendering settings")

    VRayObject.VRayAsset = bpy.props.PointerProperty(
        name="VRayAsset", type=VRayAsset, description="VRayAsset settings")

    # Add global settings to 'VRayExporterPreferences'
    # BEFORE registration
    #
    for pluginName in PLUGINS['SETTINGS_GLOBAL']:
        AddAttributes(
            PLUGINS['SETTINGS_GLOBAL'][pluginName],
            PLUGINS['SYSTEM']['VRayExporter'].VRayExporterPreferences)

    # Register properties
    #
    for pluginName in PLUGINS_ID:
        plugin = PLUGINS_ID[pluginName]
        if hasattr(plugin, 'register'):
            plugin.register()

    LoadPluginAttributes(PLUGINS['BRDF'], VRayMaterial)
    LoadPluginAttributes(PLUGINS['CAMERA'], VRayCamera)
    LoadPluginAttributes(PLUGINS['EFFECT'], VRayScene)
    LoadPluginAttributes(PLUGINS['GEOMETRY'], VRayMesh)
    LoadPluginAttributes(PLUGINS['LIGHT'], VRayLight)
    LoadPluginAttributes(PLUGINS['MATERIAL'], VRayMaterial)
    LoadPluginAttributes(PLUGINS['OBJECT'], VRayObject)
    LoadPluginAttributes(PLUGINS['RENDERCHANNEL'], VRayRenderChannel)
    LoadPluginAttributes(PLUGINS['SETTINGS'], VRayScene)
    LoadPluginAttributes(PLUGINS['TEXTURE'], VRayTexture)
    LoadPluginAttributes(PLUGINS['UVWGEN'], VRayTexture)

    LoadPluginAttributes(PLUGINS['UTILITIES'], VRayScene)
    LoadPluginAttributes(PLUGINS['SYSTEM'], VRayScene)
    LoadPluginAttributes(PLUGINS['SETTINGS_GLOBAL'], VRayScene)

    VRayScene.Exporter = bpy.props.PointerProperty(
        name="Exporter",
        type=bpy.types.VRayExporter,
        description="Global exporting settings")