Camera tracking integration

===========================

Fixes for codereview issues pointed by Brecht:

- Replace use_default_clip with use_active_clip setting for
  motion-tracking constraints.
- Removed unneeded Clip panel from toolshelf when no clip is opened.
- Put options in Display panel in one column.
  Don't want properties region be wider and it should also be
  a bit easier to find option you need. Maybe additional re-shuffle
  would be good here.
- Reversed order of items in Clip menu
- Re-ordered selection operators in clip editor Select menu to
  match 3d viewport order.
- Share common part of sensor/shift and so detection between
  object_camera_matrix and Follow Track constraint.
- Fixed typos in translate mode caused by copying files.
- Movie clip angle output is now in radians. Transform node now
  accepts rotation in radians too.
- Use scale-rotate-translate order for transformation node and
  stabilization data.
  Also makes sense when using transform node for non-tracking goals:
  image would stay centered when applying only rotation and scale.
  Think it's nicer.
- Fixed compilation error caused by recent node-update commit.
This commit is contained in:
Sergey Sharybin
2011-10-19 21:42:37 +00:00
parent 39ab569dd9
commit bb9b29bd79
17 changed files with 121 additions and 130 deletions

View File

@@ -107,6 +107,12 @@ class CLIP_OT_delete_proxy(Operator):
bl_label = "Delete Proxy"
bl_options = {'UNDO', 'REGISTER'}
@classmethod
def poll(cls, context):
sc = context.space_data
return sc.clip
def invoke(self, context, event):
wm = context.window_manager

View File

@@ -754,9 +754,9 @@ class ConstraintButtonsPanel():
col.prop(con, "rotation_range", text="Pivot When")
def FOLLOW_TRACK(self, context, layout, con):
layout.prop(con, "use_default_clip")
layout.prop(con, "use_active_clip")
if not con.use_default_clip:
if not con.use_active_clip:
layout.prop(con, "clip")
layout.prop(con, "track")
@@ -767,9 +767,9 @@ class ConstraintButtonsPanel():
layout.operator("clip.constraint_to_fcurve")
def CAMERA_SOLVER(self, context, layout, con):
layout.prop(con, "use_default_clip")
layout.prop(con, "use_active_clip")
if not con.use_default_clip:
if not con.use_active_clip:
layout.prop(con, "clip")
layout.operator("clip.constraint_to_fcurve")

View File

@@ -36,10 +36,13 @@ class CLIP_HT_header(Header):
if context.area.show_menus:
sub = row.row(align=True)
sub.menu("CLIP_MT_view")
sub.menu("CLIP_MT_clip")
if clip:
sub.menu("CLIP_MT_select")
sub.menu("CLIP_MT_clip")
if clip:
sub.menu("CLIP_MT_track")
sub.menu("CLIP_MT_reconstruction")
@@ -70,23 +73,6 @@ class CLIP_HT_header(Header):
layout.template_running_jobs()
class CLIP_PT_tools(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
bl_label = "Tools"
@classmethod
def poll(cls, context):
sc = context.space_data
clip = sc.clip
return not clip and sc.mode == 'TRACKING'
def draw(self, context):
layout = self.layout
layout.operator('clip.open')
class CLIP_PT_tools_marker(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'TOOLS'
@@ -397,27 +383,22 @@ class CLIP_PT_display(Panel):
layout = self.layout
sc = context.space_data
row = layout.row()
row.prop(sc, "show_marker_pattern", text="Pattern")
row.prop(sc, "show_marker_search", text="Search")
layout.prop(sc, "show_marker_pattern", text="Pattern")
layout.prop(sc, "show_marker_search", text="Search")
row = layout.row()
row.prop(sc, "show_track_path", text="Path")
sub = row.column()
sub.active = sc.show_track_path
sub.prop(sc, "path_length", text="Length")
layout.prop(sc, "show_track_path", text="Path")
row = layout.column()
row.active = sc.show_track_path
row.prop(sc, "path_length", text="Length")
row = layout.row()
row.prop(sc, "show_disabled", text="Disabled")
row.prop(sc, "show_bundles", text="Bundles")
layout.prop(sc, "show_disabled", text="Disabled")
layout.prop(sc, "show_bundles", text="Bundles")
row = layout.row()
row.prop(sc, "show_names", text="Names")
row.prop(sc, "show_tiny_markers", text="Tiny Markers")
layout.prop(sc, "show_names", text="Names")
layout.prop(sc, "show_tiny_markers", text="Tiny Markers")
row = layout.row()
row.prop(sc, "show_grease_pencil", text="Grease Pencil")
row.prop(sc, "use_mute_footage", text="Mute")
layout.prop(sc, "show_grease_pencil", text="Grease Pencil")
layout.prop(sc, "use_mute_footage", text="Mute")
if sc.mode == 'DISTORTION':
layout.prop(sc, "show_grid", text="Grid")
@@ -635,6 +616,12 @@ class CLIP_PT_tools_clip(Panel):
bl_region_type = 'TOOLS'
bl_label = "Clip"
@classmethod
def poll(cls, context):
sc = context.space_data
return sc.clip
def draw(self, context):
layout = self.layout
clip = context.space_data.clip
@@ -681,12 +668,11 @@ class CLIP_MT_clip(Menu):
sc = context.space_data
clip = sc.clip
layout.menu("CLIP_MT_proxy")
layout.operator("clip.open")
if clip:
layout.operator("clip.reload")
layout.operator("clip.open")
layout.menu("CLIP_MT_proxy")
class CLIP_MT_proxy(Menu):
@@ -803,12 +789,16 @@ class CLIP_MT_select(Menu):
sc = context.space_data
layout.menu("CLIP_MT_select_grouped")
layout.operator("clip.select_border")
layout.operator("clip.select_circle")
layout.separator()
layout.operator("clip.select_all", text="Select/Deselect all")
layout.operator("clip.select_all", text="Inverse").action = 'INVERT'
layout.menu("CLIP_MT_select_grouped")
class CLIP_MT_select_grouped(Menu):
bl_label = "Select Grouped"

View File

@@ -143,6 +143,8 @@ struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob,
int object_is_modified(struct Scene *scene, struct Object *ob);
void object_camera_mode(struct RenderData *rd, struct Object *camera);
void object_camera_intrinsics(struct Object *camera, struct Camera **cam_r, short *is_ortho, float *shiftx, float *shifty,
float *clipsta, float *clipend, float *lens, float *sensor_x);
void object_camera_matrix(
struct RenderData *rd, struct Object *camera, int winx, int winy, short field_second,
float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens, float *sensor_x, float *ycor,

View File

@@ -3942,7 +3942,7 @@ static void followtrack_new_data (void *cdata)
bFollowTrackConstraint *data= (bFollowTrackConstraint *)cdata;
data->clip= NULL;
data->flag|= FOLLOWTRACK_DEFAULTCLIP;
data->flag|= FOLLOWTRACK_ACTIVECLIP;
data->reference= FOLLOWTRACK_TRACK;
}
@@ -3960,7 +3960,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
MovieClip *clip= data->clip;
MovieTrackingTrack *track;
if(data->flag&FOLLOWTRACK_DEFAULTCLIP)
if(data->flag&FOLLOWTRACK_ACTIVECLIP)
clip= scene->clip;
if(!clip || !data->track[0])
@@ -3992,7 +3992,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
MovieTrackingMarker *marker;
float vec[3], disp[3], axis[3], mat[4][4];
float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
float sensor_x, lens, len, d, ortho_scale;
float sensor_x, lens, len, d, ortho_scale= 1.f;
where_is_object_mat(scene, camob, mat);
@@ -4010,39 +4010,23 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
len= len_v3(disp);
if(len>FLT_EPSILON) {
float pos[2], rmat[4][4];
int is_ortho= 0;
float pos[2], rmat[4][4], shiftx= 0.0f, shifty= 0.0f, clipsta= 0.0f, clipend= 0.0f;
short is_ortho= 0;
Camera *cam= NULL;
user.framenr= scene->r.cfra;
marker= BKE_tracking_get_marker(track, user.framenr);
add_v2_v2v2(pos, marker->pos, track->offset);
/* calculate lens and sensor size depends on object type */
if(camob->type==OB_CAMERA) {
Camera *camera= (Camera *)camob->data;
sensor_x= camera->sensor_x;
lens= camera->lens;
is_ortho= camera->type == CAM_ORTHO;
ortho_scale= camera->ortho_scale;
} else if (camob->type==OB_LAMP) {
Lamp *la= camob->data;
float fac= cosf((float)M_PI*la->spotsize/360.0f);
float phi= acos(fac);
lens= 16.0f*fac/sinf(phi);
sensor_x= 32.f;
ortho_scale= 0.f;
} else {
lens= 16.f;
sensor_x= 32.f;
ortho_scale= 0.f;
}
object_camera_intrinsics(camob, &cam, &is_ortho, &shiftx, &shifty, &clipsta, &clipend, &lens, &sensor_x);
if(is_ortho) {
vec[0]= ortho_scale * (pos[0]-0.5f);
vec[1]= ortho_scale * (pos[1]-0.5f);
if(cam)
ortho_scale= cam->ortho_scale;
vec[0]= ortho_scale * (pos[0]-0.5f+shiftx);
vec[1]= ortho_scale * (pos[1]-0.5f+shifty);
vec[2]= -len;
if(aspect>1.f) vec[1]/= aspect;
@@ -4059,8 +4043,8 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
else {
d= (len*sensor_x) / (2.f*lens);
vec[0]= d*(2.f*pos[0]-1.f);
vec[1]= d*(2.f*pos[1]-1.f);
vec[0]= d*(2.f*(pos[0]+shiftx)-1.f);
vec[1]= d*(2.f*(pos[1]+shifty)-1.f);
vec[2]= -len;
if(aspect>1.f) vec[1]/= aspect;
@@ -4103,7 +4087,7 @@ static void camerasolver_new_data (void *cdata)
bCameraSolverConstraint *data= (bCameraSolverConstraint *)cdata;
data->clip= NULL;
data->flag|= CAMERASOLVER_DEFAULTCLIP;
data->flag|= CAMERASOLVER_ACTIVECLIP;
}
static void camerasolver_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
@@ -4119,7 +4103,7 @@ static void camerasolver_evaluate (bConstraint *con, bConstraintOb *cob, ListBas
bCameraSolverConstraint *data= con->data;
MovieClip *clip= data->clip;
if(data->flag&CAMERASOLVER_DEFAULTCLIP)
if(data->flag&CAMERASOLVER_ACTIVECLIP)
clip= scene->clip;
if(clip) {

View File

@@ -649,7 +649,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if(cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) {
bFollowTrackConstraint *data= (bFollowTrackConstraint *)con->data;
if((data->clip || data->flag&FOLLOWTRACK_DEFAULTCLIP) && data->track[0]) {
if((data->clip || data->flag&FOLLOWTRACK_ACTIVECLIP) && data->track[0]) {
if(scene->camera) {
node2 = dag_get_node(dag, scene->camera);
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
@@ -2526,7 +2526,7 @@ static void dag_id_flush_update(Scene *sce, ID *id)
for(node= sce->nodetree->nodes.first; node; node= node->next) {
if(node->id==id) {
NodeTagChanged(sce->nodetree, node);
nodeUpdate(sce->nodetree, node);
}
}
}

View File

@@ -2979,27 +2979,19 @@ void object_camera_mode(RenderData *rd, Object *camera)
}
}
/* 'lens' may be set for envmap only */
void object_camera_matrix(
RenderData *rd, Object *camera, int winx, int winy, short field_second,
float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, float *sensor_x, float *ycor,
float *viewdx, float *viewdy
) {
Camera *cam=NULL;
float pixsize;
float shiftx=0.0, shifty=0.0, winside, viewfac;
short is_ortho= FALSE;
void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, float *shiftx, float *shifty,
float *clipsta, float *clipend, float *lens, float *sensor_x)
{
Camera *cam= NULL;
/* question mark */
(*ycor)= rd->yasp / rd->xasp;
if(rd->mode & R_FIELDS)
(*ycor) *= 2.0f;
(*shiftx)= 0.0f;
(*shifty)= 0.0f;
if(camera->type==OB_CAMERA) {
cam= camera->data;
if(cam->type == CAM_ORTHO) {
is_ortho= TRUE;
*is_ortho= TRUE;
}
/* solve this too... all time depending stuff is in convertblender.c?
@@ -3012,8 +3004,8 @@ void object_camera_matrix(
execute_ipo(&cam->id, cam->ipo);
}
#endif // XXX old animation system
shiftx=cam->shiftx;
shifty=cam->shifty;
(*shiftx)=cam->shiftx;
(*shifty)=cam->shifty;
(*lens)= cam->lens;
(*sensor_x)= cam->sensor_x;
(*clipsta)= cam->clipsta;
@@ -3040,6 +3032,27 @@ void object_camera_matrix(
}
}
(*cam_r)= cam;
}
/* 'lens' may be set for envmap only */
void object_camera_matrix(
RenderData *rd, Object *camera, int winx, int winy, short field_second,
float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, float *sensor_x, float *ycor,
float *viewdx, float *viewdy
) {
Camera *cam=NULL;
float pixsize;
float shiftx=0.0, shifty=0.0, winside, viewfac;
short is_ortho= FALSE;
/* question mark */
(*ycor)= rd->yasp / rd->xasp;
if(rd->mode & R_FIELDS)
(*ycor) *= 2.0f;
object_camera_intrinsics(camera, &cam, &is_ortho, &shiftx, &shifty, clipsta, clipend, lens, sensor_x);
/* ortho only with camera available */
if(cam && is_ortho) {
if(rd->xasp*winx >= rd->yasp*winy) {
@@ -3377,7 +3390,7 @@ MovieClip *object_get_movieclip(Scene *scene, Object *ob, int use_default)
if(scon) {
bCameraSolverConstraint *solver= scon->data;
if((solver->flag&CAMERASOLVER_DEFAULTCLIP)==0)
if((solver->flag&CAMERASOLVER_ACTIVECLIP)==0)
clip= solver->clip;
else
clip= scene->clip;

View File

@@ -1688,9 +1688,6 @@ static void calculate_stabdata(MovieTracking *tracking, int framenr, float width
loc[0]= (firstmedian[0]-median[0])*width*(*scale);
loc[1]= (firstmedian[1]-median[1])*height*(*scale);
loc[0]-= (firstmedian[0]*(*scale)-firstmedian[0])*width;
loc[1]-= (firstmedian[1]*(*scale)-firstmedian[1])*height;
mul_v2_fl(loc, stab->locinf);
if(stab->rot_track && stab->rotinf) {
@@ -1713,8 +1710,8 @@ static void calculate_stabdata(MovieTracking *tracking, int framenr, float width
*angle*= stab->rotinf;
/* convert to rotation around image center */
loc[0]-= (x0 + (x-x0)*cos(*angle)-(y-y0)*sin(*angle) - x);
loc[1]-= (y0 + (x-x0)*sin(*angle)+(y-y0)*cos(*angle) - y);
loc[0]-= (x0 + (x-x0)*cos(*angle)-(y-y0)*sin(*angle) - x)*(*scale);
loc[1]-= (y0 + (x-x0)*sin(*angle)+(y-y0)*cos(*angle) - y)*(*scale);
}
}
@@ -1906,7 +1903,6 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
/* scale would be handled by matrix transformation when angle is non-zero */
if(tscale!=1.f && tangle==0.f) {
ImBuf *scaleibuf;
float scale= (stab->scale-1.f)*stab->scaleinf+1.f;
stabilization_auto_scale_factor(tracking, width, height);
@@ -1914,7 +1910,7 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
stab->scaleibuf= scaleibuf;
IMB_rectcpy(scaleibuf, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y);
IMB_scalefastImBuf(scaleibuf, ibuf->x*scale, ibuf->y*scale);
IMB_scalefastImBuf(scaleibuf, ibuf->x*tscale, ibuf->y*tscale);
ibuf= scaleibuf;
}
@@ -1922,7 +1918,7 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf,
if(tangle==0.f) {
/* if angle is zero, then it's much faster to use rect copy
but could be issues with subpixel precisions */
IMB_rectcpy(tmpibuf, ibuf, tloc[0], tloc[1], 0, 0, ibuf->x, ibuf->y);
IMB_rectcpy(tmpibuf, ibuf, tloc[0]-(tscale-1.0f)*width/2.0f, tloc[1]-(tscale-1.0f)*height/2.0f, 0, 0, ibuf->x, ibuf->y);
} else {
float mat[4][4];
int i, j;
@@ -1974,7 +1970,7 @@ void BKE_tracking_stabdata_to_mat4(int width, int height, float loc[2], float sc
rotate_m4(rmat, 'Z', angle); /* rotation matrix */
/* compose transformation matrix */
mul_serie_m4(mat, lmat, smat, cmat, rmat, icmat, NULL, NULL, NULL);
mul_serie_m4(mat, lmat, cmat, rmat, smat, icmat, NULL, NULL, NULL);
}
MovieDistortion *BKE_tracking_distortion_create(void)

View File

@@ -408,7 +408,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
else if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
bFollowTrackConstraint *data = curcon->data;
if((data->flag&CAMERASOLVER_DEFAULTCLIP)==0) {
if((data->flag&CAMERASOLVER_ACTIVECLIP)==0) {
if(data->clip != NULL && data->track[0]) {
if (!BKE_find_track_by_name(&data->clip->tracking, data->track))
curcon->flag |= CONSTRAINT_DISABLE;
@@ -419,7 +419,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
else if (curcon->type == CONSTRAINT_TYPE_CAMERASOLVER) {
bCameraSolverConstraint *data = curcon->data;
if((data->flag&CAMERASOLVER_DEFAULTCLIP)==0 && data->clip == NULL)
if((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL)
curcon->flag |= CONSTRAINT_DISABLE;
}

View File

@@ -4813,7 +4813,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if(t->scene->nodetree) {
/* tracks can be used for stabilization nodes,
flush update for such nodes */
NodeTagIDChanged(t->scene->nodetree, &clip->id);
nodeUpdateID(t->scene->nodetree, &clip->id);
WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
}
}

View File

@@ -758,12 +758,12 @@ typedef enum eFollowTrack_Reference {
} FollowTrack_Reference;
typedef enum eFollowTrack_Flags {
FOLLOWTRACK_DEFAULTCLIP = (1<<0)
FOLLOWTRACK_ACTIVECLIP = (1<<0)
} eFollowTrack_Flags;
/* CameraSolver Constraint -> flag */
typedef enum eCameraSolver_Flags {
CAMERASOLVER_DEFAULTCLIP = (1<<0)
CAMERASOLVER_ACTIVECLIP = (1<<0)
} eCameraSolver_Flags;
/* Rigid-Body Constraint */

View File

@@ -163,14 +163,14 @@ void RNA_def_camera(BlenderRNA *brna)
RNA_def_property_range(prop, -10.0f, 10.0f);
RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3);
RNA_def_property_ui_text(prop, "Shift X", "Perspective Camera horizontal shift");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update");
prop= RNA_def_property(srna, "shift_y", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shifty");
RNA_def_property_range(prop, -10.0f, 10.0f);
RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3);
RNA_def_property_ui_text(prop, "Shift Y", "Perspective Camera vertical shift");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Camera_update");
prop= RNA_def_property(srna, "dof_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "YF_dofdist");

View File

@@ -2067,9 +2067,9 @@ static void rna_def_constraint_follow_track(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
/* use default clip */
prop= RNA_def_property(srna, "use_default_clip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FOLLOWTRACK_DEFAULTCLIP);
RNA_def_property_ui_text(prop, "Default Clip", "Use default clip defined in scene");
prop= RNA_def_property(srna, "use_active_clip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", FOLLOWTRACK_ACTIVECLIP);
RNA_def_property_ui_text(prop, "Active Clip", "Use active clip defined in scene");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
}
@@ -2090,9 +2090,9 @@ static void rna_def_constraint_camera_solver(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update");
/* use default clip */
prop= RNA_def_property(srna, "use_default_clip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CAMERASOLVER_DEFAULTCLIP);
RNA_def_property_ui_text(prop, "Default Clip", "Use default clip defined in scene");
prop= RNA_def_property(srna, "use_active_clip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CAMERASOLVER_ACTIVECLIP);
RNA_def_property_ui_text(prop, "Active Clip", "Use active clip defined in scene");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
}

View File

@@ -201,7 +201,7 @@ static void rna_tracking_flushUpdate(Main *UNUSED(bmain), Scene *scene, PointerR
stab->ok= 0;
NodeTagIDChanged(scene->nodetree, &clip->id);
nodeUpdateID(scene->nodetree, &clip->id);
WM_main_add_notifier(NC_SCENE|ND_NODES, NULL);
DAG_id_tag_update(&clip->id, 0);

View File

@@ -821,7 +821,7 @@ int ntreeCompositTagAnimated(bNodeTree *ntree)
}
}
else if(ELEM(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_TRANSFORM)) {
NodeTagChanged(ntree, node);
nodeUpdate(ntree, node);
tagged= 1;
}
}

View File

@@ -40,7 +40,7 @@ static bNodeSocketTemplate cmp_node_movieclip_out[]= {
{ SOCK_FLOAT, 1, "Offset X"},
{ SOCK_FLOAT, 1, "Offset Y"},
{ SOCK_FLOAT, 1, "Scale"},
{ SOCK_FLOAT, 1, "Degr"},
{ SOCK_FLOAT, 1, "Angle"},
{ -1, 0, "" }
};
@@ -146,7 +146,7 @@ static void node_composit_exec_movieclip(void *data, bNode *node, bNodeStack **U
out[2]->vec[0]= loc[1];
out[3]->vec[0]= scale;
out[4]->vec[0]= RAD2DEG(angle);
out[4]->vec[0]= angle;
}
/* generate preview */

View File

@@ -34,18 +34,18 @@
#include "node_composite_util.h"
/* **************** Translate ******************** */
/* **************** Transform ******************** */
static bNodeSocketTemplate cmp_node_stabilize2d_in[]= {
static bNodeSocketTemplate cmp_node_transform_in[]= {
{ SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 1, "X", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{ SOCK_FLOAT, 1, "Y", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{ SOCK_FLOAT, 1, "Degr", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{ SOCK_FLOAT, 1, "Angle", 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_ANGLE},
{ SOCK_FLOAT, 1, "Scale", 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, CMP_SCALE_MAX},
{ -1, 0, "" }
};
static bNodeSocketTemplate cmp_node_stabilize2d_out[]= {
static bNodeSocketTemplate cmp_node_transform_out[]= {
{ SOCK_RGBA, 0, "Image"},
{ -1, 0, "" }
};
@@ -72,7 +72,7 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f
rotate_m4(rmat, 'Z', angle); /* rotation matrix */
/* compose transformation matrix */
mul_serie_m4(mat, lmat, smat, cmat, rmat, icmat, NULL, NULL, NULL);
mul_serie_m4(mat, lmat, cmat, rmat, smat, icmat, NULL, NULL, NULL);
invert_m4(mat);
@@ -113,13 +113,13 @@ CompBuf* node_composit_transform(CompBuf *cbuf, float x, float y, float angle, f
return stackbuf;
}
static void node_composit_exec_stabilize2d(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
static void node_composit_exec_transform(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
if(in[0]->data) {
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
CompBuf *stackbuf;
stackbuf= node_composit_transform(cbuf, in[1]->vec[0], in[2]->vec[0], DEG2RAD(in[3]->vec[0]), in[4]->vec[0], node->custom1);
stackbuf= node_composit_transform(cbuf, in[1]->vec[0], in[2]->vec[0], in[3]->vec[0], in[4]->vec[0], node->custom1);
/* pass on output and free */
out[0]->data= stackbuf;
@@ -134,9 +134,9 @@ void register_node_type_cmp_transform(ListBase *lb)
static bNodeType ntype;
node_type_base(&ntype, CMP_NODE_TRANSFORM, "Transform", NODE_CLASS_DISTORT, NODE_OPTIONS);
node_type_socket_templates(&ntype, cmp_node_stabilize2d_in, cmp_node_stabilize2d_out);
node_type_socket_templates(&ntype, cmp_node_transform_in, cmp_node_transform_out);
node_type_size(&ntype, 140, 100, 320);
node_type_exec(&ntype, node_composit_exec_stabilize2d);
node_type_exec(&ntype, node_composit_exec_transform);
nodeRegisterType(lb, &ntype);
}