2
$\begingroup$

I used Cuboid to build 4 walls and make them composed like a room, the codes and result as followings.

My question is that is it possible to move the viewpoint to inside the room? The thing I want to do is making users feel themselves are inside the room, and they can rotate the screen to see what the room look like from the inside. Is it possible?

wallChosenColor = LightGray;
WallThick = 10;
roomLength = 10;
roomWidth = 5;
roomHeight = 2.5;
floorChosenColor = White;


Room3D = {
   EdgeForm[],
   Specularity[White, 50],

   (*Walls*)
   FaceForm[wallChosenColor],
   Cuboid[{{-WallThick/100, -WallThick/100, 
      0}, {roomLength + WallThick/100, 0, roomHeight}}],
   Cuboid[{{roomLength, -WallThick/100, 
      0}, {roomLength + WallThick/100, roomWidth + WallThick/100, 
      roomHeight}}],
   Cuboid[{{-WallThick/100, roomWidth, 
      0}, {roomLength + WallThick/100, roomWidth + WallThick/100, 
      roomHeight}}],
   Cuboid[{{-WallThick/100, -WallThick/100, 0}, {0, 
      roomWidth + WallThick/100, roomHeight}}],

   (*Floor*)
   Opacity[1],
   FaceForm[floorChosenColor],
   Cuboid[{0, 0, 0}, {roomLength, roomWidth, 0}]

   };


Graphics3D[{Room3D}
 , ViewPoint -> {-3, -2, 1}
 , ImageSize -> {400, 400}, Lighting -> "Neutral"]

enter image description here

$\endgroup$
2
$\begingroup$

Put the ViewPoint inside the room:

Graphics3D[{Room3D}, ViewPoint -> {-3, -2, 1}/15, 
 ImageSize -> {400, 400}, Lighting -> "Neutral"]

Mathematica graphics

See also Extract values for ViewMatrix from a Graphics3D.

$\endgroup$
  • $\begingroup$ Thank your help. May I ask why dividing 15 can make it into the room. I have read the link you posted, but am still confused how does it work, like where is the initial point(0, 0, 0) to ViewPoint? And each value in ViewPoint is stand for what meaning, what effect will happen when I change the value? $\endgroup$ – Chien-Ching Vincent Hsu Dec 5 '14 at 13:31
  • $\begingroup$ @Chien-ChingVincentHsu From the docs for ViewPoint: "The view point is given in a special scaled coordinate system in which the longest side of the bounding box has length 1. The center of the bounding box is taken to have coordinates {0,0,0}". Dividing by 15 simply put the ViewPoint near {0,0,0}. ViewVector will be a better choice for some applications (see Rahul's link), since it uses the coordinate system of the graphics. There are other View* options to consider, too. $\endgroup$ – Michael E2 Dec 5 '14 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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