Example #1
0
//----------------------------------------------------------------------
void game::extrudeObject(){
	//create and use circle
	SG_POINT   crCen = {0,0,0.0};  
	SG_VECTOR  crNor;  
	crNor.x = 0.0;  
	crNor.y = 3.0;  
	crNor.z = 0.0;
	sgSpaceMath::NormalVector(crNor); 
	SG_CIRCLE  crGeo;  
	crGeo.FromCenterRadiusNormal( crCen, 150, crNor);  
	sgCCircle* cr = sgCreateCircle(crGeo);   


	////extrude along vector
	SG_VECTOR extVec = {0,-300,0};  

	if (objectID == -1){
		extrudedObject = (sgC3DObject*)sgKinematic::Extrude((const sgC2DObject&)(*cr),NULL,0,extVec,true);
	}else{
		free(extrudedObject);
		extrudedObject = (sgC3DObject*)sgKinematic::Extrude((const sgC2DObject&)(*cr),NULL,0,extVec,true);
	}

	extrudedObject->SetAttribute(SG_OA_COLOR,30);
	extrudedB = true;
	sgDeleteObject(cr);

	//we  have the sg3DObjcect to load
	loadObject(200,slicingPos,posP);//using id=200

}
Example #2
0
sgCObject* CDrillsScene::CreateDrill(double rad, double dH)
{
	sgC2DObject* drill_1_sections[10];
	double       params[10];
	memset(params,0,sizeof(double)*10);
	drill_1_sections[0] = CreateDrillSection(rad);

	SG_POINT     rotAxeP = {0.0, 0.0, 0.0};
	SG_VECTOR    rotAxeDir = {0.0, 0.0, 1.0};
	SG_VECTOR    transVec = {0.0, 0.0, 1.0};
	for (int i=1;i<7;i++)
	{
		drill_1_sections[i] = (sgCContour*)(drill_1_sections[0]->Clone());
		drill_1_sections[i]->InitTempMatrix()->Rotate(rotAxeP,rotAxeDir,i*5.0*3.14159265/6.0);
		transVec.z = dH*i;
		drill_1_sections[i]->GetTempMatrix()->Translate(transVec);
		drill_1_sections[i]->ApplyTempMatrix();
		drill_1_sections[i]->DestroyTempMatrix();
	}

	SG_CIRCLE cirGeo;
	cirGeo.center.x = cirGeo.center.y = 0.0;  cirGeo.center.z =  7*dH+5;
	cirGeo.normal.x = cirGeo.normal.y = 0.0;  cirGeo.normal.z = 1.0;
	cirGeo.radius = rad-0.1;

	drill_1_sections[7] = sgCreateCircle(cirGeo);
	drill_1_sections[7]->ChangeOrient();
	cirGeo.center.z = 7*dH+10;
	drill_1_sections[8] = sgCreateCircle(cirGeo);
	drill_1_sections[8]->ChangeOrient();
	cirGeo.center.z =7*dH+15;
	drill_1_sections[9] = sgCreateCircle(cirGeo);
	drill_1_sections[9]->ChangeOrient();


	sgCObject* resul = sgSurfaces::SplineSurfaceFromSections((const sgC2DObject**)drill_1_sections,
		params,10,true);

	for (int i=0;i<10;i++)
		sgDeleteObject(drill_1_sections[i]);

	return resul;
}
Example #3
0
void OnBnClickedPrCircles()
{
  sgGetScene()->Clear();

  for (double i=0.0;i<2.0*3.14159265;i+=0.4)
  {
    SG_POINT   crCen = {5.0*cos(i),5.0*sin(i),0.0};
    SG_VECTOR  crNor;
    crNor.x = crCen.x - 0.0;
    crNor.y = crCen.y - 0.0;
    crNor.z = 0.0;
    sgSpaceMath::NormalVector(crNor);
    SG_CIRCLE  crGeo;
    crGeo.FromCenterRadiusNormal(crCen, 1, crNor);
    sgCCircle* cr = sgCreateCircle(crGeo);
    sgGetScene()->AttachObject(cr);
    cr->SetAttribute(SG_OA_COLOR,((int)(10*i))%200+50);
    cr->SetAttribute(SG_OA_LINE_THICKNESS, ((int)(10*i))%5);
    cr->SetAttribute(SG_OA_LINE_TYPE, ((int)(10*i))%5);
  }
}