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 colour of the material in the absence of direct light. The material will never appear darker than the ambient colour.
Diffuse - The colour of light reflected from the material.
Specular - The colour of the highlights from the material. The specular exponent controls how large the hightlight 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.
filename - The name of the model to load.
camera_position_x - The x position of the camera.
camera_position_y - The y position of the camera.
camera_position_z - The z position of the model.
azimuth - The rotation of the camera around the y axis in degrees.
elevation - The rotation of the camera around the x axis in degrees.
camera_field_of_view - 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.
model_position_x - The x position of the model.
model_position_y - The y position of the model.
model_position_z - The z position of the model.
model_orientation_phi - The rotation of the model around the x axis in degrees.
model_orientation_theta - The rotation of the model around the y axis in degrees.
model_orientation_psi - The rotation of the model around the z axis in degrees.