Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I wrote a function interactiveDesign that returns different Graphics3D items in a list. Then I call the function interactiveDesign, create a textured part (add), and show everything in one plot.

interactiveDesign[innerColors_,outerColors_,width_,length_,wallsHeight_,middleHeight_,viewPoint_,click_,procedureButton_]:=
                  (lines={};
                   For[i=1,i<= Round[((N[length/10])-1)],i++,(lines=Append[lines,Polygon[{{0,((10*i)-0.5),wallsHeight},{(width/2),((10*i)-0.5),middleHeight},{(width/2),(10*i),middleHeight},{0,(10*i),wallsHeight}}]])];
                   lines1={};
                   For[i=1,i<= Round[((N[length/10])-1)],i++,(lines1=Append[lines1,Polygon[{{width,((10*i)-0.5),wallsHeight},{(width/2),((10*i)-0.5),middleHeight},{(width/2),(10*i),middleHeight},{width,(10*i),wallsHeight}}]])];
                   gridLines1=Graphics3D[{LightBlue,lines},RotationAction->"Clip",Lighting->{innerColors},ViewPoint->viewPoint,Boxed-> False];
                   gridLines2=Graphics3D[{LightBlue,lines1},RotationAction->"Clip",Lighting->{innerColors},ViewPoint->viewPoint,Boxed-> False];
                   rightWall=Graphics3D[{innerColors,Polygon[{{0,0,0},{0,0,wallsHeight},{0,length,wallsHeight},{0,length,0}}]},Boxed-> False,Lighting->{{"Ambient",innerColors}},RotationAction->"Clip",ViewPoint-> viewPoint];
                   leftWall=Graphics3D[{innerColors,Polygon[{{width,0,0},{width,0,wallsHeight},{width,length,wallsHeight},{width,length,0}}]},Boxed-> False,Lighting->{{"Ambient",innerColors}},RotationAction->"Clip",ViewPoint-> viewPoint];
                   backWall=Graphics3D[{innerColors,Polygon[{{0,length,0},{0,length,wallsHeight},{N[width/2],length,middleHeight},{width,length,wallsHeight},{width,length,0}}]},Boxed-> False,Lighting->{{"Ambient",innerColors}},RotationAction->"Clip",ViewPoint-> viewPoint];
                   shad1=Graphics3D[{outerColors,Polygon[{{0,0,wallsHeight},{N[width/2],0,middleHeight},{N[width/2],length,middleHeight},{0,length,wallsHeight}}]},Boxed-> False ,Lighting->{{"Ambient",outerColors}},RotationAction->"Clip",ViewPoint-> viewPoint];
                  shad2=Graphics3D[{outerColors,Polygon[{{width,0,wallsHeight},{N[width/2],0,middleHeight},{N[width/2],length,middleHeight},{width,length,wallsHeight}}]},Boxed-> False,Lighting->{{"Ambient",outerColors}},RotationAction->"Clip" ,ViewPoint-> viewPoint];
                  floor=Graphics3D[{LightBlue,Polygon[{{0,0,0},{0,length,0},{width,length,0},{width,0,0}}]},Boxed-> False,Lighting->{{"Ambient",LightBlue}},RotationAction->"Clip",ViewPoint-> viewPoint ];
                  frontDoom=Graphics3D[{outerColors,Polygon[{{0,0,wallsHeight},{N[width/2],0,middleHeight},{width,0,wallsHeight}}]},Boxed-> False,Lighting->{{"Ambient",outerColors}},RotationAction->"Clip",ViewPoint-> viewPoint];
                  frontEnd1=Graphics3D[{outerColors,Polygon[{{0,0,0},{0,0,wallsHeight},{N[width/4],0,wallsHeight},{N[width/4],0,0}}]},Boxed-> False ,Lighting->{{"Ambient",outerColors}},RotationAction->"Clip",ViewPoint-> viewPoint];
                  frontEnd2=Graphics3D[{outerColors,Polygon[{{N[(width-(width/4))],0,0},{N[(width-(width/4))],0,wallsHeight},{width,0,wallsHeight},{width,0,0}}]},Boxed-> False,Lighting->{{"Ambient",outerColors}},RotationAction->"Clip",ViewPoint-> viewPoint];
                  {gridLines1,gridLines2,rightWall,leftWall,backWall,shad1,shad2,floor,frontDoom,frontEnd1,frontEnd2});

 parts = interactiveDesign[LightGreen, Gray, 500, 300, 300, 400, {2, -2, 0}, 1, ""];

 add = {Graphics3D[{EdgeForm[Gray], Gray,Texture[Style["Subbu", Bold, 25]], Opacity[1], 
                   Polygon[
 Inner[Plus, {{30, 0, 10}, {100, 0, 10}, {100, 0, 70}, {30, 0, 70}}, {-5, -5, 0},List], 
              VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}
      ]}, 
                  Boxed -> False, Lighting -> {Gray}, RotationAction -> "Clip"
                 ]};

  Show[parts, add] 

enter image description here

Everything is fine but the item with Texture(add) is blinking whenever the Graphics3D is rotated. How can I prevent this blinking during rotation?

share|improve this question
add comment

closed as too localized by rm -rf Mar 25 '13 at 7:18

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

up vote 4 down vote accepted
+50

@Subbu,

I specifically tested your code on two computers. One with a proper graphics card and other without one. There is no blinking when the code is run on the computer with a graphics card. However, the problems returns when there code is run on the computer without graphics card.

Hope this helps,

Regards, Anu

share|improve this answer
add comment

Your code, with István's fix, works fine (v9.0.0, Mac OS 10.6). Here's another way: punch a hole in the wall where the textured rectangle appears.

The following definition puts a rectangular hole in a rectangular polygon. It divides the polygon into 9 rectangles (3 x 3) and drops the middle one. The code messes up EdgeForm so an optional argument to rectWithHole3D can specify the edge style; beware, it will inherit from the current Line style, too. I suspect there may be more efficient and general ways of doing this.

rectToPoly[{LL_, UR_}] := Tuples[Transpose@{LL, UR}][[{1, 3, 4, 2}]];
insertFixed[poly2d_, fixedCoord_, fixedPart_] := Insert[#, fixedCoord, fixedPart] & /@ poly2d;
rectWithHole3D[pts_List, hole_List, edgeForm_: None] := 
  With[{fixedPart = Position[SameQ @@@ Transpose[pts], True][[1, 1]]},
    With[{fixedCoord = pts[[1, fixedPart]],
     corners = Drop[Flatten[Table[{{i, j}, {i + 1, j + 1}}, {i, 3}, {j, 3}], 1], {5}], (* Drop {5} = center *)
     newvertices = 
      Outer[List, Sequence @@ Transpose@Drop[(pts~Join~hole)[[{1, 5, 7, 3}]], None, {fixedPart}]]}, 
    {{EdgeForm[], Polygon@insertFixed[#, fixedCoord, fixedPart] &@
         rectToPoly@Extract[newvertices, #] & /@ corners}, 
     If[edgeForm =!= None, {edgeForm, Line[pts], Line[hole]}, {}]}
    ]
   ];

Then here are the changes to your code that need to be made.

addVertices = {{30, 0, 10}, {100, 0, 10}, {100, 0, 70}, {30, 0, 70}};
frontEnd1 = 
 Graphics3D[{outerColors, 
   rectWithHole3D[{{0, 0, 0}, {0, 0, wallsHeight}, {N[width/4], 0, wallsHeight}, {N[width/4], 0, 0}},
    addVertices, Black]},
  Boxed -> False, Lighting -> {{"Ambient", outerColors}}, RotationAction -> "Clip", 
  ViewPoint -> viewPoint];

add = {Graphics3D[{EdgeForm[Gray], Gray, 
    Texture[Style["Subbu", Bold, 25]], Opacity[1], 
    Polygon[addVertices, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, 
   Boxed -> False, Lighting -> {Gray}, RotationAction -> "Clip"]};

Subbu's house

You may not like that it changes your function interactiveDesign, so that it depends on the external size and position of add (managed here through the variable addVertices). But it should solve the flickering problem and put the "Subbu" rectangle right where you want it. (You can also add windows.)

share|improve this answer
add comment

The issue has nothing to do with Texture. It is because the polygon you define in add is at the same plane where the front wall is: if you only use e.g. a red polygon instead of a textured one, you still would see the blinking feature, as Mathematica fails to decide which polygon to draw before the other: the wall or the red one. So you can simply move the smaller one a bit out of the wall, like this:

Polygon[
     Inner[Plus, {{30, 0, 10}, {100, 0, 10}, {100, 0, 70}, {30, 0, 70}}, {-5, -5, 0}, List], 
     VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}
]
share|improve this answer
    
:Thank you for your reply... –  subbu Nov 1 '12 at 10:48
    
,your answer is working great,but at the rotation time,Textureis not visible clearely... How can we solve that? –  subbu Feb 26 '13 at 10:26
    
@subbu Sorry, I don't get it. If I put together everything, I can see the texture clearly during rotation. –  István Zachar Feb 26 '13 at 11:21
1  
@ István Zachar,I am using mathematica 9.0,I evaluated your code with my code.during rotation time Texture is not visible clearly. By this, I mean to say if I have a text block and some letters in the text block, during rotation, the letters disappear. It happens even if I place some images which are required to be seen even during rotation. They appear after I stop the rotation. –  subbu Feb 26 '13 at 11:36
    
@subbu At my end (Win), everything seems fine. What machine/graphics hardware do you use? Could you further specify the issue in your post so that others could join in the quest, as at the moment I cannot reproduce it. –  István Zachar Feb 27 '13 at 19:23
show 1 more comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.