コード例 #1
0
    def render_color_mesh_func(self, fv_indices, tri_colors, tri_normals, vps,
                               camera_dict):

        proj_pixels, z_vals, v_status = self.project_mesh_vps(vps, camera_dict)
        tri_proj_pixels = (proj_pixels[fv_indices]).reshape(-1, 6)  #[n_f, 6]
        tri_z_vals = z_vals[fv_indices]  #[n_f, 3]
        tri_status = (v_status[fv_indices]).all(axis=1)  #[n_f]

        cam_w = camera_dict["CameraReso"][0]
        cam_h = camera_dict["CameraReso"][1]
        ex_mat = camera_dict["ExterMat"]

        depth_img = np.ones((cam_h, cam_w), np.float32) * 100.0
        rgb_img = np.zeros((cam_h, cam_w, 3), np.float32)
        mask_img = np.zeros((cam_h, cam_w), np.int32)

        w_light_dx = self.light_dire[0]
        w_light_dy = self.light_dire[1]
        w_light_dz = self.light_dire[2]

        c_light_dx = ex_mat[0, 0] * w_light_dx + ex_mat[
            0, 1] * w_light_dy + ex_mat[0, 2] * w_light_dz
        c_light_dy = ex_mat[1, 0] * w_light_dx + ex_mat[
            1, 1] * w_light_dy + ex_mat[1, 2] * w_light_dz
        c_light_dz = ex_mat[2, 0] * w_light_dx + ex_mat[
            2, 1] * w_light_dy + ex_mat[2, 2] * w_light_dz

        ambient_strength = self.ambient_strength
        light_strength = self.light_strength

        RenderUtils.render_color_mesh(tri_normals, tri_colors, tri_proj_pixels,
                                      tri_z_vals, tri_status, depth_img,
                                      rgb_img, mask_img, c_light_dx,
                                      c_light_dy, c_light_dz, ambient_strength,
                                      light_strength)
        depth_img[mask_img < 0.5] = 0.0
        return rgb_img, depth_img, mask_img