C++ SDK Matrix object style distribution
-
Hello!
This is my first post here. See my bio for background.
I have been studying the SDK docs the last two weeks and I'm taking my first steps trying to build plugins for Cinema4D. So I have a question and I'm looking for directions...Does C++ SDK allows you to create some sort of a custom Matrix Object style distribution?
What I want to achieve is a generator/distribution that output point data that can be read by a cloner.
It is important that the points encode position, orientation and size or scale and that the cloner can read that data and apply it to instances. Is this doable with the C++ SDK?
If I have understood the SDK correctly, a point object can only encode position and possibly normals and that won't fulfill the requirements in my case.Any hint or help pointing me in the right direction would be much appreciated.
Thanks in advance!
/Fredrik -
Hello @dex,
Welcome to the Maxon developers forum and its community, it is great to have you with us!
Getting Started
Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.
- Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
- Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
- Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.
It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: How to Ask Questions.
About your First Question
Thank you for reaching out to us.
Does C++ SDK allows you to create some sort of a custom Matrix Object style distribution?
The SDK does not allow you create any MoGraph generators, the only thing you can implement are effectors and fields. A generator is effectively just an
ObjectDataplugin which generates someMoDatastored as a tag on it, and then depending on the generator type, also generates some cache and/or viewport output. What a MoGraph generator does is not strongly defined, therefore each generator might have to be handled differently by our Core API; which makes it impossible to create a custom one.In the case of a Matrix object linked in a Cloner object in object mode, the custom behavior is that the Cloner will read the
MoDatatag of the Matrix object when it sees anOmgmatrixbeing linked. You could create anObjectDataplugin which generates the sameMoDatatag as the Matrix object, but it would not be recognized by the Cloner as a Matrix object, and thus not be treated as such. But you could create your own infrastructure which picks up on that. But in general, implementing your own generators within the MoGraph system is not possible and also not trivial.It is important that the points encode position, orientation and size or scale and that the cloner can read that data and apply it to instances.
The most straight forward way to achieve what you want, would be probably to implement a custom effector which overrides the particle data to your liking. The only limitation of effectors is that they cannot change the particle count. A way out could be here to create some driver logic, e.g., a tag on the cloner which drives both the cloner and an instance of your custom generator in tandem. If you do that you have to be a bit careful with not violating threading restrictions or creating dirtiness feedback loops, but it is possible.
The other alternative could be to just implement a polygon object
ObjectDataand generate tiny polygons for each (position, orientation, scale) tuple you want to have. Then in the cloner, you just clone in polygon mode onto your object and enable 'Enable Scaling', so that the particles are also scaled according to the size of the polygons.Cheers,
Ferdinand -
Thank you so much Ferdinand!
I have a way forward now for my plugin using the EffectorData ModifyPoints() method.Kind regards
Fredrik