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


Python Vec.to_angle_roll方法代码示例

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


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

示例1: make_frames

# 需要导入模块: from srctools import Vec [as 别名]
# 或者: from srctools.Vec import to_angle_roll [as 别名]
def make_frames(vmf: VMF, targ: str, conf: dict, bbox_min: Vec, bbox_max: Vec, norm: Vec):
    """Generate frames for a rectangular glass item."""
    def make_frame(frame_type, loc, angles):
        """Make a frame instance."""
        vmf.create_ent(
            classname='func_instance',
            targetname=targ,
            file=conf['frame_' + frame_type],
            # Position at the center of the block, instead of at the glass.
            origin=loc - norm * 64,
            angles=angles,
        )

    if bbox_min == bbox_max:
        # 1x1 glass..
        make_frame('single', bbox_min, norm.to_angle())
        return

    norm_axis = norm.axis()
    u_axis, v_axis = Vec.INV_AXIS[norm_axis]

    u_norm = Vec()
    v_norm = Vec()
    u_norm[u_axis] = 1
    v_norm[v_axis] = 1

    single_u = bbox_min[u_axis] == bbox_max[u_axis]
    single_v = bbox_min[v_axis] == bbox_max[v_axis]

    # If single in either direction, it needs a u-bend.
    if single_u:
        ubend_axis = v_axis
    elif single_v:
        ubend_axis = u_axis
    else:
        ubend_axis = None

    if ubend_axis is not None:
        for bend_mag, bbox in [(1, bbox_min), (-1, bbox_max)]:
            make_frame(
                'ubend',
                bbox,
                norm.to_angle_roll(Vec.with_axes(ubend_axis, bend_mag)),
            )
    else:
        # Make 4 corners - one in each roll direction.

        for roll in range(0, 360, 90):
            angles = norm.to_angle(roll)
            # The two directions with a border in the corner instance.
            # We want to put it on those sides.
            corner_a = Vec(y=-1).rotate(*angles)
            corner_b = Vec(z=-1).rotate(*angles)

            # If the normal is positive, we want to be bbox_max in that axis,
            # otherwise bbox_min.

            pos = Vec.with_axes(
                norm_axis, bbox_min,

                corner_a.axis(),
                (bbox_max if corner_a >= (0, 0, 0) else bbox_min),

                corner_b.axis(),
                (bbox_max if corner_b >= (0, 0, 0) else bbox_min),
            )

            make_frame(
                'corner',
                pos,
                angles,
            )

    # Make straight sections.
    straight_u_pos = norm.to_angle_roll(v_norm)
    straight_u_neg = norm.to_angle_roll(-v_norm)
    straight_v_pos = norm.to_angle_roll(u_norm)
    straight_v_neg = norm.to_angle_roll(-u_norm)
    for u_pos in range(int(bbox_min[u_axis] + 128), int(bbox_max[u_axis]), 128):
        make_frame(
            'edge',
            Vec.with_axes(u_axis, u_pos, v_axis, bbox_min, norm_axis, bbox_min),
            straight_u_pos,
        )
        make_frame(
            'edge',
            Vec.with_axes(u_axis, u_pos, v_axis, bbox_max, norm_axis, bbox_min),
            straight_u_neg,
        )
    for v_pos in range(int(bbox_min[v_axis] + 128), int(bbox_max[v_axis]), 128):
        make_frame(
            'edge',
            Vec.with_axes(v_axis, v_pos, u_axis, bbox_min, norm_axis, bbox_min),
            straight_v_pos,
        )
        make_frame(
            'edge',
            Vec.with_axes(v_axis, v_pos, u_axis, bbox_max, norm_axis, bbox_min),
            straight_v_neg,
        )
开发者ID:BenVlodgi,项目名称:BEE2.4,代码行数:102,代码来源:glass.py


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