zarquon42b / Morpho

R-package providing a toolset for (3D-based) Geometric Morphometrics
51 stars 16 forks source link

Colors don't merge correctly #12

Closed klamalfa closed 6 years ago

klamalfa commented 6 years ago

Merging primitives with complex color schemes yields this warning message:

Warning message: In cbind(outmesh$material$color, tmpmesh$material$color) : number of rows of result is not a multiple of vector length (arg 2)

And furthermore, the color material is a matrix with multiple rows, not a list. When I try to fix it by concatenating the colors from each individual object, the colors end up jumbled.

zarquon42b commented 6 years ago

Hi,

can you please upload a minimal example for me to test (or post some code with the example data).

Best

Stefan

klamalfa commented 6 years ago

ico1 <- icosahedron3d() ico1$material <- list(color=rgb((1:20)/20,0,0)) plot3d(ico1)

ico2 <- icosahedron3d() ico2$material <- list(color=rgb(0,(1:20)/20,0)) ico2 <- translate3d(ico2, 0.5,0,0) plot3d(ico2, add=TRUE)

merge_ico <- mergeMeshes(ico1, ico2) plot3d(merge_ico)

zarquon42b commented 6 years ago

OK, I think I fixed it here. Please try and close the issue if it is resolved.

klamalfa commented 6 years ago

Yes this worked. However, I don't think it will work when you mix meshes with different kinds of color schemes. For instance, when one of the meshes is simple and the other complex (one color per polygon), the merging will get tripped up. The work around is to make all the colors complex for all the meshes you want to build.

Thanks for fixing the issue though!