Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Register
    • Register
    • Login
    1. Maxon Developers Forum
    2. Yaroslav
    Y
    • Profile
    • Following 0
    • Followers 0
    • Topics 6
    • Posts 18
    • Best 1
    • Controversial 0
    • Groups 0

    Yaroslav

    @Yaroslav

    1
    Reputation
    48
    Profile views
    18
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Yaroslav Unfollow Follow

    Best posts made by Yaroslav

    • RE: Can't add plugin name into cinema4d

      @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.

      posted in General Talk
      Y
      Yaroslav

    Latest posts made by Yaroslav

    • python plugin in debugging mode

      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.

      posted in Cinema 4D SDK
      Y
      Yaroslav
    • RE: phong tag

      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!

      Yaroslav.

      posted in Cinema 4D SDK
      Y
      Yaroslav
    • RE: phong tag

      @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]question_phong.png

      posted in Cinema 4D SDK
      Y
      Yaroslav
    • RE: phong tag

      What a nice and comprehensive answer!

      Thank you so much! Everything is crystal clear now!

      posted in Cinema 4D SDK
      Y
      Yaroslav
    • phong tag

      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/cpp/2023_2/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?

      Yaroslav.

      posted in Cinema 4D SDK c++ sdk
      Y
      Yaroslav
    • RE: Turn Bezier spline to linear spline

      @ferdinand
      Oh, thanks!
      Quite a nice idea!

      posted in Cinema 4D SDK
      Y
      Yaroslav
    • RE: Turn Bezier spline to linear spline

      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);
      

      q2.png

      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.

      posted in Cinema 4D SDK
      Y
      Yaroslav
    • RE: Turn Bezier spline to linear spline

      @ferdinand

      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.

      Yaroslav.

      posted in Cinema 4D SDK
      Y
      Yaroslav
    • Turn Bezier spline to linear spline

      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.

      Yaroslav.

      posted in Cinema 4D SDK
      Y
      Yaroslav
    • RE: Get Spline Data from document->GetActiveObject();

      @m_magalhaes

      Thank you, Manuel!

      posted in Cinema 4D SDK
      Y
      Yaroslav