[x3d-public] Proposal: new field "factor" in Transform node

Yves Piguet yves.piguet at gmail.com
Tue Apr 19 07:21:51 PDT 2016


Hi,

In prototypes, if a field specifies a scalar translation or rotation, you often need additional nodes (typically Script or interpolators) and routes to convert them to the SFVec3f or SFRotation required by the Transform node.

I suggest to add the following field to Transform:

SFFloat [in,out] factor 1 (-inf,inf)

A value != 1 would have the following effect on these fields:

- rotation: the angle of rotation (fourth component) is multiplied by factor;

- scale: each of the 3 components s (assumed to be != 0) is replaced by sign(s) * exp(log(abs(s)) * factor);

- translation: the translation vector is multiplied by factor.

For rotation and translation, this corresponds to a linear interpolation from identity transform if factor is between 0 and 1, and extrapolation if factor is outside this range. For the scale field, this is a logarithmic interpolation, so that 1 is left unchanged.

Here is an example where a sphere is positioned along a cylinder. First with what we have in X3D 3.3:

#X3D V3.3 utf8
PROTO Ball [
  inputOutput SFFloat y 0
] {
  Group {
    children [
      Shape {
        geometry Cylinder {
          radius 0.2
          height 4
        }
      }
      DEF tr Transform {
        children Shape {
          geometry Sphere {}
        }
      }
    ]
  }
  Script {
    inputOutput SFFloat y IS y
    initializeOnly SFNode tr USE tr
    url "ecmascript:
      function eventsProcessed() {
        tr.translation = new SFVec3f(0, y, 0);
      }
      function initialize() {
        eventsProcessed();
      }
    "
  }
}
Ball { y 0.5 }

Then with the proposed field "factor":

#X3D V4.0 utf8
PROTO Ball [
  inputOutput SFFloat y 0
] {
  Group {
    children [
      Shape {
        geometry Cylinder {
          radius 0.2
          height 4
        }
      }
      DEF tr Transform {
        translation 0 1 0
        factor IS y
        children Shape {
          geometry Sphere {}
        }
      }
    ]
  }
}
Ball { y 0.5 }

Yves




More information about the x3d-public mailing list