Surfaces of extrusion.

 

Let's create a surface of extrusion. An unclosed spline will be the extruded contour.

 

This code creates a spline:

 

SG_POINT tmpPnt;

 

 SG_SPLINE* spl2 = SG_SPLINE::Create();

 

 int fl=0;

 for (double i=0.0;i<10.0;i+=1.0)

 {

         tmpPnt.x = i;

         tmpPnt.y = (fl%2)?-i/2.0:i/2.0;

         tmpPnt.z = 0.0;

         spl2->AddKnot(tmpPnt,fl);

         fl++;

 }

 

 

 sgCSpline* spl2_obj = sgCreateSpline(*spl2);

 sgGetScene()->AttachObject(spl2_obj);

 spl2_obj->SetAttribute(SG_OA_COLOR,12);

 spl2_obj->SetAttribute(SG_OA_LINE_THICKNESS, 2);

 

 SG_SPLINE::Delete(spl2);

 

Let's extrude along the (1, -2, 3) vector:

 

 SG_VECTOR extVec = {1,-2,3};

 

 sgC3DObject* exO = (sgC3DObject*)sgKinematic::Extrude((const sgC2DObject&)(*spl2_obj),NULL,0,extVec,false);

 

 sgGetScene()->AttachObject(exO);

 exO->SetAttribute(SG_OA_COLOR,20);

 

Then we'll move the obtained surface:

 

  SG_VECTOR transV1 = {8,0,0};

 exO->InitTempMatrix()->Translate(transV1);

 exO->ApplyTempMatrix();

 exO->DestroyTempMatrix();

 

See also:

sgKinematic::Extrude  

sgCSpline   sgCSpline::Create SG_SPLINE

sgGetScene sgCScene::AttachObject   sgCObject::SetAttribute

 

Illustration:

kin_ex_s