예제 #1
0
    def test_from_obj_string17(self):
        content = """
        v 0 0 0
        v 1 0 0
        v 0 1 0                

        f 1 2 3
        g
        f 1 2 3  
        g Face
        f 1 2 3
            g   
        f 3 2 1

        """
        res = geom_tools.from_obj_string(content, compute_normals=False, triangulate=False)
        ans = geom_tools.Mesh(
            vertices=np.array([
                [0, 0, 0],
                [1, 0, 0],
                [0, 1, 0],
            ]),
            polygon_vertex_indices=[[0, 1, 2], [0, 1, 2], [0, 1, 2], [2, 1, 0]],
            polygon_groups=[-1, -1, 0, -1],
            group_names=["Face"]
        )
        self.assertTrue(res == ans)
예제 #2
0
    def test_from_obj_string08(self):
        content = """
        v 1 0 0
        v 16   3 2
        v 0 1 0
        v 0 0 1

        vt 0.5 0 0
        vt 0.5 0.5 0 
        vt 0 0.5 0

        f 1/1 2/2 3/3 4/1
        # something useful
        f 2/1 3/2 4/3

        """
        res = geom_tools.from_obj_string(content, compute_normals=False)
        ans = geom_tools.Mesh(
            vertices=np.array([
                [1, 0, 0],
                [16, 3, 2],
                [0, 1, 0],
                [0, 0, 1],
            ]),
            polygon_vertex_indices=[
                [0, 1, 2, 3],
                [1, 2, 3]
            ],
            texture_vertices=np.array([
                [0.5, 0],
                [0.5, 0.5],
                [0, 0.5]
            ]),
            texture_polygon_vertex_indices=[
                [0, 1, 2, 0],
                [0, 1, 2],
            ],
            triangle_vertex_indices=np.array([
                [0, 1, 2],
                [0, 2, 3],
                [1, 2, 3],
            ]),
            triangle_texture_vertex_indices=np.array([
                [0, 1, 2],
                [0, 2, 0],
                [0, 1, 2],
            ]),
        )
        self.assertTrue(res == ans)
예제 #3
0
 def test_from_obj_string01(self):
     content = """
     v 1 0 0
     v 0 1 0
     v 0 0 1
     
     f 1 2 3
     
     """
     res = geom_tools.from_obj_string(content, compute_normals=False)
     ans = geom_tools.Mesh(
         vertices=np.array([
             [1, 0, 0],
             [0, 1, 0],
             [0, 0, 1]
         ]),
         polygon_vertex_indices=[[0, 1, 2]],
         triangle_vertex_indices=np.array([[0, 1, 2]])
     )
     self.assertTrue(res == ans)
예제 #4
0
    def test_from_obj_string09(self):
        content = """
        v 0 0 0
        v 1 0 0
        v 0 1 0        

        vn 1 0 0

        f 1//1 2//1 3//1 

        """
        res = geom_tools.from_obj_string(content, compute_normals=True)
        ans = geom_tools.Mesh(
            vertices=np.array([
                [0, 0, 0],
                [1, 0, 0],
                [0, 1, 0],
            ]),
            polygon_vertex_indices=[[0, 1, 2]],
            triangle_vertex_indices=np.array([[0, 1, 2]]),
            normals=np.array([[0, 0, 1], [0, 0, 1], [0, 0, 1]], dtype=np.float32),
        )
        self.assertTrue(res == ans)
예제 #5
0
    def test_from_obj_string03(self):
        content = """
        v 1 0 0
        v 0 1 0
        v 0 0 1
        v 16 3 2
        
        vn 1 0 0

        f 1//1 2//1 3//1 4//1

        """
        res = geom_tools.from_obj_string(content, compute_normals=False)
        ans = geom_tools.Mesh(
            vertices=np.array([
                [1, 0, 0],
                [0, 1, 0],
                [0, 0, 1],
                [16, 3, 2],
            ]),
            polygon_vertex_indices=[[0, 1, 2, 3]],
            triangle_vertex_indices=np.array([[0, 1, 2], [0, 2, 3]])
        )
        self.assertTrue(res == ans)
예제 #6
0
    def test_from_obj_string10(self):
        content = """
        v 0 0 0
        v 1 0 0
        v 0 1 0                

        g Face
        f 1 2 3 

        """
        res = geom_tools.from_obj_string(content, compute_normals=True)
        ans = geom_tools.Mesh(
            vertices=np.array([
                [0, 0, 0],
                [1, 0, 0],
                [0, 1, 0],
            ]),
            polygon_vertex_indices=[[0, 1, 2]],
            triangle_vertex_indices=np.array([[0, 1, 2]]),
            normals=np.array([[0, 0, 1], [0, 0, 1], [0, 0, 1]], dtype=np.float32),
            polygon_groups=[0],
            group_names=["Face"]
        )
        self.assertTrue(res == ans)