Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Dear c4d fellows, Long ago I wrote a simple plugin for cinema4d in python. I didn't know how to code python back then, and learned it while writing the plugin. So I didn't even know how to debug the .pyp file in debugging mode. Now I decided to improve it. The question is: how to set up a debugging mode (the analogue of visual studio for c4d but for python). Is it possible? (I mean going line by line through pyp file and see the values of local variables in console)
Yaroslav.
Ferdinand, that indeed helps a lot! The points are indeed too many )) I may imagine how... well, "unsofisticated" my piece of code looks. Thank you for going so far in the explanation!
@ferdinand
Thank you Ferdinand for explaining everything!
Currently, I decided to temper with the normals of my polygon object to make smoothing by hand. However, what I noticed, is the following:
Suppose I don't create normal tag and simply create a phong tag for my polyobject. Unfortunately, despite appearing in the menu of the object, somehow it doesn't work (despite my changing the phong angle in the menu).
At the moment I created a function which simulates the extrude functionality (for the reasons of plugin, I refrain from using the built in c4d extrude function )
I feed it with initial closed spline, the extrude height and precision (The way I interpolate curved elements of the spline with line elements)
void wall(BaseDocument* document, SplineObject* spline, double height, double precision) { LineObject* spline_linear = spline->GetLineObject(document, precision); int n1 = spline_linear->GetPointCount(); Vector* gp = spline_linear->GetPointW(); // define point and polygon count const Int32 polyCnt = n1; const Int32 pointCnt = 4 * n1; // create polygon object PolygonObject* const polygonObject = PolygonObject::Alloc(pointCnt, polyCnt); // insert object into the document document->InsertObject(polygonObject, nullptr, nullptr); // access point and polygon data Vector* const points3 = polygonObject->GetPointW(); CPolygon* const polygons = polygonObject->GetPolygonW(); for (int i = 0; i < n1 - 1; i++) { // set points points3[4 * i] = gp[i]; points3[4 * i + 1] = gp[i + 1]; points3[4 * i + 2] = Vector(gp[i + 1].x, 100, gp[i + 1].z); points3[4 * i + 3] = Vector(gp[i].x, 100, gp[i].z); // set polygon polygons[i] = CPolygon(4 * i, 4 * i + 1, 4 * i + 2, 4 * i + 3); } points3[4 * (n1 - 1)] = gp[n1 - 1]; points3[4 * (n1 - 1) + 1] = gp[0]; points3[4 * (n1 - 1) + 2] = Vector(gp[0].x, 100, gp[0].z); points3[4 * (n1 - 1) + 3] = Vector(gp[n1 - 1].x, 100, gp[n1 - 1].z); // set polygon polygons[n1 - 1] = CPolygon(4 * (n1 - 1), 4 * (n1 - 1) + 1, 4 * (n1 - 1) + 2, 4 * (n1 - 1) + 3); BaseTag* phongTag = polygonObject->MakeTag(Tphong); polygonObject->Message(MSG_UPDATE); }
I wonder What has gone wrong? The thing builds nice polygonal object, but it is not smooth! ![alt text]
What a nice and comprehensive answer!
Thank you so much! Everything is crystal clear now!
Dear c4d fellows, I'm building polygonal objects using c++ in cinema4d (r20).
I have a small question. I need to create phong tag to make my polygonal surface smooth. Do I need to ascribe phong tag to each polygon constituing the surface or a single phong tag to the whole surface?
I scanned through different sources of c4d forums and met no formal math definition of a phong angle. Does somebody have a good source with explanation of phong angle in cinema 4D?
Also, as far as I understand I can easily set up the normal direction to orient the polygons correctly. Here is a very self explaining example from sdk:
https://developers.maxon.net/docs/Cinema4DCPPSDK/html/page_manual_normaltag.html
But I heard that phong tag might override normal tags. It is quite scary.
Suppose I set up my normals for each polygon of my surface (with love and care). Then I introduce phong tag and ... all my normals will be destroyed?
@ferdinand Oh, thanks! Quite a nice idea!
Ferdinand, just tried
LineObject* spline_linear = spline->GetLineObject(document, precision);
Works like a charm. The closer float "precision" to one the better the approximation, as far as I understand.
One thing, that confuses me is that new object appear in c4d menus with little white"question mark" sign (see picture). I don't undersytand why.
Here is my piece of code:
LineObject* spline_linear = spline->GetLineObject(document, 0.9); document->InsertObject(spline_linear, NULL, NULL, 0); // Add it to the OM spline_linear->Message(MSG_UPDATE);
Oh, I see. Now I can extract all the points from this LineObject and construct a simple linear spline if I need one. I guess cinema4d doesn't recognize the LineObject. Hence, question mark in menus.
Dear Ferdinand, thank you for the comprehensive answer!
(Dear mp5gosu, thank you for your comment too)
Dear Ferdinand, I develop plugin in c++ (using vs2019 and c4d r20) and this is precisely what I meant. Instead of using beautiful and smooth bezier-curved type splines I want to substitute them with finely approximated linear splines (and I guess SplineObject::GetLineObject is precisely the function I need.) I wonder if there is some control on the number of linear segments approximating the spline. Hopefully, I can get it from the corresponding class declaration.
Dear c4d fellows, I wonder, if there is a buit in method in SplinObject to turn Bezier spline into interpolating linear spline. Of course, it is simple to code my own function doing exactly this, but may be it is already implemented by c4d creators.
@m_magalhaes
Thank you, Manuel!
Dear Frank, Thanks for the comprehensive reply! Everything works just as expected! It is such a scientific joy to explore the cog wheels of the wander-box called cinema4D.
Understood! Thank you, PluginStudent and fwilleke80 so much! Both of your answers helped me!
I have now the follow-up question. Forgive me the lack of my expertise. Here is my code which retrieves the spline drawn by the user.
BaseDocument* const document = GetActiveDocument(); SplineObject* spline = nullptr; BaseObject* object = document->GetActiveObject(); if (object->IsInstanceOf(Ospline)) spline = ToSpline(object);
Now the question. Suppose the curve is the combination of bezier and linear elements (they are joint). How do we retrieve
I've looked through SplineObject and PointObject classes.
The only methods that I found are:
const Vector* vec = (*spline).GetPointR();
which is the coordinate of the first point only. But what about the next point?
From SplineObject I found the method GetSplinePoint(t, segment). If I write
Vector vec1 = (*spline).GetSplinePoint(1, 0);
I retrieve the coordinate of the last point of the whole curve (i.e. the end point of the last element). Do you know how to retrieve the rest of the points?
Dear c4d fellows, I've started to develop a plugin for c4d. Suppose a user drew some spline and made it an active object. I want to read out spline data (bezier coordinates and the rest).
Somehow, in debugging mode I don't see any data. I use:
BaseObject* spline = document->GetActiveObject();
But then I see in visual studio, that it created a pointer "spline" but that's it. The only thing I see is that under my variable spline BaseList2D, GeListNode, C4DAtomGoal and C4DAtom are all empty.!
So how does one achieve this?
@PluginStudent
Thank you so much! It worked! Yaroslav.
Thanks, for your comment! But:
@PluginStudent said in compiling for r20 new solution:
Every plugin has to implement PluginStart(), PluginMessage(), and PluginEnd().
Well, is this really right? I mean, look at sdk menutest example. I simply copied it and changed the name. But probably, you are right!
Dear c4d fellows, I have the following question. I'm trying to compile my own (beginner) plugin (solution) in VS2019. I have c4d r20.
I created a projectdefinition.txt
Platform=Win64;OSX Type=Solution Solution=\ plugins/architect4D;\ APIS=\ cinema.framework; \ misc.framework; \ image.framework; \ core.framework C4D=true stylecheck.level=0 ModuleId=com.streamline.architect4D INCLUDE=source/architect4D.cpp; INCLUDE=source/architect4D.h;
Then I created minimal .cpp
#include "maxon/parallelfor.h" #include "c4d.h" #include "c4d_symbols.h" #include "architect4D.h" //#include "commandlinerender.cpp" class architect4D : public CommandData { public: virtual Bool Execute(BaseDocument* doc); }; Bool architect4D::Execute(BaseDocument* doc) { return true; } Bool Registerarchitect4D() { // be sure to use a unique ID obtained from www.plugincafe.com return RegisterCommandPlugin(1054040, GeLoadString(IDS_ARCHITECT4D), 0, AutoBitmap("architect4D.tif"_s), "arhitect4D Plugin"_s, NewObjClear(architect4D)); }
and .h
#ifndef ARCHITECT4D_H__ #define ARCHITECT4D_H__ #include "ge_prepass.h" #include "c4d_plugin.h" class BaseDocument; //class AtomArray; Bool Registerarchitect4D(); //void CommandLineRendering(C4DPL_CommandLineArgs* args); #endif // ARCHITECT4D_H__
and c4d_symbols.h
enum { // string table definitions IDS_ARCHITECT4D = 10000, _DUMMY_ELEMENT_ }; #pragma once
When compiling I have the following errors from Linker:
Error LNK2019 unresolved external symbol "bool __cdecl PluginStart(void)" ([email protected]@YA_NXZ) referenced in function c4d_main architect4d C:\sdk20\plugins\architect4d\project\cinema.framework_Debug_64bit.lib(c4d_pmain.obj) Error LNK2019 unresolved external symbol "void __cdecl PluginEnd(void)" ([email protected]@YAXXZ) referenced in function c4d_main architect4d C:\sdk20\plugins\architect4d\project\cinema.framework_Debug_64bit.lib(c4d_pmain.obj) Error LNK2019 unresolved external symbol "bool __cdecl PluginMessage(int,void *)" ([email protected]@[email protected]) referenced in function c4d_main architect4d C:\sdk20\plugins\architect4d\project\cinema.framework_Debug_64bit.lib(c4d_pmain.obj)
What do I do wrong? It seems some linker settings are wrong. Could you please help me with this?
@m_magalhaes Thank you for a quick reply! I'm sorry, I made an idiotic mistake. I simply didn't add the following piece of code:
case C4DPL_INIT_SYS: { // load resources defined in the the optional "res" folder if (!g_resource.Init()) return false; return true; }
in the main.cpp
Thanks, again. I hope my next questions will have more sense. It should be an architecture plugin in the end Yaroslav.
Dear fellows, I'm trying to write my first plugin in c++. I followed instructions, and with the help of the projecttool created the plugin folders.
I managed to create a plugin that draws a cube in viewpoirt. Even more, my plugin has its own logo.tif in the r21 <extensions menu> in cinema4d r21, but it has a blank space instead of a name.
As far as I understand the name comes from the file myplugin/res/strings_en-US/c4d_strings.str
I created this folder and c4d_strings.str file with
STRINGTABLE { IDS_MYPLUGIN "Make Cube"; }
Here is my registration line in the myplugin.cpp
RegisterCommandPlugin(1054040, GeLoadString(IDS_MYPLUGIN), 0, AutoBitmap("icon.tif"_s), "MyPlugin"_s, NewObjClear(MyPlugin));
However, the name of the plugin is still missing in the extentions menu in c4d. What do I do wrong?
Yaroslav. P.S.
I'm newbe in c++ and had only python experience before. I use vs 2019