Geometry3D component - extensions

Contents:

1. Triangulation of primitives (Sphere, Cone, Cylinder, Box, Circle2D)

Triangulation demo screenshot

We add some fields to primitive geometry nodes to control their triangulation:

Box {
  ...
  SFInt32    [in,out]      divisions   -1          # [-1, infinity)
}
Cone {
  ...
  SFInt32    [in,out]      slices      -1          # {-1} + [3, infinity)
  SFInt32    [in,out]      stacks      -1          # {-1} + [2, infinity)
}
Cylinder {
  ...
  SFInt32    [in,out]      slices      -1          # {-1} + [3, infinity)
  SFInt32    [in,out]      stacks      -1          # {-1} + [2, infinity)
}
Sphere {
  ...
  SFInt32    [in,out]      slices      -1          # {-1} + [3, infinity)
  SFInt32    [in,out]      stacks      -1          # {-1} + [2, infinity)
}
Circle2D {
  ...
  SFInt32    [in,out]      slices      -1          # {-1} + [3, infinity)
}

For spheres, cones and cylinders you can set how many slices (like slices of a pizza) and how many stacks (like stacks of a tower) to create. For boxes, you can set how to triangulate faces of cubes.

You can easily test the effects of these fields by investigating your models in view3dscene. You can view in Wireframe mode to see the triangulation. You can try it on our test file: see our VRML/X3D demo models, file x3d/castle_extensions/triangulation.x3dv.

Note that our programs do two different variants of triangulation, and they automatically decide which variant to use in each case:

  1. Triangulation for collision detection and ray-tracer. This is intended to approximate quadrics as triangle meshes.
  2. Triangulation for Gouraud shading. We call this over-triangulation. To improve the shading, it's worth triangulating a little more, even the flat faces. This is used when rendering models.

    In this variant we do a little more triangulation. In particular, we divide cones and cylinders into stacks, and we divide cube faces. For collision detection, this additional triangulation is useless (as it doesn't give any better approximation of an object). But it improves how objects look with Gouraud shading.

Special value -1 for any of these fields means that we use some default, sensible value.

Generally, triangulate more if the object is large or you want to see light effects (like light spot) looking good. If the object is small you can triangulate less, to get better rendering time.

2. Specify orientation of primitives (Box.ccw)

We add Box.ccw field. The default TRUE means that box is visible only from the outside. You can specify FALSE to make it visible only from the inside. Note that you can also use solid FALSE to make it visible from both sides.

Box {
  ...
  SFBool     []            ccw         TRUE      
}