Hybrid Function-based Shape Modeling and Web Visualization

The Research Team:
Dr. Alexei Sourin
Mr. Shahzad Rasool (PhD project: 2010 - currently)
Mr. Cui Jian (PhD project: 2013-currently)
Contributed researchers:
Ms. Lai Danbo (PhD project: 2009 - 2013)

Dr. Lei Wei (PhD project: 2006 - 2011)

Dr. Qi Liu  (PhD project: 2004 - 2007)
Dr. Konstantin Levinski (MSc/PhD project: 2001-2007)
Mr. Lai Feng Min (MEng project, 2000-2002) 

Last time updated 21 November, 2013

FVRML/FX3D: Function-based extension of VRML and X3D  (version 5.0)

VIMAT: Visual Immersive Mathematics (beta testing)


FVRML/FX3D: Function-based extension of VRML and X3D  (version 5.0)

Introduction

Function-based extension of VRML and X3D (FVRML/FX3D) allows for extending VRML and its successor X3D with practically any type of object’s geometry and sophisticated graphics appearances by defining the object’s geometry, appearance (color and 3D texture) and transformations with analytical formulas which are implicit, explicit and parametric representations used concurrently. Static and time-dependent shapes and operations can be defined. In contrast to the polygon-based models of VRML/X3D, function-based nodes greatly reduce the size of the models and provide an unlimited level of detail. Also, these nodes allow for using set-theoretic as well as any analytically-defined geometric operations which can be introduced by the user. FVRML/FX3D allows for its extending with any proprietary function-based models.  The extension is developed for collaborative shape modeling as well as for building shared virtual worlds.

Back


Software Installation

The following plug-ins work with MS Internet Explorer and Mozilla Firefox.

1. Install  BS Contact VRML/X3D (32bit version).

2. Click to install the FVRML/FX3D plug-in ( Version 5.3, 11 November  2013, memory bug fixed).

Please report bugs to assourin@ntu.edu.sg


FVRML Extension Description and Programming Examples

Function-based extension of VRML—FVRML—allows for extending VRML with practically any type of object’s geometry, sophisticated graphics appearance and transformation by defining them analytically straight in the VRML code. In contrast to the polygon-based models of VRML, function-based nodes allow for a great reduction of the model sizes and provide an unlimited level of detail. Also, these nodes introduce to VRML set-theoretic as well as any other operations analytically-defined by the user.

For defining geometry, appearance and their transformations, three types of functions can be used concurrently. They are implicit, explicit and parametric functions.

Implicit functions are f(x,y,z,t)=0, where x, y, z are Cartesian coordinates and t is the time. The function equals to zero for the points located on the surface of a shape.

Explicit functions are g=f(x,y,z,t). The function value g evaluated at any point of the 3d space can be used either as an argument of other functions (e.g. for defining colors or parameters of transformations) or as an indicator of the sampled point location. Thus, explicit functions can be used for defining bounded solid objects. In this case, the function equals to zero for the points located on the surface of a shape. Positive values indicate points inside the shape and negative values are for the points outside the shape.

Parametric functions define surfaces and solid objects as:

 x= f1(u,v,w,t);  y= f2(u,v,w,t);  z= f3(u,v,w,t)  where x, y, z are Cartesian coordinates of the points, while u, v and w are parametric coordinates, and t is the time. Parametric functions can also define r, g, b values of color or parameters of transformations.

Geometry, 3D texture, and color can be defined by implicit, explicit or parametric functions in their own domains and then merged together into one shape by the predefined mapping functions. When modeling shape, first a geometric texture is mapped onto the original shape’s geometry, and then the color is mapped to the textured shape to form the final shape. This process repeats as many times as needed.

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 VRML, which has a JavaScript (VRMLScript) as a standard feature, and to ease the learning curve, FVRML emulates 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). There are also three operators ‘&’, ‘|’ and ‘^’, which denote set-theoretic ‘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, while-loops, do-while-loops, break, continue, and if-else.

When writing function scripts, implicit and explicit functions have to be named ‘frep’. Parametric functions for shapes and geometric textures have to be named ‘parametric_x’, ‘parametric_y’, and ‘parametric_z’, and for colors—‘parametric_r’, ‘parametric_g’, and ‘parametric_b’. If all these functions exist concurrently, frep function will have priority.

    FVRML offers six additional nodes, which are FShape, FGeometry, FAppearance, FMaterial, FTexture3D and FTransform. These nodes can be used together as well as with the standard VRML nodes. The nodes' prototypes are here.

FShape node is a container similar to the VRML’s Shape node. It contains FGeometry or any standard geometry node, and FAppearance or the standard Appearance node. These nodes define the geometry and the appearance of the shape, respectively. FShape may be called from FTransform node of from the standard Transform node.

FGeometry node is designed to define a geometry using implicit, explicit or parametric functions. It contains either one string, or a script defining a function representing the geometry, or a URL to the function definition.

FAppearance node may contain FMaterial or the standard Material, the standard Texture node, and FTexture3D node. FTexture3D defines geometric textures while the standard Texture node is used for image texture mapping.

FMaterial node defines diffuse, specular, and emissive colors, as well as transparency, ambient intensity, and shininess with parametric and explicit functions. Parametric functions directly define color values r, g, b. When the color is defined with an explicit function, its values are linearly mapped to the r, g, b values of the actual color with a user-defined color interpolation map. The color can be defined at every point of the 3D modeling space and then will be sampled by the geometry of the shape.

FTexture3D node defines 3D geometric textures using explicit and parametric functions. These functions define displacements of the original shape’s geometry defined in FGeometry or in any standard geometry node. The functions are defined either in one string, or in a function script, or via a URL to the function definition.

If the standard Geometry node is used in place of FGeometry node, the standard shapes of VRML will be assigned an appearance defined in FAppearance node. This ability of using the function-based nodes with the standard geometry and appearance nodes of VRML adds many new features to VRML, some of which are illustrated in this chapter.

FTransform node contains function-defined operations. It may contain FShape and other FTransform nodes as its children. FTransform contains either one string, or a script defining a function representing the operation, or a URL to the function definition as well as other fields to preserve the consistency with the standard Transform node. Both, set-theoretic and affine transformations can be defined as functions of time in FTransform node.

FVRML Examples:

In the following examples, different ways of using implicit, explicit and parametric functions for defining the shape's geometry and appearance are used.
For better performance switch the VRML viewer to OpenGL (software) mode.
Click at the images to see the VRML scene. Right click to save the .wrl file.

Time-Dependent FVRML examples:

Parametric Metamorphoses:

Curves:

Parametric solids (beta):

Parameters of the FVRML fields:

definition “f(x,y,z,t)“

or

definition"

frep(x,y,z,t){

function script; return frep(x,y,z,t);}”

or

definition”

x= x(u,v,w,t); y= y(u,v,w,t); z= z(u,v,w,t);”

or

definition”
function parametric_x(u,v,w,t){

function script; return x(u,v,w,t);}

function parametric_y(u,v,w,t){

function script; return y(u,v,w,t);}

function parametric_z(u,v,w,t){

function script; return z(u,v,w,t);}” 

In this field analytical definition of the shape's geometry or geometric texture has to be defined. It can be given either as individual implicit or parametric formulas or as a function script. The names of Cartesian coordinates are
x, y, z, while the names of parametric coordinates are u, v, w. Parameter t is the time. The number of variables is optional. For defining surfaces and solid objects x, y, z variables are to be used. For defining parametric surfaces, two of the parameters coordinates are to be used (e.g., u and v). For defining curves, only one of the parametric coordinates is to be used. New variable names can be introduced in function scripts as it is normally done in JavaScript. The formulae can be also called by a URL.

parameters [p1  p2  p3  p4  p5  p6]

 

Default: parameters [-1 1 -1 -1 1]

It defines parameters' range for u, v, w and continuity of the predefined set-theoretic operations. Default values for u, v, w are -1 1, and the continuity is 0. If the continuity equals to 0, the set-theoretic operations are implemented with min/max functions (as in Chapter 3). If the continuity is greater than 0, they are implemented with the so-called
R-functions.

bboxCenter x  y  z

Default: bboxCenter 0  0  0

It defines the origin of the coordinate system of the implicitly/explicitly defined surface.

bboxSize x  y  z

 Default: bboxSize 10 10 10

It defines the size of the bounding box, and thus the range of variables x, y, z for the implicitly/explicitly defined shape.

resolution [x  y  z]

 Default: resolution [50 50 50]

It defines the rendering resolution. There must be 3 values for solid shapes, 2 values for parametric surfaces, and 1 value for parametric curves.

diffuseColor ”frep(x,y,z,t)”

or

diffuseColor ”

frep(x,y,z,t){

function script; return frep(x,y,z,t);}”

or

diffuseColor ”

r=r(u,v,w,t); g=g(u,v,w,t); b=b(u,v,w,t);”

or

diffuseColor ”

function parametric_r(u,v,w,t){

function script; return r(u,v,w,t);}

function parametric_g(u,v,w,t){

function script; return g(u,v,w,t);}

function parametric_b(u,v,w,t){

function script; return b(u,v,w,t);}” 

In this field the function definition of the shape's diffuse color is to be given. It can be typed either as individual explicit or parametric formulas or as a function script. Cartesian coordinates are x, y, z, while the names of parametric coordinates are u, v, w. Ranges of the variables can be defined in parameters, bboxCenter, and bboxSize fields. Parameter t is the time. The formulae can be also called by a URL. In case if the color is defined by an explicit function, color interpolation will be done using the values defined in fields patternKey and patternColor.

emissiveColor ”frep(t)”

or

emissiveColor ”

frep(t){

function script; return frep(t);}”

or

emissiveColor ”

r=r(t); g=g(t); b=b(t);”

or

emissiveColor ”

function parametric_r(t){

function script; return r(t);}

function parametric_g(t){

function script; return g(t);}

function parametric_b(t){

function script; return b(t);}”  

It defines a time-dependent emissive color by an explicit function or script. In case of color definition by one explicit function, color interpolation will be done by the current pattern. Parameter t is the time. The formulae can be also called by a URL. The emissive color is assigned to the whole shape and cannot vary across it. In case if the color is defined by an explicit function, color interpolation will be done using the values defined in fields patternKey and patternColor.

specularColor ”frep(t)”

or

specularColor ”

frep(t){

function script; return frep(t);}”

or

specularColor ”

r=r(t); g=g(t); b=b(t);”

or

specularColor ”

function parametric_r(t){

function script; return r(t);}

function parametric_g(t){

function script; return g(t);}

function parametric_b(t){

function script; return b(t);}” 

It defines a time-dependent specular color by an explicit function or script. In case of color definition by one explicit function, color interpolation will be done by the current pattern. Parameter t is the time. The formulae can be also called by a URL. The specular color is assigned to the whole shape and cannot vary across it. In case if the color is defined by an explicit function, color interpolation will be done using the values defined in fields patternKey and patternColor.

ambientIntensity “frep(t)

It defines a time-dependent ambient intensity by an explicit function or script. The ambient intensity is assigned to the whole shape and cannot vary across it.

shininess frep(t)

It defines a time-dependent shininess by an explicit function or script. The shininess is assigned to the whole shape and cannot vary across it.

transparency frep(t)

It defines a time-dependent transparency by an explicit function or script. The transparency is assigned to the whole shape and cannot vary across it.

patternKey [a1   a2   a3 …  an]

It defines the values of the explicit diffuseColor, emissiveColor or specularColor function or script which will be used for mapping to patternColor.

patternColor [rgbrgb2 … rgbn]

It defines the colors which will be used for interpolating the color defined by an explicit diffuseColor, emissiveColor or specularColor function or script based on the current patternKey. Linear interpolation of colors will be done.

g=...;
patternValue(g);
The function is used in scripts to generate colors defined by patternKey and patternColor.

translation “x=x(t); y=y(t); z=z(t);”

It defines translation parameters by explicit functions or scripts.

scale “x=x(t); y=y(t); z=z(t);”

It defines scaling parameters by explicit functions or scripts.

rotation “x=x(t); y=y(t); z=z(t); a=a(t);”

It defines rotation parameters by explicit functions or scripts.

center “x=x(t); y=y(t); z=z(t);”

It specifies a function-defined translation offset from the origin of the local coordinate system (0, 0, 0).

scaleOrientation

“x=x(t); y=y(t); z=z(t); a=a(t);”

It specifies a function-defined rotation of the coordinate system before the scale (to specify scales in arbitrary orientations).

operation

 “union | intersection | difference”

or

operation “

frep(f,g,t){

function script; return frep(f,g,t);}”

 

Default: operation “union”

parameters [0]

In this field either a name of the predefined set-theoretic operation or an individual formula or script defining a set-theoretic operation on shapes defined by functions f(x,y,z,t) and g(x,y,z,t) have to be typed. The respective FShapes are to be defined as children of FTransform node. Set-theoretic operations do not apply to parametrically defined shapes.

timeSpan  t1   t2

  

 

Default: timeSpan  0  1

It defines a time interval of variable t when defining a time-dependent process (shape's geometry, color, texture or transformation). Variables t1 and t2 can take any real values including negative.

startTime  t

Default: startTime  0

It defines the values of time to start a time-dependent process.

stopTime  t

Default: stopTime  0

It defines the values of time to stop a time-dependent process.

cycleInterval  t

Default: cycleInterval  1

It defines the duration of the time-dependent process cycle in sec.

frames   n

Default: frames 0

It defines the number of frames to be cached. If 0 is defined, rendering time-dependent processes will be performed on the fly.

loop TRUE|FALSE

Default: loop FALSE

It enables or disables looping of time-dependent processes.

enabled TRUE|FALSE

Default: enabled TRUE

It enables or disables time-dependent processes.

trilinear(x,y,z,size_x,size_y,size_z,’filename’) This function is provided to support 8-bit raw CT/MRI data. Parameter x, y, and z represents the coordinates of the point to be evaluated. Parameter size_x, size_y and size_z indicates the dimension of the CT/MRI data. Parameter filename is a string, representing the volume data file. When the filename is a relative file name, it is a file relative to the C:/Program Files/FuncNodes/Processor directory of the plug-in. When the filename is an absolute file name, it reads the absolute file directly. When the filename is an URL of http, https or ftp, the function reads the file from the network according to the URL.
nurbs

Besides function scripts and analytical formulae, NURBS surface can also be defined in FVRML. When defining NURBS surface, the ‘type’ field in FGeometry should be set as ‘nurbs’. In the ‘definition’ field, write the definition of the NURBS surface. The definition of the NURBS surface is formatted as the follows:

‘uOrder <uOrder>

vOrder <vOrder>

uDimension <n>

vDimension <m>

uKnots [<uKnot1> <uKnot2> .. <uKnot n>]

vKnots [<vKnot1> <vKnot2> .. <vKnot m>]

controlPoint [<Point1_x> <Point1_y> <Point1_z> <Point2_x> <Point2_y> <Point2_z> .. <Point m*n_x> <Point m*n_y> <Point m*n_z>]

weight [<Weight1> <Weight2> .. <Weight m*n>]’

uDimension and vDimension define the number of control points in the u and v dimensions. uOrder and vOrder define the order of surface. uKnots and vKnots define the knot vectors.

controlPoint defines a set of control points of dimension uDimension * vDimension. This set of points defines a mesh similar to the grid of a ElevationGrid whereas the points do not have a uniform spacing. Depending on the weight-values and the order this hull is approximated by the resulting surface. #uDimension points define a polyline in u-direction followed by further u-polylines with the v-parameter in ascending order. The number of control points must be equal or greater than the order. A closed NURBS surface can be specified by repeating the limiting control points.

The control vertex corresponding to the control point P[i, j] on the control grid is :

    P[i,j].x = controlPoints[i + ( j × uDimension)].x

    P[i,j].y = controlPoints[i + ( j × uDimension)].y

    P[i,j].z = controlPoints[i + ( j × uDimension)].z

    P[i,j].w = weight[ i + (j × uDimension)]

    where 0 <= i < uDimension and 0 <= j < vDimension.

Back


FX3D Extension Description and Programming Examples

Preserving backward compatibility with FVRML, in function-based extension of X3D there are six concrete node types FShape, FGeometry, FAppearance, FMaterial, FTexture3D, and FTransform and one abstract node type X3DFunctionChildNode. The existing models designed using FVRML can be upgraded to FX3D with minimum efforts.

FShape node is designed to associate a function-defined geometry and a function-defined appearance, which is quite similar to Shape node. FShape may be used as a child of a function-defined operation, which results in the implementation of X3DFunctionChildNode.

FGeometry node is designed to define a geometry using any type of functions—implicit, explicit or parametric.

FAppearance node represents function-defined material, function-defined 3D geometric texture, and other regular appearance components (2D/3D image texture, texture transformation, etc.).

FMaterial node contains color information of a shape, including the function definitions used to describe the diffuse color.

 FTexture3D stores function definitions of a 3D geometric texture, such as vertex displacements.

FTransform defines affine transformations (i.e. translation, rotation, and scaling) as well as set-theoretic operations on function-defined shapes.

The detailed definitions of the function-based node types can be seen in FX3D.x3d.

FX3D examples:

If BS Contact VRML/X3D is used, make sure to deselect "resolve external XML resources" in Settings/Preferences/General.

For users of Xj3D, download fx3d.jar and copy it to the Xj3D root directory.

Back


Interactive Shape Modeling Tool

This application requires  BS Contact VRML/X3D to be installed. It works only with MS Internet Explorer and Mozilla Firefox. Make sure you have installed the most recent version of the FVRML plug-in.

Release notes:
1. Geometry and appearance are defined in their own coordinate systems and can be mutually interactively relocated to form a final shape.
2. Geometry and appearance can be changed in editing windows which can be displayed by clicking at Edit operation in Geometry and Appearance modes.
Mathematical operations and functions which can be used in formulas:
+,  - ,  *, /, ^, &, |
acos, asin, atan, atan2, cos, cosh, exp, fabs, fmod, log, log10, sin, sinh, tan, tanh, sqrt, ceil, floor, range, min, max
^           Power. E.g.  x^3 stands for x*x*x
&         
Set-theoretic "AND". The continuity of this function can be defined in parameters.
|           
Set-theoretic "OR". The continuity of this function can be defined in parameters.
range    When a>b and a<c, range(a,b,c)=1, otherwise, range(a,b,c)=0. This function is only provided for FRep shapes.
3. In the editing windows, the basic shape and tools definition functions and scripts are kept separated from the coordinate transformations and other parameters.
4. Any part constituting the shape can be edited by selecting it in Show Handle mode.
5. The models can be saved/loaded as well as exported to VRML.

Email problems to: Alexei Sourin


Web visualization of the interactively created function-based models

This part of the extension is developed for exchanging through Internet the shapes interactively created in the project Interactive Function-based Shape Modeling. The plug-in includes the polygonizer specially developed for rendering these models. This Polygonizer is capable of a quick visualization of very complicated FRep shapes. This plug-in illustrates the extensibility of our approach where any function-defined models can be used as a part of a VRML scene.

See the example of VRML scene with with the function-defined shapes modeled with the tools from  http://www3.ntu.edu.sg/home/assourin/Intshape.html. For some of the models, double-resolution is used for rendering so that when the object or observer is moving, coarse resolution is used for rendering, and when it comes at rest, fine resolution is used.

Back


VIMAT: Visual Immersive Mathematics

Introduction

In this new project, we expand our considerations to three components of the objects in shared virtual spaces: geometry, visual appearance, and tangible physical properties, which we define separately by implicit, explicit or parametric functions and then merge together into one shape. We define visual appearance properties as 3D colors and geometric textures which are applied to underlying geometry. Tangible physical properties are defined as surface properties (friction and tension), as well as inner density and forces associated with the underlying geometry. We can also touch and feel surfaces of X3D and VRML objects as well as convert them to solid tangible objects.

 

     We add new FShape and FTransform nodes. The FShape node, in turn, contains other 10 nodes (FGeometry, FAppearance, FMaterial, FTexture3D, FPhysics, FSurface, FFriction, FTension, FDensity, FForce) in the same way how the standard Shape node is organized. These nodes can be used alone as well as with some VRML and X3D standard nodes (Fig. 4).

     The FShape node is a container for the FGeometry or any standard geometry node, and the FAppearance or the standard Appearance node. These nodes define the geometry and the appearance of the shape, respectively.

     The FGeometry node is designed to define a geometry using functions typed straight in the code or stored in binary libraries.

     The FAppearance node may contain the FMaterial or the standard X3D Material nodes, as well as the standard color Texture and the function-based FTexture3D nodes. In the FMaterial node, the components of the illumination model are defined using functions. The FTexture3D node contains a displacement function for the geometry defined in the FGeometry node.

     The FPhysics node is used for defining physical properties associated with the shape’s geometry. The FPhysics contains the FSurface, FDensity and FForse nodes.

     The FSurface node defines surface physical properties. It includes FFriction and FTension nodes. The FFriction node is used for defining friction on the surface which can be examined by moving a haptic device actuator by the surface. The FTension node defines the force which has to be applied to the haptic actuator to penetrate the surface of the object. The surface friction and tension are defined by explicit functions of coordinates x, y, z and the time t. Hence, the surface friction and tension can vary on different parts of the surface.

     The FDensity node is used for defining material density of the shape. It can be examined by moving a haptic device actuator inside the visible or invisible boundary of the shape. The density is defined by explicit functions of coordinates x, y, z and the time t, and hence it can vary within the volume of the shape. The surface of the shape can be made non-tangible, while the shape still might have density inside it to define some amorphous or liquid shapes without distinct boundaries.

     The FForce node is used for defining a force field associated with the geometry of the shape. The force vector at each point of the space is defined by 3 functions of its x, y, and z components and the time t. The force can be felt by placing the haptic device actuator into the area where the force field is defined. Moving the actuator within the density and the force fields will produce a combined haptic effect.

     The FShape node may be called from the FTransform node or from the standard Transform node. The FTranform node defines affine transformation which can be functions of time, as well as any other operations over the function-defined shapes. These are predefined set-theoretic (Boolean) intersection, union, difference, as well as any other function-defined set-theoretic and any other operations, e.g. r-functions, shape morphing, etc.

Software Installation

The plug-in to BS Contact VRML/X3D is fully compatible with FVRML/X3D and requires one of the haptic devices from Sensable (e.g. OMNI, Desktop, Premium 1.5/6DOF) with OpenHaptics toolkit installed.


      Phantom OMNI             Phantom Desktop

Demos

Here is a streaming video and a few examples of the VRML scenes with tangible physical properties.

 Feeling home

Stirring virtual water

          Being a ball

Playing with a shark

Gone by the wind

Crunchy melon

 

Another video illustrates haptic collaboration in a shared scene.

Feasibility study on tangible images and video is here.


Selected Publications:


Copyright 2001-2006  Lai F.M, Lei. W., Levinski K., Liu Q., Sourin A.
This material may not be published, modified or otherwise redistributed in whole or part without prior approval.