Creating a simple diorama
Creating a simple diorama
Creating a simple diorama
Now, we will add a few objects to the scene to set up the environment, including a unit cube, a flat
plane, a red ball, and a photographic backdrop. Here is a photograph of a physical mock-up of the
diorama we will build in VR:
Adding a cube
Adding a planeLet's add the first object to the scene: a unit-sized cube. Within the Hierarchy panel,
use the Create menu and choose 3D Object | Cube. The same selection can also be found in the
main menu bar's GameObject drop-down menu. A default white cube is added to the scene,
centered on the ground plane at the (0, 0, 0) position, with no rotation, and a scale of one, as you
can see in the Inspector panel. This is the Reset setting, which can be found in the object's Transform
component of the Inspector panel.
The Reset values of the Transform component are Position (0, 0, 0), Rotation (0, 0, 0), and Scale (1, 1,
1).
If for some reason your cube has other Transform values, set these in the Inspector panel or locate
the small gear icon in the upper right-hand side of the Inspector panel's Transform component, click
on it, and select Reset. This cube has the dimensions of one unit on each side. As we'll see later, one
unit in Unity corresponds to one meter in world coordinates. Its local center is the center of the
cube.
Adding a plane
Now, let's add a ground plane object into the scene. In the Hierarchy panel, click on the Create
menu (or main GameObject menu) and choose 3D Object | Plane. A default white plane is added to
the scene, centered on the ground plane at Position (0, 0, 0). (If necessary, select Reset from the
Inspector panel's Transform component's gear icon). Rename it to (SPVOE1MBOF. Note that at a
scale of (0, 0, 0), Unity's plane object actually measures 10 by 10 units in X and Z. In other words, the
size of (SPVOE1MBOF is 10 by 10 units and its transform's Scale is 1.
The cube is centered at Position (0, 0, 0), just like the ground plane. However, maybe it doesn't look
like it to you. The Scene panel may show a Perspective projection that renders 3D scenes onto a 2D
image. The Perspective distortion makes the cube not seem centered on the ground plane, but it is.
Count the grid lines on either side of the cube. As you'll see, when it is viewed in VR and you're
actually standing in the scene, it won't look distorted at all. This is shown in the following
screenshot:
The cube is submerged in the ground plane because its local origin is at its geometric centerbit
measures 1 by 1 by 1 and its middle point is (0.5, 0.5, 0.5). This might sound obvious, but it is
possible for the origin of a model to not be its geometric center (such as one of its corners). The
Transform component's position is the world space location of the object's local origin. Let's move
the cube as follows:
1. Move the cube onto the surface of the ground planebin the Inspector panel, set its Y position to
0.5: Position (0,0.5,0).
2. Let's rotate the cube a bit around the y axis. Enter 20 into its Y rotation: Rotation (0,0.5,0).
Note the direction in which it rotates. That's 20 degrees clockwise. Using your left hand, give a
thumbs-up gesture. See the direction your fingers are pointing? Unity uses a lefthanded coordinate
system. (There is no standard for the coordinate system handedness. Some software uses left-
handedness, others use right-handedness). Unity uses a left-handed coordinate system. And the y
axis is up.
This time, let's use the Scene panel's Gizmos component to move the object. In the Scene view, you
can select graphical controls, or Gizmos, to manipulate the objects transforms, as illustrated in the
following screenshot from the Unity documentation:
In the Scene panel, with the sphere selected, make sure that the Translate tool is active (second icon
on the top-left icon toolbar) and use the arrows of the x, y, and z axes to position it. I left mine at
Position (1.6, 0.75, -1.75).
A Gizmo is a graphical control that lets you manipulate the parameters of an object or a view.
Gizmos have grab points or handles that you can click and drag with the mouse.
Save your scene and save the project. Here's what my scene looks like now (yours might be a little
different, but that's OK):
Note that we're using the folders in the Project panel "TTFUT directory to organize our stuff.
. In general, combinations of left/right mouse clicks with the Shift + Ctrl + Alt keys will let you
perform the following actions:
In the upper right-hand side of the Scene panel, you ha Adding a photove the Scene View Gizmo,
which depicts the current scene view orientation as shown in the following screenshot. It may
indicate, for example, a Perspective view, with x extending back to the left and z extending back to
the right:
You can change the view to look directly along any of the three axes by clicking on the
corresponding colored cone as shown in the following screenshot. Clicking on the small cube in the
center changes the Perspective view to the Orthographic (non-distorted) view:
Before moving on, let's first align the scene view with the Main Camera direction. You may recall me
saying that the default camera orientation, (0,0,0), is looking down the positive z direction (back to
front). Follow the following steps
: 1. Click on the white z cone on the Scene View Gizmo to adjust the view from the Back (back
direction), looking forward.
2. Also, use the Hand tool (or the middle mouse button) to slide the view up a tad.
Now, when you select the Main Camera component (from the Hierarchy panel), you will see that the
Scene view is roughly similar to the Camera Preview, looking in the same direction.
Adding a photo
Now, let's add a photo for the big-screen backdrop of our diorama. In computer graphics, an image
that is mapped onto an object is called a texture. While objects are represented in the x, y, and z
world coordinates, textures are said to be in the U, V coordinates (such as pixels). We'll see that
textures and UV maps can have their own scaling issues. Follow the following steps:
Select the new image Texture in the Project panel and review its settings in the Inspector panel. For
Unity's rendering purposes, even if the original photo was rectangular, the texture is square now (for
example, 2048 x 2048) and looks squished. When you map it onto a square-shaped face, it will be
squished there too. Let's perform the following steps:
Why 3.75? The height started at 10. So, we scaled it to 7.5. The scaling of objects is relative to their
origin. So now, the half of the height is 3.75. We want to position the center of the backdrop 3.5 unit
above the ground plane. We have the size and position set up, but the photo looks washed out.
That's because the ambient lighting in the scene is affecting it. You might want to keep it that way,
especially as you build more sophisticated lighting models and materials in your scenes. But for now,
we'll un-light it.
If you want to change the ground plane color, create a new material (in the Project panel), name it
(SPVOE, and drag it onto the ground plane. Then, change its Albedo color. I suggest using the
dropper (icon) to pick an earth tone from the image in your photo plane.
1. Definition:
2. Characteristics:
3D Models: Objects are often represented as 3D models created using software like
Blender, Maya, or Unity. These models can depict anything from simple geometric
shapes to complex characters or environments.
Textures and Materials: Objects in AR/VR can have textures that provide detail and
realism, including colors, patterns, and surface properties (e.g., shiny, matte).
Interactivity: Many objects in AR/VR environments are interactive. For example,
users might be able to pick up, move, or manipulate objects using controllers or hand
gestures.
Physics: Objects can be programmed to interact with the environment realistically.
This includes how they respond to gravity, collisions, and other physical forces.
3. Types of Objects:
Scale
1. Definition:
Scale in AR and VR refers to the size and proportion of objects within the virtual
environment relative to each other and to the real world. It significantly impacts user
perception and immersion.
2. Importance of Scale:
Realism: Correct scale enhances the realism of the environment. If objects are too
large or too small compared to the user or other objects, it can break immersion.
User Interaction: Scale affects how users interact with objects. For instance, if a
door in a VR environment is too small, users may find it difficult to open it
realistically.
Navigation: In AR, scale determines how digital objects fit within the physical world.
Objects must be accurately sized to integrate seamlessly with real-world elements.
3. Managing Scale:
Applications in AR/VR
1. Gaming:
o In VR games, the scale of characters and environments needs to feel realistic
to enhance immersion. For example, if a character is towering over the player,
it can create a sense of awe or fear.
2. Training Simulations:
o In AR/VR training applications (like medical or military simulations), objects
must be to scale to provide realistic training experiences. For example,
surgical instruments must be accurately represented to train users effectively.
3. Architecture and Design:
o Architects use AR/VR to visualize buildings at scale, allowing clients to walk
through spaces that are true to size, helping them understand dimensions and
layouts before construction.
4. Education:
o Educational tools that involve scientific concepts can use scaled objects to
demonstrate phenomena (e.g., modeling the solar system with planets
accurately scaled to their sizes and distances).
1. Purpose:
o Standard Assets are designed to help developers prototype and build games
more efficiently by providing ready-to-use components and scripts.
2. Components:
o These assets cover various functionality such as character movement, vehicle
physics, particle systems, and environmental effects.
1. Character Controllers:
o First-Person Controller: A setup for first-person gameplay, including camera
control, movement, and interaction mechanics.
o Third-Person Controller: Similar to the first-person controller but for third-
person perspective, often with animations for walking, running, and jumping.
2. Vehicles:
o Car Controller: A complete setup for vehicle physics, including handling,
acceleration, and braking.
o Airplane and Boat Controllers: Assets for simulating flying and sailing.
3. Environment:
o Particle Systems: Pre-configured particle effects for smoke, fire, and
explosions.
o Skyboxes: Different skybox textures to create varied environments.
4. Cameras:
o Cinemachine: Advanced camera tools that enable smooth transitions,
tracking, and following characters.
o FreeLook Camera: Allows for a more cinematic approach to camera
movement.
5. Utility Scripts:
o Simple AI: Basic scripts for creating NPC behaviors like patrolling or
following the player.
o Game Manager: A framework for managing game states, loading scenes, and
handling UI.
6. Audio:
o Audio Sources and Listeners: Pre-built components to help manage audio
playback and 3D sound effects.