Example #1
0
 def ray_tracing_mode(self):
     # create one spotlight
     spot_light = V3d_SpotLight(gp_Pnt(-1000, -1000, 1000),
                                V3d_XnegYnegZpos,
                                Quantity_Color(Quantity_NOC_WHITE))
     # display the spotlight in rasterized mode
     self.display.Viewer.AddLight(spot_light)
     self.display.View.SetLightOn()
     self.display.SetRaytracingMode(depth=8)
Example #2
0
from OCC.Extend.ShapeFactory import translate_shp

# first create geometry
from core_classic_occ_bottle import bottle
table = translate_shp(BRepPrimAPI_MakeBox(100, 100, 10).Shape(), gp_Vec(-50, -50, -10))
glass_out = BRepPrimAPI_MakeCone(7, 9, 25).Shape()
glass_in = translate_shp(BRepPrimAPI_MakeCone(7, 9, 25).Shape(), gp_Vec(0., 0., 0.2))
glass = BRepAlgoAPI_Cut(glass_out, glass_in).Shape()
translated_glass = translate_shp(glass, gp_Vec(-30, -30, 0))

# then inits display
display, start_display, add_menu, add_function_to_menu = init_display()

# create one spotlight
spot_light = V3d_SpotLight(display.Viewer, -100, -100, 100,
                           V3d_XnegYnegZpos, Quantity_NOC_WHITE)
## display the spotlight in rasterized mode
spot_light.Display(display.View, V3d_COMPLETE)
display.View.SetLightOn()

display.DisplayShape(bottle, material=Graphic3d_NOM_ALUMINIUM)
display.DisplayShape(table, material=Graphic3d_NOM_PLASTIC, color=Quantity_NOC_CORAL2)
display.DisplayShape(translated_glass,
                     material=Graphic3d_NOM_PLASTIC,
                     color=Quantity_NOC_BROWN,
                     transparency=0.6,
                     update=True)

def raytracing_default_depth(event=None):
    display.SetRaytracingMode()
    BRepPrimAPI_MakeCone(7, 9, 25).Shape(), gp_Vec(0., 0., 0.2))
glass = BRepAlgoAPI_Cut(glass_out, glass_in).Shape()
translated_glass = translate_shp(glass, gp_Vec(-30, -30, 0))

# then inits display
display, start_display, add_menu, add_function_to_menu = init_display()

# ambient light
ambient_light = V3d_AmbientLight(Quantity_Color(Quantity_NOC_WHITE))
display.Viewer.AddLight(ambient_light)
# directional light
dir_light = V3d_DirectionalLight(gp_Dir(0, 0, 1),
                                 Quantity_Color(Quantity_NOC_WHITE))
display.Viewer.AddLight(dir_light)
# light
spot_light = V3d_SpotLight(gp_Pnt(-100, -100, 100), V3d_XnegYnegZpos,
                           Quantity_Color(Quantity_NOC_WHITE))
## display the spotlight in rasterized mode
display.Viewer.AddLight(spot_light)

# first create the material for the bottle
pbr_mat_1 = Graphic3d_PBRMaterial()
pbr_mat_1.SetMetallic(0.8)
pbr_mat_1.SetRoughness(0.5)
alu_pbr_aspect = Graphic3d_MaterialAspect(Graphic3d_NOM_ALUMINIUM)
alu_pbr_aspect.SetPBRMaterial(pbr_mat_1)
alu_pbr_aspect.SetBSDF(Graphic3d_BSDF().CreateMetallicRoughness(pbr_mat_1))

# then the glass
pbr_mat_2 = Graphic3d_PBRMaterial()
glass_pbr_aspect = Graphic3d_MaterialAspect(Graphic3d_NOM_PLASTIC)
glass_pbr_aspect.SetPBRMaterial(pbr_mat_2)