Getting defaults

Hi there,

I wanted to know if there was another way of getting a node’s default property values aside from creating a new node and querying the values on that.

Are the default vales stored anywhere?

Could you be more specific about the specific properties you’re interested in? A new NodePath has no transform, no render attributes, and no effects, so there are no default properties to query.

Well, all of them really! I don’t want to have to serialise any property for a NodePath or a PandaNode in my editor when the value is the default. When I query a new NodePath’s xform I get an identity matrix and when I query a new light’s colour I get Vec4(1,1,1,0). There’s no point in saving that stuff out to disk.

These values are stored in the underlying RenderAttrib, ie, TextureAttrib, LightAttrib, etc. You can use make_default() to return a default RenderAttrib of a certain type, ie, LightAttrib.make_default() will return a LightAttrib with the default properties set. The default transform is in TransformState.get_identity().

Still, though, it’d be easier and more reliable to use a NodePath to create a new node and invoke the getters depending on your purpose - is it to make some kind of editor utility?

Indeed it is: https://github.com/Derfies/panda3d-editor.

If you think creating a new node and querying that is the best approach then I’ll try that.