Any advice for integrating OCCT into Unreal (or similar) engine?

I would like to use OCCT with the Unreal Engine (or possibly similar Cpp-based engines). Would anyone have any advice on how this could be accomplished given that these engines have their own scene graphs and rendering pipelines? Is there a low level in OCCT where one could hope to do a reasonably high performance conversion to the engine's low-level format? If OCCT is not suitable for this kind of integration, are there any suggestions for other geometry kernels which would be?

TIA for any enlightenment,

Adrian

 

Kirill Gavrilov's picture

Integration of two engines have the following kind of issues:

  • Combining low level rendering code - the same library (OpenGL / Direct3D / Vulkan) should be used.
    Different libraries are also possible, but very tricky.
  • Camera definition synchronization.
    To interleave 3D objects in the same view, the projection matrices should be the same.
  • Multi-pass rendering.
    Modern engines implements multi-pass rendering engines, including OCCT 3D viewer.
    If application needs to insert custom low-level rendering code - it is more or less straightforward for OCCT 3D Viewer;
    but combining two independent engines both using with multi-pass techniques might be too tricky.
    You have to know how rendering works in both engines.
  • Combining effects.
    Effects like shadows, reflections and others will not work correctly for objects existing in different engines,
    because such effects require information about entire geometry.

OCCT 3D viewer is based on OpenGL or OpenGL ES - this is first thing you should worry when checking that to renderers could co-exist.
Combining Direct3D with OpenGL is also possible (OCCT provides sample for integrating OpenGL-based 3D viewer into WPF application through WGL_NV_DX_interop extension, since WPF supports only Direct3D 9 surface), however this way comes with extra problems and compatibility issues, and OCCT 3D Viewer can also use OpenGL ES on Windows through Angle project - working on top of Direct3D.

So, integrating OCCT 3D Viewer into another renderer is technically possible - example is integrating OCCT 3D Viewer into QtQuick (Qt/QML) application, where Qt is used for rendering user interface on top of 3D Viewer (see CAD Assistant), the oppissite is also possible - OCCT 3D Viewer provides interfaces for embedding low-level rendering commands. However for such combination another rendering engine should support such kind of co-existing.

Of course, you can also use OCCT only as modeling kernel - so that OCCT will generate model and prepare triangulation but visualization will be performed by preferred 3D rendering engine.

Guido van Hilst not specified's picture

Hi,

I have made an webgl 3D viewer based on threejs, to show opencascade topods objects in the browser.

Here are some examples:

Make a bottle

Normal of faces

You could do the same for showing TopoDS object on a different view.

Best regards, Guido

Christian Schormann's picture

Hi Kirill,

I have been looking at using OCCT for modeling only. I have a couple of questions though:

  • If I use OCCT for modeling only, what is the best way to retrieve the triangular meshes?
  • Is there a way to also get edges for wireframe (on the brep level, not the triangle mesh) level, and for edge highlighting?
  • When using OCCT for modeling only, how would you suggest I do interactive selection? Especially, if I want to do edge selection too?
  • It seems that the built-in selection facilities cannot really be used independently of the viewer, or at least it seems a non-trivial task to use them without a viewer. 
  • Ideally, I'd like to have a selection function that i can provide a ray to (a location and direction in 3D space, not a 2D mouse position), and that returns me the closest hit with either a face or an edge etc. on OCCT objects in the scene.

Thanks a lot!

    CS  

Kirill Gavrilov's picture
  • If I use OCCT for modeling only, what is the best way to retrieve the triangular meshes?
  • Is there a way to also get edges for wireframe (on the brep level, not the triangle mesh) level

Retrieving triangles is more or less straightforward - I think this forum contains some code snippets on this topic.
I would say that using StdPrs facilities would be the best option in case if look-n-feel of Wireframe (StdPrs_WFShape, StdPrs_Isolines) and Shaded (StdPrs_ShadedShape) presentations of OCCT 3D Viewer is what you are looking for, but it might be tricky using them outside without copy-paste.

  • It seems that the built-in selection facilities cannot really be used independently of the viewer

Actually low-level Selection logic is implemented independently from visualization in OCCT, so that it can be reused for another viewer, although indeed, it is not trivial. IVtk component is an example of such synergy of OCCT selection (SelectMgr_ViewerSelector) and VTK visualization.