How can I create a custom Xpresso data type?
Greetings to all.
I am interested in implementing a set of nodes in Xpresso to deal with Quaternions. I could probably implement these using a vector and a real (since that's all you need to store a quaternion internally), but I'd much rather have a custom connection type literally called "Quaternion" for organizational purposes instead (reason being, I'm going to have to implement my own quaternion math and lerp nodes, so I don't want to have to deal with two input ports per quaternion).
How can I do this?
I'm pretty sure it's possible since C4DtoA's shader node network is based on the Graph View stuff and they've got custom input/output port types running, so it's gotta be doable somehow.
Hi CMPX, I'm afraid I will not find time today to really dig into your question and doing some proper tests.
With that's said to create a Custom Xpresso Datatype you have to register a CustomDataTypeClass.
Finally, you can find valuable information in these threads:
- How to implement a GvOperatorData.
- Interpolate value in a GvOperatorData of a CustomDataType.
- No updated source code of Cinema 4D math GvOperatorData.
Please let me know if it's enough for you, otherwise, I will for sure do more tests.
Hey, thanks for the reply.
A custom data type appears to be what I'm looking for. I do have one question for you, if you don't mind- both GetId() and GetValueID() state that they require unique plugin IDs from Plugincafe. Can they both return the same plugin ID, or do they need to be different?
Hi @cmpxchg8b, please do not delete your post, I think your question was really valid.
With that's said GetId() and GetValueId() can use the same ID used to register your CustomDataTypeClass.
But is not mandatory, for example, our boolean CustomDataTypeClass value, return DTYPE_BOOL to GetId() but ID_GV_VALUE_TYPE_BOOL for GetValueId().
GetValueId will be the ID used to determine which datatype is linked to a port but the internal value of this port will be a DTYPE_BOOL.
Sorry about that, I'd noticed that the API was literally wired up to return the value from GetId() inside GetValueId() by default, so I figured that was answer enough... though I suppose that's kinda why I was asking in the first place- I wasn't sure what sort of situation would require two separate IDs.
Thanks for your response though, that certainly clears up why there's two different functions to handle that.