How to write new node?

249 views
Skip to first unread message

Lee Gramling

unread,
Dec 23, 2013, 7:08:09 PM12/23/13
to gaffe...@googlegroups.com
I am still new to gaffer, but I was wondering if you could point me to an example of how to write a node.
I would like to try writing a procedural geometry node.


Thanks

Lee

ben toogood

unread,
Jan 15, 2014, 5:38:43 AM1/15/14
to gaffe...@googlegroups.com
Hi Lee - are you looking to generate geometry from scratch, or to process geometry already in the gaffer scene?

John Haddon

unread,
Jan 15, 2014, 6:10:29 AM1/15/14
to gaffe...@googlegroups.com
Hello,

Sorry, this one slipped past while I was distracted by mince pies and suchlike. We don't have documentation for writing new Scene nodes right now, and it's still not as straightforward as I'd like it to be, but hopefully one of the existing nodes provides a good starting point. Depending on what you want to do exactly, different nodes will be relevant.

If you want to generate a new object from scratch, but without needing to generate a hierarchy, deriving from the ObjectSource node is the way to go. The Sphere, Cube and Plane nodes are good examples - you just need to implement affects(), hashSource() and computeSource() and the rest will be done for you :


If you want to generate a whole hierarchy from scratch, the AlembicSource is probably the simplest example at the moment. Because you're generating a whole hierarchy you now have additional responsibilities - computing the transform, bound, attributes and child names at each location in the hierarchy :


If you want to modify an existing scene by adding on a new branch containing your geometry (because your procedural process requires some input geometry), then the BranchCreator base class is your friend. The Seeds node is probably the simplest example of that :


It might also be worth checking out the scene query API documentation - although this is written from the point of view of someone querying a scene rather than generating one, it should give you some understanding of how Gaffer represents scenes and therefore what is going on in the nodes themselves :


Please do get back to us with questions if you hit problems with any of this - I'll be less tardy with my response next time.

Cheers...
John


From: gaffe...@googlegroups.com [gaffe...@googlegroups.com] on behalf of ben toogood [bjto...@gmail.com]
Sent: Wednesday, January 15, 2014 2:38 AM
To: gaffe...@googlegroups.com
Subject: [gaffer] Re: How to write new node?

--
You received this message because you are subscribed to the Google Groups "gaffer-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gaffer-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lee Gramling

unread,
Jan 15, 2014, 4:38:50 PM1/15/14
to gaffe...@googlegroups.com, jo...@image-engine.com
Thanks Ben and John,

I was thinking of creating a new primitive, so I think the cube example will do. I was thinking of something l like stairs or a fence, just for learning.

I let you know what I come up with.

I am also interested in creating some tutorials (videos) for gaffer.

Lee

John Haddon

unread,
Jan 16, 2014, 4:31:45 AM1/16/14
to Lee Gramling, gaffe...@googlegroups.com
Cool - then I think the Cube example should be a pretty good starting point. Most of the work is then in just constructing a Cortex MeshPrimitive - you can see the code used to generate the sphere and cube in the createSphere() and createCube() methods in this file :


Some video tutorials would be great!
Cheers...
John


From: Lee Gramling [leegr...@gmail.com]
Sent: Wednesday, January 15, 2014 1:38 PM
To: gaffe...@googlegroups.com
Cc: John Haddon
Subject: Re: [gaffer] Re: How to write new node?

Reply all
Reply to author
Forward
0 new messages