PLUG'N SCRIPT
rapid plugin development
Tutorial
DSP
KUIML
How-to
Scripts
  • Tutorial
  • Element Reference
Language basics
  • SKIN
  • DUMMY
  • INCLUDE
  • INCLUDE_ONCE
  • DEFINE
  • UNDEFINE
  • VARIABLE
  • LOCAL_VARIABLE
  • TEMPLATE
  • TEMPLATE_INNER_CONTENT
  • REPEAT
Data model
  • PARAM
  • ACTION
    • Action types
  • ACTION_TRIGGER
  • TIMER
UI Layout and positioning
  • CELL
  • TABLE
UI Widgets
  • CANVAS
    • Graphics API
  • COLOR_SCALE
  • FILE_SELECT_MENU
  • GRID
  • INVISIBLE_PARAM_MENU_BUTTON
  • MENU_ITEM
  • MENU_SEPARATOR
  • POPUP_MENU
  • svg
  • RULER
  • TEXT
  • TEXT_FIELD
  • TEXT_EDIT_BOX
  • XY_PARAM_PAD
  • XY_ZOOM_SELECT_PAD
  • XYZ_PARAM_SCRATCH_PAD
  • XYZ_PARAM_CLICK_PAD
  • XYZ_IMAGE_PARAM_JOYSTICK
UI 3D Objects
  • COLOR_SURFACE_3D
  • GRID_3D
  • GL_OBJECT_3D
Data model commands
  • REQUIRED_OBJECTS
  • EXPOSED_OBJECTS
  • PERSISTENT_OBJECTS
Common attrubutes
  • For all elements
  • Widgets
  • Param Widgets
  • Param Controls
  • Param Info Viewers
  • Text Widgets
  • Surface Viewers
  • Curve Viewers
  • 3D Objects
  • Parameters mapping
  • LetiMix
KUIMLElement ReferenceGL_OBJECT_3D
March 25, 2024

GL_OBJECT_3D

This object can be used to write custom OpenGL scripts for 3D rendering. The rendering script can reference any data exposed to the scripting engine.

Most OpenGL 1.1 functions and constants (as defined in the gl.h C header) are available, execpt the functions using arrays (vertex arrays etc.). Extensions and shaders are not yet available.

This element is currently experimental and may change in future releases.

Attributes brief detailed show all inherited

Name DescriptionDefault
render_scriptOpenGL script to render the objectempty
Exposed Actions
Exposed: v. 2.0InvalidateRequests the object to be re-rendered
Name Value type Default Description Comment
render_scriptscriptemptyOpenGL script to render the object
Exposed Actions
Exposed: v. 2.0Invalidateref_type_actionRequests the object to be re-rendered

See Attributes Common to 3D Objects.

Specific Attributes

Examples

3D Shapes

Display simple 3D shapes with an OpenGL script defined in a separate file:

doc_ref_3d_objects_gl_object_3d_example1.png

Skin file:

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <SKIN background_color="#000000" text_color="#ffffff">
  3. <!-- Custom 3D Viewer definition -->
  4. <DEFINE>
  5. <CUS_3D_VIEWER base_type="VIEW_3D" width="600" height="400" cursor="system::open_hand" y_ratio=".8" z_ratio=".5" transform.tz="-7" transform.ry="-45" transform.rx="-45"/>
  6. </DEFINE>

  7. <!-- Including the script file that defines the OpenGL rendering function-->
  8. <SCRIPT src="openGLShapes.cxx"/>

  9. <!-- The 3D Viewer -->
  10. <CUS_3D_VIEWER id="view3d">
  11. <!-- Custom GL scripting object, calling the glRenderShapes function defined in openGLshapes.cxx-->
  12. <GL_OBJECT_3D id="view3d.shapes" render_script="glRenderShapes(this.opacity)"/>
  13. </CUS_3D_VIEWER>

  14. <!-- Force the engine to expose the view3d.shapes.opacity attribute, as it is not referenced elsewhere-->
  15. <EXPOSED_OBJECTS object_ids="view3d.shapes.opacity"/>
  16. </SKIN>

OpenGL script file (openGLShapes.cxx):

// function used to render simple OpenGL shapes
void glRenderShapes(float opacity)
{
// render cube
glBegin(GL_QUADS);
// Top face (y = 1.0f)
glColor4f(0.0f, 1.0f, 0.0f,opacity); // Green
glVertex3f( 1.0f, 1.0f, -1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
 
// Bottom face (y = -1.0f)
glColor4f(1.0f, 0.5f, 0.0f,opacity); // Orange
glVertex3f( 1.0f, -1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f( 1.0f, -1.0f, -1.0f);
 
// Front face (z = 1.0f)
glColor4f(1.0f, 0.0f, 0.0f,opacity); // Red
glVertex3f( 1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
 
// Back face (z = -1.0f)
glColor4f(1.0f, 1.0f, 0.0f,opacity); // Yellow
glVertex3f( 1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f( 1.0f, 1.0f, -1.0f);
 
// Left face (x = -1.0f)
glColor4f(0.0f, 0.0f, 1.0f,opacity); // Blue
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
 
// Right face (x = 1.0f)
glColor4f(1.0f, 0.0f, 1.0f,opacity); // Magenta
glVertex3f(1.0f, 1.0f, -1.0f);
glVertex3f(1.0f, 1.0f, 1.0f);
glVertex3f(1.0f, -1.0f, 1.0f);
glVertex3f(1.0f, -1.0f, -1.0f);
glEnd();
 
// Render a pyramid
glTranslatef(-1.5f, 0.0f, -6.0f); // Move
 
glBegin(GL_TRIANGLES);
// Front
glColor4f(1.0f, 0.0f, 0.0f,opacity); // Red
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor4f(0.0f, 1.0f, 0.0f,opacity); // Green
glVertex3f(-1.0f, -1.0f, 1.0f);
glColor4f(0.0f, 0.0f, 1.0f,opacity); // Blue
glVertex3f(1.0f, -1.0f, 1.0f);
 
// Right
glColor4f(1.0f, 0.0f, 0.0f,opacity); // Red
glVertex3f(0.0f, 1.0f, 0.0f);
glColor4f(0.0f, 0.0f, 1.0f,opacity); // Blue
glVertex3f(1.0f, -1.0f, 1.0f);
glColor4f(0.0f, 1.0f, 0.0f,opacity); // Green
glVertex3f(1.0f, -1.0f, -1.0f);
 
// Back
glColor4f(1.0f, 0.0f, 0.0f,opacity); // Red
glVertex3f(0.0f, 1.0f, 0.0f);
glColor4f(0.0f, 1.0f, 0.0f,opacity); // Green
glVertex3f(1.0f, -1.0f, -1.0f);
glColor4f(0.0f, 0.0f, 1.0f,opacity); // Blue
glVertex3f(-1.0f, -1.0f, -1.0f);
 
// Left
glColor4f(1.0f,0.0f,0.0f,opacity); // Red
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor4f(0.0f,0.0f,1.0f,opacity); // Blue
glVertex3f(-1.0f,-1.0f,-1.0f);
glColor4f(0.0f,1.0f,0.0f,opacity); // Green
glVertex3f(-1.0f,-1.0f, 1.0f);
glEnd();
}

 

2020 - 2025 © Site by LetiMix  |  Plug'n Script and KUIML by Blue Cat Audio