红色好看的网站网站建设电子合同
2026/4/18 20:51:53 网站建设 项目流程
红色好看的网站,网站建设电子合同,陕西省建设厅证件查询,企业官网手机版一#xff1a;主要的知识点 1、说明 本文只是教程内容的一小段#xff0c;因博客字数限制#xff0c;故进行拆分。主教程链接#xff1a;vtk教程——逐行解析官网所有Python示例-CSDN博客 2、知识点纪要 本段代码主要涉及的有①边缘着色 二#xff1a;代码及注释 #!/…一主要的知识点1、说明本文只是教程内容的一小段因博客字数限制故进行拆分。主教程链接vtk教程——逐行解析官网所有Python示例-CSDN博客2、知识点纪要本段代码主要涉及的有①边缘着色二代码及注释#!/usr/bin/env python3 import json from pathlib import Path from vtkmodules.vtkCommonColor import vtkNamedColors from vtkmodules.vtkFiltersSources import vtkSphereSource from vtkmodules.vtkIOImage import ( vtkHDRReader, vtkImageReader2Factory ) from vtkmodules.vtkImagingCore import vtkImageFlip from vtkmodules.vtkInteractionStyle import vtkInteractorStyleTrackballCamera from vtkmodules.vtkRenderingCore import ( vtkActor, vtkPolyDataMapper, vtkRenderWindow, vtkRenderWindowInteractor, vtkSkybox, vtkTexture ) from vtkmodules.vtkRenderingOpenGL2 import vtkOpenGLRenderer def main(): # fn, use_cubemap get_program_parameters() fn_path Data/PBR_Parameters.json use_cubemap False # fn_path Path(fn) paths_ok, parameters get_parameters(fn_path) if not paths_ok: return colors vtkNamedColors() ren vtkOpenGLRenderer() ren.SetBackground(colors.GetColor3d(Black)) ren_win vtkRenderWindow() ren_win.SetSize(600, 600) ren_win.AddRenderer(ren) iren vtkRenderWindowInteractor() iren.SetRenderWindow(ren_win) style vtkInteractorStyleTrackballCamera() iren.SetInteractorStyle(style) skybox vtkSkybox() irradiance ren.GetEnvMapIrradiance() irradiance.SetIrradianceStep(0.3) # Choose how to generate the skybox. is_hdr False has_skybox False gamma_correct False if use_cubemap and cubemap in parameters.keys(): print(Using the cubemap files to generate the environment texture.) env_texture read_cubemap(parameters[cubemap]) if parameters[skybox]: skybox.SetTexture(env_texture) has_skybox True elif equirectangular in parameters.keys(): print(Using the equirectangular file to generate the environment texture.) env_texture read_equirectangular_file(parameters[equirectangular]) if parameters[equirectangular].suffix.lower() in .hdr .pic: gamma_correct True is_hdr True if parameters[skybox]: # Generate a skybox. skybox.SetFloorRight(0, 0, 1) skybox.SetProjection(vtkSkybox.Sphere) skybox.SetTexture(env_texture) has_skybox True else: print(An environment texture is required,\n please add the necessary equirectangular or cubemap file paths to the json file.) return ren.UseImageBasedLightingOn() if is_hdr: ren.UseSphericalHarmonicsOn() ren.SetEnvironmentTexture(env_texture, False) else: ren.UseSphericalHarmonicsOff() ren.SetEnvironmentTexture(env_texture, True) sphere vtkSphereSource() sphere.SetThetaResolution(75) sphere.SetPhiResolution(75) pd_sphere vtkPolyDataMapper() pd_sphere.SetInputConnection(sphere.GetOutputPort()) for i in range(0, 6): actor_sphere vtkActor() actor_sphere.SetPosition(i, 0.0, 0.0) actor_sphere.SetMapper(pd_sphere) actor_sphere.GetProperty().SetInterpolationToPBR() actor_sphere.GetProperty().SetColor(colors.GetColor3d(White)) actor_sphere.GetProperty().SetMetallic(1.0) SetEdgeTint 边缘着色 (SetEdgeTint) 是金属材质的一个高级 PBR 特性 它控制了在掠射角3D物体边缘或表面与视线接近平行的角度上 反射光线的颜色。对于金属边缘反射光往往带有一种独特的颜色例如铜的绿锈或镀层 actor_sphere.GetProperty().SetEdgeTint(colors.GetColor3d(Black)) actor_sphere.GetProperty().SetRoughness(i / 5.0) ren.AddActor(actor_sphere) for i in range(0, 6): actor_sphere vtkActor() actor_sphere.SetPosition(i, 1.0, 0.0) actor_sphere.SetMapper(pd_sphere) actor_sphere.GetProperty().SetInterpolationToPBR() actor_sphere.GetProperty().SetColor(colors.GetColor3d(Black)) actor_sphere.GetProperty().SetMetallic(1.0) actor_sphere.GetProperty().SetEdgeTint(colors.GetColor3d(White)) actor_sphere.GetProperty().SetRoughness(i / 5.0) ren.AddActor(actor_sphere) for i in range(0, 6): actor_sphere vtkActor() actor_sphere.SetPosition(i, 2.0, 0.0) actor_sphere.SetMapper(pd_sphere) actor_sphere.GetProperty().SetInterpolationToPBR() actor_sphere.GetProperty().SetColor(colors.GetColor3d(Blue)) actor_sphere.GetProperty().SetMetallic(1.0) actor_sphere.GetProperty().SetEdgeTint(colors.GetColor3d(Red)) actor_sphere.GetProperty().SetRoughness(i / 5.0) ren.AddActor(actor_sphere) for i in range(0, 6): actor_sphere vtkActor() actor_sphere.SetPosition(i, 3.0, 0.0) actor_sphere.SetMapper(pd_sphere) actor_sphere.GetProperty().SetInterpolationToPBR() actor_sphere.GetProperty().SetColor(colors.GetColor3d(Red)) actor_sphere.GetProperty().SetMetallic(1.0) actor_sphere.GetProperty().SetEdgeTint(colors.GetColor3d(Blue)) actor_sphere.GetProperty().SetRoughness(i / 5.0) ren.AddActor(actor_sphere) for i in range(0, 6): actor_sphere vtkActor() actor_sphere.SetPosition(i, 4.0, 0.0) actor_sphere.SetMapper(pd_sphere) actor_sphere.GetProperty().SetInterpolationToPBR() actor_sphere.GetProperty().SetColor(colors.GetColor3d(Black)) actor_sphere.GetProperty().SetMetallic(1.0) actor_sphere.GetProperty().SetEdgeTint(colors.GetColor3d(Yellow)) actor_sphere.GetProperty().SetRoughness(i / 5.0) ren.AddActor(actor_sphere) if has_skybox: if gamma_correct: skybox.GammaCorrectOn() else: skybox.GammaCorrectOff() ren.AddActor(skybox) ren_win.SetWindowName(PBR_Edge_Tint) ren_win.Render() iren.Start() def get_parameters(fn_path): Read the parameters from a JSON file and check that the file paths exist. :param fn_path: The path to the JSON file. :return: True if the paths correspond to files and the parameters. with open(fn_path) as data_file: json_data json.load(data_file) parameters dict() # Extract the values. keys_no_paths {title, object, objcolor, bkgcolor, skybox} keys_with_paths {cubemap, equirectangular, albedo, normal, material, coat, anisotropy, emissive} paths_ok True for k, v in json_data.items(): if k in keys_no_paths: parameters[k] v continue if k in keys_with_paths: if k cubemap: if (root in v) and (files in v): root Path(v[root]) if not root.exists(): print(fBad cubemap path: {root}) paths_ok False elif len(v[files]) ! 6: print(fExpect six cubemap file names.) paths_ok False else: cm list(map(lambda p: root / p, v[files])) for fn in cm: if not fn.is_file(): paths_ok False print(fNot a file {fn}) if paths_ok: parameters[cubemap] cm else: paths_ok False print(Missing the key root and/or the key fíles for the cubemap.) else: fn Path(v) if not fn.exists(): print(fBad {k} path: {fn}) paths_ok False else: parameters[k] fn # Set Boy as the default surface. if (object in parameters.keys() and not parameters[object]) or object not in parameters.keys(): parameters[object] Boy return paths_ok, parameters def display_parameters(parameters): res list() parameter_keys [title, object, objcolor, bkgcolor, skybox, cubemap, equirectangular, albedo, normal, material, coat, anisotropy, emissive] for k in parameter_keys: if k ! cubemap: if k in parameters: res.append(f{k:15}: {parameters[k]}) else: if k in parameters: for idx in range(len(parameters[k])): if idx 0: res.append(f{k:15}: {parameters[k][idx]}) else: res.append(f{ * 17}{parameters[k][idx]}) return res def read_cubemap(cubemap): Read six images forming a cubemap. :param cubemap: The paths to the six cubemap files. :return: The cubemap texture. cube_map vtkTexture() cube_map.CubeMapOn() i 0 for fn in cubemap: # Read the images. reader_factory vtkImageReader2Factory() img_reader reader_factory.CreateImageReader2(str(fn)) img_reader.SetFileName(str(fn)) # Each image must be flipped in Y due to canvas # versus vtk ordering. flip vtkImageFlip() flip.SetInputConnection(img_reader.GetOutputPort(0)) flip.SetFilteredAxis(1) # flip y axis cube_map.SetInputConnection(i, flip.GetOutputPort()) i 1 cube_map.MipmapOn() cube_map.InterpolateOn() return cube_map def read_equirectangular_file(fn_path): Read an equirectangular environment file and convert to a texture. :param fn_path: The equirectangular file path. :return: The texture. texture vtkTexture() suffix fn_path.suffix.lower() if suffix in [.jpeg, .jpg, .png]: reader_factory vtkImageReader2Factory() img_reader reader_factory.CreateImageReader2(str(fn_path)) img_reader.SetFileName(str(fn_path)) texture.SetInputConnection(img_reader.GetOutputPort(0)) else: reader vtkHDRReader() extensions reader.GetFileExtensions() # Check the image can be read. if not reader.CanReadFile(str(fn_path)): print(CanReadFile failed for , fn_path) return None if suffix not in extensions: print(Unable to read this file extension: , suffix) return None reader.SetFileName(str(fn_path)) texture.SetColorModeToDirectScalars() texture.SetInputConnection(reader.GetOutputPort()) texture.MipmapOn() texture.InterpolateOn() return texture if __name__ __main__: main()

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询