void OnBnClickedPrCones() { sgGetScene()->Clear(); AddFloorInScene(200.0, 100.0, 50.0, 10.0, 5.0); for (int i=2;i<10;i++) { sgCCone* co1 = sgCreateCone(i,i/3,10*i,36); //SetMaterialToObject(co1,MATERIAL_METALL_BRONZE_1+i); SG_VECTOR transV1 = {10*i,10,10}; co1->InitTempMatrix()->Translate(transV1); co1->ApplyTempMatrix(); co1->DestroyTempMatrix(); sgGetScene()->AttachObject(co1); co1->SetAttribute(SG_OA_COLOR,i); } }
void CConeEditCommand::OnEnter() { if (!m_was_started) return; SWITCH_RESOURCE ASSERT(m_editable_cone); switch(m_scenar) { case 0: case 1: { ASSERT(m_r_panel); m_rad = m_r_panel->GetNumber(); bool condis = false; if (m_scenar==0) condis = (fabs(m_rad)<0.0001 && fabs(m_cone_geo.Radius2)<0.0001); else condis = (fabs(m_rad)<0.0001 && fabs(m_cone_geo.Radius1)<0.0001); if (condis) { m_message.LoadString(IDS_ERROR_ZERO_BOTH_RADS); m_app->PutMessage(IApplicationInterface::MT_ERROR, m_message); return; } sgCCone* cone = NULL; if (m_scenar==0) cone = sgCreateCone(fabs(m_rad),m_cone_geo.Radius2,fabs(m_cone_geo.Height), m_cone_geo.MeridiansCount); else cone = sgCreateCone(m_cone_geo.Radius1,fabs(m_rad),fabs(m_cone_geo.Height), m_cone_geo.MeridiansCount); if (!cone) return; cone->InitTempMatrix()->Multiply(*m_matr); cone->ApplyTempMatrix(); cone->DestroyTempMatrix(); sgGetScene()->StartUndoGroup(); sgGetScene()->DetachObject(m_editable_cone); sgGetScene()->AttachObject(cone); sgGetScene()->EndUndoGroup(); m_app->CopyAttributes(*cone,*m_editable_cone); m_app->GetViewPort()->InvalidateViewPort(); } break; case 2: { ASSERT(m_r_panel); m_height = m_r_panel->GetNumber(); if (fabs(m_height)<0.0001) { m_message.LoadString(IDS_ERROR_ZERO_LENGTH); m_app->PutMessage(IApplicationInterface::MT_ERROR, m_message); return; } else if (m_height<-0.0001) { m_message.LoadString(IDS_ERROR_HEIGHT_MUST_BE_POSIT); m_app->PutMessage(IApplicationInterface::MT_ERROR, m_message); return; } sgCCone* cone = NULL; cone = sgCreateCone(m_cone_geo.Radius1,m_cone_geo.Radius2, fabs(m_height), m_cone_geo.MeridiansCount); if (!cone) return; cone->InitTempMatrix()->Multiply(*m_matr); cone->ApplyTempMatrix(); cone->DestroyTempMatrix(); sgGetScene()->StartUndoGroup(); sgGetScene()->DetachObject(m_editable_cone); sgGetScene()->AttachObject(cone); sgGetScene()->EndUndoGroup(); m_app->CopyAttributes(*cone,*m_editable_cone); m_app->GetViewPort()->InvalidateViewPort(); } break; default: break; } m_app->StopCommander(); }