Inserting 3D objects
Blend for Visual Studio 2012 offers useful tools for creating, modifying, and animating 3D objects.
Blend can import 3D content in the .obj file format. For these files to render correctly, you must also import the material file (.mtl file) that defines the materials used on the 3D object, and import all the image files that are used in the material file.
3D content is contained in a Viewport3D control. This viewport acts as a sort of wrapper or container for the 3D content. You can modify the materials, the lights, and the camera in the Properties panel to give desired effects and visual attributes to your 3D content.
Viewport3D |
A two-dimensional (2D) control, like an ellipse, that acts as a container for rendering three-dimensional (3D) content in a document. |
|
Camera |
Represents a viewpoint in a document, and behaves like a video camera. The camera is used to take the 3D content and convert it into a 2D image (a normal, flat object) for the screen. There are two types of camera: perspective and orthographic. |
|
Material |
Materials for 3D content represent the color, texture, and general appearance of the actual 3D object itself. Lighting can also affect the visual appearance of the object, but materials directly affect the surfaces of the 3D object. There are three types of material: diffuse, emissive, and specular. |
|
Lights |
As you might expect, lights add illumination to the 3D content. Without light you will not see your 3D content. There are four types of light: ambient, spot, directional, and point. |
The 3D model
You have several ways to change the orientation and location of a 3D object using handles. For example, by using the Selection tool , you can double-click the 3D object to select it, and then drag it around the artboard while your mouse displays the relocation cursor . If you try this, you'll notice that the 3D object does not get closer or farther away from you as you drag it. If you then press Alt while dragging up and down with the mouse, you will notice that the 3D object appears to move closer and farther away from you.
You can also rotate, reposition, and scale a 3D object under Transform in the Properties panel just as you would with any object.
ヒント |
---|
Scaling and resizing are very different ways to change the size of an object. Scaling changes the size of an object and all its properties by a percentage of the starting size; for example, the stroke of an object that has a Stroke property will also scale and no longer map to a specific stroke width. Resizing means that you are changing the Height and Width properties (dimensions) of the object. |
The transformation handles are unique in 3D. The following figure and table describe how to best use each one.
3D object that shows all handles
Axis |
Description |
Handles |
---|---|---|
X axis |
You can rotate the object around the X axis (red handles) by dragging the X rotation handle (red arc). The rotation handle enables you to rotate the object around the X axis, the position handle (red arrow) enables you to move the object along the X axis, and the scaling handle (red box) enables you to scale the object along the X axis. |
X axis handles for: Rotation. Position. |
Y axis |
You can rotate the object around the Y axis (green handles) by dragging the Y rotation handle (green arc). The rotation handle enables you to rotate the object around the Y axis, the position handle (green arrow) enables you to move the object along the Y axis, and the scaling handle (green box) enables you to scale the object along the Y axis. |
Y axis handles for: Rotation. Position. |
Z axis |
You can also rotate the object around the Z axis (blue handles) by dragging the Z rotation handle (blue arc). The rotation handle enables you to rotate the object around the Z axis, the position handle (blue arrow) enables you to move the object along the Z axis, and the scaling handle (blue box) enables you to scale the object along the Z axis. |
Z axis handles for: Rotation. Position. |
[!メモ]
When rotating, you can snap the rotation every 15 degrees by holding down the Shift key.
Materials
Materials for 3D content represent the color, texture, and general appearance of the actual 3D object itself. Lighting can also affect the visual appearance of the object, but materials directly affect the surfaces of the 3D object. By selecting from the three different material types, you can make different modifications to your 3D content, as follows:
Diffuse Material Determines the color of the 3D object that has direct light (white light) applied to it, much like paint on a wall.
Emissive Material Causes the object to appear to be giving off light. The color of the light is determined by the color of the material.
Specular Material Controls the color of the specular highlight on a 3D object. Specular highlights are the bright spots that you see on a glossy surface such as chrome.
The camera
The camera for 3D content represents a vantage point and behaves much like a video camera. The camera is used to convert the 3D content into a 2D image (a normal, flat object) for the screen. The camera for each Viewport3D can be found as a property of that viewport. If you select a camera in the objects view in the Objects and Timeline panel, you can then modify its properties using the Properties panel under Camera. Each viewport has only one camera property associated with it, but you can switch the type of camera between a perspective camera and an orthographic camera to change how the objects appear in your application:
A perspective camera works like an ordinary camera lens. As objects get farther away from the camera, they appear to get smaller. Click PerspectiveCamera under Camera in the Properties panel to switch to this camera.
An orthographic camera turns off the perspective of an ordinary camera. Objects do not appear to get smaller or distort as they move farther from an orthographic camera. Click Orthographic Camera under Camera in the Properties panel to switch to this camera.
Perspective camera
Orthographic camera
You can move the camera by using the Camera Orbit tool . You can also move the camera and make additional changes to each type of camera under Camera in the Properties panel:
Perspective Field of View For the perspective camera only, this attribute changes the amount of the content that is visible through the camera and the amount that objects in the document appear to be distorted by the camera. Small values reduce the amount that an object is distorted by perspective and large values cause objects to become very distorted, as with a fisheye lens.
Width For the orthographic camera only, this attribute controls how much of the content is visible. As this number increases, more of the content will be visible.
Position The position of the camera in three-dimensional virtual space.
Direction The point at which the camera is looking in three-dimensional virtual space.
Up Vector Moving in the direction that is "up" for this camera.
Far/Near Clipping Planes These options control how close to or far away from the camera an object can get before it disappears from the rendered view.
For more information about how to modify the camera, see Move the camera.
Lights
As you might expect, lights add light to the 3D content. Without light, you will not see much of your 3D content because the appearance would be much like trying to see something with absolutely no light. Lights are properties of Viewport3D controls, and you can modify their settings by selecting them in the objects view in the Objects and Timeline panel.
You can transform a light by using the transformation handles that appear when you select a light (the red, green, and blue handles in the following images in the "Types of light" section, later in this topic).
For more information about how to move lights, see Move the direction of a light.
Additionally, you can change several attributes of a light, but the two primary attributes you will probably want to change are its color and type.
Light color
Changing the color of a light is as simple as changing the color of a 2D object. You can change light color as long as you have a Light object selected in a Viewport3D. Then, you can change a light by using the color editor under Light in the Properties panel.
For an example, see Change the color of a light.
Types of light
The following table describes the types of light that you can apply to a 3D object. You can change the light type as long as you have a Light object selected in a Viewport3D. Then, you can select a different light type under Light in the Properties panel.
For an example, see Change the type of light.
Light type and description |
Working with lights on the artboard |
---|---|
Ambient Light Ambient light casts light as if it is coming from all directions. Use this option when you want to light all objects evenly.
ヒント
If you have only an ambient light, your object might appear to be washed out and lit by only one shade of color. For the best effect, use an additional nonambient light also.
|
|
Spot Light Spot light casts light like a real spot light. The light starts from the position of the light and spreads out in the shape of a cone. Parts of a 3D object outside the cone of light will not be affected by the spot light. |
|
Directional Light Directional light casts light evenly in a specific direction, much like sunlight. |
|
Point Light Point light casts light outward from a single point in all directions, much like a standard light bulb. |
ヒント |
---|
To see all the lights acting on your object at the same time, point to 3D on the View menu, and then click Toggle Lights. |
Other light properties
You can make additional changes to each type of light under Light in the Properties panel by modifying the following attributes:
Attenuation The way in which the power of the light decays as it moves farther from the lit object. You can modify the following attenuation properties:
ConstantAttenuation The power of the light will not change as the lit object moves farther from the light.
LinearAttenuation The power of the light drops at a constant rate as the lit objects moves farther from the light.
QuadraticAttenuation The power of the light drops quickly at first and then more slowly as the lit object moves farther from the light.
[!メモ]
Attenuation properties apply only to the Spot Light and Point Light light types.
Direction The direction in which the light is facing. Direction properties apply only to the Spot Light and the Directional Light light types.
Cone Angle The angle that determines the width of the cone of light that extends from the selected light. If you shine a flashlight on the ground, the flashlight does not light the ground evenly, but is dimmer farther from the center. Cone Angle lets you control how quickly this falloff occurs. You can modify the following cone angle properties:
InnerConeAngle The angle of the brightest, central part of the light.
OuterConeAngle The angle of the dimmer, outer part of the light. To create a strong light, make the inner and outer cone angles the same. If the value of the inner cone angle is larger than the outer cone angle, the values are treated as the same as the outer cone angle.
[!メモ]
Cone angle properties apply only to the Spot Light light type.
Position The position of the light in the group that contains it. The three values are the X, Y, and Z position of the light. Position properties apply only to the Spot Light and Point Light light types.
Range The range of the light. Objects that are in range will be lit by the light. Objects beyond the range of the light will not be lit by the light. Range properties apply only to the Spot Light and Point Light light types.
Support for new 3D objects
The .NET Framework includes the following new 3D objects:
UIElement3D (not supported in XAML)
ContainerUIElement3D
ModelUIElement3D
Viewport2DVisual3D
Blend does not include the new 3D objects in the Assets panel. However, you can use them by making modifications manually in XAML, or by using Microsoft Visual Studio 2012 to add the objects and then open your project in Blend. The new 3D objects are recognized by Blend, and you can use the 3D adorners to adjust those objects in the scene.