Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if obj == 'square':
canvas_actor = square(3)
canvas_actor.GetProperty().BackfaceCullingOff()
scene.add(canvas_actor)
mapper = canvas_actor.GetMapper()
if obj == 'cube':
# rec.SetPosition(100, 0, 0)
canvas_actor = cube()
canvas_actor.GetProperty().BackfaceCullingOff()
# cu.GetProperty().FrontfaceCullingOn()
scene.add(canvas_actor)
scene.add(actor.axes())
scene.background((1, 1, 1))
# window.show(scene)
mapper = canvas_actor.GetMapper()
global timer
timer = 0
def timer_callback(obj, event):
global timer
timer += 1.0
# print(timer)
showm.render()
# cu.SetPosition(timer*0.01, 0, 0)
# scene.azimuth(10)
from fury import actor, window
from viz_shader_canvas import cube, disk, rectangle, square
import vtk
scene = window.Scene()
scene.add(actor.axes())
# scene.background((1, 1, 1))
showm = window.ShowManager(scene, size=(1920, 1080), order_transparent=True)
obj = 'square'
if obj == 'square':
canvas_actor = square()
scene.add(canvas_actor)
mapper = canvas_actor.GetMapper()
if obj == 'rectangle':
canvas_actor = rectangle(size=(100, 100))
scene.add(canvas_actor)
mapper = canvas_actor.GetMapper()
try:
program.SetUniformf("time", timer)
except ValueError:
pass
mapper.AddObserver(window.vtk.vtkCommand.UpdateShaderEvent,
vtk_shader_callback)
showm = window.ShowManager(scene, reset_camera=False)
showm.initialize()
showm.add_timer_callback(True, 10, timer_callback)
scene.add(sdfactor)
scene.add(actor.axes())
showm.start()
}
else{
fragOutput0 = vec4(0, 0, 0, 0.3);
}
""",
False
)
scene.add(box_actor)
scene.add(actor.axes())
window.show(scene, size=(1920, 1200))
# To be able to visualize the surface of the primitive sphere, we use
# ``get_actor_from_primitive``.
primitive_colors = np.zeros(vertices.shape)
primitive_colors[:, 2] = 180
primitive_actor = utils.get_actor_from_primitive(
vertices=vertices, triangles=triangles, colors=primitive_colors,
normals=normals, backface_culling=True)
##############################################################################
# We add all actors (visual objects) defined above to the scene.
scene.add(point_actor)
scene.add(arrow_actor)
scene.add(primitive_actor)
scene.add(actor.axes())
##############################################################################
# The ShowManager class is the interface between the scene, the window and the
# interactor.
showm = window.ShowManager(scene,
size=(900, 768), reset_camera=False,
order_transparent=True)
##############################################################################
# We want to make a small animation for fun!
# We can determine the duration of animation with using the ``counter``.
# Use itertools to avoid global variables.
counter = itertools.count()
###############################################################################
# Access the memory of the vertices of all the cubes
vertices = utils.vertices_from_actor(fury_actor)
num_vertices = vertices.shape[0]
num_objects = centers.shape[0]
###############################################################################
# Access the memory of the colors of all the cubes
vcolors = utils.colors_from_actor(fury_actor, 'colors')
###############################################################################
# Adding an actor showing the axes of the world coordinates
ax = actor.axes(scale=(10, 10, 10))
scene.add(fury_actor)
scene.add(label_actor)
scene.add(ax)
scene.reset_camera()
###############################################################################
# Create the Picking manager
pickm = pick.PickingManager()
###############################################################################
# Time to make the callback which will be called when we pick an object
def left_click_callback(obj, event):
vec3 normalizedPoint = normalize(vec3(point.xy, sqrt(1. - len)));
vec3 direction = normalize(vec3(1., 1., 1.));
float df = max(0, dot(direction, normalizedPoint));
float sf = pow(df, 24);
fragOutput0 = vec4(max(df * color, sf * vec3(1)), 1);*/
"""
billboard_actor = actor.billboard(centers,
colors=colors.astype(np.uint8),
scale=scale,
fs_dec=fs_dec,
fs_impl=fake_sphere)
scene.add(billboard_actor)
scene.add(actor.axes())
scene.camera_info()
matrix = scene.camera().GetViewTransformMatrix()
mat = np.zeros((4, 4))
for i in range(4):
for j in range(4):
mat[i, j] = matrix.GetElement(i, j)
print(mat)
print(np.dot(-mat[:3, 3], mat[:3, :3])) # camera position
window.show(scene)