コード例 #1
0
    def create_sample_scene(self):
        cube_node = Cube()
        cube_node.translate(2, 0, 2)
        cube_node.color_index = 1
        self.scene.add_node(cube_node)

        sphere_node = Sphere()
        sphere_node.translate(-2, 0, 2)
        sphere_node.color_index = 3
        self.scene.add_node(sphere_node)

        hierarchical_node = SnowFigure()
        hierarchical_node.translate(-2, 0, -2)
        self.scene.add_node(hierarchical_node)
コード例 #2
0
ファイル: Viewer.py プロジェクト: serpahimor/private-room
    def create_sample_scene(self):
        cube_node = Cube()
        cube_node.translate(2, 0, 2)
        cube_node.color_index = 2
        self.scene.add_node(cube_node)

        sphere_node = Sphere()
        sphere_node.translate(-2, 0, 2)
        sphere_node.color_index = 3
        self.scene.add_node(sphere_node)

        hierarchical_node = SnowFigure()
        hierarchical_node.translate(-2, 0, -2)
        self.scene.add_node(hierarchical_node)
コード例 #3
0
ファイル: viewer.py プロジェクト: darius/chispa
    def initial_scene(self):
        cube_node = Cube()
        cube_node.translate(2, 0, 2)
        cube_node.color_index = 2
        self.scene.add_node(cube_node)

        sphere_node = Sphere()
        sphere_node.translate(-2, 0, 2)
        sphere_node.color_index = 3
        self.scene.add_node(sphere_node)

        sphere_node_2 = Sphere()
        sphere_node_2.translate(-2, 0, -2)
        sphere_node_2.color_index = 1
        self.scene.add_node(sphere_node_2)
コード例 #4
0
    def create_sample_scene(self):

        cube_node = Cube()

        cube_node.translate(2, 0, 2)

        cube_node.rotate(0, 0, 0)

        cube_node.scale_init(1.0, 1.0, 1.0)

        cube_node.color_index = 1

        self.scene.add_node(cube_node)

        file_name = "new1.mol2"
        for cont, pos in enumerate(readmol.get_mol_info(file_name)[1]):

            sphere_node = Sphere()

            sphere_node.translate(pos[0], pos[1], pos[2])

            sphere_node.scale_init(2.0, 2.0, 2.0)

            sphere_node.color_index = readmol.get_mol_info(file_name)[0][str(
                cont + 1)][1] * 10

            self.scene.add_node(sphere_node)
コード例 #5
0
ファイル: scene.py プロジェクト: 343829084/500lines
    def place(self, shape, start, direction, inv_modelview):
        """ Place a new node.
            Consume:  shape             the shape to add
                      start, direction  describes the Ray to move to
                      mat               is the modelview matrix for the scene """
        new_node = None
        if shape == 'sphere': new_node = Sphere()
        elif shape == 'cube': new_node = Cube()

        self.add_node(new_node)

        # place the node at the cursor in camera-space
        translation = (start + direction * self.PLACE_DEPTH)

        # convert the translation to world-space
        pre_tran = numpy.array([translation[0], translation[1], translation[2], 1])
        translation = inv_modelview.dot(pre_tran)

        new_node.translate(translation[0], translation[1], translation[2])
コード例 #6
0
    def create_sample_scene(self):
        cube_node = Cube()
        cube_node.translate(2, 0, 2)
        cube_node.color_index = 1
        self.scene.add_node(cube_node)

        # to create a ball
        sphere_node = Sphere()
        # to set the ball's color
        sphere_node.color_index = 3
        sphere_node.translate(-2, 0, 2)

        #to put the ball in the scene.Default middle of view
        self.scene.add_node(sphere_node)

        #to add a snowman
        hierarchical_node = SnowFigure()
        hierarchical_node.translate(-2, 0, -2)
        self.scene.add_node(hierarchical_node)
コード例 #7
0
 def create_sample_scene(self):
     #创建一个球体
     sphere_node = Sphere()
     #设置球体的颜色
     sphere_node.color_index = 2
     sphere_node.translate(2,2,0)
     sphere_node.scale(12)
     #将球体放进场景中,默认在正中央
     self.scene.add_node(sphere_node)
コード例 #8
0
    def place(self, shape, start, direction, inv_modelview):
        """ Place a new node.
            Consume:  shape             the shape to add
                      start, direction  describes the Ray to move to
                      mat               is the modelview matrix for the scene """
        new_node = None
        if shape == 'sphere': new_node = Sphere()
        elif shape == 'cube': new_node = Cube()

        self.add_node(new_node)

        # place the node at the cursor in camera-space
        translation = (start + direction * self.PLACE_DEPTH)

        # convert the translation to world-space
        pre_tran = numpy.array(
            [translation[0], translation[1], translation[2], 1])
        translation = inv_modelview.dot(pre_tran)

        new_node.translate(translation[0], translation[1], translation[2])
コード例 #9
0
ファイル: viewer.py プロジェクト: 343829084/500lines
    def initial_scene(self):
        cube_node = Cube()
        cube_node.translate(2, 0, 2)
        cube_node.color_index = 2
        self.scene.add_node(cube_node)

        sphere_node = Sphere()
        sphere_node.translate(-2, 0, 2)
        sphere_node.color_index = 3
        self.scene.add_node(sphere_node)

        sphere_node_2 = Sphere()
        sphere_node_2.translate(-2, 0, -2)
        sphere_node_2.color_index = 1
        self.scene.add_node(sphere_node_2)
コード例 #10
0
ファイル: viewer.py プロジェクト: qqzhong/dst_store
    def create_sample_scene(self):
        """
        #创建一个球体
        sphere_node = Sphere()
        #设置球体的颜色
        sphere_node.color_index = 2
        #将球体放进场景中,默认在正中央
        self.scene.add_node(sphere_node)
        """

        cube_node = Cube()
        cube_node.translate(0, 0, 0)
        cube_node.scale(3)
        cube_node.color_index = 1
        self.scene.add_node(cube_node)

        sphere_node = Sphere()
        sphere_node.translate(-2, 0, 2)
        sphere_node.color_index = 3
        self.scene.add_node(sphere_node)

        hierarchical_node = SnowFigure()
        hierarchical_node.translate(-2, 0, -2)
        self.scene.add_node(hierarchical_node)
コード例 #11
0
ファイル: scene.py プロジェクト: phantom2018/shiyanlou
    def place(self, shape, start, direction, inv_modelview):
        new_node = None
        if shape == 'sphere': new_node = Sphere()
        elif shape == 'cube': new_node = Cube()
        elif shape == 'figure': new_node = SnowFigure()

        self.add_node(new_node)

        translation = (start + direction * self.PLACE_DEPTH)

        pre_tran = numpy.array(
            [translation[0], translation[1], translation[2], 1])
        translation = inv_modelview.dot(pre_tran)

        new_node.translate(translation[0], translation[1], translation[2])
コード例 #12
0
ファイル: viewer.py プロジェクト: xylt/simple-CAD
    def create_sample_scene(self):
        # 创建一个立方体
        cube_node = Cube()
        cube_node.translate(2, 0, 2)
        cube_node.color_index = 1
        self.scene.add_node(cube_node)

        # 创建一个球体
        sphere_node = Sphere()
        # 设置球体颜色
        sphere_node.color_index = 2
        sphere_node.translate(2, 2, 0)
        sphere_node.scale(4)
        # 将球体放入场景
        self.scene.add_node(sphere_node)
        # 添加雪人
        hierarchical_node = SnowFigure()
        hierarchical_node.translate(-2, 0, -2)
        hierarchical_node.scale(2)
        self.scene.add_node(hierarchical_node)
コード例 #13
0
ファイル: scene.py プロジェクト: vvhanxing/3D-builder
    def place(self, shape, start, direction, inv_modelview):
        """ Place a new node.

            Consume:  shape             the shape to add

                      start, direction  describes the Ray to move to

                      inv_modelview     is the inverse modelview matrix for the scene """

        new_node = None

        if shape == 'sphere': new_node = Sphere()

        elif shape == 'cube': new_node = Cube()

        elif shape == 'cylinder': new_node = Cylinder()

        elif shape == 'figure': new_node = SnowFigure()

        self.add_node(new_node)

        if new_node.call_list != 5:

            #print(dir(new_node),new_node.call_list)
            # place the node at the cursor in camera-space

            translation = (start + direction * self.PLACE_DEPTH)

            # convert the translation to world-space

            pre_tran = numpy.array(
                [translation[0], translation[1], translation[2], 1])

            translation = inv_modelview.dot(pre_tran)

            new_node.translate(translation[0], translation[1], translation[2])

        if new_node.call_list == 5 and len(self.selected_node_list) > 2:

            #print(dir(new_node),new_node.call_list)
            # place the node at the cursor in camera-space

            translation = (start + direction * self.PLACE_DEPTH)

            # convert the translation to world-space

            pre_tran = numpy.array(
                [translation[0], translation[1], translation[2], 1])

            translation = inv_modelview.dot(pre_tran)

            #print(self.selected_node_list[-1].translate)
            #print(self.selected_node_list[-2].translation_matrix)

            center_x = (
                self.selected_node_list[-2].translation_matrix[0, 3] +
                self.selected_node_list[-1].translation_matrix[0, 3]) / 2

            center_y = (
                self.selected_node_list[-2].translation_matrix[1, 3] +
                self.selected_node_list[-1].translation_matrix[1, 3]) / 2

            center_z = (
                self.selected_node_list[-2].translation_matrix[2, 3] +
                self.selected_node_list[-1].translation_matrix[2, 3]) / 2

            new_node.translate(center_x, center_y, center_z)

            direction_x = (
                self.selected_node_list[-2].translation_matrix[0, 3] -
                self.selected_node_list[-1].translation_matrix[0, 3])

            direction_y = (
                self.selected_node_list[-2].translation_matrix[1, 3] -
                self.selected_node_list[-1].translation_matrix[1, 3])

            direction_z = (
                self.selected_node_list[-2].translation_matrix[2, 3] -
                self.selected_node_list[-1].translation_matrix[2, 3])

            if math.fabs(direction_z) > 2:

                new_node.rotate(
                    math.atan(direction_z / direction_y) + math.pi / 2,
                    math.atan(direction_x / direction_z), 0, False)

            elif math.fabs(direction_y) > 2:

                new_node.rotate(90, 0, 0)

                new_node.rotate(
                    math.atan(direction_y / direction_z) + math.pi / 2,
                    math.atan(direction_x / direction_y), 0, False)

            elif math.fabs(direction_x) > 2:

                new_node.rotate(0, 90, 0)

                new_node.rotate(
                    math.atan(direction_x / direction_z) + math.pi / 2,
                    math.atan(direction_y / direction_x), 0, False)

            print(
                math.atan(direction_z / direction_y) * 180 / math.pi,
                math.atan(direction_x / direction_z) * 180 / math.pi)

            #print("1",math.atan(direction_z/direction_y)*(180/math.pi),math.atan(direction_x/direction_z)*(180/math.pi))

            print("2", direction_z / direction_y, direction_x / direction_z)

            print("3", direction_z, direction_y, direction_x, direction_z)