Exemplo n.º 1
0
void  AddFloorInScene(double size1, double size2, 
					  double x_shift, double y_shift, double z_shift)
{
	sgCObject*   objects_buffer[4];
	objects_buffer[0] = sgCreateLine(size1/2.0, size2/2.0, 0.0, 
		-size1/2.0, size2/2.0, 0.0);
	objects_buffer[1] = sgCreateLine(-size1/2.0, size2/2.0, 0.0, 
		-size1/2.0, -size2/2.0, 0.0);
	objects_buffer[2] = sgCreateLine(-size1/2.0, -size2/2.0, 0.0, 
		size1/2.0, -size2/2.0, 0.0);
	objects_buffer[3] = sgCreateLine(size1/2.0, -size2/2.0, 0.0, 
		size1/2.0, size2/2.0, 0.0);

	sgCContour*  cnt = sgCContour::CreateContour(objects_buffer,4);

	sgCObject*   floor = sgSurfaces::Face((const sgC2DObject&)(*cnt),NULL,0);
	sgDeleteObject(cnt);

	sgGetScene()->AttachObject(floor);
	floor->SetAttribute(SG_OA_COLOR,25);

	SG_VECTOR transV = {x_shift, y_shift, z_shift};
	floor->InitTempMatrix()->Translate(transV);
	floor->ApplyTempMatrix();
	floor->DestroyTempMatrix();

}
Exemplo n.º 2
0
//----------------------------------------------------------------------
bool game::extrudeObject(ofPolyline *drawing){
	//this functino extrudes the input ofPolylne

	vector< ofPoint > points = drawing->getVertices();

	sgCObject*  cont_objcts[2000];///////////////////////////////////////////////////////////////////////////////clean this memeory!!!
	for (int i =0; i < points.size() ; i ++)  {
		if(i!= points.size()-1){
			cont_objcts[i] = sgCreateLine(points[i].x, 0, points[i].y,points[i+1].x, 0, points[i+1].y);
		}else{
			//its the last point.. make the line with the first point
			cont_objcts[i] = sgCreateLine(points[i].x, 0, points[i].y,points[0].x, 0, points[0].y);
		}
	}  

	sgCContour* win_cont = sgCContour::CreateContour(cont_objcts, points.size()-1);

	//check if its self intersecting
	if(win_cont->IsSelfIntersecting()){
		//its self intersecting
		//abort!!!
		//for now
		extrudedB = false;
		//clear ofpolylines!!!
		//myCanvas->myPolyline->clear();
		//free(myCanvas->myPolyline);
		//myCanvas->myPolyline2->clear();
		free(drawing);
		sgDeleteObject(win_cont);
		return false;
	}else{
		////extrude along vector
		SG_VECTOR extVec = {0,-300,0};  
		if (objectID == -1){
			extrudedObject = (sgC3DObject*)sgKinematic::Extrude(*win_cont,NULL,0,extVec,true);
		}else{
			free(extrudedObject);
			extrudedObject = (sgC3DObject*)sgKinematic::Extrude(*win_cont,NULL,0,extVec,true);
		}

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

		free(drawing);
		sgDeleteObject(win_cont);
		return true;
	}
	////////free(cont_objcts);
}
Exemplo n.º 3
0
sgCContour* CDrillsScene::CreateDrillSection(double rad)
{
	sgCObject*  objcts[6];

	objcts[0] = sgCreateLine(0.0, -0.99*rad, 0.0, -0.05*rad, -0.99*rad, 0.0);
	objcts[1] = sgCreateLine(-0.05*rad, -0.99*rad, 0.0, -0.05*rad, -0.97*rad, 0.0);

	SG_ARC arcGeo;
	SG_POINT arcP1;
	SG_POINT arcP2;
	SG_POINT arcP3;

	arcP1.x = -0.05*rad;  arcP1.y = -0.97*rad; arcP1.z = 0.0;
	arcP2.x = -1.0*rad;   arcP2.y = 0.0;       arcP2.z = 0.0;
	arcP3.x = -0.87*rad;  arcP3.y = -0.5*rad;  arcP3.z = 0.0;

	arcGeo.FromThreePoints(arcP1,arcP2,arcP3,false);

	objcts[2] = sgCreateArc(arcGeo);

	arcP1.x = -1.0*rad;   arcP1.y = 0.0;       arcP1.z = 0.0;
	arcP2.x = -0.05*rad;  arcP2.y = 0.0;       arcP2.z = 0.0;
	arcP3.x = -0.35*rad;  arcP3.y = -0.33*rad; arcP3.z = 0.0;

	arcGeo.FromThreePoints(arcP1,arcP2,arcP3,false);

	objcts[3] = sgCreateArc(arcGeo);

	objcts[4] = sgCreateLine(-0.05*rad, 0.0, 0.0, -0.05*rad, 0.99*rad, 0.0);
	objcts[5] = sgCreateLine(-0.05*rad, 0.99*rad, 0.0, 0.0, 0.99*rad, 0.0);

	sgCContour*  cnt1 = sgCContour::CreateContour(objcts,6);
	sgCContour*  cnt2 = (sgCContour*)cnt1->Clone();

	SG_POINT     rotAxeP = {0.0, 0.0, 0.0};
	SG_VECTOR    rotAxeDir = {0.0, 0.0, 1.0};
	cnt2->InitTempMatrix()->Rotate(rotAxeP,rotAxeDir,3.14159265);
	cnt2->ApplyTempMatrix();
	cnt2->DestroyTempMatrix();
	
	objcts[0] = cnt1;
	objcts[1] = cnt2;

	return sgCContour::CreateContour(objcts,2);
}
Exemplo n.º 4
0
void OnBnClickedPrLines()
{
  sgGetScene()->Clear();

  for (double i=0.0;i<2.0*3.14159265;i+=0.1)
  {
      {
        sgCLine* ln = sgCreateLine(0, 0, 0.0, 5*cos(i), 5*sin(i), 0.0);
        sgGetScene()->AttachObject(ln);
        ln->SetAttribute(SG_OA_COLOR,((int)(10*i))%200);
        ln->SetAttribute(SG_OA_LINE_THICKNESS, ((int)(10*i))%5);
        ln->SetAttribute(SG_OA_LINE_TYPE, ((int)(10*i))%5);
      }
  }
}
Exemplo n.º 5
0
void OnBnClickedPrContours()
{
  sgGetScene()->Clear();

  /*std::vector<sgCObject*> objts;

  for (double i=0.0;i<2.0*3.14159265;i+=2.0*3.14159265/12.0)
  {
    SG_POINT   arP1 = {5.0*cos(i),5.0*sin(i),0.0};
    SG_POINT   arP2 = {5.0*cos(i+2.0*3.14159265/24.0),5.0*sin(i+2.0*3.14159265/24.0),0.0};
    SG_POINT   arP3 = {7.0*cos(i+2.0*3.14159265/48.0),7.0*sin(i+2.0*3.14159265/48.0),0.0};
    SG_ARC     arGeo;
    if (arGeo.FromThreePoints(arP1, arP2, arP3,false))
    {
      sgCArc* ar = sgCreateArc(arGeo);
      if (ar)
      {
        objts.push_back(ar);
      }
    }
    objts.push_back(sgCreateLine(5.0*cos(i+2.0*3.14159265/24.0),5.0*sin(i+2.0*3.14159265/24.0),0.0,
      5.0*cos(i+2.0*3.14159265/12.0),5.0*sin(i+2.0*3.14159265/12.0),0.0));
  }

  sgCContour* cnt1 = sgCContour::CreateContour(&objts[0],objts.size());
  objts.clear();
  sgGetScene()->AttachObject(cnt1);
  cnt1->SetAttribute(SG_OA_COLOR,0);
  cnt1->SetAttribute(SG_OA_LINE_THICKNESS, 1);


  for (double i=0.0;i<2.0*3.14159265;i+=2.0*3.14159265/6.0)
  {
    SG_POINT   arP1 = {2.0*cos(i),2.0*sin(i),0.0};
    SG_POINT   arP2 = {2.0*cos(i+2.0*3.14159265/12.0),2.0*sin(i+2.0*3.14159265/12.0),0.0};
    SG_POINT   arP3 = {3.0*cos(i+2.0*3.14159265/24.0),3.0*sin(i+2.0*3.14159265/24.0),2.0};
    SG_ARC     arGeo;
    if (arGeo.FromThreePoints(arP1, arP2, arP3,false))
    {
      sgCArc* ar = sgCreateArc(arGeo);
      if (ar)
      {
        objts.push_back(ar);
      }
    }
    objts.push_back(sgCreateLine(2.0*cos(i+2.0*3.14159265/12.0),2.0*sin(i+2.0*3.14159265/12.0),0.0,
      2.0*cos(i+2.0*3.14159265/6.0),2.0*sin(i+2.0*3.14159265/6.0),0.0));
  }

  sgCContour* cnt2 = sgCContour::CreateContour(&objts[0],objts.size());
  objts.clear();
  sgGetScene()->AttachObject(cnt2);
  cnt2->SetAttribute(SG_OA_COLOR,10);
  cnt2->SetAttribute(SG_OA_LINE_THICKNESS, 2);  */


 /* SG_POINT p1 = {280.0000, 64.0000, 0.0};
  SG_POINT p2 = {92.0000, 64.0000, 0.0};
  SG_POINT p3 = {61.0000, 0.0, 0.0};
  SG_POINT p4 = {-12.0000, 0.0, 0.0};
  SG_POINT p5 = {149.0000, 384.0000, 0.0};
  SG_POINT p6 = {223.0000, 384.0000, 0.0};
  SG_POINT p7 = {383.0000, 0.0, 0.0};
  SG_POINT p8 = {310.0000, 0.0, 0.0};

  sgCObject* lnes[8];
  lnes[0] = sgCreateLine(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z);
  lnes[1] = sgCreateLine(p2.x, p2.y, p2.z, p3.x, p3.y, p3.z);
  lnes[2] = sgCreateLine(p3.x, p3.y, p3.z, p4.x, p4.y, p4.z);
  lnes[3] = sgCreateLine(p4.x, p4.y, p4.z, p5.x, p5.y, p5.z);
  lnes[4] = sgCreateLine(p5.x, p5.y, p5.z, p6.x, p6.y, p6.z);
  lnes[5] = sgCreateLine(p6.x, p6.y, p6.z, p7.x, p7.y, p7.z);
  lnes[6] = sgCreateLine(p7.x, p7.y, p7.z, p8.x, p8.y, p8.z);
  lnes[7] = sgCreateLine(p8.x, p8.y, p8.z, p1.x, p1.y, p1.z);
 
  sgCContour* cnt2 = sgCContour::CreateContour(&lnes[0],8);

  sgGetScene()->AttachObject(cnt2);
  cnt2->SetAttribute(SG_OA_COLOR,10);
  cnt2->SetAttribute(SG_OA_LINE_THICKNESS, 2);

  sgC3DObject* fcO = (sgC3DObject*)sgSurfaces::Face((const sgC2DObject&)(*cnt2),
	  NULL,0);

  sgGetScene()->AttachObject(fcO);
  fcO->SetAttribute(SG_OA_COLOR,50); */




  SG_POINT pnts[] = {{228.096008301, 379.119995117, 0.0},
                     {265.567993164, 364.160003662, 0.0},
					 {294.592010498, 338.640014648, 0.0},
					 {313.343994141, 302.079986572, 0.0},
					 {320.000000000, 254.000000000, 0.0},
					 {318.127990723, 232.040008545, 0.0},
					 {312.223999023, 211.040008545, 0.0},
					 {301.856018066, 191.720001221, 0.0 },
					 {286.591979980, 174.800003052, 0.0},
					 { 266.000000000, 161.000000000, 0.0},
					 { 288.055999756, 151.632003784, 0.0},
					 { 304.208007813, 138.136001587, 0.0 },
					 { 315.032012939, 122.624000549, 0.0},
					 { 321.104003906, 107.208000183, 0.0},
   					 { 323.000000000, 94.000000000, 0.0},
					 { 315.720001221, 56.960002899, 0.0},
					 { 295.480010986, 30.240001678, 0.0},
					 { 264.679992676, 12.640000343, 0.0},
					 { 225.720001221, 2.960000038, 0.0},
					 { 181.000000000, 0.0, 0.0},
					 { 144.511993408, 0.0, 0.0},
					 { 108.216003418, 0.0, 0.0},
					 { 72.063995361, 0.0, 0.0},
					 { 36.007999420, 0.0, 0.0},
					 {0.0, 0.0, 0.0},
					 { 384.000000000, 0.0, 0.0},
					 { 34.976001740,384.000000000, 0.0 },
					 { 71.247993469, 384.000000000, 0.0},
					 { 108.431999207, 384.000000000, 0.0},
					 { 146.143997192, 384.000000000, 0.0 },
					 { 184.000000000, 384.000000000, 0.0} };

  sgCObject* lnes[31];

  for (int i=0;i<30;i++)
  {
	  lnes[i] =  sgCreateLine(pnts[i].x, pnts[i].y, pnts[i].z, pnts[i+1].x, pnts[i+1].y, pnts[i+1].z);
  }
  lnes[30] =  sgCreateLine(pnts[30].x, pnts[30].y, pnts[30].z, pnts[0].x, pnts[0].y, pnts[0].z);
 
  sgCContour* cnt2 = sgCContour::CreateContour(&lnes[0],31);

  sgGetScene()->AttachObject(cnt2);
  cnt2->SetAttribute(SG_OA_COLOR,10);
  cnt2->SetAttribute(SG_OA_LINE_THICKNESS, 2);

/*  sgC3DObject* fcO = (sgC3DObject*)sgSurfaces::Face((const sgC2DObject&)(*cnt2),
	  NULL,0);

  sgGetScene()->AttachObject(fcO);
  fcO->SetAttribute(SG_OA_COLOR,50); */
}