Solved, it works this way:
Vector v(0.0);
tps->GetData(pid, channel, &v, ID_GV_VALUE_TYPE_VECTOR);
Solved, it works this way:
Vector v(0.0);
tps->GetData(pid, channel, &v, ID_GV_VALUE_TYPE_VECTOR);
Hi All,
There is thinking particles system and it has few named channels such as here:
Float [chan 5] DataChannelType 19 DataChannelName mass(Real)
Float [chan 6] DataChannelType 19 DataChannelName oldP(Real)
Float [chan 8] DataChannelType 19 DataChannelName pscale(Real)
Float [chan 10] DataChannelType 19 DataChannelName spriteuv(Real)
Vector [chan 1] DataChannelType 23 DataChannelName Cd(Vector)
I get channel info using tps->DataChannelType(chan) and etc.
19 is DTYPE_REAL, 23 is DTYPE_VECTOR
But when I try to read the channel value per particle then it returns false and doesn't read the values. For example this request returns false:
TP_MasterSystem* tps;
Vector fval(0.0);
tps->GetData(pid, channel, &fval, DTYPE_VECTOR);
// nothing is written in fval. I also tried to use GeData, but it didn't help
Other particle data such as tps->Transform(...), tps->Color(...), tps->Age(...) is returning relevant results.
Please, can someone show me a valid example of correct TP data channel access?
Cheers
Hi @m_adam Maxime,
I don't understand yet, how to use the Python example within a C++ environment. Can't find C++ functions such as this:
md = c4d.modules.mograph.GeGetMoData(op)
...
offset = op[c4d.MG_LINEAR_OFFSET]
I have noticed that for example the Text object type has MoData->GetCount() with N elements corresponding to the number of letters. And then the cache object of Text has N children each with Motion Graphics Color Tag [tag->GetType() = 1018768].
I thought there could be a way to read this color tag somehow.
But if no then during scene traversal there is a way to inherit the array of the Text object with MoData->GetCount() > 0 and then count each descendant object with Motion Graphics Color Tag with increasing id to reference to the correct element of MoData->GetArray()
Same extraction can be done for Voronoi Fracture and other MoGraph objects with some checks.
Hi @Manuel I have checked the new update 2023.2.0 and the feature works just fine with custom bitmaps without any change from my side. Congrats with a very quick bugfix! This is very cool!
Also it's great the half-year version 2023.2 doesn't need 3rd party plugin rebuild and recompile as in S24, S26. Thanks for this!
Hello colleagues,
Ho can we access the color of MoGraph data for each object where Motion Graphics Color Tag [with tag->GetType() = 1018768] is assigned?
For example there is Text object or Voronoi Fracture object which have these tags for generated child objects.
Thanks in advance!
Hi @Manuel, thanks a lot! It's very good that things work in 2023.1.2, I will check it. Also there was an issue in S26.000
Btw I am on beta forum too and I can duplicate a topic there.
Will return to the topic on Tuesday because need to travel
@Deyan thank you, in our case nodespace nodes (e.g. bitmap) didn't require too much message handling. All I did was making node layout in Resource Editor, and then describing this layout data access inside the code and the parse it. Message handling was used in the previous material system using BaseMaterial / BaseShader concept.
@Manuel thanks for investigation! This is my screenshot from bitmap layout in resource editor. Url type is used. But I have opened it in R25. Still can't open resource editor in 2023 even removing the option you mentioned.
How can I include Import Data node for tests? Btw, it can be easy to test it with CentiLeo plugin, I mean the nodespace & bitmap. No registration is required https://centileo.com/download/
@Manuel Hi Manuel, I am Kirill from CentiLeo project. I have written a question here because it seems there is more life on the public forum and the nodes api is now public.
The issue performs as I have described. So there is a custom bitmap that is described with ImageTupple for Cinema inside
MAXON_METHOD maxon::Result<void> NodeSpaceExample::Init(maxon::DataDictionary spaceData)
{
..
}
Then when I try to save "Project with Assets" I get the new project file where the filenames defined as maxon::Url in the resource editor are not updated to local file paths such as tex/texturename.jpg and they remain old in attrib manager. But in fact the files are copied to the specified project folder together with images. Only manual change can fix them. Also the asset inspector doesn't change the filenames.
The node structure was defined in the resource editor of the older Cinema R21.
The issue is on R26 and still on R2023. It works well for older Cinema versions.
I thought there is some new property appeared on resource editor that prevents from Url modification (something like ownership or perfmission) or maybe some little API feature that intervene into the process.
The other issue is that I still can't open resource editor in R2023. Cinema was launched with a cmd line
"C:\Program Files\Maxon Cinema 4D 2023\Cinema 4D.exe" g_applicationRepositoryWritable=true g_descriptionEditorDeveloperMode=true
Hello colleagues,
There is a custom node space and there is a bitmap node with a the filepath of the type Url. The image drag&drop to nodes area is working from windows expolrer, everyting his working except for "Save project with Assets".
So the bitmap files are copied to the specified location, but the file strings are not updated in the custom bitmap node. None of them.
This code links C4D logic with the custom file path as described in the C++ API:
spaceData.Set(maxon::nodes::NODESPACE::IMAGENODEASSETID, mynodes::NODE::BITMAP::GetId()) iferr_return;
maxon::nodes::NODESPACE::ImageNodePortTuple imageTuple;
imageTuple.first = maxon::NodePath::Create(maxon::ToSingletonBlock<maxon::InternedId>(mynodes::NODE::BITMAP::RESULT)) iferr_return;
imageTuple.second = maxon::NodePath::Create(maxon::ToSingletonBlock<maxon::InternedId>(mynodes::NODE::BITMAP::FILENAME)) iferr_return;
imageTuple.third = maxon::NodePath::Create(maxon::ToSingletonBlock<maxon::InternedId>(mynodes::NODE::BITMAP::FRAME_START)) iferr_return;
imageTuple.fourth = maxon::NodePath::Create(maxon::ToSingletonBlock<maxon::InternedId>(mynodes::NODE::BITMAP::FRAME_END)) iferr_return;
spaceData.Set(maxon::nodes::NODESPACE::IMAGENODEPORTS, std::move(imageTuple)) iferr_return;
Also the Asset Inspector relink doesn't actually change the file strings on the node.
This functionality is not working in R26 and 2023.
But it is working in R21-R25 nicely! The bitmap related code is the same.
I also can't open the Resource Editor in 2023.1.3. I am using the options to launch the Cinema:
"C:\Program Files\Maxon Cinema 4D 2023\Cinema 4D.exe" g_applicationRepositoryWritable=true g_developerNodeEditorFunctions=true g_descriptionEditorDeveloperMode=true
Then click Resource Edit in the node editor and nothing happens.
Cinema version is 2023.1.3. The compiled SDK for node space was 2023.0.0.
Please help me to fix this
Ok, I will. Just need to remove all not-needed things
Hello!
There is a problem. There is a bitmap button in material description. After click it sends a message MSG_DESCRIPTION_CHECKUPDATE. Inside this message there is a call to base shader -> Edit(). I just want to show the properties of shader in attribute manager instead of material properties. And C4D R20 demo hangs.
If the button is not bitmap (but a usual one) then it sends a message MSG_DESCRIPTION_COMMAND which calls base shader->Edit() and we get no any hang.
One thing: if there is no GetDDescription there is no hang after Edit() call. But GetDDescription is used to make bitmap buttons and other staff. Even basic GetDDescription with checks for null input vars and just LoadDescription is enough to make the hang.
StopAllThreads() befor calling shader->Edit doesn't help to avoid the problem.
My guess is there will be no any SDK for long time because it didn't happen yet for the first R20 release. This looks a bit strange. But this is the choice of Maxon. Would be interesting just to know what Maxon developers think about it.
Hi Riccardo, I think the issue is solved because there is no any issue. Some not good methods of software distribution just confused us.
Btw, what benefits different parameters of SetPluginPriority() give to us? For example the xdll has several plugins like materials, shader, tags and renderer. Even some icons with plugin ids. What priority is better to use in this case? I see https://developers.maxon.net/docs/cpp/2023_2/page_manual_module_functions.html
For example, what is C4DPL_INIT_PRIORITY_ADVANCEDRENDER:
Hi, Maxime! Also another node-related question: will you ever make the SDK access for custom material and shader plugins operating inside node based GUI?
Hi Riccardo, thank you for help! Do you have any other shader plugin in the plugins/ folder?
I had 2 reports about a problem of not launching Cinema R20 after update to 059. Originally I thought that the problem was the large 80MB size of resulting CentiLeo renderer xdll64 (my plugin) where I statically linked all dependencies. One user hasn't replied on further questions about the problem but the other one has helped to investigate.
For example when plugins folder had:
And that second user has also told that his Cinema 4D R20 version is a cracked pack from cgpersia which he has updated to 059 with usual C4D updater. So this can be the easy explanation of a problem. It's strange that before update things were ok. However I don't know how the cracks are working and what has influenced. At least the factors that I have found like different number of plugins and plugin priority seem not logical for me.
@r_gigante Hi Riccardo! Thanks for help! Actually, your code doesn't reproduce the issue. Have a look at my code too:
https://www.dropbox.com/s/opwo59utbiup3ks/test.rar?dl=0
There you will find the generated shader resource files + plugin code + xdll for windows (I don't have mac yet).
One interesting note is that there is no problem on Cinema R20.059 Demo (I have downloaded R20.057 from Maxon website and then updated to R20.059 using online update). But few users who have updated their non-demo C4D reported a bug with these issues and I have tested it with them using TeamViewer. It looks strange. The issue however seems to be solved when we use
SetPluginPriority(data, C4DPL_INIT_PRIORITY_PLUGINS);
instead of
SetPluginPriority(data, C4DPL_INIT_PRIORITY_ADVANCEDRENDER);
I don't remember why and when I started using priority C4DPL_INIT_PRIORITY_ADVANCEDRENDER. Somewhere from pluginscafe advice or maybe the whole system is a 3rd party renderer. But it was ok all the time.
Here is the code from my example (see comments there):
/*
There was no problem in the cases described here for R20.057 or earlier.
But this example doesn't launch Cinema when copied to the plugins folder of Windows (7 or 10) + Cinema R20.059.
Note that there should be no any other plugins in the C4D/plugins folder.
Note that this example doesn't launch if it has 40 shaders (but launces if it has 30 or 50 shaders).
Note that this example successfully launches Cinema if you use SetPluginPriority(data, C4DPL_INIT_PRIORITY_PLUGINS); instead of C4DPL_INIT_PRIORITY_ADVANCEDRENDER (see below)
Read comments in the code below.
*/
#include "c4d.h"
#include "c4d_symbols.h"
#define TEST_PLUGIN_ID 1055000
class xshaderTest : public ShaderData
{
INSTANCEOF(xshaderTest, ShaderData)
public:
virtual Bool Init(GeListNode* node);
virtual Bool Message(GeListNode* node, Int32 type, void* data);
virtual Vector Output(BaseShader* chn, ChannelData* cd);
virtual INITRENDERRESULT InitRender(BaseShader* chn, const InitRenderStruct& irs);
virtual void FreeRender(BaseShader* chn);
static NodeData * Alloc(void) { return NewObjClear(xshaderTest); }
};
Bool xshaderTest::Init(GeListNode* node)
{
return ShaderData::Init(node);
}
Vector xshaderTest::Output(BaseShader* chn, ChannelData* cd)
{
return Vector(0.0);
}
INITRENDERRESULT xshaderTest::InitRender(BaseShader* chn, const InitRenderStruct& irs)
{
return INITRENDERRESULT::OK;
}
void xshaderTest::FreeRender(BaseShader* chn)
{
}
Bool xshaderTest::Message(GeListNode* node, Int32 type, void* msgdat)
{
return ShaderData::Message(node, type, msgdat);
}
/*
#include <windows.h>
static const WORD MAX_CONSOLE_LINES = 500;
inline void RedirectIOToConsole()
{
// create the console (see https://stackoverflow.com/questions/32185512/output-to-console-from-a-win32-gui-application-on-windows-10)
if (AllocConsole()) {
FILE* pCout;
freopen_s(&pCout, "CONOUT$", "w", stdout);
SetConsoleTitle(L"Debug Console");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
// SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
}
}
*/
Bool PluginStart(void)
{
// generate different shader resource files and move them in the res folder of the plugin
// uncomment to generate files again
/* FILE * f = 0;
char shader_name[1024];
char shader_desc[1024];
for (int i = 0; i < 50; i++)
{
sprintf_s(shader_name, 1024, "F:\\testshaders\\test_shader%d_res.res", i, i, i, i);
sprintf_s(shader_desc, 1024, "CONTAINER test_shader%d_res \n{\n NAME test_shader%d_res;\n GROUP TEST_SHADER%d_GROUP {\n DEFAULT 1;\n VECTOR TEST_SHADER%d_DATA { UNIT REAL; STEP 0.01; }\n }\n}\n", i, i, i, i);
size_t strsize = strlen(shader_desc);
fopen_s(&f, shader_name, "w");
size_t written = fwrite(shader_desc, 1, strsize, f);
fclose(f);
// printf("\n %2d: strsize %3d written %3d", i, int(strsize), int(written));
}
for (int i = 0; i < 50; i++)
{
sprintf_s(shader_name, 1024, "F:\\testshaders\\test_shader%d_res.h", i, i, i, i);
sprintf_s(shader_desc, 1024, "#ifndef TEST_SHADER%d_RES_H__\n#define TEST_SHADER%d_RES_H__\n enum \n { \n TEST_SHADER%d_GROUP = 10000, \n TEST_SHADER%d_DATA = 10100,\n };\n#endif", i, i, i, i);
size_t strsize = strlen(shader_desc);
fopen_s(&f, shader_name, "w");
size_t written = fwrite(shader_desc, 1, strsize, f);
fclose(f);
// printf("\n %2d: strsize %3d written %3d", i, int(strsize), int(written));
}
for (int i = 0; i < 50; i++)
{
sprintf_s(shader_name, 1024, "F:\\testshaders\\test_shader%d_res.str", i, i, i, i);
sprintf_s(shader_desc, 1024, "STRINGTABLE test_shader%d_res \n{ \n test_shader%d_res \"test_shader%d_res\"; \n TEST_SHADER%d_GROUP \"test_shader%d_res\"; \n TEST_SHADER%d_DATA \"test_shader%d_res\"; \n}", i, i, i, i, i, i, i);
size_t strsize = strlen(shader_desc);
fopen_s(&f, shader_name, "w");
size_t written = fwrite(shader_desc, 1, strsize, f);
fclose(f);
// printf("\n %2d: strsize %3d written %3d", i, int(strsize), int(written));
}*/
VERSIONTYPE versionType = GeGetVersionType();
// RedirectIOToConsole();
// register shaders
// for (int i = 0; i < 30; i++) // Cinema is launching
// for (int i = 0; i < 50; i++) // Cinema is launching
for (int i = 0; i < 40; i++) // Cinema is NOT launching if you use SetPluginPriority(data, C4DPL_INIT_PRIORITY_ADVANCEDRENDER);
{
String resfile = String("test_shader") + String::IntToString(i) + String("_res");
RegisterShaderPlugin(TEST_PLUGIN_ID + i, resfile, 0, xshaderTest::Alloc, resfile, 0);
}
return true;
}
void PluginEnd(void)
{
}
Bool PluginMessage(Int32 id, void* data)
{
switch (id)
{
case C4DPL_INIT_SYS:
{
// RedirectIOToConsole();
if (!g_resource.Init())
return false;
return true;
}
case C4DMSG_PRIORITY:
{
SetPluginPriority(data, C4DPL_INIT_PRIORITY_ADVANCEDRENDER); // Cinema is NOT launching if you use 40 shaders
// SetPluginPriority(data, C4DPL_INIT_PRIORITY_PLUGINS); // Cinema launches even if you use 40 shaders and priority is set to this.
// But if you add unchanged compiled c4dsdkplugins to the C4D plugins folder
// then Cinema will not launch with 2 plugins like c4dsdkplugins and test (which has 40 shaders)
return true;
}
}
return false;
}
Hello everyone,
After update to this build there is a bug:
In real apps this means that one alone 3rd party renderer plugin launches with Cinema. The other alone also launces. But if you place them both to the plugin folder they may crash Cinema at launch.
There was no such problem at R20.030 and R20.057... Wasted a day to investigate this.