visualization-scene-graph-2010
visualization-scene-graph-2010
Visualization of the finite element model requires rendering its visual components
– finite element faces, edges and nodes. A scene graph is used for organizing visual
components (objects). The scene graph determining the hierarchy of the objects of
the visualizer Jvis is shown in Figure 28.1. Visual objects of the scene graph are
finite element faces, edges and nodes. They are represented by Shape3D objects.
The geometry of the faces is described by array of triangles. Appearance references
polygon attributes, material and texture. Texture is used for drawing results in the
form of contours. Edges are represented as line segments defined in a line array.
Appearance includes line attributes and color. Nodes are described by a point array
with references to point attributes and color.
All Shape3D objects (faces, edges and nodes) are attached to a transform group
TG, which defines the initial transformation for the finite element model. In our
case, we need scaling of the finite element model that is necessary to place the
model inside a window used for visualization.
The next (upper) transform group is used for providing interaction with the user.
Mouse behavior, which includes rotation, translation and zooming is connected to
this transform group. Lights, background and transform group are attached to branch
group BG, which is connected to utility class SimpleUniverse. Lights, back-
ground and mouse behavior have references to bounds that define the influence of
the corresponding scene graph nodes.
325
326 28 Visualization Scene Graph
SimpleUniverse
BG
Lights TG
Mouse
Background Behavior
Bounds TG
Fig. 28.1 Scene graph for visualization of finite element model and results
A Java 3D scene graph for visualization of the finite element model and results is
created by class J3dScene. The source code of the class constructor and a method
for adding the shape of a visual object is given below.
1 package visual;
2
3 import javax.media.j3d.*;
4 import javax.vecmath.*;
5 import java.awt.*;
6 import java.applet.Applet;
7 import com.sun.j3d.utils.universe.SimpleUniverse;
8
9 // Scene graph for visualization.
10 public class J3dScene {
11
12 private SurfaceSubGeometry subGeometry;
13
14 // Construct Java3D scene for visualization.
15 public J3dScene(Applet c) {
16
17 GraphicsConfiguration config =
18 SimpleUniverse.getPreferredConfiguration();
19
28.2 Implementation of the Scene Graph 327
74
75 return tg;
76 }
Material defined in lines 93–101 is used for specifying the reflecting properties of
the surface. Different materials are specified for mesh visualization and for results
visualization. The following constructor for the material is employed:
Material(Color3f ambientColor, Color3f emissiveColor,
Color3f diffuseColor, Color3f specularColor,
float shininess)
Here, ambientColor is the ambient color reflected off the surface of the material;
emissiveColor is the color of the light the material emits (like a light source);
diffuseColor is the color of the material when illuminated (the light bounces
off objects in random directions); specularColor is the specular color of the
material (highlights); shininess is the material’s shininess.
We use black color as the emissive color. The model color specified in class
Data is used for both ambient and diffuse colors. If results are drawn by applying
texture then an almost white color is used as the surface color (line 94). Specular
effects are modeled by a color that is close to white. In order to have light effects
line 100 enables lighting for the material. Line 101 sets material properties for the
appearance of the faces.
If the results file name is specified in the input data and, consequently, we are
going to draw results contours then a texture and its appearance are set in lines 105–
110. A one-dimensional color gradation strip is created by method getTexture
of the class ColorScale (line 105). It is set as a texture for the faces appearance
in line 106. A texture mode in the texture attributes is set to MODULATE. Choosing
this parameter means that polygon material colors will be modulated by the speci-
fied texture. Lights effects including shading and bright spots are produced for the
polygon material and are visible through the texture since it is applied as modulation
of material colors.
Line 114 creates a Shape3D object using faces geometry and appearance and
returns it to the calling method.
A shape object for the edges of the finite element model surface is created by
method edgesShape.
117 // Shape object for element edges
118 private Shape3D edgesShape() {
119
120 LineArray edges = subGeometry.getModelLines();
121
122 Appearance edgesApp = new Appearance();
123
124 LineAttributes la = new LineAttributes();
125 la.setLineAntialiasingEnable(true);
126 edgesApp.setLineAttributes(la);
127
128 ColoringAttributes ca = new ColoringAttributes();
129 ca.setColor(VisData.edgeColor);
130 edgesApp.setColoringAttributes(ca);
131
132 return new Shape3D(edges, edgesApp);
133 }
Problems 331
Problems
28.1. Analyze the scene graph shown in Figure 28.1. Currently, lights are attached
to branch group BG. What changes occur in visualization of the finite element model
if lights are attached to the upper transform group TG through an additional branch
group?
28.2. The scene graph of Figure 28.1 contains shape objects for element edges and
nodes. Is it possible to refer to the same appearance for both edges and nodes? Are
references to the same color attributes possible for edges and nodes (through their
appearances)?
28.3. An antialiasing technique is used for smoothing lines and points in meth-
ods edgesShape and nodesShape. Explain how antialiasing is performed on
a computer screen consisting of pixels.