Ejemplo n.º 1
0
void OnBnClickedPrTors()
{
  sgGetScene()->Clear();

  AddFloorInScene(100.0, 50.0, 50.0, 10.0, 2.0);

  for (int i=2;i<10;i++)
  {
    sgCTorus* tor1 = sgCreateTorus(i,i/6+2,24,24);
    //SetMaterialToObject(tor1,MATERIAL_METALL_CHROME_1+i);
    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);
  }

}
Ejemplo n.º 2
0
//----------------------------------------------------------------------
void game::loadObject(int objID, SG_VECTOR p, SG_VECTOR t){
	if (objectID == -1){
		objectDisplayed = new myobject3D(p,t);
	}else{
		objectDisplayed->exit();
		delete objectDisplayed;
		objectDisplayed = new myobject3D(p,t);
	}
	objectID = objID;
	if(step == 0 || step==1 || step == 6){
		if(objID == 1){
			//torus
			objectDisplayed->loadObject(sgCreateTorus(100,70,50,50),1);//(radius,thickness,meridiansDonut,meridiansDonutCut)
			if(extrudedB){
				sgDeleteObject(extrudedObject);
				extrudedB = false;
			}
		}
		if(objID == 2){
			//cube
			objectDisplayed->loadObject(sgCreateBox(300,300,300),2);//(tamX,tamY,tamZ)
			if(extrudedB){
				sgDeleteObject(extrudedObject);
				extrudedB = false;
			}
		}if(objID == 3){
			//cone
			//objectDisplayed->loadObject(sgCreateCone(250,1,250,3),3);
			objectDisplayed->loadObject((sgC3DObject *)sgTetrahedron->Clone(),3);
			if(extrudedB){
				sgDeleteObject(extrudedObject);
				extrudedB = false;
			}
		}
		if(objID == 4){
			//try to load the bunny
			objectDisplayed->loadObject((sgC3DObject *)sgBunny->Clone(),4);
			if(extrudedB){
				sgDeleteObject(extrudedObject);
				extrudedB = false;
			}
		}
		if(objID == 5){
			//try to load the dodecahedron
			objectDisplayed->loadObject((sgC3DObject *)sgDodecahedron->Clone(),5);
			if(extrudedB){
				sgDeleteObject(extrudedObject);
				extrudedB = false;
			}
		}
		if(objID == 6){
			//try to load the Icosahedron
			objectDisplayed->loadObject((sgC3DObject *)sgIcosahedron->Clone(),6);
			if(extrudedB){
				sgDeleteObject(extrudedObject);
				extrudedB = false;
			}
		}
		if(objID == 7){
			//try to load the Octahedron
			objectDisplayed->loadObject((sgC3DObject *)sgOctahedron->Clone(),7);
			if(extrudedB){
				sgDeleteObject(extrudedObject);
				extrudedB = false;
			}

		}
		//if(objID == 8){
		//	//try to load the Teapot
		//	objectDisplayed->loadObject((sgC3DObject *)sgTeapot->Clone(),8);
		//}
		if(objID == 200){
			//load extruded object
			objectDisplayed->loadObject((sgC3DObject *)extrudedObject->Clone(),200);
		}
		objectDisplayed->setup();
		step = 1;
	}
	////////////////////// from STL file
	/*const char* nel =  ofToDataPath("cube.stl",false).c_str();
	objectDisplayed.loadObjectFromFile(nel);*/
}