Set Xray in GetVirtualObjects()
-
Hi all, i'm trying to generate an XRAY pyramid inside the GetVirtualObjects() without luck.
Here my source code:BaseObject* pyramid = BaseObject::Alloc(Ocone); if (pyramid) { BaseContainer* cone_bc = pyramid->GetDataInstance(); const Float pyra_height = 0.75; const Vector v1 = Vector(0.0, 1.0, 0.0); const Vector v2 = Vector(1.0, 0.0, 0.0); const Vector v3 = Vector(0.0, 0.0, 1.0); const Vector center = bot_pos + Vector(0.0, pyra_height, 0.0); const Matrix mg = Matrix(center, v2, v1, v3); pyramid->SetMg(mg); cone_bc->SetFloat(PRIM_CONE_TRAD, mid_lower * supp_scale); cone_bc->SetFloat(PRIM_CONE_BRAD, mid_lower * 2.0 * supp_scale); cone_bc->SetFloat(PRIM_CONE_HEIGHT, pyra_height); cone_bc->SetFloat(PRIM_CONE_HSUB, 1); cone_bc->SetFloat(PRIM_CONE_SEG, subdivision); cone_bc->SetBool(PRIM_CONE_CAPS, true); cone_bc->SetInt32(PRIM_CONE_CSUB, 1); cone_bc->SetInt32(PRIM_CONE_FSUB, fstep); // Try to set Xray --------------------------- ObjectColorProperties prop; pyramid->GetColorProperties(&prop); prop.xray = true; pyramid->SetColorProperties(&prop); pyramid->SetParameter(ID_BASEOBJECT_XRAY, GeData(TRUE), DESCFLAGS_SET_0); pyramid->Message(MSG_UPDATE); // Try also with Container ------------------- cone_bc->SetBool(ID_BASEOBJECT_XRAY, true); doc->InsertObject(pyramid, ret, nullptr); }
Thanks in advance
Renato T. -
I just checked with a Python generator, and it works, so at least it is not a general problem in virtual objects
def main(): pyramid = c4d.BaseObject(c4d.Ocone) if pyramid == None: return None pyramid[c4d.PRIM_CONE_SEG] = 4 pyramid[c4d.ID_BASEOBJECT_XRAY] = True return pyramid
(but maybe I don't get your code; why are you inserting the object into the doc instead of returning it? I may be looking for the wrong context here)
-
Thanks Cairyn for the test.
Yes, is a right question ... let me check.
-
Ok, I miss to use OBJECT_USECACHECOLOR. I found it on this older post:
https://developers.maxon.net/forum/topic/6674/7275_setting-xray-for-virtual-objects/8 -
Hi @RenatoT thanks for reaching out us.
By looking at the code it's clear that your intent is to change the visual appearance of a portion of the cache and this can only be done registering the ObjectData with
OBJECT_USECACHECOLOR
. This, at the same time, comes with the drawback that the user can't change anything about the visual appearance of the object from AM.Different could be to set the
ID_BASEOBJECT_XRAY
parameter's value intercepting theMSG_MENUPREPARE
but in this case, while the user retains the option to change the visual appearance, the whole geometry of the cache is affected.def GetVirtualObjects(self, op, hh): res = c4d.BaseObject(c4d.Osphere) if res is not None: pyramid = c4d.BaseObject(c4d.Ocone) if pyramid is not None: pyramid.InsertUnder(res) return c4d.BaseObject(c4d.Onull) def Message(self, node, type, data): if type==c4d.MSG_MENUPREPARE: node[c4d.ID_BASEOBJECT_XRAY] = True return True
Last but not least, be aware that you're misusing the
BaseDocument::InsertObject()
: for the scope of inserting the pyramid under the object returned by theObjectData::GetVirtualObjects()
it's more appropriate to useGeListNode::InsertUnder()
Cheers, R
-
Thanks R, the insert was an error, i already corrected. OBJECT_USECACHECOLOR work as expected
Cheers
Renato