Toruses.

 

Let's create an array of the toruses lying on the same line but having different parameters and randomly turned in space:

 

 

 for (int i=2;i<10;i++)

 {

   sgCTorus* tor1 = sgCreateTorus(i,i/6+2,24,24);

   SG_POINT rotCen = {0.0,0.0,0.0};

   SG_VECTOR rotDir = {rand(),rand(),rand()};

   tor1->InitTempMatrix()->Rotate(rotCen,rotDir, rand()*360);

   SG_VECTOR transV1 = {10*i,10,10};

   tor1->GetTempMatrix()->Translate(transV1);

   tor1->ApplyTempMatrix();

   tor1->DestroyTempMatrix();

 

   sgGetScene()->AttachObject(tor1);

   tor1->SetAttribute(SG_OA_COLOR,i);

 }

 

See also:

 

sgCTorus   sgCTorus::Create

sgCObject::InitTempMatrix sgCMatrix::Translate   sgCObject::ApplyTempMatrix   SgCObject::DestroyTempMatrix   sgGetScene sgCScene::AttachObject   sgCObject::SetAttribute

 

Illustration:

tors