Interface PrimitiveManagerLineInterface

The PrimitiveManagerLineInterface is used to display 3D lines on top of the DMU.

The PrimitiveManagerLineInterface is accessed through the PrimitiveManagerInterface.getLineManager function (the PrimitiveManagerInterface is accessed through InfiniteEngineInterface.getPrimitiveManager).

A 3D line is defined as a segment, thus with two 3D points. Rendered 3D lines are manipulated through their ids (and not a dedicated object), indeed each line is assigned a strictly positive integer id that will represent it. 0 is an invalid line id.

The color of the 3D line is handled by the PrimitiveManagerMaterialInterface, accessed through PrimitiveManagerInterface.getPrimitiveMaterialManager. Materials are accessed by their ids, and modified by their ids. 3D primitives are rendered colored with their primitive material id, and not directly from a color.
WARNING : do not confuse the PrimitiveManagerMaterialInterface and the MaterialManagerInterface, these two interfaces are separated, do not use MaterialManagerInterface ids to draw lines !!!

line display

Creating a 3D line may be done with the following :

/** 
* Sample to explain how to create 3d lines on top of the rendering (PrimitiveManagerLineInterface).
*/
import { InfiniteEngineInterface, PrimitiveManagerMaterialInterface, PrimitiveManagerLineInterface, Vector4, Vector3 } from 'generated_files/documentation/appinfiniteapi';

// created previously
let lInfiniteEngine : InfiniteEngineInterface;
// created previously, the segment point position 1
let lLinePosition1 : Vector3;
// created previously, the segment point position 2
let lLinePosition2 : Vector3;

// the material for the line color
let lLineColorMaterial : number = -1;
// the primitive material manager
const lPrimitiveMaterialManager : PrimitiveManagerMaterialInterface = lInfiniteEngine.getPrimitiveManager().getPrimitiveMaterialManager();
// the line manager
const lLineManager : PrimitiveManagerLineInterface = lInfiniteEngine.getPrimitiveManager().getLineManager();
// line color is white opaque (1 as last parameter)
const lLineColor : Vector4 = new Vector4(1, 1, 1, 1);

// create material
lLineColorMaterial = lPrimitiveMaterialManager.createPrimitiveMaterial(lLineColor);

// and create the line
const lLineId : number = lLineManager.createLine(
// segment extents
lLinePosition1,
lLinePosition2,
lLineColorMaterial,
// line width
5
);

console.log('Line id is ' + lLineId);

You may create also boxes, points, etc with PrimitiveManagerBoxInterface, PrimitiveManagerPointInterface, etc.
3D Primitives

interface PrimitiveManagerLineInterface {
    createLine(pPointA, pPointB, pLineMaterialId, pLineWidth): number;
    getLineMaterial(pLineId): number;
    getLinePointA(pLineId, pPointAOut): boolean;
    getLinePointB(pLineId, pPointBOut): boolean;
    getLineWidth(pLineId): number;
    getLines(pLines): boolean;
    getLinesCount(): number;
    isLineVisible(pLineId): boolean;
    removeAllLines(): void;
    removeLine(pLineId): boolean;
    setLineGeometry(pLineId, pPointA, pPointB, pLineWidth): boolean;
    setLineMaterial(pLineId, pLineMaterialId): boolean;
    setLineVisible(pLineId, pVisible): boolean;
}

Methods

  • Creates a new line given two points positions (extents of the segment), A and B, with a given width in pixels.

    The width in pixels and the color of the line are set by the user.
    The line is assigned a strictly positive id that will represent this line from now on. 0 is an invalid line id. Please note that this id will be reused if the line is removed and another created again.
    Before creating a line, materials to render this line must be created in the PrimitiveManagerMaterialInterface.

    Parameters

    • pPointA: Vector3
      in
      The 3D position of the A point of the line.
    • pPointB: Vector3
      in
      The 3D position of the B point of the line.
    • pLineMaterialId: number
      in
      The material that will be used to draw the line (primitive material id).
    • pLineWidth: number
      in
      The width of the line in pixels.

    Returns number

    The id of the created line.

  • Gets the primitive material id used to render the given line.

    Returns 0 if a line with the given id does not exist.

    Parameters

    • pLineId: number
      in
      The id of the line to query.

    Returns number

    The primitive material id used to render the line.

  • Gets the A point (origin) of the given line.

    If found, pPointAOut is updated. Returns true if the line is found and therefore pPointAOut is updated.

    Parameters

    • pLineId: number
      in
      The id of the line to query.
    • pPointAOut: Vector3
      out
      The A point of the line.

    Returns boolean

    true if pPointAOut was updated.

  • Gets the B point (other end) of the given line.

    If found, pPointBOut is updated. Returns true if the line is found and therefore pPointBOut is updated.

    Parameters

    • pLineId: number
      in
      The id of the line to query.
    • pPointBOut: Vector3
      out
      The B point of the line.

    Returns boolean

    true if pPointBOut was updated.

  • Gets the line width in pixels used to render the given line.

    Returns 0 if a line with the given id does not exist.

    Parameters

    • pLineId: number
      in
      The id of the line to query.

    Returns number

    The line width in pixels used to render the line.

  • Gets all the created line ids.

    Parameters

    • pLines: number[]
      out
      The resulting line ids.

    Returns boolean

    trueif the call succeeded.

  • Gets the actual number of rendered lines.

    Returns number

    The number of lines drawn.

  • Tells if the given line is visible.

    Returns false if the line does not exists or is setLineVisible with false has been called.

    Parameters

    • pLineId: number
      in
      The id of the line to query.

    Returns boolean

    true if the line exists and is visible.

  • Removes all the lines.

    Returns void

  • Removes the line with the given id.

    Parameters

    • pLineId: number
      in
      The id of the line to remove.

    Returns boolean

    true if the line exists and therefore is removed.

  • Updates the shape of the given line, by changing the extents and the line width.

    Returns true if the line was updated.

    Parameters

    • pLineId: number
      in
      The id of the line to change.
    • pPointA: Vector3
      in
      The new 3D position of the A point (origin).
    • pPointB: Vector3
      in
      The new 3D position of the B point (other end).
    • pLineWidth: number
      in
      The new line width in pixels.

    Returns boolean

    true if the line was found and therefore the line rendering is updated.

  • Updates the rendering of the given line, by changing the color of the line.

    Returns true if the line was updated.

    Parameters

    • pLineId: number
      in
      The id of the line to change.
    • pLineMaterialId: number
      in
      The primitive material id to be used to draw the line.

    Returns boolean

    true if the line was found, if the materials exist and therefore the line rendering is updated.

  • Updates the rendering of the given line, by changing its visibility.

    Returns true if the line was updated.

    Parameters

    • pLineId: number
      in
      The id of the line to change.
    • pVisible: boolean
      in
      The new visibility state of the line.

    Returns boolean

    true if the line exists.