Toggle visibility of a group of X3D / glTF nodes

Posted on

Free Modular Shed with interior - model by denniswoo1993 from https://sketchfab.com/3d-models/free-modular-shed-with-interior-30b1eb71bb0e4b889160f8283e1750c1

We support now visible field on various X3D nodes:

We also support very similar glTF extension KHR_node_visibility. The logic of this glTF extension directly maps to X3D visible field.

The main use-case is to toggle visibility of a group of visual things at run-time. From Pascal code in Castle Game Engine, you can find the TTransformNode that interests you using e.g. the TCastleSceneCore.Node method and then toggle the Visible boolean property. If you don’t know what transform nodes are available (e.g. because you load model in other format, like glTF) then inspect it, by first saving it to X3D using e.g. our Castle Model Viewer, and then open X3D in any text editor.

As a testcase, open x3d/visible_toggling.x3dv in our demo-models repository, https://github.com/castle-engine/demo-models/ . We recommend to just get the whole repository (git clone ...) to have all files. It shows spheres (some visible, some hidden by default) and allows toggling “visible” at runtime (using KeySensor.controlKey routed to “visible” fields).

For more notes see API docs on TAbstractGroupingNode.Visible.

TODO:

  • Both the X3D and glTF features specifications’ say to also disable light and fog nodes within a group that you made invisible. We don’t implement this yet — for now, the Visible field only affects the visibility of shapes. If you use this feature, be aware that we will toggle lights and fog in the future too.

  • In case of glTF, it would be great to also support KHR_animation_pointer. This is a bit like X3D routes: allows to animate almost every part of the glTF, in particular it allows to animate the visibility defined by KHR_node_visibility.

If you enjoy this, please support our work on Patreon!

Our screenshot shows house 3D model by denniswoo1993. Not really related to the feature described here, just something pretty arranged in our editor:)

Comments on the forum ➤

Various asset improvements: Wavefront OBJ texture options and possible PBR, Spine free form deformation with curve animation, fixes for creaseAngle in X3D and OBJ

Posted on

Oak Wavefront OBJ model
Spine FFD animation test

Various improvements to various asset formats:

  • We now implement Wavefront OBJ texture options. They are all parsed correctly, and the scale, offset, clamp are actually handled.

    We can also generate PBR (physical) materials when reading Wavefront OBJ files. This feature is for now experimental, and you have to toggle global WavefrontPhongMaterial in X3DLoadInternalOBJ unit to false. In effect, we will create X3D PhysicalMaterial nodes from Wavefront materials, and we’ll use Pr for the PhysicalMaterial.MetallicRoughnessTexture. See the X3D specification of PhysicalMaterial for details what it implies.

  • We now support curve animation for Spine free form deformation. Thanks go to Kagamma (Trung Le) for implementing this!

    The testcase is in our demo-models, open spine/free_form_deformation/exported/skeleton.json and run head_curve animation.

  • Fixed important bug on all 3D models that could use automatic normals generation based on creaseAngle (like X3D and Wavefront OBJ by default).

Comments on the forum ➤