Example #1
0
def _get_np_length(start_obj, end_obj):
    point1 = Vector(start_obj.location)
    tang1 = start_obj.matrix_world.to_quaternion() * Vector((0, 1, 0))
    point2 = Vector(end_obj.location)
    tang2 = end_obj.matrix_world.to_quaternion() * Vector((0, 1, 0))
    result = _curve_utils.compute_smooth_curve_length(point1, tang1, point2, tang2, 300)
    return result
Example #2
0
def _get_np_length(start_obj, end_obj):
    point1 = Vector(start_obj.location)
    tang1 = start_obj.matrix_world.to_quaternion() * Vector((0, 1, 0))
    point2 = Vector(end_obj.location)
    tang2 = end_obj.matrix_world.to_quaternion() * Vector((0, 1, 0))
    result = _curve_utils.compute_smooth_curve_length(point1, tang1, point2,
                                                      tang2, 300)
    return result
Example #3
0
    def prepare_curves(curves_l):
        """Calculates lengths and leads to nodes variables for given curves.
        Should be used before calling get_as_section() on curves class instances.

        :param curves_l: list of curves to prepare
        :type curves_l: collections.Iterable[Curve]
        """

        for curve in curves_l:

            # first calculate length
            pos0, dir0 = curve.get_start(cartes_tang=False)
            pos1, dir1 = curve.get_end(cartes_tang=False)

            for i in range(
                    4):  # converge to actual length with four iterations
                curr_dir0 = Vector(dir0 * Vector(
                    (0, 0, -1)) * Curve.__NODE_DIR_LEN_COEF *
                                   curve.get_length())
                curr_dir1 = Vector(dir1 * Vector(
                    (0, 0, -1)) * Curve.__NODE_DIR_LEN_COEF *
                                   curve.get_length())

                new_length = _curve_utils.compute_smooth_curve_length(
                    pos0, curr_dir0, pos1, curr_dir1,
                    _PL_consts.CURVE_MEASURE_STEPS)
                curve.set_length(new_length)

            # second calculate leads to nodes
            if curve.is_inbound():
                curve.calc_leads_to_nodes_forward(0)

        # report invalid curves
        invalid_curves = []
        """:type : list[Curve]"""
        for curve in curves_l:

            if not curve.is_valid():
                invalid_curves.append(curve)

        if len(invalid_curves) > 0:
            msg = (
                "W Connections with loose ends detected, expect problems in game.\n\t   "
                "Check connections with starting Navigation Points:\n\t   [")

            for curve in invalid_curves:
                msg += "'" + curve.get_ui_name() + "', "

            msg = msg[:-2] + "]"
            lprint(msg)
Example #4
0
    def prepare_curves(curves_l):
        """Calculates lengths and leads to nodes variables for given curves.
        Should be used before calling get_as_section() on curves class instances.

        :param curves_l: list of curves to prepare
        :type curves_l: collections.Iterable[Curve]
        """

        for curve in curves_l:

            # first calculate length
            pos0, dir0 = curve.get_start(cartes_tang=False)
            pos1, dir1 = curve.get_end(cartes_tang=False)

            for i in range(4):  # converge to actual length with four iterations
                curr_dir0 = Vector(dir0 * Vector((0, 0, -1)) * Curve.__NODE_DIR_LEN_COEF * curve.get_length())
                curr_dir1 = Vector(dir1 * Vector((0, 0, -1)) * Curve.__NODE_DIR_LEN_COEF * curve.get_length())

                new_length = _curve_utils.compute_smooth_curve_length(pos0, curr_dir0, pos1, curr_dir1, _PL_consts.CURVE_MEASURE_STEPS)
                curve.set_length(new_length)

            # second calculate leads to nodes
            if curve.is_inbound():
                curve.calc_leads_to_nodes_forward(0)

        # report invalid curves
        invalid_curves = []
        """:type : list[Curve]"""
        for curve in curves_l:

            if not curve.is_valid():
                invalid_curves.append(curve)

        if len(invalid_curves) > 0:
            msg = ("W Connections with loose ends detected, expect problems in game.\n\t   "
                   "Check connections with starting Navigation Points:\n\t   [")

            for curve in invalid_curves:
                msg += "'" + curve.get_ui_name() + "', "

            msg = msg[:-2] + "]"
            lprint(msg)