The 3D model render extension renders a 3D model into the control. Currently models in Wavefront Object (.obj) format are supported. This extension is only available when using OpenGL or OpenGL ES 2.0 based render managers, and requires the model3d plugin to be loaded.
The coordinate system in the render extension is the default OpenGL default coordinate system, with positive x to the right, positive y up, and positive z towards the viewer. The camera position defaults to (0, 0, 0), with the view direction along the negative z axis.
A Phong reflection model is implemented. A directional light source is present with white light coming from the (0, 1, 1) direction. The Phong model makes use of three terms:
Ambient - The color of the material in the absence of direct light. The material will never appear darker than the ambient color.
Diffuse - The color of light reflected from the material.
Specular - The color of the highlights from the material. The specular exponent controls how large the highlight is.
For more details on the Phong reflection model refer to Phong Reflection Model or to any book on computer graphics.
Rotations for the model are defined using Euler angles, with rotations applied around the z (psi), y (theta) and then x (phi) axes.
An OBJ file defines vertices and faces, and optionally normals and texture coordinates. If normals are not present, they will be calculated according to the convention that vertices in a face are specified in counter-clockwise order. If texture coordinates are not present, the model will not be rendered using a texture. Faces may be grouped together, and each group may be rendered with a different material.
Each OBJ file may also specify a Material (.mtl) file which allows for the material properties of the model to be specified. The following properties in a material file are currently supported:
d - The transparency (alpha) of the material.
Ka - The ambient lighting component of the material.
Kd - The diffuse lighting component of the material.
Ks - The specular lighting component of the material.
Ns - The specular lighting exponent of the material.
map_Kd - The texture specifying the diffuse color of the material. If the texture can be loaded, it will be used rather than the Kd parameter to when calculating the diffuse color.
If a material file is not present, the object will be rendered with a white color.
The 3D model render extension uses many standard options but also includes:
The name of the model to load.
The X/Y/Z position of the camera.
The rotation of the camera around the y axis in degrees.
The rotation of the camera around the x axis in degrees.
The field of view the camera in degrees. The field of view specifies how much of visual sphere is mapped to the control. A larger field of view is equivalent to using a wide-angle lens on a camera, and a smaller field of view is equivalent to using a zoom lens.
The X/Y/Z position of the model.
The rotation of the model around the x axis in degrees.
The rotation of the model around the y axis in degrees.
The rotation of the model around the z axis in degrees.