lhit from BaseVolumeData
-
Hi,
I've been trying to understand what type of structure I would need to be able to access what lhit offers, although I know what a PyCobject is, I still don't understand what structure I should use, or what data it affords me, I reviewed the C++ documentation but ended up with more questions than answers, I work in python in a simple sahder, I really don't plan anything elaborate and at this point I'm just testing what information I can get to identify what will be useful to me, I would appreciate it if someone could help me with this problemimport ctypes import c4d PyCObject_AsVoidPtr = ctypes.pythonapi.PyCObject_AsVoidPtr PyCObject_AsVoidPtr.restype = ctypes.c_void_p PyCObject_AsVoidPtr.argtypes = [ctypes.py_object] def Message(sh, msg, data): return True def InitRender(sh, irs, customdata): return c4d.INITRENDERRESULT_OK def FreeRender(sh, customdata): pass once = True def Output(sh, cd, customdata): global once if not cd.vd: return c4d.Vector(0) pyco = cd.vd.lhit if not pyco: return c4d.Vector(0) if once: ptr = PyCObject_AsVoidPtr(pyco) print (ptr) once = False return c4d.Vector(0)
I experimented with the PyCObjects of the PolygonObjects and managed to obtain information from the indices. It is not useful to me, but I wanted to know first if it was possible, but I require prior knowledge of the information I hope to obtain. In this case, I feel blind, I would appreciate it if someone would light my way.
thanks in advance
JH -
Hi sadly there is not much you can do with it in Python. The only use case is if your want to create a kind of hashmap on the pointer, but I do not see a big use case of that to be honest. I will see if I can improve thing a bit here, because in C++ via the lhit you can retrieve the polygon and the underlying object being hit, which is important information but this is very low on my priority list. So in general regarding shader I would say you better at look at C++ since in any case doing a Shader in Python will most likely be a performance killer.
Cheers,
Maxime. -
Hey @m_adam,
Thanks for the reply! What you’re saying makes a lot of sense C++ is clearly the better option for this kind of stuff, especially when you need more control and better performance. I haven’t had much chance to dive into C++ yet, but I’m well aware it’s way more powerful than Python when it comes to working with the engine.
It’s a bit of a shame that there’s no way to directly access polygon info from Python, since that’s exactly what I needed. But still, I really appreciate you taking the time to explain it.
Cheers,
James H.