fury-gl / fury

FURY - Free Unified Rendering in pYthon.
https://fury.gl
Other
227 stars 165 forks source link

Cylinder repeat primitive #766

Closed Clarkszw closed 1 year ago

Clarkszw commented 1 year ago

Fix the issue: Cylinder actor needs to use repeat_primitives by default #531 It has passed the test originally written for cylinder. pytest -svv fury/tests/test_actors.py::test_advanced_geometry_actor fury/tests/test_actors.py::test_actors_primitives_count

Should I write another test for new repeat_primitive parameter in cylinder() ?

skoudoro commented 1 year ago

Thanks, Can you add a screenshot of the results, using primitives and not using primitives. Multiple Cylinders should be present with different scale and orientation.

Thanks!

Clarkszw commented 1 year ago

Thanks, Can you add a screenshot of the results, using primitives and not using primitives. Multiple Cylinders should be present with different scale and orientation.

Thanks!

Here is the screenshot with primitive:

primitive_cylinders

This is without primitive:

without_primitive_cylinders

code for the generation:

from fury import window, actor
import numpy as np

scene = window.Scene()
showm = window.ShowManager(scene,size=(1024, 720), reset_camera=False)
showm.initialize()

centers = np.random.rand(11,3) * 3
directions = np.random.rand(11,3) - 0.5
heights = np.random.rand(11)
colors = np.random.rand(11,3)

cylinders = actor.cylinder(centers, directions, colors, 
                           radius=0.3 ,heights=heights, capped=True,
#                         repeat_primitive=False)

scene.add(cylinders)
showm.start()
window.record(scene, out_path='viz_cylinders.png',size =(1024,720))
Clarkszw commented 1 year ago

I saw that in your screenshot the two methods generated perpendicular cylinders(which should identical except colours). But mine deviations of directions are random..

image

I will try to check how two methods using “directions”..

skoudoro commented 1 year ago

In both cylinder actor, are you making sure to use the same direction (random or not) , the same direction should be used.

If it work correctly, they should blend and be identical, with weird color.

in your case, they should all be the same so there is clearly some wrong in the script you run.

Clarkszw commented 1 year ago

I have fix the prim_cylinder(),now it create the primitive cylinder along x axis as no primitive.

image

Both methods generates the same shape of cylinders at the same positions.

If we shift a bit the centers of two methods, one can see they are parallel.

image

Here is code for the test:

from fury import window, actor
import numpy as np

scene = window.Scene()
showm = window.ShowManager(scene, size=(1024, 720), reset_camera=False)
showm.initialize()

centers = np.random.rand(11, 3) * 3
directions = np.random.rand(11, 3) - 0.5
heights = np.random.rand(11)
colors_1 = np.random.rand(11, 3)
colors_2 = np.random.rand(11, 3)

cylinders_1 = actor.cylinder(centers, directions, colors_1,
                             radius=0.3, heights=heights, capped=True,
                             repeat_primitive=False)

centers_2 = centers.copy()
# centers_2 = centers + 0.1

cylinders_2 = actor.cylinder(centers_2, directions, colors_2,
                             radius=0.3, heights=heights, capped=True,
                             repeat_primitive=True)

scene.add(cylinders_1, cylinders_2)
showm.start()
skoudoro commented 1 year ago

Nice, thanks @Clarkszw! no time today or this weekend, so I will look more in details this Monday or Tuesday