Skip to content

Commit

Permalink
feat: use cv::warpPerspective in use_skill
Browse files Browse the repository at this point in the history
  • Loading branch information
horror-proton committed Aug 19, 2024
1 parent 17ef91e commit cf69527
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 119 deletions.
18 changes: 6 additions & 12 deletions 3rdparty/include/Arknights-Tile-Pos/TileCalc2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ inline matrix4x4 camera_matrix_from_trans(
const vec3d& euler,
double ratio,
double fov_2_y = 20 * degree,
double far = 1000,
double near = 0.3)
double far_c = 1000,
double near_c = 0.3)
{
const double cos_y = std::cos(euler[0]);
const double sin_y = std::sin(euler[0]);
Expand All @@ -66,20 +66,19 @@ inline matrix4x4 camera_matrix_from_trans(
0, -sin_x, -cos_x, 0, //
0, 0, 0, 1,
};
const matrix4x4 proj = {
const matrix4x4 proj = matrix4x4 {
// clang-format off
ratio / tan_f, 0, 0, 0,
0, 1 / tan_f, 0, 0,
0, 0, -(far + near) / (far - near), -(far * near * 2) / (far - near),
0, 0, -(far_c + near_c) / (far_c - near_c), -(far_c * near_c * 2) / (far_c - near_c),
0, 0, -1, 0,
// clang-format on
};

return proj * matrixX * matrixY * translate;
}

inline cv::Point
world_to_screen(const Level& level, const vec3d& world_pos, bool side, const vec3d& offset = {})
inline cv::Point world_to_screen(const Level& level, const vec3d& world_pos, bool side, const vec3d& offset = {})
{
static constexpr double width = 1280;
static constexpr double height = 720;
Expand Down Expand Up @@ -107,12 +106,7 @@ inline vec3d get_tile_world_pos(const Level& level, int tile_y, int tile_x)
};
}

inline auto get_tile_screen_pos(
const Level& level,
int tile_y,
int tile_x,
bool side = false,
const vec3d& offset = {})
inline auto get_tile_screen_pos(const Level& level, int tile_y, int tile_x, bool side = false, const vec3d& offset = {})
{
return world_to_screen(level, get_tile_world_pos(level, tile_y, tile_x), side, offset);
}
Expand Down
29 changes: 6 additions & 23 deletions resource/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4627,29 +4627,12 @@
"BattleSkillReady": {
"rectMove": [-28, -140, 64, 64]
},
"BattleSkillReadyOnClick": {
"roi": [748, 414, 210, 118],
"templThreshold": 0.7,
"action": "ClickSelf",
"rectMove": [0, -110, 90, 90],
"postDelay": 300,
"next": ["#self", "Stop"]
},
"BattleSkillReadyOnClick-SquareMap": {
"baseTask": "BattleSkillReadyOnClick",
"template": "BattleSkillReadyOnClick-SquareMap.png"
},
"BattleSkillStopOnClick": {
"baseTask": "BattleSkillReadyOnClick",
"template": "BattleSkillStopOnClick.png"
},
"BattleSkillStopOnClick-MiddleMap": {
"baseTask": "BattleSkillReadyOnClick",
"template": "BattleSkillStopOnClick-MiddleMap.png"
},
"BattleSkillStopOnClick-SquareMap": {
"baseTask": "BattleSkillReadyOnClick",
"template": "BattleSkillStopOnClick-SquareMap.png"
"BattleSkillReadyOnClick-TopView": {
"template": [
"BattleSkillReadyOnClick-TopView.png",
"BattleSkillStopOnClick-TopView.png"
],
"templThreshold": [ 0.8, 0.8 ]
},
"BattleUseOper": {
"algorithm": "JustReturn",
Expand Down
Binary file removed resource/template/BattleSkillReady.png
Binary file not shown.
Binary file removed resource/template/BattleSkillReadyOnClick-SquareMap.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resource/template/BattleSkillReadyOnClick.png
Binary file not shown.
Binary file removed resource/template/BattleSkillStopOnClick-MiddleMap.png
Binary file not shown.
Binary file removed resource/template/BattleSkillStopOnClick-SquareMap.png
Binary file not shown.
Binary file added resource/template/BattleSkillStopOnClick-TopView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resource/template/BattleSkillStopOnClick.png
Binary file not shown.
Loading

0 comments on commit cf69527

Please sign in to comment.