This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

engine.visualizer Functions

This set of functions controls visualizer-related settings. The visualizer allows to render mesh wireframe, object bounding boxes, and all sorts of visual helpers (such as physical collision shapes, joints etc).

  • 3D visualizer (engine.visualizer.render*3D()) is rendered based on scene depth.
  • 2D visualizer (engine.visualizer.render*2D()) is rendered atop of everything else.

To render 3D objects atop of the scene, you can transform 3D space coordinates into screen space and render lines and triangles using 2D visualizer functions.

Rendering Visualizer

By default, in-game the visualizer uses a projection and model-view matrix from the previous frame rather than the current one. (in the editor, visualizer is updated automatically.)

Before calling any of engine.visualizer.render*() functions, you need to update these matrices first based on the current in-game player:

Source code (UnigineScript)
// my_world.cpp

Player player;  // In-game camera.

int init() {

player = new PlayerSpectator();   // Create a new player
engine.game.setPlayer(player);	// used in the game.

...

return 1;
}

int update() {

// The player position is updated.
...  

// 1. Get the player's projection and model-view matrices for the current frame.
mat4 projection = player.getProjection();
mat4 modelview = player.getModelview();

// 2. Update the projection and model-view matrices used by the visualizer.
engine.visualizer.setProjection(projection);
engine.visualizer.setModelview(modelview);

// 3. Call a rendering function.
engine.visualizer.renderVector(vec3_zero,vec3(1.0f,0.0f,0.0f),vec4_one);

return 1;
}

mat4 engine.visualizer.getModelview ()

Returns the current modelview matrix of the visualizer. This matrix prevents the desynchronization between the visualizer and the render. It is set after the camera update in the editor.

Return value

The modelview matrix

mat4 engine.visualizer.getProjection ()

Returns the current projection matrix of the visualizer.

Return value

Projection matrix.

float engine.visualizer.getScale (vec3 vector)

Returns a factor, by which a given vector should be scaled to match the current handler size.

Arguments

  • vec3 vector - Vector to normalize.

Return value

Scaling factor.

int engine.visualizer.getSize ()

Returns the handler size. All handlers have the same size. The default is 16 pixels.

Return value

Size of a handler in pixels.

string engine.visualizer.getTextureName ()

Returns the string with the name of the texture.

Return value

Name of the texture.

int engine.visualizer.isEnabled ()

Returns a value indicating if visualization of helper objects like handlers and bound boxes is enabled.

Return value

Positive number if visualization is enabled; otherwise, 0.

void engine.visualizer.renderBillboard3D (vec3 v, float size, vec4 texcoord)

Renders a 3D billboard of the specified size.

Arguments

  • vec3 v - Dimensions of the box.
  • float size - Billboard size.
  • vec4 texcoord - Texture coordinates.

void engine.visualizer.renderBoundBox (vec3 min, vec3 max, mat4 transform, vec4 color)

Renders a bound box in a given color.

Arguments

  • vec3 min - Bound box minimum.
  • vec3 max - Bound box maximum.
  • mat4 transform - Transformation matrix for the bounding box.
  • vec4 color - Color, in which the box will be rendered.

void engine.visualizer.renderBoundSphere (vec3 center, float radius, mat4 transform, vec4 color)

Renders a bound sphere in a given color.

Arguments

  • vec3 center - Center of the bound sphere.
  • float radius - Radius of the bound sphere.
  • mat4 transform - Transformation matrix for the bounding sphere.
  • vec4 color - Color, in which the sphere will be rendered.

void engine.visualizer.renderBoxHandler (Node node, vec3 size, vec4 color)

Renders a handler in a form of a box.

Arguments

  • Node node - Node, for which the handler is rendered.
  • vec3 size - Dimensions of the box.
  • vec4 color - Color, in which the box will be rendered.

void engine.visualizer.renderBox (vec3 size, mat4 transform, vec4 color)

Renders a box in a given color.

Arguments

  • vec3 size - Dimensions of the box.
  • mat4 transform - Transformation matrix used to position the box.
  • vec4 color - Color, in which the box will be rendered.

void engine.visualizer.renderCapsule (float radius, float height, mat4 transform, vec4 color)

Renders a capsule (capped cylinder) in a given color.

Arguments

  • float radius - Radius of the capsule.
  • float height - Height of the capsule.
  • mat4 transform - Transformation matrix used to position the capsule.
  • vec4 color - Color, in which the capsule will be rendered.

void engine.visualizer.renderCircle (float radius, mat4 transform, vec4 color)

Renders a circle in a given color.

Arguments

  • float radius - Radius of the circle.
  • mat4 transform - Transformation matrix used to position the circle.
  • vec4 color - Color, in which the circle will be rendered.

void engine.visualizer.renderCone (float radius, float angle, mat4 transform, vec4 color)

Renders a cone in a given color.

Arguments

  • float radius - Radius of the cone.
  • float angle - Angle of the cone.
  • mat4 transform - Transformation matrix used to position the cone.
  • vec4 color - Color, in which the cone will be rendered.

void engine.visualizer.renderCylinder (float radius, float height, mat4 transform, vec4 color)

Renders a cylinder in a given color.

Arguments

  • float radius - Radius of the cylinder.
  • float height - Height of the cylinder.
  • mat4 transform - Transformation matrix used to position the cylinder.
  • vec4 color - Color, in which the cylinder will be rendered.

void engine.visualizer.renderDirection (vec3 position, vec3 direction, vec4 color)

Renders a direction vector in a given color.

Arguments

  • vec3 position - Position of the vector origin.
  • vec3 direction - Target direction.
  • vec4 color - Color, in which the vector will be rendered.

void engine.visualizer.renderEllipse (vec3 radius, mat4 transform, vec4 color)

Renders an ellipse in a given color.

Arguments

  • vec3 radius - Ellipse radius values along three axes.
  • mat4 transform - Transformation matrix for the ellipse.
  • vec4 color - Color, in which the box will be rendered.

void engine.visualizer.renderFrustum (mat4 projection, mat4 transform, vec4 color)

Renders a frustum in a given color.

Arguments

  • mat4 projection - Projection matrix used to transform the coordinates.
  • mat4 transform - Transformation matrix used to position the frustum.
  • vec4 color - Color, in which the frustum will be rendered.

void engine.visualizer.renderLightProbHandler (LightProb light, float radius, vec4 color)

Renders a colored light prob handler in a form of a sphere.

Arguments

  • LightProb light - Light prob, for which the handler is rendered.
  • float radius - Radius of the sphere.
  • vec4 color - Color, in which the sphere will be rendered.

void engine.visualizer.renderLine2D (vec3 v0, vec3 v1, vec3 v2, vec3 v3, vec4 color)

Renders a 2D line of a given color. 2D lines are rendered in the screen plane; coordinates of the upper left corner are (0; 0), of the lower right corner — (1; 1).

Arguments

  • vec3 v0 - Starting point of the line.
  • vec3 v1 - First intermediate point of the line.
  • vec3 v2 - Second intermediate point of the line.
  • vec3 v3 - Ending point of the line.
  • vec4 color - Color, in which the line will be rendered.

void engine.visualizer.renderLine2D (vec3 v0, vec3 v1, vec3 v2, vec4 color)

Renders a 2D line of a given color. 2D lines are rendered in the screen plane; coordinates of the upper left corner are (0; 0), of the lower right corner — (1; 1).

Arguments

  • vec3 v0 - Starting point of the line.
  • vec3 v1 - Intermediate point of the line.
  • vec3 v2 - Ending point of the line.
  • vec4 color - Color, in which the line will be rendered.

void engine.visualizer.renderLine2D (vec3 start, vec3 end, vec4 color)

Renders a 2D line in a given color. 2D lines are rendered in the screen plane; coordinates of the upper left corner are (0; 0), of the lower right corner—(1; 1).

Arguments

  • vec3 start - Starting point of the line.
  • vec3 end - Ending point of the line.
  • vec4 color - Color, in which the line will be rendered.

void engine.visualizer.renderLine3D (vec3 v0, vec3 v1, vec3 v2, vec3 v3, vec4 color)

Renders a 3D line in a given color. 3D lines are rendered in the world space.

Arguments

  • vec3 v0 - Starting point of the line.
  • vec3 v1 - First intermediate point of the line.
  • vec3 v2 - Second intermediate point of the line.
  • vec3 v3 - Ending point of the line.
  • vec4 color - Color, in which the line will be rendered.

void engine.visualizer.renderLine3D (vec3 v0, vec3 v1, vec3 v2, vec4 color)

Renders a 3D line in a given color. 3D lines are rendered in the world space.

Arguments

  • vec3 v0 - Starting point of the line.
  • vec3 v1 - Intermediate point of the line.
  • vec3 v2 - Ending point of the line.
  • vec4 color - Color, in which the line will be rendered.

void engine.visualizer.renderLine3D (vec3 start, vec3 end, vec4 color)

Renders a 3D line in a given color. 3D lines are rendered in the world space.

Arguments

  • vec3 start - Starting point of the line.
  • vec3 end - Ending point of the line.
  • vec4 color - Color, in which the line will be rendered.

void engine.visualizer.renderMessage2D (vec3 position, vec3 center, string str, vec4 color, int outline)

Renders a message in a given color. Message position is specified in screen coordinates.

Arguments

  • vec3 position - Anchor point of the message in range [0;1].
  • vec3 center - Message alignment. The first two values in the vector set the offset, the third one is ignored. For example, vec3(-1,-1,0) means the center of the message will be offset to its upper left edge. vec3(1,1,0) offsets the center to the lower right corner.
  • string str - Message to display.
  • vec4 color - Color, in which the message will be rendered.
  • int outline - 1 to use font outlining, 0 not to use.

void engine.visualizer.renderMessage3D (vec3 position, vec3 center, string str, vec4 color, int outline)

Renders a message in a given color. Message position is specified in world coordinates.

Arguments

  • vec3 position - Anchor point of the message.
  • vec3 center - Message alignment. The first two values in the vector set the offset, the third one is ignored. For example, vec3(-1,-1,0) means the center of the message will be offset to its upper left edge. vec3(1,1,0) offsets the center to the lower right corner.
  • string str - Message to display.
  • vec4 color - Color, in which the message will be rendered.
  • int outline - 1 to use font outlining, 0 not to use.

void engine.visualizer.renderNodeBoundBox (Node node, vec4 color)

Renders an axis-aligned bound box of a given node.

Arguments

  • Node node - Node, for which the bound box is rendered.
  • vec4 color - Color, in which the box will be rendered.

void engine.visualizer.renderNodeBoundSphere (Node node, vec4 color)

Renders a bound sphere of a given node.

Arguments

  • Node node - Node, for which the bound sphere is rendered.
  • vec4 color - Color, in which the sphere will be rendered.

void engine.visualizer.renderObjectSurfaceBoundBox (Object object, int surface, vec4 color)

Renders a bound box of a given object surface.

Arguments

  • Object object - Object, which contains the target surface.
  • int surface - ID number of the target surface in the object.
  • vec4 color - Color, in which the box will be rendered.

void engine.visualizer.renderObjectSurfaceBoundSphere (Object object, int surface, vec4 color)

Renders a bound sphere of a given object surface.

Arguments

  • Object object - Object, which contains the target surface.
  • int surface - ID number of the target surface in the object.
  • vec4 color - Color, in which the sphere will be rendered.

void engine.visualizer.renderObjectSurface (Object object, int surface, vec4 color)

Renders borders of a given object surface.

Arguments

  • Object object - Object, which contains the target surface.
  • int surface - ID number of the target surface in the object.
  • vec4 color - Color, in which the borders will be rendered.

void engine.visualizer.renderObject (Object object, vec4 color)

Renders an object wireframe.

Arguments

  • Object object - Object, which wireframe will be rendered.
  • vec4 color - Color, in which the wireframe will be rendered.

void engine.visualizer.renderPoint2D (vec3 coordinates, float size, vec4 color)

Renders a 2D point in a given color. 2D points are rendered in the screen plane; coordinates of the upper left corner are (0; 0), of the lower right corner—(1; 1).

Arguments

  • vec3 coordinates - Point coordinates.
  • float size - Point size.
  • vec4 color - Color, in which the point will be rendered.

void engine.visualizer.renderPoint3D (vec3 coordinates, float size, vec4 color)

Renders a 3D point in a given color. 3D points are rendered in the world space.

Arguments

  • vec3 coordinates - Point coordinates.
  • float size - Point size.
  • vec4 color - Color, in which the point will be rendered.

void engine.visualizer.renderQuad2D (vec3 vertex0, vec3 vertex1, vec3 vertex2, vec3 vertex3, vec4 color)

Renders a 2D quad in a given color. 2D quads are rendered in the screen plane; coordinates of the upper left corner are (0; 0), of the lower right corner—(1; 1).

Arguments

  • vec3 vertex0 - Coordinates of the first vertex.
  • vec3 vertex1 - Coordinates of the second vertex.
  • vec3 vertex2 - Coordinates of the third vertex.
  • vec3 vertex3 - Coordinates of the fourth vertex.
  • vec4 color - Color, in which the quad will be rendered.

void engine.visualizer.renderQuad3D (vec3 vertex0, vec3 vertex1, vec3 vertex2, vec3 vertex3, vec4 color)

Renders a 3D quad in a given color. 3D quads are rendered in the world space.

Arguments

  • vec3 vertex0 - Coordinates of the first vertex.
  • vec3 vertex1 - Coordinates of the second vertex.
  • vec3 vertex2 - Coordinates of the third vertex.
  • vec3 vertex3 - Coordinates of the fourth vertex.
  • vec4 color - Color, in which the quad will be rendered.

void engine.visualizer.renderSector (float radius, float angle, mat4 transform, vec4 color)

Renders a sector of the circle in a given color.

Arguments

  • float radius - Radius of the circle from which a sector will be cut.
  • float angle - Angle of the sector.
  • mat4 transform - Transformation matrix used to position the sector.
  • vec4 color - Color, in which the sector will be rendered.

void engine.visualizer.renderSolidBox (vec3 size, mat4 transform, vec4 color)

Renders a solid box in a given color.

Arguments

  • vec3 size - Size of the solid box.
  • mat4 transform - Transformation matrix used to position the solid box.
  • vec4 color - Color, in which the solid box will be rendered.

void engine.visualizer.renderSolidCapsule (float radius, float height, mat4 transform, vec4 color)

Renders a solidly colored capsule.

Arguments

  • float radius - Radius of the capsule.
  • float height - Height of the capsule.
  • mat4 transform - Transformation matrix used to position the capsule.
  • vec4 color - Color, in which the capsule will be rendered.

void engine.visualizer.renderSolidCylinder (float radius, float height, mat4 transform, vec4 color)

Renders a solidly colored cylinder.

Arguments

  • float radius - Radius of the cylinder.
  • float height - Height of the cylinder.
  • mat4 transform - Transformation matrix used to position the cylinder.
  • vec4 color - Color, in which the cylinder will be rendered.

void engine.visualizer.renderSolidEllipse (vec3 radius, mat4 transform, vec4 color)

Renders a solidly colored ellipse.

Arguments

  • vec3 radius - Ellipse radius values along three axes.
  • mat4 transform - Transformation matrix used to position the ellipse.
  • vec4 color - Color, in which the ellipse will be rendered.

void engine.visualizer.renderSolidSphere (float radius, mat4 transform, vec4 color)

Renders a solid sphere in a given color.

Arguments

  • float radius - Radius of the solid sphere.
  • mat4 transform - Transformation matrix used to position the solid sphere.
  • vec4 color - Color, in which the solid sphere will be rendered.

void engine.visualizer.renderSphereHandler (Node node, float radius, vec4 color)

Renders a node handler in a form of a sphere.

Arguments

  • Node node - Node, for which the handler is rendered.
  • float radius - Radius of the sphere.
  • vec4 color - Color, in which the sphere will be rendered.

void engine.visualizer.renderSphere (float radius, mat4 transform, vec4 color)

Renders a sphere in a given color.

Arguments

  • float radius - Radius of the sphere.
  • mat4 transform - Transformation matrix used to position the sphere.
  • vec4 color - Color, in which the sphere will be rendered.

void engine.visualizer.renderTextureHandler (Node node, float size)

Renders a texture handler of the specified size.

Arguments

  • Node node - Node pointer.
  • float size - Handler size.

void engine.visualizer.renderTriangle2D (vec3 vertex0, vec3 vertex1, vec3 vertex2, vec4 color)

Renders a 2D triangle in a given color. 2D triangles are rendered in the screen plane; coordinates of the upper left corner are (0; 0), of the lower right corner—(1; 1).

Arguments

  • vec3 vertex0 - Coordinates of the first vertex.
  • vec3 vertex1 - Coordinates of the second vertex.
  • vec3 vertex2 - Coordinates of the third vertex.
  • vec4 color - Color, in which the triangle will be rendered.

void engine.visualizer.renderTriangle3D (vec3 vertex0, vec3 vertex1, vec3 vertex2, vec4 color)

Renders a 3D triangle in a given color. 3D triangles are rendered in the world space.

Arguments

  • vec3 vertex0 - Coordinates of the first vertex.
  • vec3 vertex1 - Coordinates of the second vertex.
  • vec3 vertex2 - Coordinates of the third vertex.
  • vec4 color - Color, in which the triangle will be rendered.

void engine.visualizer.renderVector (vec3 position, vec3 vector, vec4 color)

Renders a vector in a given color.

Arguments

  • vec3 position - Position of the vector origin.
  • vec3 vector - Position of the end of the vector.
  • vec4 color - Color, in which the vector will be rendered.

void engine.visualizer.renderWorldSectorObjectSurfaces (WorldSector sector, vec4 color)

Renders objects wireframes inside a given sector.

Arguments

  • WorldSector sector - Sector, in which the object wireframes will be rendered.
  • vec4 color - Color, in which the wireframes will be rendered.

void engine.visualizer.setEnabled (int mode)

Enables or disables visualization of helper objects like handlers and bound boxes.

Arguments

  • int mode - Positive number to enable visualization of helper objects, 0 to disable it.

void engine.visualizer.setModelview (mat4 modelview)

Updates the modelview matrix of the visualizer. This matrix prevents the desynchronization between the visualizer and the render. It is set after the camera update in the editor.

Arguments

  • mat4 modelview - Modelview matrix.

void engine.visualizer.setProjection (mat4 projection)

Updates the projection matrix of the visualizer.

Arguments

  • mat4 projection - Projection matrix.

void engine.visualizer.setSize (int size)

Updates the current handler size.

Arguments

  • int size - New handler size in pixels.

void engine.visualizer.setTextureName (string name)

Updates the current name of the texture.

Arguments

  • string name - New name of the texture.
Last update: 2017-07-03
Build: ()