VIEW_3D
This widget creates a 3D view that displays a 3D Scene where 3D Objects can be aggregated and represented as a tree structure. The viewpoint for the 3D scene is set by a translation vector (tx,ty,tz) followed by a rotation defined by Euler angles (rx,ry,rz) which coordinates can be initialized and controlled by exposed parameters.
Inside VIEW_3D you can have one or more GL_OBJECT_3D, GRID_3D, COLOR_SURFACE_3D.
Attributes brief detailed show all inherited
Example
Here's an example of a VIEW_3D that contains a 3d grid, a color surface and a 3d object. Mouse interaction is enabled. The view is slowly rotated with help of a TIMER.

- <!-- The formula that defines the surface -->
- <FORMULA_SURFACE id="demo_surface" formula="-cos(x)+0.5" x_min="-2" x_max="2" x_default="0" y_min="-2" y_max="2" y_default="0" z_min="-1" z_max="1" z_default="0"/>
- <!-- The 3D Viewer -->
- <VIEW_3D id="my_3d_view" width="400" height="250" x_ratio="1" y_ratio="0.8" z_ratio="0.8" transform.tx="0.02" transform.ty="0.02" transform.tz="-1.6" transform.rx="65" transform.ry="0" transform.rz="-30" mouse_sensitive="true" cursor="system::open_hand" persistent_viewpoint="false">
- <!-- Grid object -->
- <GRID_3D x_param_info_id="demo_surface.x_info" y_param_info_id="demo_surface.y_info" z_param_info_id="demo_surface.z_info" y_positions_count="11" x_positions_count="11" z_positions_count="11" x_position="-0.5" y_position="-0.5" z_position="-0.5" opacity="0.4" />
- <!-- Color surface-->
- <COLOR_SURFACE_3D surface_id="demo_surface" visible="true" draw_style="solid" high_color="#ff0000" low_color="#000030" opacity="0.8" x_positions_count="100" y_positions_count="100" x_position="-.5" y_position="-.5" z_position="-.5" />
- <!-- 3D object -->
- <GL_OBJECT_3D x_position="-0.4" z_position="-0.4" render_script="
- double opacity = 0.8;
- double size = .15;
- /* render cube */
- glBegin(GL_QUADS);
- /* Top face (y = size) */
- glColor4f(0.0f, 1, 0.0f, 1); /* Green */
- glVertex3f( size, size, -size);
- glVertex3f(-size, size, -size);
- glVertex3f(-size, size, size);
- glVertex3f( size, size, size);
- /* Bottom face (y = -size) */
- glColor4f(1, 0.5f, 0.0f,opacity); /* Orange */
- glVertex3f( size, -size, size);
- glVertex3f(-size, -size, size);
- glVertex3f(-size, -size, -size);
- glVertex3f( size, -size, -size);
- /* Front face (z = size) */
- glColor4f(1, 0.0f, 0.0f,opacity); /* Red */
- glVertex3f( size, size, size);
- glVertex3f(-size, size, size);
- glVertex3f(-size, -size, size);
- glVertex3f( size, -size, size);
- /* Back face (z = -size) */
- glColor4f(1, 1, 0.0f,opacity); /* Yellow */
- glVertex3f( size, -size, -size);
- glVertex3f(-size, -size, -size);
- glVertex3f(-size, size, -size);
- glVertex3f( size, size, -size);
- /* Left face (x = -size) */
- glColor4f(0.0f, 0.0f, 1,opacity); /* Blue */
- glVertex3f(-size, size, size);
- glVertex3f(-size, size, -size);
- glVertex3f(-size, -size, -size);
- glVertex3f(-size, -size, size);
- /* Right face (x = size) */
- glColor4f(1, 0.0f, size,opacity); /* Magenta */
- glVertex3f(size, size, -size);
- glVertex3f(size, size, size);
- glVertex3f(size, -size, size);
- glVertex3f(size, -size, -size);
- glEnd();
- " />
- </VIEW_3D>
- <!-- a timer to rotate the VIEW_3D -->
- <TIMER id="forever_timer" refresh_time_ms="10" />
- <SCRIPT script="double timer_var_a = 0;" />
- <ACTION_TRIGGER event_id="forever_timer.elapsed"
- script="
- my_3d_view.transform.rz += 0.5;
- if (my_3d_view.transform.rz>=180) my_3d_view.transform.rz=-180;
- " requires="my_3d_view.transform.r*" />
Related elements
Also see GL_OBJECT_3D, GRID_3D, COLOR_SURFACE_3D.
Comments
Please, authorize to view and post comments.