Previous Thread  Next Thread

chat icon Add controls to a node

Marv

Posted: Sat Nov 27, 2010 4:46 pm
Joined: 05 Nov 2010
Posts: 7
Hi,

I was following http://wiki.blender.org/index.php/Dev:Doc/How_to/Add_A_Node and successfully added two nodes to the gui, but the controls that I added in drawnode.c aren't displayed - although I copied them over exactly from other working nodes.

In the Blender console I get uiTemplateID: pointer property not found: Node.material

This should be the codeline causing my problem:
Code:
uiTemplateID(layout, C, ptr, "material", NULL, NULL, NULL);

Please give me a hint.
Reply with quote


Marv

Posted: Mon Dec 06, 2010 6:48 pm
Joined: 05 Nov 2010
Posts: 7
It seems that I forgot to define my typecode in rna_nodetree_types.h
Reply with quote


bLTR

Posted: Wed Nov 07, 2012 3:39 pm
Joined: 07 Nov 2012
Posts: 3
I have a similar problem: I want to add a shader node for cycles that would provide a material with the incident light angle and the length of the ray. Initially I thought this could be combined with some (reflection?) shaders that respond in one way or another to the light sources as well. Meanwhile (also in the mockup shown here) I think it should work with any kind of Object (Empties) that indicate a position.
Mockup: https://dl.dropbox.com/u/9632359/mockup.jpg
(After copying almost everything in the code I found about the "Light_Path" node) I updated the rna_nodetree_types.h file as follows:
Code:
DefNode( ShaderNode,     SH_NODE_LIGHT_INCIDENT,     def_sh_light_incident,  "LIGHT_INCIDENT",     LightIncident,    "Light Incident",    ""       )

and the rna_nodetree.c file like this:
Code:
static void def_sh_light_incident(StructRNA *srna)
{
   PropertyRNA *prop;
   
   RNA_def_struct_sdna_from(srna, "NodeShaderLightIncident", "storage");
   
   prop = RNA_def_property(srna, "light_name", PROP_POINTER, PROP_NONE);
   RNA_def_property_pointer_sdna(prop, NULL, "id");
   RNA_def_property_struct_type(prop, "Object");
   RNA_def_property_flag(prop, PROP_EDITABLE);
   RNA_def_property_ui_text(prop, "Light Name", "Incident light source");
}


In the drawnode.c file I put:
Code:
static void node_shader_buts_light_incident(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
   bNode *node = ptr->data;

   uiTemplateID(layout, C, ptr, "light_name", NULL, NULL, NULL);
}


Since I got the compile error that "light_name" could not be found I also typedefd a struct in DNA_node_types.h as follows:
Code:

#include "../makesrna/RNA_types.h"

typedef struct NodeLight {
   PointerRNA name;   
} NodeLight;


Now the following error message is a bit cryptic to me:
""Error! can't make correct DNA.c file from /.........../Blender/trunk/blender/source/blender/makesdna/intern/makesdna.c:1181, STUPID!"

Could somebody help me please?
Reply with quote


bLTR

Posted: Wed Nov 07, 2012 8:44 pm
Joined: 07 Nov 2012
Posts: 3
With some help from a gentle developer I met at Blender Conf I got a step further. The strategy of "just copy the code of an existing NODE" is not appropriate when you actually should omit a few or even only a single line of code!
In my case deleting
Code:
RNA_def_struct_sdna_from(srna, "NodeShaderLightIncident", "storage");
helped already a lot.
Reply with quote


bLTR

Posted: Wed Nov 07, 2012 8:47 pm
Joined: 07 Nov 2012
Posts: 3
Oh and... storing a PointerRNA in a node struct is a really BAD idea, I've been told --> so in any case DON'T copy my DNA_node_types.h !!!
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group