save code
This commit is contained in:
@@ -45,6 +45,8 @@ layout(push_constant) uniform PushConstants {
|
|||||||
float radius;
|
float radius;
|
||||||
float ux;
|
float ux;
|
||||||
float uy;
|
float uy;
|
||||||
|
float offset_x;
|
||||||
|
float offset_y;
|
||||||
} pushConstants;
|
} pushConstants;
|
||||||
|
|
||||||
|
|
||||||
@@ -55,6 +57,8 @@ void main() {
|
|||||||
// 获取顶点位置
|
// 获取顶点位置
|
||||||
vec2 position = positions[gl_VertexIndex];
|
vec2 position = positions[gl_VertexIndex];
|
||||||
position = position * pushConstants.zoom;
|
position = position * pushConstants.zoom;
|
||||||
|
position.x = position.x + (pushConstants.offset_x/480);
|
||||||
|
position.y = position.y + (pushConstants.offset_y/480);
|
||||||
|
|
||||||
// 设置输出位置(Vulkan使用不同的坐标系)
|
// 设置输出位置(Vulkan使用不同的坐标系)
|
||||||
gl_Position = vec4(position, 0.0, 1.0);
|
gl_Position = vec4(position, 0.0, 1.0);
|
||||||
|
|||||||
Binary file not shown.
@@ -24,6 +24,8 @@ layout(push_constant) uniform PushConstants {
|
|||||||
float radius;
|
float radius;
|
||||||
float ux;
|
float ux;
|
||||||
float uy;
|
float uy;
|
||||||
|
float offset_x;
|
||||||
|
float offset_y;
|
||||||
} pushConstants;
|
} pushConstants;
|
||||||
|
|
||||||
out gl_PerVertex
|
out gl_PerVertex
|
||||||
@@ -37,6 +39,8 @@ void main()
|
|||||||
|
|
||||||
vec2 position = vec2(inPos.xy*2 -1);
|
vec2 position = vec2(inPos.xy*2 -1);
|
||||||
position = position * pushConstants.zoom;
|
position = position * pushConstants.zoom;
|
||||||
|
position.x = position.x + (pushConstants.offset_x/480);
|
||||||
|
position.y = position.y + (pushConstants.offset_y/480);
|
||||||
gl_Position = vec4(position, 0.5, 1.0);
|
gl_Position = vec4(position, 0.5, 1.0);
|
||||||
|
|
||||||
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
vec4 pos = ubo.model * vec4(inPos, 1.0);
|
||||||
|
|||||||
Binary file not shown.
@@ -8,7 +8,8 @@ public class InitArg {
|
|||||||
public float g;
|
public float g;
|
||||||
public float b;
|
public float b;
|
||||||
public float radius;
|
public float radius;
|
||||||
|
public float offset_x;
|
||||||
|
public float offset_y;
|
||||||
public String toJson() {
|
public String toJson() {
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
@@ -18,6 +19,8 @@ public class InitArg {
|
|||||||
jsonObject.put("g", g);
|
jsonObject.put("g", g);
|
||||||
jsonObject.put("b", b);
|
jsonObject.put("b", b);
|
||||||
jsonObject.put("radius", radius);
|
jsonObject.put("radius", radius);
|
||||||
|
jsonObject.put("offset_x", offset_x);
|
||||||
|
jsonObject.put("offset_y", offset_y);
|
||||||
return jsonObject.toString();
|
return jsonObject.toString();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class MakeupActivity : FaceActivity()
|
|||||||
lateinit var motionMgr: MotionManager
|
lateinit var motionMgr: MotionManager
|
||||||
private var updateJob: Job? = null
|
private var updateJob: Job? = null
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
motionMgr = MotionManager(this, 10, 1.5f, 0f,0f,1f,240f)
|
motionMgr = MotionManager(this, 10, 1.5f, 0f,0f,1f,240f, 200f, -200f)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
// 启动一个生命周期感知的协程, 每10ms 调用一次,可以通过update 来处理业务的逻辑
|
// 启动一个生命周期感知的协程, 每10ms 调用一次,可以通过update 来处理业务的逻辑
|
||||||
updateJob = lifecycleScope.launch {
|
updateJob = lifecycleScope.launch {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import java.io.InputStreamReader
|
|||||||
class MotionManager {
|
class MotionManager {
|
||||||
var faceActivity:FaceActivity
|
var faceActivity:FaceActivity
|
||||||
|
|
||||||
constructor(activity: FaceActivity, fps: Int, z: Float, r: Float, g: Float, b: Float, radius: Float) {
|
constructor(activity: FaceActivity, fps: Int, z: Float, r: Float, g: Float, b: Float, radius: Float, offset_x:Float, offset_y: Float) {
|
||||||
faceActivity = activity
|
faceActivity = activity
|
||||||
val initArg = InitArg().apply {
|
val initArg = InitArg().apply {
|
||||||
action_fps = fps
|
action_fps = fps
|
||||||
@@ -25,6 +25,8 @@ class MotionManager {
|
|||||||
this.g = g
|
this.g = g
|
||||||
this.b = b
|
this.b = b
|
||||||
this.radius = radius
|
this.radius = radius
|
||||||
|
this.offset_x = offset_x;
|
||||||
|
this.offset_y = offset_y;
|
||||||
}
|
}
|
||||||
activity.SetInitArg(initArg.toJson())
|
activity.SetInitArg(initArg.toJson())
|
||||||
existMotions = readMotionsFromAssets(activity, "pic/motion_data_ex.json")
|
existMotions = readMotionsFromAssets(activity, "pic/motion_data_ex.json")
|
||||||
|
|||||||
@@ -1377,6 +1377,8 @@ void FaceApp::SetInitArg(const char* arg)
|
|||||||
pushConstants.g = _initArg.g;
|
pushConstants.g = _initArg.g;
|
||||||
pushConstants.b = _initArg.b;
|
pushConstants.b = _initArg.b;
|
||||||
pushConstants.radius = _initArg.radius;
|
pushConstants.radius = _initArg.radius;
|
||||||
|
pushConstants.offset_x = _initArg.offset_x;
|
||||||
|
pushConstants.offset_y = _initArg.offset_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceApp::drawFrame(long long frameTime)
|
void FaceApp::drawFrame(long long frameTime)
|
||||||
|
|||||||
+5
-1
@@ -42,8 +42,10 @@ struct InitArg
|
|||||||
float g;
|
float g;
|
||||||
float b;
|
float b;
|
||||||
float radius;
|
float radius;
|
||||||
|
float offset_x;
|
||||||
|
float offset_y;
|
||||||
//Motion motion;
|
//Motion motion;
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(InitArg, action_fps, zoom, r, g, b, radius);
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(InitArg, action_fps, zoom, r, g, b, radius, offset_x, offset_y);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -55,6 +57,8 @@ struct PushConstants {
|
|||||||
float radius = 240;
|
float radius = 240;
|
||||||
float ux = 0;
|
float ux = 0;
|
||||||
float uy = 0;
|
float uy = 0;
|
||||||
|
float offset_x = 0;
|
||||||
|
float offset_y = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Callback = std::function<void()>;
|
using Callback = std::function<void()>;
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ int main() {
|
|||||||
init_arg.g = 0;
|
init_arg.g = 0;
|
||||||
init_arg.b = 0;
|
init_arg.b = 0;
|
||||||
init_arg.radius = 240;
|
init_arg.radius = 240;
|
||||||
|
init_arg.offset_x = 100;
|
||||||
|
init_arg.offset_y = -100;
|
||||||
|
|
||||||
string json_str = json(init_arg).dump();
|
string json_str = json(init_arg).dump();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user