This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
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.

Visualizer Class

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;
}

Visualizer Class

Members


void 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 - The number of the target surface in the object.
  • vec4 color - Color, in which the box will be rendered.

void renderMessage2D (vec3 arg1, vec3 arg2, string arg3, vec4 arg4, int arg5)

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

Arguments

  • vec3 arg1 - Anchor point of the message in range [0;1].
  • vec3 arg2 - 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 arg3 - Message to display.
  • vec4 arg4 - Color, in which the message will be rendered.
  • int arg5 - 1 to use font outlining, 0 not to use.

void renderTriangle2D (vec3 arg1, vec3 arg2, vec3 arg3, vec4 arg4)

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 arg1 - Coordinates of the first vertex.
  • vec3 arg2 - Coordinates of the second vertex.
  • vec3 arg3 - Coordinates of the third vertex.
  • vec4 arg4 - Color, in which the triangle will be rendered.

void renderLine3D (Vec3 arg1, Vec3 arg2, Vec3 arg3, Vec3 arg4, vec4 arg5)

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

Arguments

  • Vec3 arg1 - Starting point of the line.
  • Vec3 arg2 - First intermediate point of the line.
  • Vec3 arg3 - Second intermediate point of the line.
  • Vec3 arg4 - Ending point of the line.
  • vec4 arg5 - Color, in which the line will be rendered.

void renderObjectSurface (Object object, int arg2, vec4 arg3)

Renders borders of a given object surface.

Arguments

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

void renderTriangle3D (Vec3 arg1, Vec3 arg2, Vec3 arg3, vec4 arg4)

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

Arguments

  • Vec3 arg1 - Coordinates of the first vertex.
  • Vec3 arg2 - Coordinates of the second vertex.
  • Vec3 arg3 - Coordinates of the third vertex.
  • vec4 arg4 - Color, in which the triangle will be rendered.

void renderLine2D (vec3 arg1, vec3 arg2, vec3 arg3, vec3 arg4, vec4 arg5)

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 arg1 - Starting point of the line.
  • vec3 arg2 - First intermediate point of the line.
  • vec3 arg3 - Second intermediate point of the line.
  • vec3 arg4 - Ending point of the line.
  • vec4 arg5 - Color, in which the line will be rendered.

void setSize (int size)

Updates the current handler size.

Arguments

  • int size - New handler size in pixels.

string getTextureName ()

Returns the string with the name of the texture.

Return value

Name of the texture.

void 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 - The number of the target surface in the object.
  • vec4 color - Color, in which the sphere will be rendered.

void renderSolidCapsule (float arg1, float arg2, Mat4 arg3, vec4 arg4)

Renders a solid-colored capsule.

Arguments

  • float arg1 - Radius of the capsule.
  • float arg2 - Height of the capsule.
  • Mat4 arg3 - Transformation matrix used to position the capsule.
  • vec4 arg4 - Color, in which the capsule will be rendered.

void renderObject (Object object, vec4 arg2)

Renders an object wireframe.

Arguments

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

void renderSolidObject (Object object, vec4 arg2)

Renders a solid-colored object.

Arguments

  • Object object - Object that will be rendered.
  • vec4 arg2 - Color in which the object will be rendered.

void renderPoint3D (Vec3 arg1, float arg2, vec4 arg3)

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

Arguments

  • Vec3 arg1 - Point coordinates.
  • float arg2 - Point size.
  • vec4 arg3 - Color, in which the point will be rendered.

void renderSolidBox (vec3 arg1, Mat4 arg2, vec4 arg3)

Renders a solid-colored box.

Arguments

  • vec3 arg1 - Size of the solid box.
  • Mat4 arg2 - Transformation matrix used to position the solid box.
  • vec4 arg3 - Color, in which the solid box will be rendered.

void renderLine3D (Vec3 arg1, Vec3 arg2, vec4 arg3)

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

Arguments

  • Vec3 arg1 - Starting point of the line.
  • Vec3 arg2 - First intermediate point of the line.
  • vec4 arg3 - Second intermediate point of the line.

void renderLine2D (vec3 arg1, vec3 arg2, vec4 arg3)

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 arg1 - Starting point of the line.
  • vec3 arg2 - First intermediate point of the line.
  • vec4 arg3 - Second intermediate point of the line.

void setTextureName (string name)

Updates the current name of the texture.

Arguments

  • string name - New name of the texture.

void renderCylinder (float arg1, float arg2, Mat4 arg3, vec4 arg4)

Renders a cylinder in a given color.

Arguments

  • float arg1 - Radius of the cylinder.
  • float arg2 - Height of the cylinder.
  • Mat4 arg3 - Transformation matrix used to position the cylinder.
  • vec4 arg4 - Color, in which the cylinder will be rendered.

void renderBillboard3D (Vec3 arg1, float arg2, vec4 arg3)

Renders a 3D billboard of the specified size.

Arguments

  • Vec3 arg1 - Dimensions of the box.
  • float arg2 - Billboard size.
  • vec4 arg3 - Texture coordinates.

void renderVector (Vec3 arg1, Vec3 arg2, vec4 arg3)

Renders a vector in a given color.

Arguments

  • Vec3 arg1 - Position of the vector origin.
  • Vec3 arg2 - Position of the end of the vector.
  • vec4 arg3 - Color, in which the vector will be rendered.

void renderSphere (float arg1, Mat4 arg2, vec4 arg3)

Renders a sphere in a given color.

Arguments

  • float arg1 - Radius of the sphere.
  • Mat4 arg2 - Transformation matrix used to position the sphere.
  • vec4 arg3 - Color, in which the sphere will be rendered.

mat4 getProjection ()

Returns the current projection matrix of the visualizer.

Return value

Projection matrix.

void renderFrustum (mat4 arg1, Mat4 arg2, vec4 arg3)

Renders a frustum in a given color.

Arguments

  • mat4 arg1 - Projection matrix used to transform the coordinates.
  • Mat4 arg2 - Transformation matrix used to position the frustum.
  • vec4 arg3 - Color, in which the frustum will be rendered.

void renderSolidSphere (float arg1, Mat4 arg2, vec4 arg3)

Renders a solid sphere in a given color.

Arguments

  • float arg1 - Radius of the solid sphere.
  • Mat4 arg2 - Transformation matrix used to position the solid sphere.
  • vec4 arg3 - Color, in which the solid sphere will be rendered.

Mat4 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

void renderCone (float arg1, float arg2, Mat4 arg3, vec4 arg4)

Renders a cone in a given color.

Arguments

  • float arg1 - Radius of the cone.
  • float arg2 - Angle of the cone.
  • Mat4 arg3 - Transformation matrix used to position the cone.
  • vec4 arg4 - Color, in which the cone will be rendered.

float getScale (Vec3 arg1)

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

Arguments

  • Vec3 arg1 - Vector to normalize.

Return value

Scaling factor.

void renderCapsule (float arg1, float arg2, Mat4 arg3, vec4 arg4)

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

Arguments

  • float arg1 - Radius of the capsule.
  • float arg2 - Height of the capsule.
  • Mat4 arg3 - Transformation matrix used to position the capsule.
  • vec4 arg4 - Color, in which the capsule will be rendered.

void renderTextureHandler (Node node, float arg2)

Renders a texture handler of the specified size.

Arguments

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

void 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 renderDirection (Vec3 arg1, vec3 arg2, vec4 arg3)

Renders a direction vector in a given color.

Arguments

  • Vec3 arg1 - Position of the vector origin.
  • vec3 arg2 - Target direction.
  • vec4 arg3 - Color, in which the vector will be rendered.

void renderSolidObjectSurface (Object object, int arg2, vec4 arg3)

Renders a solid-colored surface of a given object.

Arguments

  • Object object - Object that will be rendered.
  • int arg2 - The number of the object's surface.
  • vec4 arg3 - Color, in which the object's surface will be rendered.

void renderSolidCylinder (float arg1, float arg2, Mat4 arg3, vec4 arg4)

Renders a solid-colored cylinder.

Arguments

  • float arg1 - Radius of the cylinder.
  • float arg2 - Height of the cylinder.
  • Mat4 arg3 - Transformation matrix used to position the cylinder.
  • vec4 arg4 - Color, in which the cylinder will be rendered.

void setProjection (mat4 projection)

Updates the projection matrix of the visualizer.

Arguments

  • mat4 projection - Projection matrix.

void renderQuad2D (vec3 arg1, vec3 arg2, vec3 arg3, vec3 arg4, vec4 arg5)

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 arg1 - Coordinates of the first vertex.
  • vec3 arg2 - Coordinates of the second vertex.
  • vec3 arg3 - Coordinates of the third vertex.
  • vec3 arg4 - Coordinates of the fourth vertex.
  • vec4 arg5 - Color, in which the quad will be rendered.

void setEnabled (int enabled)

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

Arguments

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

void 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 renderLine2D (vec3 arg1, vec3 arg2, vec3 arg3, vec4 arg4)

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 arg1 - Starting point of the line.
  • vec3 arg2 - First intermediate point of the line.
  • vec3 arg3 - Second intermediate point of the line.
  • vec4 arg4 - Ending point of the line.

void renderLine3D (Vec3 arg1, Vec3 arg2, Vec3 arg3, vec4 arg4)

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

Arguments

  • Vec3 arg1 - Starting point of the line.
  • Vec3 arg2 - First intermediate point of the line.
  • Vec3 arg3 - Second intermediate point of the line.
  • vec4 arg4 - Ending point of the line.

void renderPoint2D (vec3 arg1, float arg2, vec4 arg3)

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 arg1 - Point coordinates.
  • float arg2 - Point size.
  • vec4 arg3 - Color, in which the point will be rendered.

void 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 renderSphereHandler (Node node, float arg2, vec4 arg3)

Renders a node handler in a form of a sphere.

Arguments

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

void renderSolidEllipse (vec3 arg1, Mat4 arg2, vec4 arg3)

Renders a solid-colored ellipse.

Arguments

  • vec3 arg1 - Ellipse radius values along three axes.
  • Mat4 arg2 - Transformation matrix used to position the ellipse.
  • vec4 arg3 - Color, in which the ellipse will be rendered.

void renderQuad3D (Vec3 arg1, Vec3 arg2, Vec3 arg3, Vec3 arg4, vec4 arg5)

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

Arguments

  • Vec3 arg1 - Coordinates of the first vertex.
  • Vec3 arg2 - Coordinates of the second vertex.
  • Vec3 arg3 - Coordinates of the third vertex.
  • Vec3 arg4 - Coordinates of the fourth vertex.
  • vec4 arg5 - Color, in which the quad will be rendered.

int 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 renderBox (vec3 arg1, Mat4 arg2, vec4 arg3)

Renders a box in a given color.

Arguments

  • vec3 arg1 - Dimensions of the box.
  • Mat4 arg2 - Transformation matrix used to position the box.
  • vec4 arg3 - Color, in which the box will be rendered.

int getSize ()

Returns the handler size. All handlers have the same size.

Return value

Size of a handler in pixels.

void renderCircle (float arg1, Mat4 arg2, vec4 arg3)

Renders a circle in a given color.

Arguments

  • float arg1 - Radius of the circle.
  • Mat4 arg2 - Transformation matrix used to position the circle.
  • vec4 arg3 - Color, in which the circle will be rendered.

void renderBoundSphere (BoundSphere bs, Mat4 transform, vec4 color)

Renders the bounding sphere in a given color.

Arguments

  • BoundSphere bs - The bounding sphere.
  • Mat4 transform - Transformation matrix for the bounding sphere.
  • vec4 color - Color, in which the sphere will be rendered.

void 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 renderSector (float arg1, float arg2, Mat4 arg3, vec4 arg4)

Renders a sector of the circle in a given color.

Arguments

  • float arg1 - Radius of the circle from which a sector will be cut.
  • float arg2 - Angle of the sector.
  • Mat4 arg3 - Transformation matrix used to position the sector.
  • vec4 arg4 - Color, in which the sector will be rendered.

void renderBoxHandler (Node node, vec3 arg2, vec4 arg3)

Renders a handler in a form of a box.

Arguments

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

void renderMessage3D (Vec3 arg1, vec3 arg2, string arg3, vec4 arg4, int arg5)

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

Arguments

  • Vec3 arg1 - Anchor point of the message.
  • vec3 arg2 - 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 arg3 - Message to display.
  • vec4 arg4 - Color, in which the message will be rendered.
  • int arg5 - 1 to use font outlining, 0 not to use.

void renderEllipse (vec3 arg1, Mat4 arg2, vec4 arg3)

Renders an ellipse in a given color.

Arguments

  • vec3 arg1 - Ellipse radius values along three axes.
  • Mat4 arg2 - Transformation matrix for the ellipse.
  • vec4 arg3 - Color, in which the box will be rendered.

void renderBoundBox (BoundBox bb, Mat4 transform, vec4 color)

Renders the bounding box in a given color.

Arguments

  • BoundBox bb - The bounding box.
  • Mat4 transform - Transformation matrix for the bounding box.
  • vec4 color - Color, in which the box will be rendered.

renderBillboard3D (Vec3 arg1, float arg2, vec4 arg3, int screen_space = 0)

Arguments

  • Vec3 arg1
  • float arg2
  • vec4 arg3
  • int screen_space

renderVector (Vec3 arg1, Vec3 arg2, vec4 arg3, float arrow_size = 0.25f, int screen_space = 0)

Arguments

  • Vec3 arg1
  • Vec3 arg2
  • vec4 arg3
  • float arrow_size
  • int screen_space

renderPoint3D (Vec3 arg1, float arg2, vec4 arg3, int screen_space = 0)

Arguments

  • Vec3 arg1
  • float arg2
  • vec4 arg3
  • int screen_space

renderTextureHandler (Node node, float arg2, int screen_space = 1)

Arguments

  • Node node
  • float arg2
  • int screen_space

renderDirection (Vec3 arg1, vec3 arg2, vec4 arg3, float arrow_size = 0.25f, int screen_space = 1)

Arguments

  • Vec3 arg1
  • vec3 arg2
  • vec4 arg3
  • float arrow_size
  • int screen_space
Last update: 2017-07-03
Build: ()