Web Visualization of Function-Defined Shapes Alexei Sourin1, Lai Feng Min2, Konstantin Levinski1 1 Nanyang Technological University, Singapore {assourin, P44-0521757}@ntu.edu.sg http://www.ntu.edu.sg/home/assourin 2 Creative Technology Ltd., Singapore
[email protected]
Abstract. This paper describes how function-based shape modeling can be expanded to web visualization, as well as how web-based visualization can be greatly improved by using the function-based shape modeling technique. We have proposed a function-defined VRML shape node, which allows the content creators to describe any complex models with relatively small functions compared to the large-size polygonal mesh models. These function-defined shapes can be used together with the common VRML shapes. The design, the implementation details, and the application examples of the proposed node are discussed.
1 Function-Based Shape Modeling Dramatic advances in computer technology have driven up the methods and tools of interactive 3D shape modeling where the unique geometric reasoning of the human brain couples with the rapid computing and rendering abilities of the computer. Some geometric models, which existed rather theoretically just a few years ago, now revolutionize the ways of shape representation and rendering. Thus, there can be noticed a trend toward function-based shape modeling. The idea of function-based approach to shape modeling is that complex geometric shapes can be produced from a "small formula" rather than thousands of polygons. Usually, parametric or implicit functions and their modifications are used to define the shapes. For rendering such function-defined shapes, either ray tracing or polygonization followed by fast polygon rendering is used. Alternatively, the functiondefined shapes can be voxelized and rendered as a set of points. It must be mentioned, though, that function-defined shapes may sometimes suffer a serious problem, which is large time needed for evaluation of the defining functions. Nevertheless, many works have been done in the direction of accelerating the function evaluation when performing rendering. In the next sections, we overview the existing web visualization projects, justify the usefulness of the function-based modeling in web visualization, and propose our own solution to function-based web visualization. This work is a continuation of the project briefly described in [1]. V. Kumar et al. (Eds.): ICCSA 2003, LNCS 2669, pp. 428-437, 2003. Springer-Verlag Berlin Heidelberg 2003
Web Visualization of Function-Defined Shapes
429
2 Web-Based Visualization A variety of web-based visualization systems have been developed. Progressive reconstruction and isosurface transmission suggested by Engel et al. [2][3] aimed to reduce the amount of data to be reconstructed and transmitted during visualization. Seidel et al. [4] have presented a framework to acquire high quality 3D models of real world objects including both geometry and appearance information presented by textures, bump maps or bi-directional reflectance distribution function used to describe the way a surface reflects light. Fogel et al. [5] have proposed a web architecture for progressive delivery of 3D content, which is based on a progressive compression representation integrated into X3D framework. Taubin et al. [6] have proposed another popular approach to delivering a 3D content over the Internet within a reasonable time, besides introducing a new adaptive refinement scheme [7] for storing and transmitting the triangular meshes in progressive and highly compressed form. Pajarola and Rossignac [8] have proposed a compressed progressive meshes approach, which used a new technique to refine the topology of the mesh in batches. Among these services, the polygon mesh representation is commonly used for representing geometric shapes. Thus, the most popular 3D web content format Virtual Reality Modeling Language (VRML) [9] uses this representation for complex objects. To improve the performance of VRML and to enrich its content, various VRML extensions have been implemented. For example, Alexa et al. [10] have suggested the Morph node that helps to interpolate between several shapes. Another example is customized GeoVRML [11] node, which is defined to provide a suite of solutions for representing and visualizing geographic data using a standard VRML97 browser. Wyvil and Guy [12] have introduced a new VRML extension for skeletal implicit surfaces with a limited set of operations like blending, warping and Boolean operations. Besides that, Pittet et al. [13] have proposed a new real-time Isosurfacing node, which is based on the so-called Marching Cubes algorithm [14] and allows real time rendering of an isosurface from 3D source data. Grahn et al. [15] have introduced trimmed NURBS in VRML to allow visualization of complex CAD models in VRML. Ginis and Nadeau [16] have presented new VRML extensions for scientific visualizations.
3 FShape Node for VRML In this project, a generic function-based FShape node for VRML is proposed as a plug-in to VRML browsers. The idea of introducing such a node is to replace large polygonal representations of complex shapes with small formulae, which will be transmitted through the Internet much faster and therefore will improve the efficiency of web visualization. Besides that, these function-based shape models have an unlimited level of detail. The FShape node is designed in such a way that it offers a generic infrastructure to support various function-defined models to be plugged-in during runtime. This can be achieved if the respective parsing and polygonization modules are implemented according to the defined plug-in interface. With this node, the content publishers can
430
A. Sourin, L.F. Min, and K. Levinski
present any proprietary function-defined model to the viewers since they can develop the respective parsing and polygonizing modules. In general, a VRML node can be implemented either via plug-in customization or through VRML EAI interface [17]. For plug-in customization, the overall performance of the extended node will be much better than the other one, since the module is implemented with a low level programming language. The performance improvement becomes obvious when it involves complex geometric models, which may require long computations and algorithm evaluations. Although the plug-in customization may closely tie the node extension with the supported VRML browser plug-ins, the overall performance may need to be considered first if the node extension involves heavy computation processes. Another possible approach to implementation of the extension is via a VRML Script node and its EAI interface. The implementation using JavaScript or Java may allow extension across different browsers, however this approach may have a serious performance setback. The polygonization implemented using JavaScript language will only be interpreted when it is about to be executed. Therefore, the function models represented using a script language will always need more time to get executed as compared with the precompiled modules. As overall performance is very important in the context of web visualization, the proposed FShape node is VRML browser plug-in dependent, in which the VRML extension is implemented via customizing a VRML browser plug-in. The proposed function-based geometric node could be extended via different browser plug-ins, e.g. Blaxxun Contact 3D [18], OpenVRML [19], FreeWRL [20], and other customizable browsers. In order to prove the concept proposed in this paper, we have extended Blaxxun Contact 3D to support FShape node. With the extension, viewers are able to visualize function-based objects in VRML paradigm. The extension of other VRML browsers can be done in a similar way, and we are working on it. The proposed FShape node definition is listed in Figure 1. The visualization pipeline in FShape node is categorized into three main modules: Seeker, Parser and Polygonizer components. The Seeker component is used to obtain any type of function definition, which is either located inline with the VRML source or is remotely located at the content server. The inline source will always have higher precedence than the external source. The Seeker component will be triggered first whenever the scene graph traversal engine encounters the FShape node. As data seeking is independent from any function-based shape modeling approach, the Seeker component is embedded as part of the core module. In order to allow for future extension of the Parser component in runtime, the component is dynamically loaded into the FShape core module. The component is dependent on the data used to describe the model. For every supported function based model, the respective Parser module is to be developed separately with a set of standard function calls. The Parser component is to be created as a dynamic linked library and stored into the relative Parser directory of the core module Like the Parser component, the Polygonizer component is dependent on the chosen function language/model used to describe the shape. For every supported functionbased model, the respective Polygonizer component is to be developed and a set of standard function calls must be supported. The Polygonizer component is to be cre-
Web Visualization of Function-Defined Shapes
431
ated as a dynamic linked library and stored into the relative Polygonizer directory of the core module. FShape { exposedField SFString sourceString “” # contains the definition of a function-defined shape. exposedField SFString sourceURL “” # alternatively, defines the path to the model source file. exposedField SFString objectName “my_model” # specifies the model name for a function-defined shape. field SFString sourceType “” # identifies the type of the model referred in the scene. field SFBool ccw TRUE # specifies the order of points in a face created by Polygonizer field SFBool convex TRUE # specifies if the faces created by Polygonizer are convex or not. field SFFloat creaseAngle 0 # specifies an angle threshold. field SFBool normalPerVertex TRUE # specifies whether the normal of each vertex is computed. field SFBool solid TRUE # determines whether to draw both sides of a face or just the front side. field SFBool reduce FALSE # defines whether to produce the least number of polygons. field SFBool searchVertex FALSE # turns on recursive searching for vertex positions. field SFFloat searchPer 0.1 # specifies the search accuracy in percentage of cell lengths. field MFFloat modelPar 0.0 # specifies model-specific parameters if any. field MFInt32 gridSize 30 # specifies the rendering resolution used in polygonization. field MFFloat boundingBoxMax 10 # specifies the bounding box for the shape. } Fig. 1. FShape node definition with default values.
4 Support for Implicit Functions and the F-Rep Model In order to support any proprietary function-defined models in FShape node, one has to develop respective Parser and Polygonizer components based on the predefined plug-in interfaces. Developing a Parser depends on the model and/or language used, while developing a Polygonizer depends only on the model. To illustrate the proposed design and to prove the correctness of our assumptions, we shall describe in this section just two of the developed plug-ins. These are the FShape node plug-ins for shapes defined with implicit functions and the function representation model named F-Rep [21, 22], as well as the F-Rep based geometric high-level language HyperFun [23].
432
A. Sourin, L.F. Min, and K. Levinski
The F-Rep, being an extension of implicit functions, assumes that geometric shapes are defined with an inequality f(x,y,z) ≥ 0, where the real function f is positive for the points inside the shape, equal to zero on its border and negative outside it. The F-Rep functions can be defined either analytically, or procedurally with a function evaluation algorithm. Different operations can then be applied to the F-Rep geometric models. In fact, any operation that can be defined with a function f(x,y,z) ≥ 0, which provides at least C0 continuity, may be used for making a shape. All the functions are applied as function superpositions thus allowing one to create sophisticated hierarchically organized shapes, which are in turn function-defined shapes. F-Rep allows one to use together practically any geometric models since this representation is very generic and highly extensible. When using F-Rep models developed elsewhere and stored in a proprietary data format, the respective Parser module is a rather simple procedure. It just reads the function model from the data file and makes it available for the Polygonizer. For testing purposes, we used our own F-Rep models developed in the project Interactive Function-based Shape Modeling [24], [25] and [26]. To facilitate the inclusion of any proprietary function-defined model, we developed a generic Polygonizer, which works efficiently for a large range of implicitly defined and F-Rep defined shapes. The algorithm, described in details in [25] and [27], is an extension and improvement of the so-called continuation algorithm, which calculates polygons only on the surface of the shape. Since its description is beyond the scope of this paper, we refer the reader to the printed papers for the details. The FShape node will dynamically load the corresponding Parser and Polygonizer components based on the string value stored in sourceType field. The plug-in polygonizer supports several level of detail (LOD) depending on the distance between the observer and the shape. The LOD switching is to be done outside the FShape node acting like a group node. The example of a VRML source code that links to this proprietary function model is shown in Figure 2. In this code, the model is encoded to ASCII using base64 format and used inline. The examples of using such functiondefined shapes in VRML scenes are presented in Figure 3. #VRML V2.0 utf8 EXTERNPROTO FShape [...] geometry DEF vase-FACES FShape { sourceString "AQAAAAEAAABFAAAABwAAADDFFGGHJJHJKL..." sourceType "tetrapoly" gridSize 24 ccw FALSE } Fig. 2. VRML source code for the proprietary F-Rep shape model used inline.
Since the Polygonizer was developed for a large class of models, in order to use any other implicitly or F-Rep defined models, only the respective Parser procedure is to be written. It just should be able to evaluate the shape defining function f(x,y,z) ≥ 0 for any given coordinates. The examples of such an implementation can be found in [28].
Web Visualization of Function-Defined Shapes
a
b
c
d
e
f
433
Fig 3. a-c: Examples of VRML scenes where F-Rep models are used together with VRML shapes. d-e: FShape node is used for visualizing very complex function-defined shapes, which polygonal equivalents consist of millions of triangles and hardly can be visualized through the Internet using conventional VRML IndexedFaceSet node.
Besides developing a generic plug-in for F-Rep defined shapes, where the model is stored in a proprietary data format and can be modified only with the respective software, we have also developed a plug-in for HyperFun [23]--a high-level open source modeling language designed to describe F-Rep models. We developed a plug-in supporting HyperFun to illustrate how a high-level modeling language can be incorporated into the framework of the Fshape node. In case of using HyperFun, the F-Rep model description can be included into VRML code and edited along with other VRML lines if needed. In case of HyperFun, the integration with FShape node has been achieved easily since the respective Parser and Polygonizer modules are based on the original HyperFun codes kindly provided by the HyperFun developers. Only modifications to fit those modules with basic interfaces defined by FShape node have been required. A sample VRML and HyperFun definitions are given in Figure 4 for the resulting VRML shape shown in Figure 5a. In Figure 5b, several HyperFun objects are used in a VRML scene.
434
A. Sourin, L.F. Min, and K. Levinski
#VRML V2.0 utf8 EXTERNPROTO FShape [...] geometry DEF model-FACES FShape { sourceString my_model(x[3], a[1]){ array center[3], p[3], vertex[3]; center = [0, 0, 0]; p[1] = x[1]/10; p[2] = x[2]/10; p[3] = x[3]/10; dX = p[1]^2; dY = p[2]^2; dZ = p[3]^2; cylz =hfCylinderZ(p,center,0.548); cylx = hfCylinderX(p,center,0.316); cyl = cylz | cylx; spcyl = fSphere(p,center,0.894)|cyl; hole = hfCylinderY(p,center,0.316); inside = spcyl \ hole; cube = 0.9-dX*dX-dY*dY-dZ*dZ; blend = hfBlendInt(cube,inside,0.8,0.2,0.3); my_model = blend;} sourceURL " " sourceType "hyperfun" gridSize [50,50,50] } Fig. 4. Using a HyperFun code for specifying a function-based model description in VRML.
a
b
Fig. 5. Examples of models defined in VRML with HyperFun.
More examples as well as all the developed VRML FShape plug-ins can be freely downloaded from our project site at [28]. An alternative approach to using HyperFun in VRML based on employing a Script node and the EAI interface, as it is described in Section 3, is reported in [29].
5 Performance Analysis Under different configurations shown in Table 1, the loading times for multiple complex objects such as the ones presented in Figure 3c are shown in Table 2. The loading time for the shapes represented using FShape nodes is shorter than the loading time for the shapes converted to IndexedFaceSet nodes. When the scene complexity increases, the FShape nodes can be exploited to greatly reduce the loading time of the scene. When the network is highly congested and the model description includes complex mathematical functions, the total time used to download the model description and to evaluate the complex mathematical functions can be quite significant. This may explain why the performance improvement in Configuration C and D is rela-
Web Visualization of Function-Defined Shapes
435
tively lesser, as compared with other configurations. The Polygonizer uses about 65 seconds on average to complete polygonization, which results in 55900 triangles. This is much better than what the conventional IndexedFaceSet node can offer, i.e. about 600 seconds on average. Table 1. Configurations tested
Configuration Speed (MHz) Connection
A Athlon 650 56 KB/s
B P III 733 100 MB/s
C P II 300 100 MB/s
D PII 350 56 KB/s
Table 2. Loading times for multiple F-Rep objects from Fig. 3c.
For Multiple Objects File Size (Bytes) Loading Time for A Loading Time for B Loading Time for C Loading Time for D
Representation IndexedFaceSet FShape 7938059 113686 743 sec 54 sec 477 sec 32 sec 520 sec 76 sec 695 sec 101 sec
Rate
13.76 14.91 6.84 6.88
For the HyperFun plug-in, we used shapes from Fig. 5b and we set the gridSize of the FShape node to the same LOD as the one of the respective IndexedFaceSet. The average loading times are shown in Table 3. Table 3. Loading times for multiple HyperFun objects from Fig. 5b.
For Multiple Objects File Size (Bytes) Loading Time for A Loading Time for B Loading Time for C Loading Time for D
Representation IndexedFaceSet FShape 3056690 3052 272 sec 18 sec 163 sec 14 sec 178 sec 16 sec 286 sec 22 sec
Rate
15.11 11.64 11.13 13.00
The loading time for HyperFun models in FShape nodes is shorter than the loading time for the respective IndexedFaceSet. The loading time includes the downloading time and the rendering time. The time difference between these two representations for all the configurations becomes greater as compared to the time difference between them for loading a single object. This means that the efficiency of using FShape node, as compared to using IndexedFaceSet node, becomes more obvious for more complex objects. Objects represented using FShape nodes take longer time to load for slower machine. This may be due to the complex computation routines, which require faster CPU to process the HyperFun scripts and execute the polygonization.
436
A. Sourin, L.F. Min, and K. Levinski
6 Further Extension Other plug-ins for different function-based models, as well as plug-ins for other VRML browsers, are being developed now. Thus, we have recently developed a plug-in for the Visualization Toolkit (VTK) [30] and for a large class of parametric functions. The examples of using this plug-in for importing 3D Studio models into VRML scenes are given in Figure 6.
Fig. 6. Using one of the VTK classes for importing 3D Studio models into VRML scenes.
7 Conclusion and Future Work In this paper, a generic function-based VRML geometric shape node has been described. The integration between function-defined models and VRML is proposed to implement through a VRML browser plug-in, where the customized node can be referred to as like a normal VRML node together with other conventional VRML nodes. Currently, the Blaxxun’s Contact3D VRML browser has been extended to support this integration. The extension of other VRML browsers is on the way. The use of the function-based geometric representations in VRML has open new prospects for VRML modeling and indeed improved the overall performance under the bottleneck of the Internet bandwidth. Complex geometric models with an unlimited level of detail can be easily represented with a smaller file size, as compared to the conventional polygonal based representation.
References 1 Lai Feng Min, Alexei Sourin. Function-defined shape node for VRML, Eurographics 2002, Short Presentations, ISSN 1017-4565, 2002, pp.207-215. 2 K.Engel, R.Grosso, and T.Ertl. Progressive Isosurfaces on the Web, Proc. Visualisation 98, 1998, pp. 37-40. 3 K.Engel, R.Westermann and T.Ertl. Isosurface Extraction Techniques for Web-based Volume Visualisation, Proc. IEEE Visualisation '99, 1999, pp. 139–146. 4 H-P.Seidel, H.P.A.Lensch, M.Goesele and J.Kautz. A Framework for the Acquisition, Processing, Transmission,and Interactive Display of High Quality 3D Models on the Web, Tech Report MPI-I-2001-4-002, Max-Planck-Institut fur Informatik, Germany.
Web Visualization of Function-Defined Shapes
437
5 E.Fogel, D.Cohen-Or, R.Ironi and T.Zvi. A Web Architecture for Progressive Delivery of 3D Content, Proc. On 3D technologies for the World Wide Web, Proc Virtual Reality Modeling Language Symposium, 2001, pp. 15–22. 6 G.Taubin, W.Horn, F.Lazarus, and J.Rossignac. Geometry Coding and VRML, Proc. of the IEEE, 96:6, 1998, pp. 1228-1243. 7 G.Taubin, A.Gueziec, W.Horn and F.Lazarus. Progressive Forest Split Compression, SIGGRAPH’98, 1998, pp. 123-132. 8 R.Pajarola and J.Rossignac. Compressed Progressive Meshes, IEEE Trans Vis Comput Graph, 6:1, 2000, pp. 79–93. 9 VRML, http://www.web3d.org/technicalinfo/specifications/vrml97/index.htm. 10 M.Alexa, J.Behr and W.Müller. The Morph Node, Proc. of the Web3D-VRML 2000 Fifth Symposium on Virtual Reality Modeling Language, 2000, pp. 29–34. 11 GeoVRML 1.1 Specification, http://www.geovrml.org. 12 B.Wyvill and A.Guy. The Blob Tree, Implicit Modeling and VRML, Proc. Int Conf From the Desktop to the Webtop: Virtual Environments on the Internet, WWW and Networks, NMPFT, Bradford, 1997, pp. 193–206. 13 J.J.Pittet, A.Engel and B.Heymann. Visualizing 3D Data Obtained from Microscopy on the Internet, JSB 125, 1999, pp. 123–132. 14 W.E.Lorensen and H.E.Cline. Marching Cubes: a High Resolution 3D Surface Construction Algorithm, Computer Graphics, 21:4, 1987, pp. 163-169. 15 H.Grahn, T.Volk and H.J.Wolters. NURBS in VRML, Proc. of the Web3D-VRML 2000 Fifth Symposium on Virtual Reality Modeling Language, 2000, pp. 35–43. 16 R.Ginis and D.Nadeau. Creating VRML Extensions to Support Scientific Visualisation, Proc. 1995 Symposium on Virtual Reality Modeling Language, 1995, pp. 13–20. 17 C.Marrin. Proposal for a VRML 2.0 Informative Annex: External Authoring Interface Reference, http://www.web3d.org/WorkingGroups/vrml-eai/history/eai_draft.html. 18 Blaxxun Contact. http://www.blaxxun.com. 19 OpenVRML. http://www.openvrml.org. 20 FreeWRL. http://freewrl.sourceforge.net. 21 F-Rep site. http://www.ntu.edu.sg/home/assourin/Frep.htm 22 A.A.Pasko, V.D.Adzhiev, A.I.Sourin, V.V.Savchenko. Function Representation in Geometric Modeling: Concepts, Implementations and Applications, Visual Comput, 11:8, 1995, pp. 429-446. 23 HyperFun site. http://www.hyperfun.org 24 A.Sourin. Functionally based virtual embossing. Visual Comput, 17, 2001, 4, pp.258-271. 25 K.Levinski and A.Sourin. Interactive polygonisation for function-based shape modelling, Eurographics 2002, Short Presentations, ISSN 1017-4565, pp.71-79, 2002. 26 Interactive Function-based Shape Modelling. http://www.ntu.edu.sg/home/assourin/ Intshape.html 27 K.Levinski and A.Sourin, "Interactive function-based artistic shape modeling", 2002 International Symposium Cyber Worlds: Theory and Practice 2002, Tokyo, Japan 6-8 November, 2002 pp.521-528. 28 Function-based web visualization. http://www.ntu.edu.sg/home/assourin/FVRML.htm 29 Web-page by Jiri Zara. http://www.cgg.cvut.cz/~zara/HyperFun/ 30 Visualization Toolkit. http://www.vtk.org