Skip to content

Commit

Permalink
workable transition feature
Browse files Browse the repository at this point in the history
  • Loading branch information
CatxFish committed Aug 18, 2018
1 parent 1210d34 commit 8c222d0
Show file tree
Hide file tree
Showing 12 changed files with 487 additions and 390 deletions.
53 changes: 4 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,52 +1,7 @@
cmake_minimum_required(VERSION 3.5)
project(motion-filter)
project(motion-effect)

include(external/FindLibObs.cmake)
find_package(LibObs REQUIRED)
set(motion-filter_SOURCES
src/helper.c
src/motion-filter.c
)

set(motion-filter_HEADERS
src/helper.h
)

include_directories(
"${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api")

add_library(motion-filter MODULE
${motion-filter_SOURCES}
${motion-filter_HEADERS})

target_link_libraries(motion-filter
libobs)

if(UNIX AND NOT APPLE)

if(ARCH EQUAL 64)
set(ARCH_NAME "x86_64")
else()
set(ARCH_NAME "i686")
endif()

set_target_properties(motion-filter PROPERTIES PREFIX "")

install(TARGETS motion-filter
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/obs-plugins)
install(DIRECTORY locale/
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/obs/obs-plugins/motion-filter/locale")
endif()


if(WIN32)
set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library")
if(OBS_FRONTEND_LIB EQUAL "OBS_FRONTEND_LIB-NOTFOUND")
message(FATAL_ERROR "OBS_FRONTEND_LIB NOTFOUND")
endif()

target_link_libraries(motion-filter
"${OBS_FRONTEND_LIB}")

endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
add_subdirectory(src/motion-filter)
add_subdirectory(src/motion-transition)

1 change: 1 addition & 0 deletions locale/en-US.ini → data/motion-filter/en-US.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Motion="Motion"
Behavior="Trigger Behavior"
Behavior.OneWay="Hotkey (One way)"
Behavior.RoundTrip="Hotkey (Round trip)"
Expand Down
1 change: 1 addition & 0 deletions locale/zh-TW.ini → data/motion-filter/zh-TW.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Motion="動畫"
Behavior="觸發方式"
Behavior.OneWay="熱鍵 (單向動畫)"
Behavior.RoundTrip="熱鍵 (往返動畫)"
Expand Down
3 changes: 3 additions & 0 deletions data/motion-transition/en-US.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Motion="Motion"
Acceleration.X="Acceleration (x-axis)"
Acceleration.Y="Acceleration (y-axis)"
3 changes: 3 additions & 0 deletions data/motion-transition/zh-TW.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Motion="動畫"
Acceleration.X="X軸加速度"
Acceleration.Y="Y軸加速度"
15 changes: 15 additions & 0 deletions src/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,19 @@ float bezier(float point[], float coefficient, int order)
t * bezier(&point[1], t, order - 1);
}

void vec_linear(struct vec2 a, struct vec2 b, struct vec2 *result ,float t)
{
float x[2] = { a.x, b.x };
float y[2] = { a.y, b.y };
result->x = bezier(x, t, 1);
result->y = bezier(y, t, 1);
}

void vec_bezier(struct vec2 a, struct vec2 b, struct vec2 c ,
struct vec2 *result, float t)
{
float x[3] = { a.x,b.x,c.x };
float y[3] = { a.y,b.y,c.y };
result->x = bezier(x, t, 2);
result->y = bezier(y, t, 2);
}
5 changes: 5 additions & 0 deletions src/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ void save_hotkey_config(obs_hotkey_id id, obs_data_t *settings,
const char *name);

float bezier(float point[], float percent, int order);

void vec_linear(struct vec2 a, struct vec2 b, struct vec2 *result, float t);

void vec_bezier(struct vec2 a, struct vec2 b, struct vec2 c,
struct vec2 *result, float t);
52 changes: 52 additions & 0 deletions src/motion-filter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.5)
project(motion-filter)

include(${CMAKE_SOURCE_DIR}/external/FindLibObs.cmake)
find_package(LibObs REQUIRED)
set(motion-filter_SOURCES
../helper.c
motion-filter.c
)

set(motion-filter_HEADERS
../helper.h
)

include_directories(
"${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api")

add_library(motion-filter MODULE
${motion-filter_SOURCES}
${motion-filter_HEADERS})

target_link_libraries(motion-filter
libobs)

if(UNIX AND NOT APPLE)

if(ARCH EQUAL 64)
set(ARCH_NAME "x86_64")
else()
set(ARCH_NAME "i686")
endif()

set_target_properties(motion-filter PROPERTIES PREFIX "")

install(TARGETS motion-filter
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/obs-plugins)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/data/motion-filter/
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/obs/obs-plugins/motion-filter/")
endif()


if(WIN32)
set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library")
if(OBS_FRONTEND_LIB EQUAL "OBS_FRONTEND_LIB-NOTFOUND")
message(FATAL_ERROR "OBS_FRONTEND_LIB NOTFOUND")
endif()

target_link_libraries(motion-filter
"${OBS_FRONTEND_LIB}")

endif()

8 changes: 3 additions & 5 deletions src/motion-filter.c → src/motion-filter/motion-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <obs-scene.h>
#include <obs-frontend-api.h>
#include <util/dstr.h>
#include "helper.h"
#include "../helper.h"

// Define property keys

Expand Down Expand Up @@ -831,7 +831,7 @@ static const char *motion_filter_get_name(void *unused)
}

OBS_DECLARE_MODULE()
OBS_MODULE_USE_DEFAULT_LOCALE("motion-filter", "en-US")
OBS_MODULE_USE_DEFAULT_LOCALE("motion-transitions", "en-US")

struct obs_source_info motion_filter = {
.id = "motion-filter",
Expand All @@ -848,10 +848,8 @@ struct obs_source_info motion_filter = {
.filter_remove = motion_filter_remove
};

extern struct obs_source_info motion_transition;

bool obs_module_load(void) {
obs_register_source(&motion_filter);
obs_register_source(&motion_transition);
return true;
}

Loading

0 comments on commit 8c222d0

Please sign in to comment.