コード例 #1
0
def rotateCamera(value):
    value = value / 100.0
    cam_pos = camera.get_transform().get_position()

    camera.get_transform().look_at(
        at=(0, 0, 0.5),  # at position
        up=(0, 0, 1),  # up vector
        eye=(5 * math.cos(value * 2 * nvisii.pi()),
             5 * math.sin(value * 2 * nvisii.pi()), cam_pos[2])  # eye position
    )
コード例 #2
0
    def interact():
        global speed_camera
        global cursor
        global rot

        # nvisii camera matrix
        cam_matrix = camera.get_transform().get_local_to_world_matrix()
        dt = nvisii.vec4(0, 0, 0, 0)

        # translation
        if nvisii.is_button_held("W"): dt[2] = -speed_camera
        if nvisii.is_button_held("S"): dt[2] = speed_camera
        if nvisii.is_button_held("A"): dt[0] = -speed_camera
        if nvisii.is_button_held("D"): dt[0] = speed_camera
        if nvisii.is_button_held("Q"): dt[1] = -speed_camera
        if nvisii.is_button_held("E"): dt[1] = speed_camera

        # control the camera
        if nvisii.length(dt) > 0.0:
            w_dt = cam_matrix * dt
            camera.get_transform().add_position(nvisii.vec3(w_dt))

        # camera rotation
        cursor[2] = cursor[0]
        cursor[3] = cursor[1]
        cursor[0] = nvisii.get_cursor_pos().x
        cursor[1] = nvisii.get_cursor_pos().y
        if nvisii.is_button_held("MOUSE_LEFT"):
            nvisii.set_cursor_mode("DISABLED")
            rotate_camera = True
        else:
            nvisii.set_cursor_mode("NORMAL")
            rotate_camera = False

        if rotate_camera:
            rot.x -= (cursor[0] - cursor[2]) * 0.001
            rot.y -= (cursor[1] - cursor[3]) * 0.001
            init_rot = nvisii.angleAxis(nvisii.pi() * .5, (1, 0, 0))
            yaw = nvisii.angleAxis(rot.x, (0, 1, 0))
            pitch = nvisii.angleAxis(rot.y, (1, 0, 0))
            camera.get_transform().set_rotation(init_rot * yaw * pitch)

        # change speed movement
        if nvisii.is_button_pressed("UP"):
            speed_camera *= 0.5
            print('decrease speed camera', speed_camera)
        if nvisii.is_button_pressed("DOWN"):
            speed_camera /= 0.5
            print('increase speed camera', speed_camera)
コード例 #3
0
opt.out = '15_camera_motion_car_blur.png'
opt.control = True

# # # # # # # # # # # # # # # # # # # # # # # # #
nvisii.initialize()
nvisii.set_dome_light_intensity(.8)
nvisii.resize_window(int(opt.width), int(opt.height))
# # # # # # # # # # # # # # # # # # # # # # # # #

# load the textures
dome = nvisii.texture.create_from_file("dome", "content/teatro_massimo_2k.hdr")

# we can add HDR images to act as dome
nvisii.set_dome_light_texture(dome)
nvisii.set_dome_light_rotation(
    nvisii.angleAxis(nvisii.pi() * .5, nvisii.vec3(0, 0, 1)))

car_speed = 0
car_speed_x = car_speed
car_speed_y = -2 * car_speed

camera_height = 80
# # # # # # # # # # # # # # # # # # # # # # # # #

if not opt.noise is True:
    nvisii.enable_denoiser()

camera = nvisii.entity.create(name="camera",
                              transform=nvisii.transform.create("camera"),
                              camera=nvisii.camera.create(
                                  name="camera",
コード例 #4
0
nvisii.initialize(headless=False, verbose=True)

camera = nvisii.entity.create(name="camera",
                              transform=nvisii.transform.create("camera"),
                              camera=nvisii.camera.create(
                                  name="camera",
                                  aspect=float(opt.width) / float(opt.height)))

# Add some motion to the camera
angle = 0
camera.get_transform().look_at(at=(0, 0, .1),
                               up=(0, 0, 1),
                               eye=(math.sin(angle), math.cos(angle), .2),
                               previous=True)

angle = -nvisii.pi() * .05
camera.get_transform().look_at(at=(0, 0, .1),
                               up=(0, 0, 1),
                               eye=(math.sin(angle), math.cos(angle), .2),
                               previous=False)

nvisii.set_camera_entity(camera)

# # # # # # # # # # # # # # # # # # # # # # # # #

floor = nvisii.entity.create(name="floor",
                             mesh=nvisii.mesh.create_plane("floor"),
                             transform=nvisii.transform.create("floor"),
                             material=nvisii.material.create("floor"))

floor.get_material().set_roughness(1.0)
コード例 #5
0
ファイル: 22.volumes.py プロジェクト: owl-project/NVISII
mat = floor.get_material()
floor_tex = nvisii.texture.create_from_file(
    "floor_tex",
    "./content/salle_de_bain_separated/textures/WoodFloor_BaseColor.jpg")
mat.set_base_color_texture(floor_tex)
trans = floor.get_transform()
trans.set_scale((5, 5, 1))

# Make a procedural torus volume
torus = nvisii.entity.create(name="torus",
                             volume=nvisii.volume.create_torus("torus"),
                             transform=nvisii.transform.create("torus"),
                             material=nvisii.material.create("torus"))
torus.get_transform().set_position((0.8, 2, .2))
torus.get_transform().set_scale((0.003, 0.003, 0.003))
torus.get_transform().set_angle_axis(nvisii.pi() * .5, (1, 0, 0))
torus.get_material().set_base_color((1., 1., 1.0))
# The gradient factor here controls how "surface like" the volume is.
# Higher values mean "more surface like" in areas where there is a strong
# gradient in the scalar field of the volume (which occurs near surfaces defined
# by high density regions)
torus.get_volume().set_gradient_factor(10)

# Absorption controls the probability of light being absorbed by the volume
torus.get_volume().set_absorption(1.)
# Absorption controls the probability of light bouncing off one of the particles in the volume
torus.get_volume().set_scattering(.0)
# The scale here controls how "big" a voxel is, where "1" means a voxel is 1cm wide.
# Larger scales result in particles being distributed over longer distances,
# causing the volume to appear less dense
torus.get_volume().set_scale(100)
コード例 #6
0
# # # # # # # # # # # # # # # # # # # # # # # # #

# lets turn off the ambiant lights
# load a random skybox
skyboxes = glob.glob(f'{opt.skyboxes_folder}/*.hdr')
skybox_random_selection = skyboxes[random.randint(0, len(skyboxes) - 1)]

dome_tex = visii.texture.create_from_file('dome_tex', skybox_random_selection)
visii.set_dome_light_texture(dome_tex)
visii.set_dome_light_intensity(random.uniform(1.1, 2))
# visii.set_dome_light_intensity(1.15)
visii.set_dome_light_rotation(
    # visii.angleAxis(visii.pi()/2,visii.vec3(1,0,0)) \
    # * visii.angleAxis(visii.pi()/2,visii.vec3(0,0,1))\
    visii.angleAxis(random.uniform(-visii.pi(),visii.pi()),visii.vec3(0,0,1))\
    # * visii.angleAxis(visii.pi()/2,visii.vec3(0,1,0))\
    # * visii.angleAxis(random.uniform(-visii.pi()/8,visii.pi()/8),visii.vec3(0,0,1))\
)

# # # # # # # # # # # # # # # # # # # # # # # # #
# Lets set some objects in the scene

mesh_loaded = {}
objects_to_move = []

sample_space = [[-20, 20], [-20, 20], [-30, -2]]

if opt.interactive:
    physicsClient = p.connect(p.GUI)  # non-graphical version
else:
コード例 #7
0
ファイル: 06.textures.py プロジェクト: owl-project/NVISII
# Checkout create_hsv, create_add, create_multiply, and create_mix
floor_tex = nvisii.texture.create_hsv("floor",
                                      tex,
                                      hue=0,
                                      saturation=.5,
                                      value=1.0,
                                      mix=1.0)

# we can add HDR images to act as a dome that lights up our scene

# use "enable_cdf" for dome light textures that contain
# bright objects that cast shadows (like the sun). Note
# that this has a significant impact on rendering performance,
# and is disabled by default.
nvisii.set_dome_light_texture(dome, enable_cdf=True)
nvisii.set_dome_light_rotation(nvisii.angleAxis(nvisii.pi() * .1, (0, 0, 1)))

# Lets set some objects in the scene
entity = nvisii.entity.create(
    name="floor",
    mesh=nvisii.mesh.create_plane("mesh_floor"),
    transform=nvisii.transform.create("transform_floor"),
    material=nvisii.material.create("material_floor"))
entity.get_transform().set_scale((1, 1, 1))
mat = nvisii.material.get("material_floor")

mat.set_roughness(.5)

# Lets set the base color and roughness of the object to use a texture.
# but the textures could also be used to set other
# material propreties
コード例 #8
0
blocker = nvisii.entity.create(name="blocker",
                               mesh=nvisii.mesh.create_capped_tube(
                                   "blocker", innerRadius=.04),
                               transform=nvisii.transform.create("blocker"),
                               material=nvisii.material.create("blocker"))
blocker.get_transform().set_scale((10, 10, .01))
blocker.get_transform().set_position((0, 0, 3.0))

# Teapot
teapotahedron = nvisii.entity.create(
    name="teapotahedron",
    mesh=nvisii.mesh.create_teapotahedron("teapotahedron", segments=32),
    transform=nvisii.transform.create("teapotahedron"),
    material=nvisii.material.create("teapotahedron"))
teapotahedron.get_transform().set_rotation(
    nvisii.angleAxis(nvisii.pi() / 4.0, (0, 0, 1)))
teapotahedron.get_transform().set_position((0, 0, 0))
teapotahedron.get_transform().set_scale((0.4, 0.4, 0.4))
teapotahedron.get_material().set_base_color(
    (255.0 / 255.0, 100.0 / 255.0, 2.0 / 256.0))
teapotahedron.get_material().set_roughness(0.0)
teapotahedron.get_material().set_specular(1.0)
teapotahedron.get_material().set_metallic(1.0)

# Make a QT window to demonstrate the difference between alpha transparency and transmission
app = QApplication([])  # Start an application.
window = QWidget()  # Create a window.
layout = QVBoxLayout()  # Create a layout.


def rotateCamera(value):
コード例 #9
0
obj3.get_material().set_base_color((0, 0, 1))
obj3.get_material().set_roughness(0.7)
obj3.get_material().set_specular(1)
obj3.get_material().set_sheen(1)

obj4.get_transform().set_position((1.5, 0, 0))
obj4.get_transform().set_rotation((0.7071, 0, 0, 0.7071))
obj4.get_material().set_base_color((.5, .5, .5))
obj4.get_material().set_roughness(0.7)
obj4.get_material().set_specular(1)
obj4.get_material().set_sheen(1)

# Use linear motion blur on the first object...
obj1.get_transform().set_linear_velocity((.0, .0, .2))

# angular motion blur on the second object...
obj2.get_transform().set_angular_velocity(
    (nvisii.pi() / 16, nvisii.pi() / 16, nvisii.pi() / 16, 1))

# and scalar motion blur on the third object
obj3.get_transform().set_scalar_velocity((-.5, -.5, -.5))

# # # # # # # # # # # # # # # # # # # # # # # # #

nvisii.render_to_file(width=int(opt.width),
                      height=int(opt.height),
                      samples_per_pixel=int(opt.spp),
                      file_path=f"{opt.out}")

# let's clean up the GPU
nvisii.deinitialize()