當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。