• How to set the shadow for polygon drawing

    c++ r21
    3
    1
    0 Votes
    3 Posts
    727 Views
    ferdinandF
    Hello @aimidi, thank you for reaching out to us. Please excuse the delay, but your questions had to be reassigned internally, which is why I only took it on yesterday. The main reason for your problems is the incomplete initialization of Vector Box_vc[4] = {Vector(0)};. Box_vc should be initialized with four vectors as you do declare yourself. This partial initialization causes the shading errors you did experience. Please also note that you did flag your posting as R21, which is out of the support cycle. Below I do provide some example code written for S24. It should work on R21, since there have been no changes to the involved interfaces and methods as far as I am aware of, but I did not try to compile the code for R21. The code is also narrative in nature and lines out a few other problems with the code provided by you. I hope this will be helpful to you. Cheers, Ferdinand The result: [image: example.gif] The code: // Example for some drawing operations via ObjectData::Draw(). // // Draws a white polygon and a red cube in the local coordinate system of the BaseObject. The main // problem of your code was that you did not initialize the color array properly. // // As discussed in: // https://developers.maxon.net/forum/topic/13441 #include "c4d.h" #include "c4d_symbols.h" class Pc13441 : public ObjectData { INSTANCEOF(Pc13441, ObjectData) public: static NodeData* Alloc() { return NewObjClear(Pc13441); } DRAWRESULT Draw(BaseObject* op, DRAWPASS drawpass, BaseDraw* bd, BaseDrawHelp* bh) { if (drawpass == DRAWPASS::OBJECT) { if (op == nullptr || bd == nullptr) { return DRAWRESULT::FAILURE; } // Set the drawing matrix to the global matrix of the object we are drawing for. This is // more intuitive than what you did, because we can now just draw as if the origin of // our object is the origin of the drawing space and also will respect the orientation // of the that object. Or in short: We will draw in the local matrix of op. bd->SetMatrix_Matrix(nullptr, op->GetMg()); // The replacement for the drawing size parameter(s) of your example. Vector poylgonSize = Vector(100); // We are now going to draw a manually shaded polygon. This will ignore shading defined // by the user/scene. The user turning on and off shadows in the viewport or moving // lights will have no impact on this. // Define the vertices of the polygon to draw. Vector vertices[4] = { Vector(+poylgonSize.x, +poylgonSize.y, 0), Vector(-poylgonSize.x, +poylgonSize.y, 0), Vector(-poylgonSize.x, -poylgonSize.y, 0), Vector(+poylgonSize.x, -poylgonSize.y, 0) }; // Define the color for each vertex to draw, Cinema will interpolate between these // colors. Vector colors[4] = { Vector(1), Vector(1), Vector(1), Vector(1) }; // You did not initialize this array properly and also did pass in black as a color. // So, this, // // Vector colors[4] = { Vector(0) }; // // where we only initialize the 0th element, is not equivalent to that: // // Vector colors[4] = { Vector(0), Vector(0), Vector(0), Vector(0) }; // // The first one will give you the weird shading errors you had while the latter will // give you an all black polygon. Black as a color is of course not that useful if we // want to see some shading. // If our polygon is a quad or triangle. bool isQuad = true; // Set the drawing transparency to about 50%. bd->SetTransparency(127); // Draw the polygon. bd->DrawPolygon(vertices, colors, isQuad); // Now we are going to draw a box. // The size of the box. float boxSize = 50; // A transform for the box, we are going to draw it a bit off-center, so that it does // not overlap with the polygon we did draw. Matrix boxTransform = Matrix(); boxTransform.off = Vector(200, 0, 0); // The color for the box, this can only be a solid color. Vector boxColor = Vector(1, 0, 0); // And if we want to draw it as a wire frame. bool isWireFrame = false; // Draw the box. bd->DrawBox(boxTransform, boxSize, boxColor, isWireFrame); // For more complex drawing operations one could use DrawPoly() to draw a single // polygon, while respecting scene shading, or DrawPolygonObject() to draw a BaseObject // that is a PolygonObject. Which will also respect user defined scene shading by // default. I would not recommend constructing such polygon object to draw in Draw() as // this method is rather performance critical. If possible, this should be done // beforehand, i.e., in a cached manner. } return SUPER::Draw(op, drawpass, bd, bh); } };
  • How is the Plugin ID parameter used by GeDialogs?

    macos windows python r21 s24
    3
    0 Votes
    3 Posts
    907 Views
    a_blockA
    Hello Ferdinand, yes, I was talking about the plugin ID argument of GeDialog.Open() and Restore(). Thanks for your explanation. I'm completely fine with your answer, despite some seeming here and there. I do understand the problems a codebase grown over decades can cause for answering such questions definitely. Nevertheless your explanations largely sync with my expectations from quite a few experiments. Regarding the mentioned issue of the other thread, I can acknowledge, the plugin ID parameter did not seem to have influence on the issue in my experiments. This question here was really more targeted the sizing issues I have with requesters of varying content. And your answer provides me with some confidence, I can make use of different plugin IDs (I should probably rather say unique IDs from Plugin Café) even if they are not related to any registered plugins at all. While I had already thought so and did not find any issues with this practice, it's always a bit hard to know for sure from the outside. And there's always this feeling one could be doing something harmful, which will only bite at the worst possible point in future. Thanks for the clarification. Cheers, Andreas
  • Select the object on which the plugin Tag is associated

    5
    0 Votes
    5 Posts
    953 Views
    mocolocoM
    I changed my code to use BaseDocument.SearchObject(self, name) and it is working perfectly without compromising anything. Thanks again, Cheers, Christophe
  • Enable Isoline Editing in tool plugin

    13
    0 Votes
    13 Posts
    3k Views
    ferdinandF
    Hi @mdr74, yes, it is and thanks for doing it! Cheers, Ferdinand
  • 0 Votes
    10 Posts
    2k Views
    ManuelM
    Hi, This question has been answered by email. You can use the DescriptionProcessors to build/rebuild the wires inside the Usernode. Cheers, Manuel
  • render progress callback is called wrong by Redshift

    python r21
    4
    0 Votes
    4 Posts
    783 Views
    ferdinandF
    Hello @Boony2000, without any further questions or postings, we will consider this topic as solved by Wednesday and flag it accordingly. Cheers, Ferdinand
  • Finding name/handle to last object merged into scene

    3
    0 Votes
    3 Posts
    688 Views
    ferdinandF
    Hello @nicholas_yue, without any further questions or postings, we will consider this topic as solved by Wednesday and flag it accordingly. Cheers, Ferdinand
  • How can I retrieve the copied data?

    python
    3
    0 Votes
    3 Posts
    613 Views
    ferdinandF
    Hello @kng_ito, without any further questions or postings, we will consider this topic as solved by Wednesday and flag it accordingly. Cheers, Ferdinand
  • Insert User Data Track in Python

    Moved
    10
    0 Votes
    10 Posts
    2k Views
    ferdinandF
    Hello @JH23, without any further questions or postings, we will consider this topic as solved by Wednesday and flag it accordingly. Cheers, Ferdinand
  • create a cube that disappears when you return?

    Moved
    10
    0 Votes
    10 Posts
    2k Views
    ferdinandF
    Hello @JH23, without any further questions or postings, we will consider this topic as solved by Wednesday and flag it accordingly. Cheers, Ferdinand
  • Help needed with sketch material

    4
    0 Votes
    4 Posts
    751 Views
    I
    It worked! Thank you so much!
  • MCOMMAND JOIN Polygon max limit ?

    7
    0 Votes
    7 Posts
    1k Views
    M
    Hi with release R24, the new limit is now 500 millions points. Cheers, Maxime.
  • 0 Votes
    15 Posts
    2k Views
    beatgramB
    @m_adam Oh, that's a little update for many users but huge for tiny developers like me! Thank you so much for the heads up.
  • json.dumps truncated in R23 Console

    python r23
    7
    0 Votes
    7 Posts
    769 Views
    ?
    Excellent, thank you for following up, @m_adam !
  • Dealing with Symbolcache

    python
    12
    0 Votes
    12 Posts
    3k Views
    M
    Hi with the latest update of Cinema 4D (R24 SP1), any update to a description files should now be reflected correctly to the symbolcache files, so it's not needed to delete it manually anymore. Cheers, Maxime.
  • SearchPluginMenuResource has wrong default value

    r21
    3
    0 Votes
    3 Posts
    517 Views
    M
    Hi @Boony2000 with the latest update of Cinema 4D (R24 SP1), c4d.gui.SearchPluginMenuResource default value was fixed in Python. Cheers, Maxime.
  • CKey Auto Tangents

    c++ r23 s24
    7
    0 Votes
    7 Posts
    2k Views
    M
    Hi @AiMiDi with the latest update of Cinema 4D (R24 SP1), CKey::GetValueLeft/Right and CKey::GetTimeLeft/Right documentation have been improved to mention what was described by @ferdinand. Cheers, Maxime.
  • 0 Votes
    4 Posts
    798 Views
    M
    Hi @pyxelrigger, with the latest update of Cinema 4D (R24 SP1), fixed the issue with the Python Console, and it is now able to properly handle pairs of carriage return and new line characters. Cheers, Maxime.
  • Delete Third-Party-Tags?

    7
    0 Votes
    7 Posts
    1k Views
    M
    Hi with the latest update of Cinema 4D (R24 SP1), BasePlugin.GetFilename now also return the file extension in Python. Cheers, Maxime.
  • How to know baking is end with BakeTextureTag?

    python r19
    7
    0 Votes
    7 Posts
    2k Views
    M
    Hi @velbie with the latest update of Cinema 4D (R24 SP1), the BAKE_TEX_AO_VERTEXMAPS issue is fixed. Cheers, Maxime.