Background
I'm trying to implement a highly non-linear lens to do lens distortion in Panda3D for a complex projection setup. I want to use this implementation following this approach.
The question
Can I do it in Python (and if so, how, what am I doing wrong) or do I have to do it in C++ (and if so, where do I start)?
Attempts so far
I've tried subclassing Lens, but if I let my subclass call the super constructor (or don't override the constructor at all), I get an error:
>>> from panda3d.core import Lens
>>> class MyLens(Lens):
... def __init__(self):
... super(MyLens,self).__init__()
...
>>> l = MyLens()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in __init__
TypeError: Error Can Not Init Constant Class (Lens)
If I don't call the super constructor, the class isinstance(Lens)
, but not recognized as such by Panda3D code:
fcamNode = Camera('fcam')
flens = MyLens.MyLens()
assert isinstance(flens, Lens)
fcamNode.setLens(flens)
results in TypeError: LensNode.set_lens() argument 1 must be Lens, not MyLens
.
If I subclass PerspectiveLens
instead, I can call the super constructor and pass instances of my class to setLens()
, but none of its overridden methods are ever called and the rendered scene looks like it was rendered with the stock PerspectiveLens
.