2D/3D

 

Organizing the Data

Many design-intent and MCAD applications need to display several views of a 3D model, with each view having a unique orientation and set of view-specific 2D annotations. These views may exist as part of an overall drawing that contains it's own annotation information, background color, etc.. Since there are both 2D and 3D aspects to the scene graph, you should review the AEC/GIS/ECAD and 3D/MCAD scene-graph documents.

Such a hybrid scene graph typically includes the following concepts:

3D Model Library

  • This is the repository for the master model, which should generally be designed with the 3D/MCAD scene-graph principles in mind. The HOOPS/3dGS 'shell' primitive would be used to represent your 3D objects. Each part would ideally have a segment, which in turn would have a single segment for each body. This segment would have it's visibility turned off, since we'd only want parts to show up in the main drawing if they were specfically included by the views.

Drawing

  • This is the segment that corresponds with the top of the 'viewable' scene-graph. It contains a subsegment for each 'view' of the model, as well as a separate segment for the 'border' of the drawing.
  • The 'border' has a 'paper' subsegment containing the geometry for the drawing background (a polygon, typically). This paper segment has a "depth range" setting that pushes it to the background. Refer to Section 6.1.4 of the HOOPS/3dGS Programming Guide for more information about ordering geometry.

Views

  • Each view contains a translation that places it at the correct location on the virtual drawing, and contains two subsegments: one for the the 'model', and another for 'markup' information.
  • The 'markup' subsegment contains the 2D annotation information.
  • The 'model' subsegment includes parts from the 3D model library as necessary, and applies transforms specific to the view. It could contain a polygonal clip region setting (Set_Polygonal_Clip_Region), which has the affect of defining another software viewport within the scene. Anything outside the region (that's in the containing segment or subsegments) gets clipped.

The diagram below depicts how the scene graph might look:

 

drawing.gif

 

The HOOPS/3dGS pseudo-code corresponding with the blue portions of the diagram is listed down below. This code actually corresponds with the scene-graph contained in the '/datasets/hsf/cad/mcad_drawing.hsf' file located in the datasets package (available at the Tech Soft 3D Developer Zone). Visually explore its scene graph in a dynamic fashion by loading it into the Hoops3DPartViewer, and then opening the 'Segment Browser' dialog. Additionally, review the ASCII readable version of mcad_drawing.hsf (and thus the scene-graph), by saving the HSF file out to an HMF file and then loading it into a text editor.

 
// define the model

HC_Open_Segment("?Include Library");

  HC_Open_Segment("Model_0");

    HC_Open_Segment("drawing");

      HC_Open_Segment("view1");
   
        HC_Set_Modelling_Matrix(...);   // translate the view

        HC_Open_Segment("model");
          // define the model using shells
          // turn off the visibility of 'edges' (to hide the implicit 'shell' edges)
          HC_Set_Modelling_Matrix(...);   // rotate the view
        HC_Close_Segment();

        HC_Open_Segment("markup");
          // insert geometry to represent the 2D annotations
        HC_Close_Segment();

      HC_Close_Segment();  // close "view1"


      HC_Open_Segment("border");

        // insert geometry representing the border annotations (text, polylines, polygons, etc...)

        HC_Open_Segment("paper");
          HC_Set_Rendering_Options("depth range = (1,1)");
        HC_Close_Segment();

      HC_Close_Segment();  // close "border"

    HC_Close_Segment();    // close "drawing"


    HC_Open_Segment("library");
      HC_Set_Visibililty("off");

      HC_Open_Segment("master_objects");
        HC_Open_Segment("object1");
          // insert geometry defining this reusable object
          // set any attributes that are a fixed property of the object
        HC_Close_Segment();
      HC_Close_Segment();

      HC_Open_Segment("part");
        HC_Open_Segment("body1");
          // define the body using shells, lines, arc, etc...
          HC_Include_Segment(../../master_objects/object1");
        HC_Close_Segment(); 
      HC_Close_Segment();  

    HC_Close_Segment();  // close "library"
  
  HC_Close_Segment();    // close "Model_0"

HC_Close_Segment();      // close "?Include Library"


// include the model into the scene

HC_Open_Segment("?driver/opengl/window0");
  HC_Open_Segment("Scene");
    HC_Include_Segment("Model_0");
  HC_Close_Segment();
HC_Close_Segment();