Skip to content

Commit

Permalink
RF: convert actor module into fury/actor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
m-agour committed Dec 15, 2024
1 parent e4176d9 commit fdc1388
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
15 changes: 6 additions & 9 deletions fury/actor/actor.py → fury/actor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import fury.primitive as fp
from fury.actor.materials import _create_mesh_material
from fury.actor.geometry import buffer_to_geometry, create_mesh
from fury.material import _create_mesh_material
from fury.geometry import buffer_to_geometry, create_mesh


def sphere(
Expand All @@ -11,8 +11,6 @@ def sphere(
radii=1.0,
phi=16,
theta=16,
vertices=None,
faces=None,
opacity=None,
material='phong',
enable_picking=True
Expand All @@ -21,8 +19,7 @@ def sphere(
scales = radii
directions = (1, 0, 0)

if faces is None and vertices is None:
vertices, faces = fp.prim_sphere(phi=phi, theta=theta)
vertices, faces = fp.prim_sphere(phi=phi, theta=theta)

res = fp.repeat_primitive(
vertices,
Expand All @@ -32,7 +29,7 @@ def sphere(
colors=colors,
scales=scales,
)
big_verts, big_faces, big_colors, _ = res
big_vertices, big_faces, big_colors, _ = res

prim_count = len(centers)

Expand All @@ -48,8 +45,8 @@ def sphere(

geo = buffer_to_geometry(
indices=big_faces.astype('int32'),
positions=big_verts.astype('float32'),
texcoords=big_verts.astype('float32'),
positions=big_vertices.astype('float32'),
texcoords=big_vertices.astype('float32'),
colors=big_colors.astype('float32'),
)

Expand Down
1 change: 0 additions & 1 deletion fury/actor/__init__.py

This file was deleted.

File renamed without changes.
11 changes: 2 additions & 9 deletions fury/actor/materials.py → fury/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ def _create_mesh_material(
enable_picking=True,
color=None,
opacity=1.0):
if material == 'phong':

if opacity is None:
opacity = 1.0

if material == 'phong':
return gfx.MeshPhongMaterial(
pick_write=enable_picking,
color_mode='vertex' if color is None else 'auto',
Expand All @@ -20,9 +17,5 @@ def _create_mesh_material(
return gfx.MeshBasicMaterial(
pick_write=enable_picking,
color_mode='vertex' if color is None else 'auto',
color=color if color is not None else (
1,
1,
1,
opacity if color is None else 1),
color=color if color is not None else (1, 1, 1, opacity),
)

0 comments on commit fdc1388

Please sign in to comment.