Super shape

From H3D.org

Jump to: navigation, search

In addition to the X3D specified geometries, H3DAPI has a SuperShape node that can create shapes derived from Superformula, a formula used to describe geometric shapes found in nature. The SuperShape node fields represent the parameters corresponding to Superformula.

Image:Note-info.pngMore information about Superformula here.
Image:Note-tip.pngThis tutorial refers to the source code. You can download it from SVN at H3D release branch, or find it at H3D/H3DAPI/examples/SuperShape.
 
<!!-- SuperShape.x3d -->
<Group>
   <FitToBoxTransform boxCenter="0 0 0" boxSize="0.3 0.3 0.3" 
   uniformScalingOnly="true" active="true">
     <Shape>
       <Appearance>
        <Material diffuseColor="0.7 1 0.7"/>
        <SmoothSurface />
       </Appearance>
       <SuperShape DEF="SS" resolution="128" 
                   ss1_m="6" ss1_a="1" ss1_b="1"
                   ss1_n1="1" ss1_n2="1" ss1_n3="1"
                   ss2_m="3" ss2_a="1" ss2_b="1"
                   ss2_n1="1" ss2_n2="1" ss2_n3="1"  />
     </Shape>
   </FitToBoxTransform>
</Group>
 
An example of SuperShape.
Enlarge
An example of SuperShape.

In the example above, the Shape is contained in a FitToBoxTransform node. The FitToBoxTransform node transforms its children into a specified region defined by a box. In the code above, Shape is transformed into a box-region positioned at the origin with sides of length 0.3m. uniformScalingOnly is set to True so that Shape is uniformly scaled into the box and active is True to ensure that the transformation matrix is updated.

The SuperShape is created by specifying the parameters that correspond to the two formulae making up Superformula. Fields are prefixed with ss1_ and ss2_ to indicate parameters for the first and second formulae respectively.

References

Personal tools
go to