Function-defined Shape Metamorphoses in VRML - CiteSeerX

2 downloads 0 Views 636KB Size Report
nodes can be used independently of such external controls as ... TimeSensor is such a node. .... functions are implemented: abs(x), sqrt(x), exp(x), log(x), sin(x),.
Function-defined Shape Metamorphoses in VRML Qi Liu* and Alexei Sourin† Nanyang Technological University, Singapore

such as video and audio clips, hyperlinks, sensors, etc. A VRML file is a collection of objects which are shapes, sounds, lights, and viewpoints. Nodes are fundamental building blocks of a VRML file. Each node can contain other nodes. Each node contains fields which hold the data for the node. Different nodes can produce different events, which can be exchanged between the nodes and used as triggers for various purposes. By properly compositing these nodes, the virtual environment created by VRML can be animated following the user’s interaction. In addition to interactions, standard VRML97 provides three time-dependent nodes, which allow for creating virtual environments dynamically changing through time. The time-dependent nodes are AudioClip, MovieTexture and TimeSensor. Based on their properties, we classify them into two groups, Self-contained Time-dependent Nodes and Non-self-contained Time-dependent Nodes.

Abstract In this paper we propose FVRML—a function-based extension of Virtual Reality Modeling Language which allows for timedependent shape modeling on the web. Shape’s geometry, 3D texture, color and transformations changing through time can be defined with analytical functions typed straight in VRML code. FVRML allows us to greatly extend the abilities of VRML with a very intuitive approach to shape modeling based on using analytical functions. Several functions can be combined into one using java scripts emulated in FVRML, which allows for even greater flexibility and convenience of shape modeling. CR Categories: I.3.5 [Computing Methodologies]: Computational Geometry and Object Modeling—Curve, surface, solid, and object representations; I.6.5 [Simulation and Modeling]: Model Development

Self-contained Time-dependent Nodes can be used independently of any additional nodes. These nodes always contain some internal time sensing mechanisms which allow them to track changes of time. Usually, the self-contained time-dependent nodes expose only a few parameters and events to other nodes. By changing these parameters, default behavior can be changed accordingly. In VRML97, AudioClip and MovieTexture belong to this group. AudioClip is a node which can play an audio file. The cycle interval (i.e. the time required for playing the node) is defined by both the pitch property and the length information contained in the audio file. MovieTexture is used for playing a video clip. Its cycle interval is defined by both the speed property and the length information hidden in the video clip. Both these nodes can be used independently of such external controls as TimeSensors and JavaScripts. Though they have exposed fields start time, stop time, and loop, in fact only infinite cycles can be played back since only the absolute time originated from January 1, 1970 can be used in VRML97.

Keywords: function-based shape modeling, computer animation, 3D web visualization, VRML

1

Time-dependent processes in VRML

Animated shape transformations are often required in shared virtual environments built on the web, specifically when using Virtual Reality Modeling Language (VRML). However, only limited and polygon-based shape animation tools are available there. This greatly limits the expressive power of VRML and motivates our research in this direction. In this paper, we propose a hybrid function-based approach to time-dependent shape modeling based on concurrent using implicit, explicit and parametric functions defining the shape’s geometry, appearance and transformation through time.

Non-self-contained Time-dependent Nodes cannot be used on their own, and therefore they expose as much properties and events as possible to provide for more flexibility. TimeSensor is such a node. Combining the TimeSensor and various interpolators provided by VRML97, time-dependent objects can be modeled in two ways: either by time-dependent transformations of a static object, or by time-dependent morphing between several objects. This allows for only simple animation to be done. Timedependent morphing proposed in [Alexa and Muller 1999] can achieve more sophisticated shape transformations. However, it requires using VRML’s CoordinateInterpolator for each pair of objects which results in a very large file size even for simple objects. In order to reduce the file size, three morphing nodes were proposed to simplify the definition of the interpolation [Alexa et al. 2000]. VectorInterpolator node, which interpolates a set of vectors linearly, can replace a set of interpolators. CoodinateMorpher node, and NormalMorpher node, which calculate the coordinates and normals of a morphing object, can replace the JavaScripts and make the morphing algorithm more transparent to authors.

Virtual Reality Modeling Language is an international standard file format commonly used for creating 3D objects and virtual worlds on the web including multimedia and interactive elements

* †

[email protected] [email protected]

Copyright © 2005 by the Association for Computing Machinery, Inc. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from Permissions Dept, ACM Inc., fax +1 (212) 869-0481 or e-mail [email protected]. © 2005 ACM 1-59593-201-1/05/0010 $5.00

339

colors are mapped to the textured shape to form the final textured colored shape. This process repeats as many times as needed.

An alternative approach, which also reduces the file size of timedependent objects, is to replace a set of complex models with several simple parameters and coordinates. In H-Anim specification (http://www.h-anim.org), human avatars are simplified into segments and joints. With compression and decompression method, humanoid animations can be even transmitted through telephone lines [Naka et al. 1999]. In addition to this, common human motions can be predefined with several parameters. For example, in [Liu and Li 2003], avatars in virtual worlds can have several JavaScript controlled predefined motions (e.g. walking, running, gesticulating). Certain parts of avatars (e.g. face), which require detailed motion, may have more controlling parameters [Breton et al. 2001; Pandzic 2002]. Such messagebased time-dependent visualization can be used in dynamic model presentation system [Esuli et al. 2003]. However, it requires preinstallation of all models before visualization, which is not practical if frequent changes of the models are expected.

Though very efficient, the developed function-based nodes have two limitations: 1. They do hot support time-dependent functions, and 2. Only single formula can be typed in function definitions. These problems are resolved in our work. Based on the idea of employing analytical functions for defining time-dependent geometry, texture and color, the nodes proposed in [Liu and Sourin 2005] must be extended accordingly to constitute the new Function-based Extension of VRML (FVRML). In order to define time-dependent shapes, we introduce an additional argument representing the time. Therefore, to define time-dependent shapes four arguments of FRep or parametric functions are to be used.

Time-dependent scientific data can also be visualized by VRML. The examples are web visualization of oceanographic data [Roberts 1998] and molecular quantum dynamics [Davies et al. 2005]. However, these approaches are model-dependent and they cannot be generalized.

Since we do not want to impose any restrictions on mathematical functions which can be treated as functions of time, it appears feasible to allow for defining any range of the time parameter including negative real numbers. Eventually, this time domain will be somehow, e.g. linearly, mapped to the real time which is used in VRML’s animation.

In conclusion, the ability of defining time-dependent object in VRML is still very limited and there is a room for further research on this topic motivated by large sizes of animated VRML objects, limited set of animated transformations, and limited set of timedependent models.

2

It appears feasible to allow the new nodes work in two modes: as self-contained nodes for novice users, and as nodes communicating with TimeSensors for more advance applications. While in VRML cycleTime is missing in the self-contained nodes, we will include this field in our prototypes. The proposed prototypes are shown in Appendix. The time-related events and fields are typed in bold.

Time-dependent FVRML nodes

2.1 Time-dependent FVRML prototypes The extension of VRML with function-based shape modeling was proposed by the authors in [Liu and Sourin 2005] following the preliminary work [Lai and Sourin 2002]. The proposed hybrid function-based nodes (FShape, FGeometry, FMaterial, FTexture3D, FAppearance, FTransform) allow for extending VRML97 with practically any type of object’s geometry and sophisticated graphics appearances by defining the object’s geometry, appearance (color and 3D geometric texture) and transformations with analytical formulas which are implicit, explicit and parametric representations used concurrently. In contrast to the polygon-based models of VRML, function-based nodes greatly reduce the size of the models and provide an unlimited level of detail. Also, these nodes allow for using settheoretic as well as any analytically-defined geometric operations which can be introduced by the user.

In this prototype, timeSpan defines the range of the time used in visualization. Event set_fraction is designed to communicate with an external TimeSensor whose fraction_changed event will be routed. Other fields and events are designed to be consistent with the VRML97 TimeSensor. Since the fields and events provided by TimeSensor are exposed, all time-controlled cases considered in Section 1.3, including three start controls, five stop controls and two cycle controls, can be easily implemented following either the self-contained schemes or the schemes for TimeSensor node.

2.2 Function scripts Defining complex shapes, appearances and operations usually assumes using multiple formulas and temporary variables. This requires a script-like mathematical language. To be consistent with VRML97, which has a JavaScript as a standard feature, and to ease the learning curve, we emulated in the FVRML a subset of JavaScipt. In this JavaScript emulation, all variables, arrays and constants have only one type float. The following mathematical functions are implemented: abs(x), sqrt(x), exp(x), log(x), sin(x), cos(x), tan(x), acos(x), asin(x), atan(x), ceil(x), floor(x), round(x), max(x,y), min(x,y), atan2(y,x), mod(x,y), cosh(x), sinh(x), tanh(x), log10(x). We also introduced three operators ‘&’, ‘|’ and ‘^’, which represent ‘intersection’, ‘union’, and ‘power’ operations, respectively. Custom functions can be defined in the same way as defining a function in JavaScript. Recursions are allowed. There are also the following flow control operators: for-loops, whileloops, do-while-loops, break, continue, and if-else.

Two types of functions are used in these nodes. They are explicit FRep functions [Pasko et al. 1995] and parametric functions. FRep functions incorporate implicit surface representations and volume representations by implicit and explicit functions: f(x,y,z)=0; g=f(x,y,z)≥0. Parametric functions define surfaces and solids as: x= φ1(u,v,w); y= φ2(u,v,w); z= φ3(u,v,w); Geometry, 3D texture, and color are defined by FRep or parametric functions in their own domains and then merged together into one shape by the predefined mapping functions. First, geometric textures are mapped onto the original shape, and then

340

The script is compiled into intermediate codes when it is loaded or changed. The intermediate codes are executed by a virtual machine whenever evaluation is required. If a function named ‘FRep’ with three or four arguments exists in the script, the script is recognized as a definition of FRep function. Otherwise, functions named ‘parametric_x’, ‘parametric_y’, and ‘parametric_z’ (for shapes and geometric textures), or ‘parametric_r’, ‘parametric_g’, and ‘parametric_b’ (for colors) must be used to define parametric functions. If all these four functions exist concurrently, FRep function will have priority.

2.3 Examples of shape metamorphoses With the proposed FVRML prototypes and scripts, animated shape metamorphoses can be easily defined as time-dependent transformations of shape’s geometry, 3D texture and color. We will illustrate these transformations using a linear function interpolation: #VRML V2.0 utf8 FVRML PROTOs are omitted to save space

f (p) = f1 (p) + ( f 2 (p) − f1 (p))t

FShape { enabled TRUE Infinite looping with cycleInterval 5 period 5 sec is loop TRUE defined appearance FAppearance { material FMaterial { diffuseColor "sin(sqrt(x*x+y*y+z*z) * pi)" patternColor [0 1 0 1 0 0] patternKey [-1 1] Fancy color is type "analytical" } } defined by an geometry FGeometry { explicit function resolution [50 50] parameters [0 2 0 2 -1 1] Initial shape definition "

where parameter t is in the range [0, 1]. In this formula, function f1 defines the initial shape’s geometry, texture or color, while function f2 represents the final shape’s geometry, texture or color, respectively. For FRep functions, vector p defines Cartesian coordinates x,y,z, and only one such a morphing function is needed. For parametric functions, vector p defines coordinates u,v,w in parametric domain, and three morphing functions are needed to define Cartesian coordinates x,y,z, respectively. In Figure 1, four snapshots of geometric morphing from the snaillike shape to the star-like shape and the respective FVRML code of this morphing transformation are shown. Both, the initial and final shapes are defined in FVRML parametrically inside the function script. The time-dependent shape is defined as a linear interpolation between the initial and final shapes. The internal timer of the FShape node is used for defining an infinite looping with period 5 sec, while the time within the script is changing in the range [0, 1].

function snail_x(u,v,w) { return 0.03*pi*v*(10+5*cos(pi*u))*cos(3*pi*v); } function snail_y(u,v,w) { return 0.03*pi*v*(10+5*cos(pi*u))*sin(3*pi*v); } function snail_z(u,v,w) { return 0.03*pi*v*(6+5*sin(pi*u)); } Final shape function star_x(u,v,w) { return (0.3-0.1*sin(v*5*pi))*cos(v*pi)*(4+cos(u*pi)); } function star_y(u,v,w) { return (0.3-0.1*sin(v*5*pi))*sin(v*pi)*(4+cos(u*pi)); } function star_z(u,v,w) Morphing as a { return 0.2*sin(u*pi); } function of time

Besides geometric morphing, FVRML is also capable of defining concurrent metamorphoses of geometric textures and colors. In Figure 2, we show four snapshots of a time-dependent process of growing geometric texture on the initial shape. The texture is defined by a time-dependent displacement which value is controlled by Perlin noise function as it was illustrated in Section 2. The swing animation combining into an infinite loop the growth of texture and the reverse process is defined with the shown FVML code. In this code, both internal and external time sensors are used to define a gap between two cycles. The internal timer defines a single 5 sec execution of the node. The external timer defines an infinite looping with 7 sec duration of each cycle. Thus there will be a 2 sec time gap between each cycle. Note that in this example the explicitly defined time-dependent geometric texture is mapped onto the parametrically defined geometric shape and the resulting shape is colored by the explicit functions.

function parametric_x(u,v,w,t) { return snail_x(u,v,w)*(1-t)+star_x(u,v,w)*t; } function parametric_y(u,v,w,t) { return snail_y(u,v,w)*(1-t)+star_y(u,v,w)*t; } function parametric_z(u,v,w,t) { return snail_z(u,v,w)*(1-t)+star_z(u,v,w)*t; }" type "script" } } Figure 1: Geometric shape morphing

341

#VRML V2.0 utf8

#VRML V2.0 utf8 FVRML PROTOs are omitted to save space

FVRML PROTOs are omitted to save space

DEF shape FShape { cycleInterval 5 loop FALSE

5 sec duration and a single execution of the cycle are defined

DEF shape FShape { enabled FALSE appearance FAppearance {

appearance FAppearance { material FMaterial { diffuseColor "r=1;g=fabs(sin(u));b=0;" type "analytical" Time span used in the } texture function texture3D FTexture3D { timeSpan 0 0.4 definition "fabs(t-0.2)*2*(sin(4*pi*x)*sin(4*pi*y)+ sin(4*pi*x)*sin(4*pi*z)+sin(4*pi*y)*sin(4*pi*z))" type "displacement" } } 3D texture is defined with an geometry FGeometry { explicit function resolution [120 120]

}

material FMaterial { timeSpan -3.1415926 3.1415926 diffuseColor "sin(sqrt(x*x+y*y+z*z) * pi + t)" patternColor [0 1 0 1 0 0] patternKey [-1 1] type "analytical" Time-dependent } color is defined } explicitly geometry DEF geo FGeometry { resolution [100 100] parameters [0 1 0 2 -1 1] definition " x=1.6*cos(0.5*u)^3; y=1.6*(cos(v)*sin(0.5*u))^3; z=1.6*sin(v)*sin(0.5*u);" type "analytical" }

parameters [-1 1 -1 1 -1 1] definition "x=(1-0.3*sin(v*5*pi))*cos(v*pi)*(4+cos(u*pi)); y=(1-0.3*sin(v*5*pi))*sin(v*pi)*(4+cos(u*pi)); z=sin(u*pi);" type "analytical" Infinite looping } and 7 sec period

DEF Time TimeSensor { loop TRUE cycleInterval 7 }

Internal timer is disabled

}

are defined with TimeSensor

DEF

ROUTE Time.cycleTime TO shape.startTime

Time TimeSensor { cycleInterval 5 loop TRUE }

Infinite looping with 5 sec period is defined with external TimeSensor

ROUTE Time.fraction_changed TO shape.set_fraction

Figure 2: Growing geometric texture

Figure 3: Animated color permutations

342

In Figure 3, we show four snapshots of the time-dependent color metamorphoses on a surface of the function-defined shape. In this case, the shape remains static, but the colors on the shape are permuting in a fancy way. The FVRML code of this color transformation is shown in Listing 1. In this code the external time sensor is used in place of the internal one.

The proposed FVRML extension is being used when teaching computer graphics at the School of Computer Engineering of Nanyang Technological University, Singapore. This is a part of computer graphics assignments “Implicit Fantasies” and “Parametric Metamorphoses” where the students have to design complex animated function-defined VRML scenes. These scenes are then used as meeting places of the Virtual Campus of NTU [Sourin 2004]—a shared virtual world built with blaxxun Contact platform, VRML, AIML, and multimedia files. The snapshot of the graphics window of the interactive collaborative modeling session at the Virtual Shape Modeling Laboratory, which is a part of the Virtual Campus, is shown in Figure 4a. The example of a completed student assignment is shown in Figure 4b.

FVRML allows for defining operations with analytical functions. Therefore, the linear morphing used in the previous examples can be defined as a custom-defined operator to make programming even easier. For example, the geometric morphing defined in Figure 1 can be also defined as it is done in Listing 1. In this example we also illustrate a concurrent definition of timedependent transformations of geometry and color. 3D texture also can be transformed concurrently with geometry and color. FTransform { cycleInterval 10 loop TRUE timeSpan 0 1 operation "f*(1-t)+g*t" type "analytical" polygonizer "analytical" parameters [0 2 0 2 -1 1] children [

Morphing transformations defined analytically

Time-dependent color FShape { appearance FAppearance { material FMaterial { timeSpan -3.1415926 3.1415926 diffuseColor "sin(sqrt(x*x+y*y+z*z) * pi + t)" patternColor [0 1 0 1 0 0] patternKey [-1 1] type "analytical" } } geometry FGeometry { resolution [50 50 50] Initial shape definition " function parametric_x(u,v,w) {return 0.03*pi*v*(10+5*cos(pi*u))*cos(3*pi*v);} function parametric_y(u,v,w) {return 0.03*pi*v*(10+5*cos(pi*u))*sin(3*pi*v);} function parametric_z(u,v,w) {return 0.03*pi*v*(6+5*sin(pi*u));}" type "script" } }

(a) FVRML shape changing through time

Time-dependent color FShape { appearance FAppearance { material FMaterial { timeSpan -3.1415926 3.1415926 diffuseColor "sin(sqrt(x*x+y*y+z*z) * pi + t)" patternColor [0 1 0 1 0 0] patternKey [-1 1] type "analytical" } } geometry FGeometry { resolution [50 50 50] Final shape definition " function parametric_x(u,v,w) {return (0.3-0.1*sin(v*5*pi))*cos(v*pi)*(4+cos(u*pi));} function parametric_y(u,v,w) {return (0.3-0.1*sin(v*5*pi))*sin(v*pi)*(4+cos(u*pi));} function parametric_z(u,v,w) {return 0.2*sin(u*pi);}" type "script" } } ] }

(b) Figure 4: (a) Collaborative Shape Modeling Laboratory (b) A shared virtual environment developed by a student as a part of the assignment “Parametric Metamorphoses in Cyberworlds”. A fancy moving FVRML shape is a part of the scene.

2.4 Interactive Shape Modeling Though the proposed way of modeling shapes with analytical functions and scripts is very versatile, it may be a problem to model something meaningful just by direct typing an FVRML code. Therefore, we have also developed an interactive modeling tool which saves models into FRML code. In the pilot version of

Listing 1: Using user-defined operations and scripts

343

This program can be used for creating a morphing animation between two absolutely different function-based shapes. This can be done by simply copying the scripts of two interactively modeled shapes, making necessary editing if needed, and finally applying the morphing transformation described in Section 2.3. Figure 6 shows several snapshots of the morphing between two shapes (A and B) modeled by this tool.

the modeling tool, a basic shape is first defined. Then, this shape is gradually modified with different set-theoretic operations which carve out or add material to the shape. The user can select different tools and operations with or without blending (Figure 5). geometry FGeometry { type "script" bboxSize 2.5 2.5 2.5 bboxCenter 0 0 0 resolution [100 100 100] definition " function sphere(x, y, z, cx, cy, cz, r) { xx = cx - x; yy = cy - y; zz = cz - z; return r*r - xx*xx - yy*yy - zz*zz; } function addblend(f1, f2, a1, a2, a3) { fa1=f1/a2; fa2=f2/a3; return (f1+f2+sqrt(f1*f1+f2*f2)+a1/(1.+fa1*fa1+fa2*fa2)); } function removeblend(f1, f2, a1, a2, a3) { fa1=f1/a2; fa2=f2/a3; return (f1+f2-sqrt(f1*f1+f2*f2)-a1/(1.+fa1*fa1+fa2*fa2)); }

More sophisticated tool [Levinski and Sourin 2004] can model very complex function-based shapes and save them in Base64encoded binary form of FVRML format which can be visualized by our plug-in but only can be edited with this modeling tool.

3

During implementation, several important factors must be considered. First, the development platform must be chosen reasonably. Second, the implementation of scripts must be elegant and sufficient, since the functions require numerous evaluations. Finally, the visualization pipeline must be designed properly and efficiently.

3.1 Development platform When choosing the development platform, several considerations have been taken into account. First, FVRML extension is a general extension of the standard VRML, so its implementation must not stick to one specific browser. Though the implementation itself may not be portable across browsers or platforms, at least the source code of the implementation should be adaptable to other browsers with only minor modifications. Second, the implementation must act as a part of the existing browsers, rather than a stand-alone application. Third, the implementation itself must be transparent so that its presence must not be evident to the users if they are not using it. Also, if not installed, no errors must happen when the FVRML code is found in the standard VRML code. Finally, the implementation must have good performance.

Figure 5: Interactive modeling FVRML shapes and a fragment of an FVRML script code created by the program

A

Based on these considerations, we have investigated all the possible ways of implementing FVRML: plugin customization, VRML External Authoring Interface (EAI), and VRML script. We have chosen VRML script and C++ as the most optimal solution. VRML script is a part of the standard VRML, so it is browser-independent and can be integrated into the browsers. Scripts are totally transparent to the users. Even if they are missing, no errors will be generated. C++ is known as a very efficient programming language. Of course, it is not truly crossplatform, and there is no standard for implementing C++ scripts for different browsers. Nevertheless, since the architectures of the VRML browsers are similar, and we do not use any platform specific features, C++ codes can be easily ported to different browsers and platforms.

B FShape { loop TRUE cycleInterval 10 frames 10 appearance FAppearance { material FMaterial { } geometry FGeometry { type "script" bboxSize 2.5 2.5 2.5 bboxCenter 0 0 0 resolution [200 200 200] definition " function sphere(x, y, z, cx, cy, cz, r) { function frep1(x, y, z) { . . . . . . } #shape A function frep2(x, y, z) { . . . . . . } #shape B

}

3.2 Script implementation details

function frep(x,y,z,t) return frep1(x,y,z) * (1-t) + frep2(x,y,z) * t; }"

{

Implementation details

The compiler of the script is built with the skeleton code generated by Yet Another Compiler Compiler (YACC) from the Backus Naur Form (BNF) definition of the script. For each userdefined function, the intermediate code is generated and stored in the memory. In order to achieve better performance, the predefined mathematical functions are defined by C++ code instead of intermediate code.

} }

Figure 6: Morphing animation created by interactively modeled shapes A and B

344

In order to simplify the implementation, for each expression in the script no more than one thousand mathematical operations are allowed. Longer expressions are to be split into several notations using temporary variables. Since floating point number is the only possible data type, whenever accessing an array the index of the array will be rounded up to the nearest integer. For example, definition array[1.6] is equivalent to array[2].

optimization can only gain a little performance enhancement since the code is still interpreted on a virtual machine. The other way is to employ so-called Just-In-Time (JIT) compiling techniques [Krall 1998], which has been already widely used by crossplatform languages such as Java and C#. JIT techniques dynamically convert the intermediate code into assembly code, and then the assembly code is executed directly by computer. The optimized assembly code demonstrates the best performance.

3.3 Visualization pipeline

We employed the JIT techniques in our FVRML extension. When evaluation is required, the intermediate code is converted into the assembly code on the fly. The conversion is done only once provided the source code remains unchanged. We have observed a 4 times performance boost when running our JIT compiler on main stream CPUs with SSE technology, which are Pentium III, AMD Athlon XP or higher.

To implement time-dependent FVRML extension, an efficient visualization pipeline must have been designed. It should allow time-dependent objects to be rendered and changed continuously while users are interacting and navigating through the virtual worlds. This is achieved by adopting multi-threading techniques. The visualization pipeline for time-dependent FVRML objects consists of two threads and eight modules, which are Parser, Compiler, TimeGenerator, ShapeGenerator, TextureGenerator, ColorGenerator, TransformOperator, and Polygonizer (Figure 7). VRML Source

Generation of numerous polygon meshes constituting animated shape metamorphoses requires very fast poygonization for making these meshes on the fly. However when computationally expensive mathematical functions and scripts are used, caching of the meshes appears to be feasible. We implemented caching as follows. Whenever a mesh is required for a certain time parameter, it is first searched in the cache memory. If the mesh can not be found, it is generated and cached. If the mesh is available in the cache, we generate and cache the next unavailable mesh. Using this algorithm, a progressive visualization is achieved. Initially, the animation is not smooth, but it improves gradually while all the required meshes are being generated and cached.

TimeGenerator

Parser

Code

ShapeGenerator

TextureGenerator

Compiler

VRML Interaction

Due to the limited memory size, caching the VRML nodes directly is not feasible. A computer equipped with 1GByte RAM can only cache a few hundreds of meshes, which is very little for making animation. Because of this, we use our own proprietary data format which is converted into VRML nodes during the fetching process. By doing this, even without any compression algorithms 1G memory can store thousands of meshes, which is sufficient for storing reasonable animated sequences.

ColorGenerator

Transform Operator VRML Renderer

VRML Nodes

Polygonizer

4 VRML Browser

FVRML Extension

Conclusion and future work

In this paper we propose a new function-based extension of VRML that allows for defining time-dependent shapes. The shapes are defined by analytical parametric, implicit and explicit functions which define shape’s geometry, 3D geometric texture and color. All these functions can be functions of time. The functions can be grouped into scripts. Custom time-dependent operations can be defined by analytical functions as well. With the proposed extension, programming of fancy animated shape metamorphoses becomes very easy in VRML. Sophisticated shaped can be defined without increasing the file size as it normally happens when polygon-based models of VRML97 are used. The developed FVRML extension was successfully used when teaching computer graphics and shape modeling at Nanyang Technological University. The FVRML plug-in is available at http://www.ntu.edu.sg/home/assourin/fvrml.htm.

Figure 7: FVRML Visualization pipeline The diagram shows how FVRML code can cooperate with the VRML browser. Solid lines represent the execution flow, and dotted lines represent the communication between the threads. One thread is responsible for parsing and compiling the source code into an intermediate code executed by virtual machine, while the other thread is responsible for conversion of the timedependent function-based model into polygons. For each specific frame, one set of polygons is generated on-the-fly. Visualization of function-based time-dependent objects is a time critical task. Speeding up function evaluation can greatly improve the polygonization process. However, with introducing scripts the performance of the evaluation process has slowed down since executing scripts on a virtual machine is far more computationally demanding than evaluation of analytical functions. As such, finding a way of improving the performance of scripts is a must for visualizing time-dependent function-based models. One common way of improving the performance of a virtual machine is to optimize the compiled intermediate code. However, this

References ALEXA, M., BEHR, J., AND MULLER, W. 2000. The morph node. In Proc. 5th Symp. Virtual Reality Modeling Language (Web3D-VRML), 29–34.

345

ALEXA, M. AND MULLER, W. 1999. The morphing space. In Proc. WSCG 99.

exposedField SFVec3f bboxSize 10 10 10 exposedField SFString type "" exposedField MFNode parents [] exposedField SFVec2f timeSpan 0 1 ] PROTO FMaterial [ exposedField SFString diffuseColor "" exposedField SFString type "" exposedField MFColor patternColor [] exposedField MFFloat patternKey [] exposedField SFFloat ambientIntensity 0.2 exposedField SFColor emissiveColor 0 0 0 exposedField SFFloat shininess 0.2 exposedField SFColor specularColor 0 0 0 exposedField SFFloat transparency 0 exposedField MFNode parents [] exposedField SFVec2f timeSpan 0 1 ] PROTO FTexture3D [ exposedField SFString definition "" exposedField SFString type "" exposedField MFFloat parameters [0] exposedField MFNode parents [] exposedField SFVec2f timeSpan 0 1 ] PROTO FAppearance [ exposedField SFNode material NULL exposedField SFNode texture NULL exposedField SFNode textureTransform NULL exposedField SFNode texture3D NULL exposedField MFNode parents [] eventIn SFBool refresh ] PROTO FShape [ exposedField SFNode geometry NULL exposedField SFNode appearance NULL exposedField SFString polygonizer "analytical" exposedField MFNode parents [] eventIn SFBool refresh exposedField SFTime startTime 0 exposedField SFTime stopTime 0 exposedField SFTime cycleInterval 1 exposedField SFBool loop FALSE exposedField SFBool enabled TRUE eventOut SFTime cycleTime eventIn SFFloat set_fraction ] PROTO FTransform [ exposedField SFString operation "union" exposedField SFString type "setoperator" exposedField SFString polygonizer "analytical" exposedField MFFloat parameters [0] exposedField SFVec3f center 0 0 0 exposedField SFRotation rotation 0 0 1 0 exposedField SFVec3f scale 1 1 1 exposedField SFRotation scaleOrientation 0 0 1 0 exposedField SFVec3f translation 0 0 0 exposedField MFNode children [] exposedField MFNode parents [] eventIn SFBool refresh exposedField SFVec2f timeSpan 0 1 exposedField SFTime startTime 0 exposedField SFTime stopTime 0 exposedField SFTime cycleInterval 1 exposedField SFBool loop FALSE exposedField SFBool enabled TRUE eventOut SFTime cycleTime eventIn SFFloat set_fraction ]

BRETON, G., BOUVILLE, C., AND PELE, D. 2001. FaceEngine a 3D facial animation engine for real time applications. In Proc. ACM Web3D’01, 15–22. DAVIES, R. A., JOHN, N. W., MACDONALD, J. N., AND HUGHES, K. H. 2005. Visualization of molecular quantum dynamics: a molecular visualization tool with integrated Web3D and haptics. In Proc. ACM Web3D '05, 143–150. ESULI, A., CISTERNINO, A., PACINI, G., AND SIMI, M. 2003. Multimodal presentation of dynamic object scenarios on the web. In Proc. ACM Web3D’03, 147–153. KRALL, A. 1998. Efficient JavaVM just-in-time compilation. In Proc. Int. Conf. Parallel Architectures and Compilation Techniques, 54–61. LAI, F. M., AND SOURIN, A. 2002. Function-defined shape node for VRML. In Eurographics 2002, Short Presentations, 207–215. LEVINSKI, K. AND SOURIN, A. 2004. Interactive Function-Based Shape Modeling for Cyberworlds. In Proc. Int. Conf. Cyberworlds, CW2004, 54–61. LIU, Q. AND SOURIN, A. 2005. Function-based Representation of Complex Geometry Appearance. In Proc. ACM Web3D '05, 123–134. LIU, Y. L. AND LI, T. Y. 2003. A multi-user virtual environment system with extensible animations. In Proc. ACM Web3D’03, 129–134. NAKA, T., MOCHIZUKI, Y., HIJIRI, T., CORNISH, T., AND ASAHARA, S. 1999. A compression/ decompression method for streaming based humanoid animation. In Proc. 4th Symp. Virtual Reality Modeling Language, 63–70. PANDZIC, I. S. 2002. Facial animation framework for the web and mobile platforms. In Proc. ACM Web3D’02, 27–34. PASKO, A. A., ADZHIEV, V. D., SOURIN, A. I., AND SAVCHENKO, V. V. 1995. Function Representation in Geometric Modeling: Concepts, Implementations and Applications, The Visual Computer, 11, 8, 429–446. ROBERTS, J. C. 1998. Publishing Time Dependent Oceanographic Visualizations using VRML. In Proc. 5th UK Virtual Reality Special Interest Group -- VRSIG '98. SOURIN, A. 2004. Nanyang Technological University Virtual Campus, IEEE Computer Graphics & Applications, 24, 6, 6– 8.

Appendix. FVRML Prototypes PROTO FGeometry [ exposedField SFString definition "" exposedField MFFloat parameters [0] exposedField MFInt32 resolution [50 50 50] exposedField SFVec3f bboxCenter 0 0 0

346

Function-defined Shape Metamorphoses in VRML Liu and Sourin

Modeling Landscapes with Ridges and Rivers: bottom up approach Belhadj and Audibert

464