当前位置: 首页>>代码示例>>Python>>正文


Python object_utils.world_to_camera_view方法代码示例

本文整理汇总了Python中bpy_extras.object_utils.world_to_camera_view方法的典型用法代码示例。如果您正苦于以下问题:Python object_utils.world_to_camera_view方法的具体用法?Python object_utils.world_to_camera_view怎么用?Python object_utils.world_to_camera_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bpy_extras.object_utils的用法示例。


在下文中一共展示了object_utils.world_to_camera_view方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_bone_locs

# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import world_to_camera_view [as 别名]
def get_bone_locs(self, scene, bpy_camera_obj):
        '''
        Calculate the bone location, given the camera parameters
        '''

        n_bones = 24
        render_scale = scene.render.resolution_percentage / 100
        render_size = (int(scene.render.resolution_x * render_scale),
                       int(scene.render.resolution_y * render_scale))
        bone_locations_2d = np.empty((n_bones, 2))
        bone_locations_3d = np.empty((n_bones, 3), dtype='float32')

        # obtain the coordinates of each bone head in image space
        for bone_idx in range(n_bones):
            bone = self.armature.pose.bones[self.gender_name+'_'+part_match['bone_%02d' % bone_idx]]
            co_3d = self.armature.matrix_world * bone.head
            co_2d = world2cam(scene, bpy_camera_obj, co_3d)
            bone_locations_3d[bone_idx] = (co_3d.x,
                                     co_3d.y,
                                     co_3d.z)
            bone_locations_2d[bone_idx] = (round(co_2d.x * render_size[0]),
                                     round(co_2d.y * render_size[1]))
        return(bone_locations_2d, bone_locations_3d) 
开发者ID:lvzhaoyang,项目名称:RefRESH,代码行数:25,代码来源:motion_surreal.py

示例2: get_render_location

# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import world_to_camera_view [as 别名]
def get_render_location(mypoint):
    v1 = mathutils.Vector(mypoint)
    scene = bpy.context.scene
    co_2d = object_utils.world_to_camera_view(scene, scene.camera, v1)
    # Get pixel coords
    render_scale = scene.render.resolution_percentage / 100
    render_size = (int(scene.render.resolution_x * render_scale),
                   int(scene.render.resolution_y * render_scale))

    return [round(co_2d.x * render_size[0]), round(co_2d.y * render_size[1])] 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:opengl_dim.py

示例3: get_render_location

# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import world_to_camera_view [as 别名]
def get_render_location(self, context, coord):
        scene = context.scene
        co_2d = object_utils.world_to_camera_view(scene, scene.camera, coord)
        # Get pixel coords
        render_scale = scene.render.resolution_percentage / 100
        render_size = (int(scene.render.resolution_x * render_scale),
                       int(scene.render.resolution_y * render_scale))
        return Vector(round(co_2d.x * render_size[0]), round(co_2d.y * render_size[1])) 
开发者ID:s-leger,项目名称:archipack,代码行数:10,代码来源:archipack_gl.py

示例4: DefRenderOnlyInCamera

# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import world_to_camera_view [as 别名]
def DefRenderOnlyInCamera():
    # crea grupos
    if "INCAMERA" not in bpy.data.groups:
        bpy.data.groups.new("INCAMERA")
    if "NOTINCAMERA" not in bpy.data.groups:
        bpy.data.groups.new("NOTINCAMERA")

    # limpio grupos
    for ob in bpy.data.objects:
        if ob.name in bpy.data.groups["INCAMERA"].objects:
            bpy.data.groups["INCAMERA"].objects.unlink(ob)
        if ob.name in bpy.data.groups["NOTINCAMERA"].objects:
            bpy.data.groups["NOTINCAMERA"].objects.unlink(ob)

    # ordeno grupos
    for ob in bpy.data.objects:
        obs = False
        if ob.type == "MESH":
            tm = ob.to_mesh(bpy.context.scene, True, "RENDER")
            for vert in tm.vertices:
                cam = world_to_camera_view(
                    bpy.context.scene,
                    bpy.context.scene.camera,
                    vert.co + ob.location)
                if cam[0] >= -0 and cam[0] <= 1 and cam[1] >= 0 and cam[1] <= 1:
                    obs = True
            del(tm)
        else:
            obs = True
        if obs:
            bpy.data.groups["INCAMERA"].objects.link(ob)
        else:
            bpy.data.groups["NOTINCAMERA"].objects.link(ob) 
开发者ID:oscurart,项目名称:BlenderAddons,代码行数:35,代码来源:oscurart_objects.py

示例5: autoCrop

# 需要导入模块: from bpy_extras import object_utils [as 别名]
# 或者: from bpy_extras.object_utils import world_to_camera_view [as 别名]
def autoCrop(dummy):
    margin = bpy.context.scene.automatic_render_border_margin
    sc = bpy.context.scene
    sc.render.use_border = True
    x, y = [], []
    objetos = [bpy.context.visible_objects[:] if len(
        bpy.context.selected_objects) == 0 else
        bpy.context.selected_objects[:]]
    for ob in objetos[0]:
        if ob.type in ["MESH", "FONT", "CURVE", "META"] and ob.is_visible(sc):
            nmesh = ob.to_mesh(sc, True, "RENDER")
            for vert in nmesh.vertices:
                gl = ob.matrix_world * vert.co
                cc = world_to_camera_view(sc, sc.camera, gl)
                x.append(cc[0])
                y.append(cc[1])
            bpy.data.meshes.remove(nmesh)
        if ob.dupli_type == "GROUP" and ob.type == "EMPTY":
            for iob in ob.dupli_group.objects:
                if iob.type == "MESH" and ob.is_visible(sc):
                    nmesh = iob.to_mesh(sc, True, "RENDER")
                    for vert in nmesh.vertices:
                        gl = ob.matrix_world * iob.matrix_world * vert.co
                        cc = world_to_camera_view(sc, sc.camera, gl)
                        x.append(cc[0])
                        y.append(cc[1])
                    bpy.data.meshes.remove(nmesh)
    x.sort()
    y.sort()
    sc.render.border_min_x = x[0] - margin
    sc.render.border_max_x = x[-1] + margin
    sc.render.border_min_y = y[0] - margin
    sc.render.border_max_y = y[-1]+margin
    del x
    del y 
开发者ID:oscurart,项目名称:BlenderAddons,代码行数:37,代码来源:oscurart_auto_render_border.py


注:本文中的bpy_extras.object_utils.world_to_camera_view方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。