void OnBnClickedPrBoxes() { sgGetScene()->Clear(); AddFloorInScene(7.0, 7.0, 1.0, 1.0, -0.3); sgCBox* bx1 = sgCreateBox(1,2,2.1); SG_VECTOR transV = {-5,-5,0}; /* bx1->InitTempMatrix()->Translate(transV); bx1->ApplyTempMatrix(); bx1->DestroyTempMatrix();*/ sgGetScene()->AttachObject(bx1); bx1->SetAttribute(SG_OA_COLOR,8); //SetMaterialToObject(bx1,MATERIAL_IMAGE_1); sgCBox* bx2 = sgCreateBox(1,1,1); transV.x = 1.5; transV.y = 0.0; transV.z = 0.0; bx2->InitTempMatrix()->Translate(transV); bx2->ApplyTempMatrix(); bx2->DestroyTempMatrix(); //SetMaterialToObject(bx2,MATERIAL_GLASS_4); sgGetScene()->AttachObject(bx2); bx2->SetAttribute(SG_OA_COLOR,0); bx2->SetAttribute(SG_OA_LINE_THICKNESS,1); bx2->SetAttribute(SG_OA_LINE_TYPE,1); }
//---------------------------------------------------------------------- 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);*/ }
CDrillsScene::CDrillsScene() { sgGetScene()->Clear(); m_drills[0] = CreateDrill(1.0,5.0); //SetMaterialToObject(m_drills[0],MATERIAL_METALL_GOLD_4); m_drills[1] = m_drills[0]->Clone(); //SetMaterialToObject(m_drills[1],MATERIAL_METALL_GOLD_4); m_drills[2] = m_drills[0]->Clone(); //SetMaterialToObject(m_drills[2],MATERIAL_METALL_GOLD_4); m_drills[3] = m_drills[0]->Clone(); //SetMaterialToObject(m_drills[3],MATERIAL_METALL_GOLD_4); sgCCylinder* holes[5]; for (int i=0;i<4;i++) holes[i] = sgCCylinder::Create(1.0, 20.0, 24); holes[4] = sgCCylinder::Create(2.5, 20.0, 24); SG_VECTOR transVec = {15.0, 15.0, 0.0}; m_drills[0]->InitTempMatrix()->Translate(transVec); m_drills[0]->ApplyTempMatrix(); m_drills[0]->DestroyTempMatrix(); transVec.z = -10.0; holes[0]->InitTempMatrix()->Translate(transVec); holes[0]->ApplyTempMatrix(); holes[0]->DestroyTempMatrix(); sgGetScene()->AttachObject(m_drills[0]); m_drills[0]->SetAttribute(SG_OA_COLOR,2); m_drills[0]->SetAttribute(SG_OA_LINE_THICKNESS, 1); transVec.x = -15.0; transVec.y = 15.0; transVec.z = 0.0; m_drills[1]->InitTempMatrix()->Translate(transVec); m_drills[1]->ApplyTempMatrix(); m_drills[1]->DestroyTempMatrix(); transVec.z = -10.0; holes[1]->InitTempMatrix()->Translate(transVec); holes[1]->ApplyTempMatrix(); holes[1]->DestroyTempMatrix(); sgGetScene()->AttachObject(m_drills[1]); m_drills[1]->SetAttribute(SG_OA_COLOR,3); m_drills[1]->SetAttribute(SG_OA_LINE_THICKNESS, 1); transVec.x = -15.0; transVec.y = -15.0; transVec.z = 0.0; m_drills[2]->InitTempMatrix()->Translate(transVec); m_drills[2]->ApplyTempMatrix(); m_drills[2]->DestroyTempMatrix(); transVec.z = -10.0; holes[2]->InitTempMatrix()->Translate(transVec); holes[2]->ApplyTempMatrix(); holes[2]->DestroyTempMatrix(); sgGetScene()->AttachObject(m_drills[2]); m_drills[2]->SetAttribute(SG_OA_COLOR,4); m_drills[2]->SetAttribute(SG_OA_LINE_THICKNESS, 1); transVec.x = 15.0; transVec.y = -15.0; transVec.z = 0.0; m_drills[3]->InitTempMatrix()->Translate(transVec); m_drills[3]->ApplyTempMatrix(); m_drills[3]->DestroyTempMatrix(); transVec.z = -10.0; holes[3]->InitTempMatrix()->Translate(transVec); holes[3]->ApplyTempMatrix(); holes[3]->DestroyTempMatrix(); sgGetScene()->AttachObject(m_drills[3]); m_drills[3]->SetAttribute(SG_OA_COLOR,5); m_drills[3]->SetAttribute(SG_OA_LINE_THICKNESS, 1); m_drills[4] = CreateDrill(2.5,8.0); sgGetScene()->AttachObject(m_drills[4]); m_drills[4]->SetAttribute(SG_OA_COLOR,10); m_drills[4]->SetAttribute(SG_OA_LINE_THICKNESS, 1); //SetMaterialToObject(m_drills[4],MATERIAL_METALL_GOLD_4); transVec.x = 0.0; transVec.y = 0.0; transVec.z = -10.0; holes[4]->InitTempMatrix()->Translate(transVec); holes[4]->ApplyTempMatrix(); holes[4]->DestroyTempMatrix(); sgCObject* tmpOb1; sgCGroup* tmpGroup; tmpOb1 = sgCreateBox(40.0,40.0, 1.0); transVec.x = -20.0; transVec.y = -20.0; transVec.z = -4.0; tmpOb1->InitTempMatrix()->Translate(transVec); tmpOb1->ApplyTempMatrix(); tmpOb1->DestroyTempMatrix(); for (int i=0;i<5;i++) { tmpGroup = sgBoolean::Sub((const sgC3DObject&)(*tmpOb1), (const sgC3DObject&)(*holes[i])); sgDeleteObject(tmpOb1); tmpGroup->BreakGroup(&tmpOb1); sgDeleteObject(tmpGroup); sgDeleteObject(holes[i]); } m_box = tmpOb1; //SetMaterialToObject(m_box,MATERIAL_WOOD_7); sgGetScene()->AttachObject(m_box); m_box->SetAttribute(SG_OA_COLOR,10); m_box->SetAttribute(SG_OA_LINE_THICKNESS, 1); }