Viewer3D refactoring

kerautret edited this page Jun 25, 2012 · 23 revisions

Discussion on the new design of Display3D/Viewer3D


  • Be able to display fundamental objects (point,..)

  • Be able to display complex shapes (digitalsurface as a true surface, ...)

  • Keep Mode/Style things as designed for Board2D

  • Have a general notion of 3D Scenes

    • camera/light models
    • possibility to export the scene (VrML, x3D,xml,...)
  • Interactors

    • be able to click on the viewer and to get the associated geometrical elements
      • eg. for point we get a point, for surface (clicking on a bel) -> bel (or iterator on the bel)
    • to be able to move selected bel through iterator on surface with keyboard (It was fine with previous work with QGLviewer and ImaGene) (BK).
    • update colors/properties of an element online
    • to associate a callback to a given primitive and event. For each primitive, the targeted element should be returned.
  • Loading exported set of primitive using boost serialization ? (I tested with imagine it was very efficient).

  • Export scene in pdf3d ;)

  • Export for display with webGL for html 5 display.

  • Animators

    • ...
  • Styles in 3D

    • related to diffuse/specular colors, brightness, normals, texture ?
    • e.g., we should be able to give a function f: cell -> Color to specify the color of each cell of a given surface, same for normals
    • I am not sure that the 2D style mechanism can be translated as is.


For any model of CDrawable...3D

  • draw method
  • defaultStyle
  • marker (aka ID) (or a tree of marker for recursively drawn object)
  • have to possiblity to create a "callback" on a marker (callback to be called when picking)

What has been done so far:

First design of the Viewer3D base on Ogre3D:

The viewer is composed of an input listenner, a main class coordinating the different events and a Tree representing the Scene.

The Tree is a DGtal representation of the ogre tree nodes.

Here is the two main classes that composes the DGtalScene.

DGtalNode : It's as the name refers to it a node of the tree. It's composed by :

  • A TDrawableWithDisplay3D object, it's a form that we can display. Going from fundamental objects (Voxel, surfel, lignel, pointel,etc.) to more complex shapes ( A DGtal surface ..).

  • A Representation (Defined just below).

  • A Pointer to his parent node.

  • A list of his son nodes.

  • A Pointer to the upper node of the tree of his branch that is not the RootNode (I'll name it U.N.T.N.R.N).

Representation : It's a structure that contains every object, attribute that is related to the Ogre representation of this Object. It contains:

  • A pointer on the Ogre Node.

  • A pointer on the Ogre entity.

  • A string wich describes wich texture is currently applied to it.

  • The name of this object

  • The representation mode.

Viewer3D (the main class) : Is the part of the program that permits a syncronisation between, events, creations, the OgreScene and the DGtalScene. it contains

  • A bunch of Ogre attributes ( not interesting i guess).

  • A pointer on the tree.

  • A pointer on the current selected DGtalNode.

  • A pointer on the U.N.T.N.R.N(if you don't get what this is, look up of it's definition ).

Here is a little scheme that represents the UML strcture of the viewer:


BK edit:

=> OK, but we could also add a way to handle actions which are detected from the InputListener and transmitted to the Viewer3D. Perhaps adding a concept like: "CActionHandler" with methods:

  • 'actionSelectedObject()'
  • 'actionKeyStrokeEvent()'
  • Primitive type

By this way, it will be possible to apply particular algorithm to specific elements (recovered after associating maker (ID)). The class which wants apply the particular processing has to follows the concept "CActionHandler" and could be connected to the viewer using always the operator "<<". For instance, to apply a plane recognition algorithm to a particular voxel, we can just include the previous methods to follow the concept "CActionHandler" and connect it to the viewer as follows:

View << shapeSet ;

View << actionPlaneRecognition;

with the methods actionSelectedObject(), actionKeyStrokeEvent() and actionMouseEvent(). Then the viewer will be able to potentially call these methods with parameters associated to the primitive makers.

Here is a little graph that represents the paralelism between the two Worlds ( the Dgtal one and the Ogre one). Graph

Example of interations that has been done so far : Here is the code that generates this scene:


BK edit :

On Click:

On clicking , the Input listenner sends a order to the viewer to look for the object that matches with the mouse coordinates. The viewer does a ray tracing and gives back a list of concerned object, for each of the objects, we get it's position (in fact the node's, but not important), then we look up in the tree to found the matching Representation (so the DGtalNode), and we set the current selection to it. If nothing matches that click, nothing is selected any more.

We can also use a notion of "cursor" or "selector" in Viewer3D in order to process interaction and providing a way to an ActionHandler to get the current selected element or to set a new current cursor to another primitive. And then the Viewer3D has to perform the highlighted visualization of the current cursor and update it after a cursor change (for instance: view << selector(markerID)).

Fly mode:

The user has the possibility to interact with the world in two ways : 
	* ViewerMode, very similar to the one in the actual viewer.
  	* FlyMode , if you use shift mode you can fly arround in the scene so you can change the camera position and angle more easily.

Some picture to what has been done to now.


Screen 1

Screen 2

Screen 3

Fly Mode:

Screen 4

Design/ Developpement difficultés:

BK edit:

Each DGtalNode represents a Complex ou fundamental DGtal object, then it has an attribute of general type "DGtalObject but as TDrawableWith3D is not a class, there is no possible virtual class to the pointer in the DGtalNode: Maybe if you have an advice about it.

=> We can include the boost concept check with BOOST_CONCEPT_ASSERT( CDrawableWithDisplay3D ).