I am trying to construct a building with a manipulated sliding roof and other objects that can be manipulated. I have found that the manipulation of translations and rotations of graphics groups of polygons proceeds too slowly, so I have rasterized the moving objects to speed things up, but it seems the rasters don't manipulate, or they don't work in Show. I get the error
Show::gcomb: Could not combine the graphics objects in Show[slider,stationaryObj]. >>
This script abstracts the essentials of my attempt by creating a stationary Cuboid in color Gray and a list of rasterized translated Cuboids that represent the sliding object in Brown. The sliding object should slide along the top of the stationary object. The sliding is supposed to be accomplished by manipulating the presentation of successive translated and then rasterized images from a list. The program does not work. The question is, what am I missing, or is there a better approach?
Clear["Global`*"]
(* dimensions of two-by-four in inches *)
thkns = 1.5;
wdth = 3.5;
len = 12;
(* two by four of length 12 inches *)
slidingObj = Cuboid[{0, 0, 0}, {thkns, len, wdth}];
(* a stationary base on which the two by four should slide *)
stationaryObj = Rasterize[Graphics3D[{Gray, Translate[slidingObj, {0, 0, - wdth}]}]]
slidingImages = Table[
Rasterize[Graphics3D[{Brown, Translate[slidingObj, {0, s, 0}]}]],{s, Range[5]}];
Manipulate[slider = slidingImages[[s]], {s, Range[5]}];
Show[ slider, stationaryObj] // Dynamic
Following suggestions in the comments, I rasterized stationaryObj and removed the semi-colon from the Manipulate function (though I kept it here). The "could not combine objects" error persists. I tried moving stationaryObj inside a list with slidingImages[[s]] in Manipulate.
Manipulate[
slider = {stationaryObj, slidingImages[[s]]}, {s, Range[5]}];
Show[slider]
This produced the error message
Show::gtype: Symbol is not a type of graphics.
Using just
Manipulate[{stationaryObj, slidingImages[[s]]}, {s, Range[5]}]
without the Show function does not produce an error message, but it also doesn't combine the Graphics.
The suggestions by @halirutan deleted the Rasterize, which seem to be needed for the more complicated objects I am working on outside this page, as they move slowly. However, @halirutan's second script worked with Rasterize added. The following works as desired:
With[{thkns = 1.5, wdth = 3.5, len = 12},
With[{slidingObj = Cuboid[{0, 0, 0}, {thkns, len, wdth}]},
Manipulate[
Rasterize[
Graphics3D[{Gray, Translate[slidingObj, {0, 0, -wdth}], Brown,
Translate[slidingObj, {0, s, 0}]},
PlotRange -> {Automatic, {0, len + 10}, Automatic}]], {s, 0, 10}]]]
But I might have been too hasty in accepting this answer. I do need to combine several different shapes in a single screen in which only two objects will be manipulated. I now realize that the script makes use of only one object.
*
is starting (and then ending) italic formatting. Formatting the inputs as code will avoid this. $\endgroup$slider
has headGraphics
butstationaryObj
has headGraphics3D
, so you can't combine them withShow
. $\endgroup$