/* グレネードの情報をロードする関数 */ int Weapon_Gun::GunLoad_Grenade( const int Wpno){ /* 変数の初期化 */ int ech = 0; char loadname[256] = ""; // 存在がエラーなので強制終了 return -1; //一時的な変数(モデル格納等など) int hsid = 0;//銃モデルのID int g_spid = 0;//銃スプライトのスプライトID int Garbage = 0;//いらない変数を格納します //変数をメンバー変数に格納します Set_Model( hsid);//武器のモデルを格納 Set_Sprite( g_spid);//武器スプライトを格納 OtherModel = 0;//武器の使用済み弾薬モデルを格納 return 0; }
//--------------------------------------------------------- void CVariogram_Dialog::Set_Variogram(void) { double lagDist = m_Settings("LAGDIST")->asDouble(); double maxDist = m_Settings("MAXDIST")->asDouble(); if( lagDist > 0.0 ) { double Diagonal = SG_Get_Length(m_pPoints->Get_Extent().Get_XRange(), m_pPoints->Get_Extent().Get_YRange()); // bounding box's diagonal if( maxDist <= 0.0 || maxDist > Diagonal ) { m_Settings("MAXDIST")->Set_Value(maxDist = Diagonal); } CSG_Variogram::Calculate(m_pPoints, m_Attribute, m_bLog, m_pVariogram, 1 + (int)(0.5 + maxDist / lagDist), maxDist, m_Settings("SKIP")->asInt() ); m_pDistance->Set_Range(0.0, m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_DISTANCE)); m_pDistance->Set_Value(m_pVariogram->Get_Maximum(CSG_Variogram::FIELD_DISTANCE)); m_pDiagram->Set_Variogram(); Set_Model(); } }
//--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Set_Residuals(void) { CSG_Shapes *pResiduals = Parameters("RESIDUALS")->asShapes(); if( !pResiduals ) { return( false ); } //----------------------------------------------------- pResiduals->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_Points.Get_Name(), _TL("Residuals"))); pResiduals->Add_Field(m_Points.Get_Field_Name(0), SG_DATATYPE_Double); pResiduals->Add_Field("TREND" , SG_DATATYPE_Double); pResiduals->Add_Field("RESIDUAL", SG_DATATYPE_Double); //------------------------------------------------- for(int iShape=0; iShape<m_Points.Get_Count() && Set_Progress(iShape, m_Points.Get_Count()); iShape++) { CSG_Shape *pShape = m_Points.Get_Shape(iShape); double zShape = pShape->asDouble(0); for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++) { for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++) { double zRegression; TSG_Point Point = pShape->Get_Point(iPoint, iPart); if( Set_Model(Point.x, Point.y, zRegression) ) { CSG_Shape *pResidual = pResiduals->Add_Shape(); pResidual->Add_Point(Point); pResidual->Set_Value(0, zShape); pResidual->Set_Value(1, zRegression); pResidual->Set_Value(2, zShape - zRegression); } } } } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- bool CGWR_Grid_Downscaling::Set_Model(void) { CSG_Grid *pRegression = Parameters("REGRESSION" )->asGrid(); CSG_Grid *pReg_ResCorr = Parameters("REG_RESCORR")->asGrid(); pRegression->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pDependent->Get_Name(), _TL("GWR"))); if( pReg_ResCorr ) { pReg_ResCorr->Set_Name(CSG_String::Format(SG_T("%s [%s, %s]"), m_pDependent->Get_Name(), _TL("GWR"), _TL("Residual Correction"))); } for(int y=0; y<Get_NY() && Set_Progress(y); y++) { double p_y = Get_YMin() + y * Get_Cellsize(); #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { double Value, Residual, p_x = Get_XMin() + x * Get_Cellsize(); if( Set_Model(p_x, p_y, Value, Residual) ) { pRegression->Set_Value(x, y, Value); if( pReg_ResCorr ) { pReg_ResCorr->Set_Value(x, y, Value + Residual); } } else { pRegression->Set_NoData(x, y); if( pReg_ResCorr ) { pReg_ResCorr->Set_NoData(x, y); } } } } return( true ); }
//--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Set_Model(void) { CSG_Grid *pRegression = Parameters("REGRESSION")->asGrid(); CSG_Grid *pQuality = Parameters("QUALITY" )->asGrid(); pRegression->Set_Name(CSG_String::Format(SG_T("%s [%s]" ), m_Points.Get_Name(), _TL("GWR"))); pQuality ->Set_Name(CSG_String::Format(SG_T("%s [%s, %s]"), m_Points.Get_Name(), _TL("GWR"), _TL("Quality"))); if( m_pQuality == Parameters("QUALITY")->asGrid() ) { pQuality = NULL; } //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { double p_y = Get_YMin() + y * Get_Cellsize(); #pragma omp parallel for for(int x=0; x<Get_NX(); x++) { double Value, p_x = Get_XMin() + x * Get_Cellsize(); if( Set_Model(p_x, p_y, Value) ) { GRID_SET_VALUE(pRegression, x, y, Value); GRID_SET_VALUE(pQuality , x, y, m_pQuality->Get_Value(p_x, p_y)); } else { GRID_SET_NODATA(pRegression, x, y); GRID_SET_NODATA(pQuality , x, y); } } } //----------------------------------------------------- Set_Residuals(); return( true ); }
/* アサルトライフルの情報をロードする関数 */ int Weapon_Gun::GunLoad_Assault( const int Wpno){ //変数の初期化 int ech = 0; char loadname[256] = ""; //一時的な変数(モデル格納等など) int hsid;//銃モデルのID int g_spid;//銃スプライトのスプライトID int bone[4];//銃のボーン int sound[6];//効果音データ int Garbage = 0;//いらない変数を格納します if( Wpno == 0){//M4 //モデルデータのロード wsprintf( loadname, "%s\\data\\3d\\weapon\\assault\\m4\\m4a5.sig", System::path); ech = E3DSigLoad( loadname, 0, 0.042f, &hsid); _ASSERT( ech != 1 );//エラーチェック //武器スプライトのロード wsprintf( loadname, "%s\\data\\3d\\weapon\\assault\\m4\\pict.png", System::path); ech = E3DCreateSprite( loadname, 0, 0, &g_spid); _ASSERT( ech != 1 );//エラーチェック //武器のモーションを読み込み wsprintf( loadname, "%s\\data\\3d\\weapon\\handgun\\m1911\\wait.qua", System::path); //ech = E3DAddMotion( hsid, loadname, 1, &Garbage, &Garbage); _ASSERT( ech != 1 );//エラーチェック /* ////////////////////////////// */ // ボーンデータのロードを行います /* ////////////////////////////// */ // ボーンネームからボーンIDの取得「銃根」 ech = E3DGetBoneNoByName( hsid, "銃根", &bone[0]); _ASSERT( ech != 1 );//エラーチェック //ボーンネームからボーンIDの取得「銃先」 ech = E3DGetBoneNoByName( hsid, "銃先", &bone[1]); _ASSERT( ech != 1 );//エラーチェック } if( Wpno == 1){//AK-74u //モデルデータのロード wsprintf( loadname, "%s\\data\\3d\\weapon\\assault\\ak-74u\\ak-74u.sig", System::path); ech = E3DSigLoad( loadname, 0, 0.096f, &hsid); _ASSERT( ech != 1 );//エラーチェック //武器スプライトのロード wsprintf( loadname, "%s\\data\\3d\\weapon\\assault\\ak-74u\\pict.png", System::path); ech = E3DCreateSprite( loadname, 0, 0, &g_spid); _ASSERT( ech != 1 );//エラーチェック //武器のモーションを読み込み /*wsprintf( loadname, "%s\\data\\3d\\weapon\\handgun\\m1911\\wait.qua", System::path); ech = E3DAddMotion( hsid, loadname, 1, &Garbage, &Garbage); _ASSERT( ech != 1 );//エラーチェック*/ /* ////////////////////////////// */ // ボーンデータのロードを行います /* ////////////////////////////// */ // ボーンネームからボーンIDの取得「銃根」 ech = E3DGetBoneNoByName( hsid, "銃根", &bone[0]); _ASSERT( ech != 1 );//エラーチェック //ボーンネームからボーンIDの取得「銃先」 ech = E3DGetBoneNoByName( hsid, "銃先", &bone[1]); _ASSERT( ech != 1 );//エラーチェック } if( Wpno == 6){//HK 416 //モデルデータのロード wsprintf( loadname, "%s\\data\\3d\\weapon\\assault\\hk_416\\hk_416.sig", System::path); ech = E3DSigLoad( loadname, 0, 0.042f, &hsid); _ASSERT( ech != 1 );//エラーチェック //武器スプライトのロード wsprintf( loadname, "%s\\data\\3d\\weapon\\assault\\hk_416\\pict.png", System::path); ech = E3DCreateSprite( loadname, 0, 0, &g_spid); _ASSERT( ech != 1 );//エラーチェック //武器のモーションを読み込み wsprintf( loadname, "%s\\data\\3d\\weapon\\handgun\\m1911\\wait.qua", System::path); //ech = E3DAddMotion( hsid, loadname, 1, &Garbage, &Garbage); _ASSERT( ech != 1 );//エラーチェック /* ////////////////////////////// */ // ボーンデータのロードを行います /* ////////////////////////////// */ // ボーンネームからボーンIDの取得「銃根」 E3DGetBoneNoByName( hsid, "銃根", &bone[0]); _ASSERT( ech != 1 );//エラーチェック //ボーンネームからボーンIDの取得「銃先」 E3DGetBoneNoByName( hsid, "銃先", &bone[1]); _ASSERT( ech != 1 );//エラーチェック } /*サウンドをロードします*/ //発射音 wsprintf( loadname, "%s\\data\\sound\\se\\shot\\rifle_fire.wav", System::path); ech = E3DLoadSound( loadname, 1, 1, 30, &sound[0]); _ASSERT( ech != 1 );//エラーチェック //空撃ち wsprintf( loadname, "%s\\data\\sound\\se\\shot\\sky_fire.wav", System::path); ech = E3DLoadSound( loadname, 1, 0, 30, &sound[1]); _ASSERT( ech != 1 );//エラーチェック /*音が届く範囲を指定*/ ech = E3DSet3DSoundEmiDist( sound[0], 25000.0f); _ASSERT( ech != 1 );//エラーチェック ech = E3DSet3DSoundEmiDist( sound[1], 4000.0f); _ASSERT( ech != 1 );//エラーチェック //変数をメンバー変数に格納します Set_Model( hsid);//武器のモデルを格納 Set_Sprite( g_spid);//武器スプライトを格納 OtherModel = 0;//武器の使用済み弾薬モデルを格納 Set_Bones( bone[0], 0);//銃口手前のボーンを格納 Set_Bones( bone[1], 0);//銃口手先のボーンを格納 Set_Sounds( sound[0], 0); Set_Sounds( sound[1], 1); return 0; }
//--------------------------------------------------------- bool CGW_Multi_Regression_Grid::On_Execute(void) { int i; //----------------------------------------------------- CSG_Parameter_Grid_List *pPredictors = Parameters("PREDICTORS")->asGridList(); if( !Initialize(Parameters("POINTS")->asShapes(), Parameters("DEPENDENT")->asInt(), pPredictors) ) { Finalize(); return( false ); } //----------------------------------------------------- CSG_Grid Quality; m_dimModel = *Get_System(); if( Parameters("RESOLUTION")->asInt() == 1 && Parameters("RESOLUTION_VAL")->asDouble() > Get_Cellsize() ) { CSG_Rect r(Get_System()->Get_Extent()); r.Inflate(0.5 * Parameters("RESOLUTION_VAL")->asDouble(), false); m_dimModel.Assign(Parameters("RESOLUTION_VAL")->asDouble(), r); Quality.Create(m_dimModel); m_pQuality = &Quality; } else { m_pQuality = Parameters("QUALITY")->asGrid(); } //----------------------------------------------------- Process_Set_Text(_TL("upsetting model domain")); m_pPredictors = (CSG_Grid **)SG_Calloc(m_nPredictors , sizeof(CSG_Grid *)); m_pModel = (CSG_Grid **)SG_Calloc(m_nPredictors + 1, sizeof(CSG_Grid *)); for(i=0; i<m_nPredictors; i++) { if( m_dimModel.Get_Cellsize() > Get_Cellsize() ) // scaling { m_pPredictors[i] = SG_Create_Grid(m_dimModel); m_pPredictors[i] ->Assign(pPredictors->asGrid(i), GRID_INTERPOLATION_NearestNeighbour); // GRID_INTERPOLATION_Mean_Cells } else { m_pPredictors[i] = pPredictors->asGrid(i); } m_pModel [i] = SG_Create_Grid(m_dimModel); m_pModel [i] ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPredictors->asGrid(i)->Get_Name(), _TL("Factor"))); } m_pModel[m_nPredictors] = SG_Create_Grid(m_dimModel); m_pModel[m_nPredictors] ->Set_Name(_TL("Intercept")); //----------------------------------------------------- Process_Set_Text(_TL("model creation")); bool bResult = Get_Model(); //----------------------------------------------------- if( m_dimModel.Get_Cellsize() > Get_Cellsize() ) // scaling { for(i=0; i<m_nPredictors; i++) { delete(m_pPredictors[i]); m_pPredictors[i] = pPredictors->asGrid(i); } } //----------------------------------------------------- if( bResult ) { Process_Set_Text(_TL("model application")); bResult = Set_Model(); } //----------------------------------------------------- if( Parameters("MODEL_OUT")->asBool() ) { CSG_Parameter_Grid_List *pModel = Parameters("MODEL")->asGridList(); pModel->Del_Items(); pModel->Add_Item(m_pModel[m_nPredictors]); for(i=0; i<m_nPredictors; i++) { pModel->Add_Item(m_pModel[i]); } } else { for(i=0; i<=m_nPredictors; i++) { delete(m_pModel[i]); } } SG_FREE_SAFE(m_pModel); SG_FREE_SAFE(m_pPredictors); Finalize(); return( bResult ); }
//--------------------------------------------------------- bool CGWR_Grid_Downscaling::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pPredictors = Parameters("PREDICTORS")->asGridList(); if( (m_nPredictors = pPredictors->Get_Count()) <= 0 ) { return( false ); } m_pDependent = Parameters("DEPENDENT")->asGrid(); if( !m_pDependent->Get_Extent().Intersects(Get_System()->Get_Extent()) ) { return( false ); } //----------------------------------------------------- int i; Process_Set_Text(_TL("upscaling of predictors")); m_pPredictors = (CSG_Grid **)SG_Calloc(m_nPredictors , sizeof(CSG_Grid *)); m_pModel = (CSG_Grid **)SG_Calloc(m_nPredictors + 1, sizeof(CSG_Grid *)); for(i=0; i<m_nPredictors; i++) { m_pPredictors[i] = SG_Create_Grid(m_pDependent->Get_System()); m_pPredictors[i] ->Assign(pPredictors->asGrid(i), GRID_INTERPOLATION_NearestNeighbour); // GRID_INTERPOLATION_Mean_Cells m_pModel [i] = SG_Create_Grid(m_pDependent->Get_System()); m_pModel [i] ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPredictors->asGrid(i)->Get_Name(), _TL("Factor"))); } m_pModel[m_nPredictors] = SG_Create_Grid(m_pDependent->Get_System()); m_pModel[m_nPredictors] ->Set_Name(_TL("Intercept")); //----------------------------------------------------- Process_Set_Text(_TL("model creation")); bool bResult = Get_Model(); //----------------------------------------------------- for(i=0; i<m_nPredictors; i++) { delete(m_pPredictors[i]); m_pPredictors[i] = pPredictors->asGrid(i); } //----------------------------------------------------- if( bResult ) { Process_Set_Text(_TL("downscaling")); bResult = Set_Model(); } //----------------------------------------------------- if( Parameters("MODEL_OUT")->asBool() ) { CSG_Parameter_Grid_List *pModel = Parameters("MODEL")->asGridList(); pModel->Del_Items(); pModel->Add_Item(m_pModel[m_nPredictors]); for(i=0; i<m_nPredictors; i++) { pModel->Add_Item(m_pModel[i]); } } else { for(i=0; i<=m_nPredictors; i++) { delete(m_pModel[i]); } } SG_FREE_SAFE(m_pModel); SG_FREE_SAFE(m_pPredictors); return( bResult ); }
void CVariogram_Dialog::On_Update_Choices(wxCommandEvent &WXUNUSED(event)) { m_pFormula->SetValue(m_pFormulas->GetStringSelection().c_str()); Set_Model(); }
//--------------------------------------------------------- void CVariogram_Dialog::On_Update_Control(wxCommandEvent &WXUNUSED(event)) { Set_Model(); }