2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2012 Blender Foundation. */
|
2012-06-19 17:29:58 +00:00
|
|
|
|
2018-08-08 11:49:51 +10:00
|
|
|
#pragma once
|
2012-06-19 17:29:58 +00:00
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2021-08-10 15:24:28 +02:00
|
|
|
#include "COM_ConstantOperation.h"
|
2012-06-19 17:29:58 +00:00
|
|
|
|
|
|
|
|
#include "DNA_movieclip_types.h"
|
2012-07-27 11:07:09 +00:00
|
|
|
#include "DNA_tracking_types.h"
|
2012-06-19 17:29:58 +00:00
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
2013-07-14 22:08:56 +00:00
|
|
|
#include "BLI_string.h"
|
2012-06-19 17:29:58 +00:00
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2012-06-19 17:29:58 +00:00
|
|
|
/**
|
2012-10-04 13:26:15 +00:00
|
|
|
* Class with implementation of green screen gradient rasterization
|
|
|
|
|
*/
|
2021-08-10 15:24:28 +02:00
|
|
|
class TrackPositionOperation : public ConstantOperation {
|
2012-06-19 17:29:58 +00:00
|
|
|
protected:
|
2021-10-13 23:01:15 +02:00
|
|
|
MovieClip *movie_clip_;
|
2021-10-13 23:01:04 +02:00
|
|
|
int framenumber_;
|
2021-10-13 23:01:15 +02:00
|
|
|
char tracking_object_name_[64];
|
|
|
|
|
char track_name_[64];
|
2021-10-13 23:01:04 +02:00
|
|
|
int axis_;
|
|
|
|
|
int position_;
|
2021-10-13 23:01:15 +02:00
|
|
|
int relative_frame_;
|
2021-10-13 23:01:04 +02:00
|
|
|
bool speed_output_;
|
|
|
|
|
|
|
|
|
|
int width_, height_;
|
2021-10-13 23:01:15 +02:00
|
|
|
float marker_pos_[2];
|
|
|
|
|
float relative_pos_[2];
|
2021-08-10 15:24:28 +02:00
|
|
|
float track_position_;
|
|
|
|
|
bool is_track_position_calculated_;
|
2012-06-19 17:29:58 +00:00
|
|
|
|
|
|
|
|
/**
|
2012-10-04 13:26:15 +00:00
|
|
|
* Determine the output resolution. The resolution is retrieved from the Renderer
|
|
|
|
|
*/
|
2021-09-28 19:32:49 +02:00
|
|
|
void determine_canvas(const rcti &preferred_area, rcti &r_area) override;
|
2012-06-19 17:29:58 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TrackPositionOperation();
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_movie_clip(MovieClip *clip)
|
2012-07-27 11:07:09 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
movie_clip_ = clip;
|
2013-07-14 22:08:56 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_tracking_object(char *object)
|
2013-07-14 22:08:56 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
BLI_strncpy(tracking_object_name_, object, sizeof(tracking_object_name_));
|
2013-07-14 22:08:56 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_track_name(char *track)
|
2013-07-14 22:08:56 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
BLI_strncpy(track_name_, track, sizeof(track_name_));
|
2012-07-27 11:07:09 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_framenumber(int framenumber)
|
2012-07-27 11:07:09 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
framenumber_ = framenumber;
|
2012-07-27 11:07:09 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_axis(int value)
|
2012-07-27 11:07:09 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
axis_ = value;
|
2012-07-27 11:07:12 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_position(int value)
|
2012-07-27 11:07:12 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
position_ = value;
|
2012-07-27 11:07:12 +00:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_relative_frame(int value)
|
2012-07-27 11:07:12 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
relative_frame_ = value;
|
2016-03-05 09:13:16 +11:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
void set_speed_output(bool speed_output)
|
2016-03-05 09:13:16 +11:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
speed_output_ = speed_output;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-07-27 11:07:09 +00:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void init_execution() override;
|
2012-06-19 17:29:58 +00:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override;
|
2021-08-10 15:24:28 +02:00
|
|
|
|
|
|
|
|
const float *get_constant_elem() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void calc_track_position();
|
2012-06-19 17:29:58 +00:00
|
|
|
};
|
2021-03-23 17:12:27 +01:00
|
|
|
|
|
|
|
|
} // namespace blender::compositor
|