Boolean subtraction.
Let's create a group by subtracting a torus from another one.
As sgCore is a solid modeling library the resulting Boolean operations objects are in no way connected with each other. They are grouped to return from the function. For the further work with each object separately you should take this group component parts.
The code of creating toruses and constructing objects from their subtraction looks as follows:
sgCTorus* tor1 = sgCreateTorus(2,1 ,24,24);
sgCTorus* tor2 = sgCreateTorus(2,0.8 ,24,24);
SG_VECTOR transV1 = {1,1,0};
tor2->InitTempMatrix()->Translate(transV1);
tor2->ApplyTempMatrix();
tor2->DestroyTempMatrix();
sgGetScene()->AttachObject(tor1);
tor1->SetAttribute(SG_OA_COLOR,5);
sgGetScene()->AttachObject(tor2);
tor2->SetAttribute(SG_OA_COLOR,25);
SG_VECTOR transV2 = {-6.0,0,0};
sgCGroup* bool1 = sgBoolean::Sub(*tor1, *tor2);
bool1->InitTempMatrix()->Translate(transV2);
bool1->ApplyTempMatrix();
bool1->DestroyTempMatrix();
sgGetScene()->AttachObject(bool1);
bool1->SetAttribute(SG_OA_COLOR,3);
See also:
sgCGroup sgCGroup::BreakGroup sgCGroup::GetChildrenList
sgCObject::InitTempMatrix sgCMatrix::Translate sgCObject::ApplyTempMatrix SgCObject::DestroyTempMatrix sgGetScene sgCScene::AttachObject sgCObject::SetAttribute
Illustration: