-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy path04.load_obj_file.py
69 lines (55 loc) · 1.61 KB
/
04.load_obj_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import nvisii
opt = lambda : None
opt.nb_objects = 50
opt.spp = 256
opt.width = 500
opt.height = 500
opt.out = "04_load_obj_file.png"
# # # # # # # # # # # # # # # # # # # # # # # # #
nvisii.initialize(headless=True, verbose=True)
nvisii.enable_denoiser()
camera = nvisii.entity.create(
name = "camera",
transform = nvisii.transform.create("camera"),
camera = nvisii.camera.create(
name = "camera",
aspect = float(opt.width)/float(opt.height)
)
)
camera.get_transform().look_at(
at = (0,0.1,0.1),
up = (0,0,1),
eye = (1,0.7,0.2),
)
nvisii.set_camera_entity(camera)
nvisii.set_dome_light_sky(sun_position = (10, 10, 1), saturation = 2)
nvisii.set_dome_light_exposure(1)
# # # # # # # # # # # # # # # # # # # # # # # # #
# This function loads a signle obj mesh. It ignores
# the associated .mtl file
mesh = nvisii.mesh.create_from_file("obj", "./content/dragon/dragon.obj")
obj_entity = nvisii.entity.create(
name="obj_entity",
mesh = mesh,
transform = nvisii.transform.create("obj_entity"),
material = nvisii.material.create("obj_entity")
)
# lets set the obj_entity up
obj_entity.get_transform().set_rotation(
(0.7071, 0, 0, 0.7071)
)
obj_entity.get_material().set_base_color(
(0.9,0.12,0.08)
)
obj_entity.get_material().set_roughness(0.7)
obj_entity.get_material().set_specular(1)
obj_entity.get_material().set_sheen(1)
# # # # # # # # # # # # # # # # # # # # # # # # #
nvisii.render_to_file(
width=opt.width,
height=opt.height,
samples_per_pixel=opt.spp,
file_path=opt.out
)
# let's clean up GPU resources
nvisii.deinitialize()