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
    • Login
    1. Maxon Developers Forum
    2. mastergog
    3. Topics
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 41
    • Best 0
    • Controversial 0
    • Groups 0

    Topics created by mastergog

    • M

      Get normals of an arbitrary Cinema 4d object

      Cinema 4D SDK
      • r23 maxon api c++ windows sdk • • mastergog
      3
      0
      Votes
      3
      Posts
      602
      Views

      M

      Aha I see, this makes sense for the NormalTag data. And yeah of course cross product is what I need...

      Regarding the primitives not turning into polygon object, I thought that was happening with a cube, but now after testing it again it definitely is. So I must have been mistaken before.

      Thanks for the help, going to mark this as solved.

    • M

      How to natively create an object with tons of triangles for a test purpose.

      Cinema 4D SDK
      • • • mastergog
      7
      0
      Votes
      7
      Posts
      1.1k
      Views

      M

      Hey guys, thanks for the explanations.

      My only concern is that I can't really do anything besides closing Cinema4D to cancel the operation. Just for reference my plugin is a fluid volume that needs to be visualized in the viewport. This is not an expected workload, stumbled on it by chance, but so can one of the users.

      Anyway we can close this thread if it's not a bug.

      Regards,
      Georgi.

    • M

      LineObject custom segment colors

      Cinema 4D SDK
      • r23 sdk c++ • • mastergog
      7
      0
      Votes
      7
      Posts
      1.2k
      Views

      ferdinandF

      Hi @mastergog,

      thank you for reaching out to us. I can reproduce your problem and this would have not been something which we would have expected. If you go significantly over one million segments (1.1 million still works for me for example) no matter if in one node or scattered over multiple nodes, the viewport will freeze.

      It is a bit hard to assess for us at the moment if this a bug or just a limitation of our viewport API. We will investigate the problem and I will report back here if there are going to be any short or mid-term fixes for that (or not if this is a limitation). For now there is unfortunately nothing you can do, since spreading out the segments over multiple nodes won't help you.

      Sorry for the inconvenience and cheers,
      Ferdinand

    • M

      Difficulty with cloners and and lifetime of objects

      Cinema 4D SDK
      • • • mastergog
      13
      0
      Votes
      13
      Posts
      2.0k
      Views

      M

      All right, thank you for all the help.

      I'll close this now.

    • M

      Calling ExecuteOnMainThread() from ObjectData::GetVirtualObjects()

      Cinema 4D SDK
      • c++ windows macos sdk • • mastergog
      17
      0
      Votes
      17
      Posts
      2.1k
      Views

      M

      Glad you found a way and yes I think it's safe now 🙂
      I guess there is no more open pint? If so I let you define your topic as solved (see Forum Structure and Features - Ask as Question If you don't know how to do it).

      Just in case a BaseContainer can also store a BaseContainer. so you could store your own BaseContainer at the ID_PLUGIN And in this BaseContainer at ID 0 stores, the obj counts, and then you can safely iterate over it.

      Cheers,
      Maxime.

    • M

      How to disable orange highlight on per object basis

      Cinema 4D SDK
      • r23 c++ windows macos sdk classic api • • mastergog
      4
      0
      Votes
      4
      Posts
      1.8k
      Views

      M

      @m_adam Thanks for the clarification.

      Regards,
      Georgi.

    • M

      Cannot set ID_BASEOBJECT_USECOLOR to a child object.

      Cinema 4D SDK
      • • • mastergog
      4
      0
      Votes
      4
      Posts
      637
      Views

      M

      @m_adam Yay thank you very much! Was almost ready to compromise with the default color.

      Will use the Q&A functionality, excuse me for the posts so far.

      Warm regards,
      Georgi.

    • M

      Drawing large amounts of billboarded triangles in the viewport

      Cinema 4D SDK
      • c++ r23 sdk • • mastergog
      16
      0
      Votes
      16
      Posts
      2.3k
      Views

      r_giganteR

      As already told by @zipit, I'm terribly sorry for coming so late here.
      I've prepared a full example showing how to fill a VertexColorTag in the ObjectData::GetVirtualObjects() and use this values to color the triangles shown up in the ObjectData::Draw() method. My code actually uses the VertexColorTag::SetColor()/GetColor().
      5b4213d8-e4b4-434a-ad71-5ef0d69be6ea-image.png

      The VertexColorTag in this case is not specify to each vertex of the triangle but specifies the color for the whole triangle: this is because the tag is created in the ObjectData::GetVirtualObjects() and store color for each point of the cloud, but then it's used in the ObjectData::Draw() method to specify the ObjectColorProperty used to color the drawn PolygonObject. As far as I know the BaseDraw::DrawPolygonObject() ignores any VertexColorTag assigned to the PolygonObject to be drawn.

      BaseObject* PC_12974::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh) { // check cache before continue BaseObject* cache = op->GetCache(); if (cache) return cache; // init the random gen and get a arbitrary number of tris _rndGen.Init(GeGetTimer()); _randomTrisCnt = (SAFEINT32(_rndGen.Get01() * (1 + _max - _min)) + _min); // allocate a PolygonObject and fill it with points randomly PolygonObject* po = PolygonObject::Alloc(_randomTrisCnt, 0); if (!po) return BaseObject::Alloc(Onull); // fill the points array with random positions Vector* points = po->GetPointW(); for (Int32 i = 0; i < _randomTrisCnt; i++) points[i] = Vector (100.0 * _rndGen.Get11(), 100.0 * _rndGen.Get11(), 100.0 * _rndGen.Get11()); // look for VertexColor tag BaseTag* tag = po->GetTag(Tvertexcolor); // if not existing just create a new one VertexColorTag* vcTag = nullptr; if (!tag) { tag = VertexColorTag::Alloc(_randomTrisCnt); po->InsertTag(tag); } vcTag = static_cast<VertexColorTag*>(tag); vcTag->SetPerPointMode(true); VertexColorHandle handle = vcTag->GetDataAddressW(); // fill the vertexcolor tag with random values for (Int32 i = 0; handle && i < _randomTrisCnt; i++) VertexColorTag::SetColor(handle, nullptr, nullptr, i, maxon::Color32(_rndGen.Get01(), _rndGen.Get01(), _rndGen.Get01())); // update host object po->Message(MSG_UPDATE); return po; } Bool PC_12974::TriangleOnPoint(const Vector &pos, PolygonObject& po) { // given a point create a triangle centered over there. Vector* points = po.GetPointW(); const Matrix poMG = po.GetMg(); const Vector posMG = poMG * pos; if (!points) return false; // set vertexes positions for the triangle. points[0] = Vector(0, 0, _triangleRad) + posMG; points[1] = Vector(_triangleRad * Cos(-PI / 6), 0, _triangleRad * Sin(-PI / 6)) + posMG; points[2] = Vector(_triangleRad * Cos(-PI * 5 / 6), 0, _triangleRad * Sin(-PI * 5 / 6)) + posMG; // create the polygon CPolygon* polys = po.GetPolygonW(); if (!polys) return false; polys[0] = CPolygon(0, 1, 2); return true; } DRAWRESULT PC_12974::Draw (BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, BaseDrawHelp *bh) { // skip anything but OBJECT drawpass if (drawpass != DRAWPASS::OBJECT) return DRAWRESULT::SKIP; // check for the object and its cache if (op && op->GetCache()) { // get the PolygonObject from the cache PolygonObject* opPO = static_cast<PolygonObject*>(op->GetCache()); // look for the attached VertexColor Tag BaseTag* const tag = opPO->GetTag(Tvertexcolor); if (!tag) return DRAWRESULT::SKIP; VertexColorTag* const vcTag = static_cast<VertexColorTag*>(tag); // retrieve the read-only handle ConstVertexColorHandle vcTagHandleR = vcTag->GetDataAddressR(); // get the points and iterate over the VertexColor to set the color // of each triangle drawn maxon::Int pointCnt = opPO->GetPointCount(); Vector const *points = opPO->GetPointR(); for (maxon::Int i = 0; i < pointCnt; i++) { maxon::Color32 vtxCol(0.0); // get the color if (vcTagHandleR && vcTag->IsPerPointColor()) vtxCol = VertexColorTag::GetColor(vcTagHandleR, nullptr, nullptr, (Int32)i); // set the color in the ObjectColorProperties ObjectColorProperties colProp; colProp.usecolor = ID_BASEOBJECT_USECOLOR_ALWAYS; colProp.color.x = vtxCol.r; colProp.color.y = vtxCol.g; colProp.color.z = vtxCol.b; colProp.xray = false; // allocate the temp triangle PolygonObject* tri = PolygonObject::Alloc(3, 1); // set the color prop, create the tri and draw! tri->SetColorProperties(&colProp); if (TriangleOnPoint(op->GetMg() * points[i], *tri)) bd->DrawPolygonObject(bh, tri, DRAWOBJECT::NONE, nullptr); // free the tri PolygonObject::Free(tri); } } return DRAWRESULT::OK; }

      Feel free to comment and again sorry for the silence.

      Riccardo