[Closed] C++ Convert to Editable Poly ?
Hi, Im sure this is a really easy thing to do, but can’t find anything within the samples that is helping me. I want to be able to convert a normal box into a Editable Poly. I’ve try the EPOLYOBJ_CLASS_ID, but it comes back as its not convertable. I can convert my object to a PolyMesh using the polyObjectClassID. What am I missing ?? Code below converts to PolyMesh:
Object *newObject = node->GetObjectRef();
PolyObject *newPoly = NULL;
newPoly = (PolyObject*)newObject->ConvertToType(ip->GetTime(),polyObjectClassID);
node->SetObjectRef(newPoly);
node->SetNodeTM(ip->GetTime(),node->GetNodeTM(TimeValue(0)));
node->SetMtl(node->GetMtl());
Hi, Sorry for late reply, I’ve only just tried this out. But if you convert it to a polyObjectClassID and then collapse it. It just leaves me with a PolyMesh and not an editable poly. I can do it by adding a mod and collapsing it, but just think there has to be a better way. Thanks.
Object* obj = node->GetObjectRef();
PolyObject* poly = (PolyObject*)pObj->ConvertToType(t, Class_ID(polyObjectClassID));
Object *ret = poly->CollapseObject();
node->SetObjectRef(ret);
// if ret != poly you should delete poly
Ahh Perfect, thank you very much ! I was using my own Collapsing function which is why it wasn’t working xD Time to change some code ^^
Hi, Can I ask how to delete the*poly?
Object* obj = node->GetObjectRef();
PolyObject* poly = (PolyObject*)pObj->ConvertToType(t, Class_ID(polyObjectClassID));
Object *ret = poly->CollapseObject();
node->SetObjectRef(ret);
// if ret != poly you should delete poly
when I run this function,application will crash when *node->SetObjectRef(ret); *
Object* obj = node->GetObjectRef();
PolyObject* poly = (PolyObject*)obj->ConvertToType(t, Class_ID(polyObjectClassID));
Object *pObj = poly->CollapseObject();
if (pObj != poly) delete poly;
node->SetObjectRef(pObj);
it has to work…*
Hi, I have a question with how to delete the poly
Object* obj = node->GetObjectRef();PolyObject* poly = (PolyObject*)pObj->ConvertToType(t, Class_ID(polyObjectClassID));
Object *ret = poly->CollapseObject();
node->SetObjectRef(ret);
// if ret != poly you should delete poly
*
when I run this function , it will crash ,if I did not delete the poly
denisT thank you very much and sorry for reply so late! I has tried in this way,but the application still crashed:eek:
Object* obj = node->GetObjectRef();PolyObject* poly = (PolyObject*)obj->ConvertToType(t, Class_ID(polyObjectClassID));
Object *pObj = poly->CollapseObject();
if (pObj != poly) delete poly;
node->SetObjectRef(pObj);