Interface PrimitiveManagerBoxInterface

The PrimitiveManagerBoxInterface is used to display 3D boxes on top of the DMU, with a rendering hint depending on the relative depth between the 3D boxes and the geometries.

The PrimitiveManagerBoxInterface is accessed through the PrimitiveManagerInterface.getBoxManager function (the PrimitiveManagerInterface is accessed through InfiniteEngineInterface.getPrimitiveManager).

A 3D box is an axis aligned box, consisting of 12 lines, and 6 faces. Rendered 3D boxes are manipulated through their ids (and not a dedicated object), indeed each box is assigned a strictly positive integer id that will represent it. 0 is an invalid box id.

The colors of the 3D boxes are 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 boxes !!!

box display
Creating a 3D box may be done with the following :
/** 
* Sample to explain how to create 3d boxes on top of the rendering (PrimitiveManagerBoxInterface).
*/
import { InfiniteEngineInterface, PrimitiveManagerMaterialInterface, PrimitiveManagerBoxInterface, Vector4, Vector3 } from 'generated_files/documentation/appinfiniteapi';

// created previously
let lInfiniteEngine : InfiniteEngineInterface;
// created previously, the box center
let lBoxCenter : Vector3;
// created previously, the box half extent in x,y,z
let lBoxHalfExtent : Vector3;

// the material edges of the box
let lEdgeColorMaterial : number = -1;
// the material for the faces of the box
let lFaceColorMaterial : number = -1;
// the primitive material manager
const lPrimitiveMaterialManager : PrimitiveManagerMaterialInterface = lInfiniteEngine.getPrimitiveManager().getPrimitiveMaterialManager();
// the box manager
const lBoxManager : PrimitiveManagerBoxInterface = lInfiniteEngine.getPrimitiveManager().getBoxManager();

// face color is white opaque (1 as last parameter)
const lFaceColor : Vector4 = new Vector4(1, 1, 1, 1);
// edge color is red semi transparent (0.5 as last parameter)
const lEdgeColor : Vector4 = new Vector4(1, 0, 0, 0.5);

// create materials
lFaceColorMaterial = lPrimitiveMaterialManager.createPrimitiveMaterial(lFaceColor);
lEdgeColorMaterial = lPrimitiveMaterialManager.createPrimitiveMaterial(lEdgeColor);

// and create the box
const lBoxId : number = lBoxManager.createBox(
// center, half extent
lBoxCenter,
lBoxHalfExtent,
// colors
lEdgeColorMaterial,
lFaceColorMaterial,
// line width
5
);

console.log('Box id is ' + lBoxId);

You may create also lines, points, etc with PrimitiveManagerLineInterface, PrimitiveManagerPointInterface, etc.
3D Primitives

interface PrimitiveManagerBoxInterface {
    createBox(pBoxCenter, pHalfExtent, pLineMaterialId, pFaceMaterialId, pLineWidth): number;
    getBoxCenter(pBoxId, pBoxCenterOut): boolean;
    getBoxFaceMaterial(pBoxId): number;
    getBoxHalfExtent(pBoxId, pBoxExtentOut): boolean;
    getBoxLineMaterial(pBoxId): number;
    getBoxLineWidth(pBoxId): number;
    getBoxes(pBoxes): boolean;
    getBoxesCount(): number;
    isBoxVisible(pBoxId): boolean;
    removeAllBoxes(): void;
    removeBox(pBoxId): boolean;
    setBoxGeometry(pBoxId, pCenter, pHalfExtent, pLineWidth): boolean;
    setBoxMaterial(pBoxId, pLineMaterialId, pFaceMaterialId): boolean;
    setBoxVisible(pBoxId, pVisible): boolean;
}

Methods

  • Creates a new 3D box at the given position with the given size.

    A 3D box is an axis aligned box, consisting of 12 lines, and 6 faces.
    The width of the lines, the color of the lines, the color of the faces are set by the user.
    The box is assigned a strictly positive id that will represent this box from now on. 0 is an invalid box id. Please note that this id will be reused if the box is removed and another created again.
    Before creating a box, materials to render this box must be created in the PrimitiveManagerMaterialInterface.

    Parameters

    • pBoxCenter: Vector3
      in
      The 3D position of the center of the box.
    • pHalfExtent: Vector3
      in
      The half extent of the box.
    • pLineMaterialId: number
      in
      The material that will be used to draw lines (primitive material id).
    • pFaceMaterialId: number
      in
      The material that will be used to draw the faces (primitive material id).
    • pLineWidth: number
      in
      The width of the lines in pixels.

    Returns number

    The id of the created box.

  • Gets the position of the center of the given box.

    If found, pBoxCenterOut is updated. Returns true if the box is found and therefore pBoxCenterOut is updated.

    Parameters

    • pBoxId: number
      in
      the id of the box to query.
    • pBoxCenterOut: Vector3
      out
      the center of the box.

    Returns boolean

    true if pBoxCenterOut is updated.

  • Gets the primitive material id used to render the faces of the given box.

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

    Parameters

    • pBoxId: number
      in
      The id of the box to query.

    Returns number

    The primitive material id used to render the faces of the box.

  • Gets the half extents of the given box.

    If found, pBoxExtentOut is updated. Returns true if the box is found and therefore pBoxExtentOut is updated.

    Parameters

    • pBoxId: number
      in
      The id of the box to query.
    • pBoxExtentOut: Vector3
      out
      The half extent of the box.

    Returns boolean

    true if pBoxExtentOut was updated.

  • Gets the primitive material id used to render the lines of the given box.

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

    Parameters

    • pBoxId: number
      in
      The id of the box to query.

    Returns number

    The primitive material id used to render the lines of the box.

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

    Returns 0 if the box was not found.

    Parameters

    • pBoxId: number
      in
      The id of the box to query.

    Returns number

    The line width in pixels used to render the lines of the box.

  • Gets all the created box ids.

    Parameters

    • pBoxes: number[]
      out
      The resulting box ids.

    Returns boolean

    trueif the call succeeded.

  • Gets the actual number of rendered boxes.

    Returns number

    The number of drawn boxes.

  • Tells if the given box is visible.

    Returns false if the box does not exists or is setBoxVisible with false has been called.

    Parameters

    • pBoxId: number
      in
      The id of the box to query.

    Returns boolean

    true if the box exists and is visible.

  • Removes all the boxes.

    Returns void

  • Removes the box with the given id.

    Parameters

    • pBoxId: number
      in
      The id of the box to remove.

    Returns boolean

    true if the box exists and therefore is removed.

  • Updates the shape of the given box, by changing the center, the half extent and the line width.

    Returns true if the box was updated.

    Parameters

    • pBoxId: number
      in
      The id of the box to change.
    • pCenter: Vector3
      in
      The new center of the box.
    • pHalfExtent: Vector3
      in
      The new half extent of the box.
    • pLineWidth: number
      in
      The new line width in pixels of the lines of the box.

    Returns boolean

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

  • Updates the rendering of the given box, by changing the colors of the lines and the faces.

    Returns true if the box was updated.

    Parameters

    • pBoxId: number
      in
      The id of the box to change.
    • pLineMaterialId: number
      in
      The primitive material id to be used to draw the lines of the box.
    • pFaceMaterialId: number
      in
      The primitive material id to be used to draw the faces of the box.

    Returns boolean

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

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

    Returns true if the box was updated.

    Parameters

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

    Returns boolean

    true if the box exists.