def turn_clipping_planes_on(self):
        """ the lines may extend outside of the 'frame'
            setting clipping planes are one way to prevent them from being
            rendered outside """

        self.turn_clipping_planes_off()

        for length, normal_vector in zip(
            [self.clipping_panel_geometry.l1, self.clipping_panel_geometry.l2],
            [self.clipping_panel_geometry.n1, self.clipping_panel_geometry.n2
             ]):
            d = length
            a, b, c = math_utils.p3d_to_np(normal_vector)

            plane1 = LPlanef(a, b, c, 0)
            plane1_node = PlaneNode('', plane1)
            plane1_node.setClipEffect(1)
            plane1_nodepath = NodePath(plane1_node)

            plane2 = LPlanef(-a, -b, -c, d)
            plane2_node = PlaneNode('', plane2)
            plane2_node.setClipEffect(1)
            plane2_nodepath = NodePath(plane2_node)

            plane1_nodepath.reparentTo(self.clipped_thing_p3d_nodepath)
            self.clipped_thing_p3d_nodepath.setClipPlane(plane1_nodepath)
            self.clipping_planes_p3d_nodepaths.append(plane1_nodepath)

            plane2_nodepath.reparentTo(self.clipped_thing_p3d_nodepath)
            self.clipped_thing_p3d_nodepath.setClipPlane(plane2_nodepath)
            self.clipping_planes_p3d_nodepaths.append(plane2_nodepath)
Exemple #2
0
    def turn_clipping_planes_on(self):
        """ the lines may extend outside of the 'frame'
            setting clipping planes are one way to prevent them from being
            rendered outside

            if dimensions of the frame are updated, set_clipping_panel_geometry must be called before this
            with the appriopriate panel geometry """

        self.turn_clipping_planes_off()

        for i, normal_vector in zip(Frame2d.axis_direction_indices,
                                    Frame2d.axis_direction_vectors):
            d = self.get_p3d_axis_length_from_axis_direction_index(i)
            a, b, c = math_utils.p3d_to_np(normal_vector)

            plane1 = LPlanef(a, b, c, 0)
            plane1_node = PlaneNode('', plane1)
            plane1_node.setClipEffect(1)
            plane1_nodepath = NodePath(plane1_node)

            plane2 = LPlanef(-a, -b, -c, d)
            plane2_node = PlaneNode('', plane2)
            plane2_node.setClipEffect(1)
            plane2_nodepath = NodePath(plane2_node)

            clipped_thing_nodepath = self.linesin2dframe.get_p3d_nodepath()

            plane1_nodepath.reparentTo(clipped_thing_nodepath)
            clipped_thing_nodepath.setClipPlane(plane1_nodepath)
            self.clipping_planes_p3d_nodepaths.append(plane1_nodepath)

            plane2_nodepath.reparentTo(clipped_thing_nodepath)
            clipped_thing_nodepath.setClipPlane(plane2_nodepath)
            self.clipping_planes_p3d_nodepaths.append(plane2_nodepath)