I’ve been working on adding lights to the egg file format. I’ve finished the egg writer and am now working on the reader. I have all the parsing working properly.
I currently use EggLoader::make_node to create a DirectionalLight when I come across my new EggLight type. I add this node to _root (ModelRoot)
So this obviously doesn’t work. From what I can gather, I need to add this light to a NodePath (which I dont have in EggLoader). Could someone please clarify the difference between NodePaths and Pandanodes? How do these relate to each other? This would help me greatly.
A NodePath is just a handle, or a pointer, to a node. The NodePath class has almost no data itself; it’s just a way to reference a node, which is where the actual data is. You use a NodePath to refer to a node.
You can create a NodePath on-the-fly for any node, by wrapping it the NodePath constructor.
That sounds great! You should consider submitting a patch when you’ve done so.
NodePath is a simple handle to a node, it is a disposable wrapper that is comparable to a C++ pointer in terms of how it works. It just stores a pointer to the PandaNode, and the methods are just convenience methods for the lower level interfaces.
So in this case, you should use the lower level LightAttrib to apply your lights, which is the interface that NodePath::set_light operates internally. (It also helps to check out the source code of NodePath::set_light).
Great thanks guys. This work is part of a larger initiative that will be open sourced. Would we need to submit patches for all of our changes or just post all of the source with tagged revision history so you could take what you wanted?
Unified patches are usually preferred, if possible, as the CVS repository might change in the meantime.
Ok. I’ll keep this in mind.
Thanks again for the direction, lights seem to be working now. My sample model doesn’t have normals so it isn’t lit properly; but that shouldn’t be difficult to add.
I would really like to use this feature. Has it been released at all?