Day and night with TCastleImageTransform

To gradually dim brightness of all scenes I had to call them one by one.
Now with the new ImageTransform I have added all transforms and scenes to the ImageTransform so I wondered if it now is possible to dim all at once by just “dimming” the colors of the ImageTransform because I thought they now are childs of the ImageTransform?

And I noticed this funny deprecated issue but it suggests using the same FindNode symbol? :slight_smile:

Sorry for a delay in answering!

No, the TCastleImageTransform.Color only affects this particular TCastleImageTransform, not any children.

The ability to influence a look of multiple objects by toggling a single thing will come – along with new components for materials. I plan to expose a lot of cool things related to materials still in 2022, for 7.0 release. And they will work on TCastleScene, TCastleImageTransform, and many primitives. One of the goals is to be able to have a “reusable” material component that you can assign to multiple places, and then changing it’s parameter would change lots of other scenes/images where it was referred to.

For now, you just have to change Color on multiple TCastleImageTransform instances. You can of course keep them on some list to make it easy.

You can also implement on your own to change TCastleImageTransform.Color on all children of something:

for Child in MyTransformParent do
  if Child is TCastleImageTransform then
    TCastleImageTransform(Child).Color := ...;

Ups, improved the deprecation message. Some overloaded versions of FindNode were deprecated, and we now recommend this one for all usage:

    { Find a node by name and class, in this node and children (recursively).

      By default it searches both active and inactive graph parts.
      Add fnOnlyActive to search only in active parts.

      @raises(EX3DNotFound When node is not found.
        Unless fnNilOnMissing in Options, then it returns @nil on missing node,
        and EX3DNotFound is never raised.)
    function FindNode(const NodeClass: TX3DNodeClass; const FindName: String;
      const Options: TFindNodeOptions = []): TX3DNode; overload;

I see you use RootNode.FindNode(TUnlitMaterialNode, false) which means you don’t provide a material name, you just find the first instance of TUnlitMaterialNode in the scene. We discourage from doing this, since you rely on the order of material nodes in your scene – providing an explicit material name is more reliable.

You can disregard this warning for now, in practice I do not plan to remove any API here, until the new material components API is really ready and rocks. If you want to selectively hide the deprecation warning, you can use {$warnings off}...{$warnings on} around these lines.