ViewPort3D
The
ViewPort3D is 2D element which is used to project and display 3D content.
[<ViewPort3D>]
[<ViewPort3D.Camera>]
<!-- Camera definition -->
[</ViewPort3D.Camera>]
[<ViewPort3D.Models>]
<!-- Scene definition (Model3Ds) -->
[</ViewPort3D.Models>]
[</ViewPort3D>]
Cameras
OrthographicCamera
The
OrthographicCamera defines an orthographic project of the 3D scene.
[<OrthographicCamera] Position="0,0,5" LookAtPoint="0,0,0" Up="0,1,0" Width="4" NearPlaneDistance="1" FarPlaneDistance="20" />
Notes: Width defines the width of the projection and is in model units. Height is computed by the aspect ratio of the
ViewPort3D.
PerspectiveCamera
The
PerspectiveCamera defines a perspective projection of the 3D scene.
[<PerspectiveCamera] Position="0,0,5" LookAtPoint="0,0,0" Up="0,1,0" FieldOfView="45" NearPlaneDistance="1" FarPlaneDistance="20"/>
Notes:
FieldOfView is the horizontal field of view and is in degrees. The vertical field of view is computed by the aspect ratio of the
ViewPort3D.
Model3Ds
Model3DCollection
A 3D scene is build primarily of
Model3DCollections which render no content, but are used to group a and transform their children.
[<Model3DCollection>]
[<Model3DCollection.Transform>]
<!-- Optional Transform3D Definition -->
[</Model3DCollection.Transform>]
[<Model3DCollection.Children>]
<!-- More Model3Ds -->
[</Model3DCollection.Children>]
[<Model3DCollection>]
Lights
Note: There is a bug in build 4074 where the color assigned to a light is not converted from scRGB before being used by sRGB render targets (i.e., Direct3D).
AmbientLight
Adds constant omni-directional lighting to the scene
[<AmbientLight] Color="White">
[<AmbientLight.Transform>]
<!-- Optional Transform3D Definition -->
[</AmbientLight.Transform>]
[</AmbientLight>]
DirectionalLight
Adds constant directional light to the scene. This approximates the effect one gets when the light source is very far away (i.e. the sun).
[<DirectionalLight] Color="White" Direction="-1,-1,-1">
[<DirectionalLight.Transform>]
<!-- Optional Transform3D Definition -->
[</DirectionalLight.Transform>]
[</DirectionalLight>]
PointLight
Adds light to a portion of a scene which diminishes with distance. Point lights emit light in all directions.
[<PointLight] Color="White" Position="-2, 0, 2" Range="10" ConstantAttenuation="1" LinearAttenuation="1" QuadraticAttenuation="1">
[<PointLight.Transform>]
<!-- Optional Transform3D Definition -->
[</PointLight.Transform>]
[</PointLight>]
MeshPrimitive3D
A
MeshPrimitive3D combines a Mesh3D and a Material to render.
[<MeshPrimitive3D>]
[<MeshPrimitive3D.Transform>]
<!-- Optional Transform3D Definition -->
[</MeshPrimitive3D.Transform>]
[<MeshPrimitive3D.Mesh>]
<!-- Mesh3D Definition -->
[</MeshPrimitive3D.Mesh>]
[<MeshPrimitive3D.Material>]
<!-- Material Definition -->
[</MeshPrimitive3D.Material>]
[</MeshPrimitive3D>]
Mesh3D
A Mesh3D describes a triangle based geometry.
<Mesh3D
TriangleIndices="0 1 2 2 1 3"
TextureCoordinates="0,0 0,0 0,0 0,0"
Normals="0,1,0 0,1,0 0,1,0 0,1,0"
Positions="-2,-1,2 -2,-1,-2 2,-1,2 2,-1,-2"/>
Note: The
TriangleIndices are interpreted as a triangle list (as opposed to a triangle fan or triangle strip.)
Transform3Ds
TranslateTransform3D
Translates by the given offset.
[<TranslateTransform3D] Offset="-1,0,0" />
ScaleTransform3D
Scales by the given vector about the given center.
[<ScaleTransform3D] ScaleVector="1,-1,1" ScaleCenter="0,-.5,0"/>
RotateTransform3D
Applies the rotation described by the given quaternion.
[<RotateTransform3D] QuaternionRotation="0,0.258819045102521,0,0.965925826289068" />
Note: You may have noticed that
RotateTransform3D has properties like Axis, Angle and Center. Unfortunately these do not work from Xaml in build 4074. You can find a small console app to construct a quaternion given an axis and angle
here.