/*! \file valuenode_bline.cpp
** \brief Template File
**
** $Id: valuenode_bline.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
**
** \legal
/*! \file valuenode_bline.cpp
** \brief Template File
**
** $Id: valuenode_bline.cpp,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
**
** \legal
-** This software and associated documentation
-** are CONFIDENTIAL and PROPRIETARY property of
-** the above-mentioned copyright holder.
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
-** You may not copy, print, publish, or in any
-** other way distribute this software without
-** a prior written agreement with
-** the copyright holder.
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
{
affine_combo<Real,float> mag_combo;
affine_combo<Angle,float> ang_combo;
{
affine_combo<Real,float> mag_combo;
affine_combo<Angle,float> ang_combo;
Real mag(mag_combo(a.mag(),b.mag(),c));
Angle ang(ang_combo(Angle::tan(a[1],a[0]),Angle::tan(b[1],b[0]),c));
Real mag(mag_combo(a.mag(),b.mag(),c));
Angle ang(ang_combo(Angle::tan(a[1],a[0]),Angle::tan(b[1],b[0]),c));
// std::vector<BLinePoint> list(bline.operator std::vector<BLinePoint>());
//std::vector<BLinePoint> list(bline);
std::vector<BLinePoint> list(bline.get_list().begin(),bline.get_list().end());
std::vector<BLinePoint>::const_iterator iter;
BLinePoint prev,first;
// std::vector<BLinePoint> list(bline.operator std::vector<BLinePoint>());
//std::vector<BLinePoint> list(bline);
std::vector<BLinePoint> list(bline.get_list().begin(),bline.get_list().end());
std::vector<BLinePoint>::const_iterator iter;
BLinePoint prev,first;
if(list.empty()) return ValueBase(ret,bline.get_loop());
first = prev = list.front();
if(list.empty()) return ValueBase(ret,bline.get_loop());
first = prev = list.front();
{
std::vector<Real> ret;
// std::vector<BLinePoint> list(bline.operator std::vector<BLinePoint>());
//std::vector<BLinePoint> list(bline);
std::vector<BLinePoint> list(bline.get_list().begin(),bline.get_list().end());
std::vector<BLinePoint>::const_iterator iter;
{
std::vector<Real> ret;
// std::vector<BLinePoint> list(bline.operator std::vector<BLinePoint>());
//std::vector<BLinePoint> list(bline);
std::vector<BLinePoint> list(bline.get_list().begin(),bline.get_list().end());
std::vector<BLinePoint>::const_iterator iter;
std::vector<BLinePoint>::const_iterator iter;
for(iter=bline_points.begin();iter!=bline_points.end();iter++)
std::vector<BLinePoint>::const_iterator iter;
for(iter=bline_points.begin();iter!=bline_points.end();iter++)
value_node->add(ValueNode::Handle(ValueNode_Composite::create(*iter)));
}
value_node->set_loop(value.get_loop());
value_node->add(ValueNode::Handle(ValueNode_Composite::create(*iter)));
}
value_node->set_loop(value.get_loop());
// into a list of BLinePoints. We make an assumption
// that the segment list is continuous(sp), but not necessarily
// smooth.
// into a list of BLinePoints. We make an assumption
// that the segment list is continuous(sp), but not necessarily
// smooth.
value_node->set_loop(false);
// std::vector<Segment> segments(value.operator std::vector<Segment>());
// std::vector<Segment> segments(value);
value_node->set_loop(false);
// std::vector<Segment> segments(value.operator std::vector<Segment>());
// std::vector<Segment> segments(value);
std::vector<Segment>::const_iterator iter,last(segments.end());
--last;
ValueNode_Const::Handle prev,first;
std::vector<Segment>::const_iterator iter,last(segments.end());
--last;
ValueNode_Const::Handle prev,first;
#define PREV_POINT prev->get_value().get(BLinePoint())
#define FIRST_POINT first->get_value().get(BLinePoint())
#define CURR_POINT curr->get_value().get(BLinePoint())
#define PREV_POINT prev->get_value().get(BLinePoint())
#define FIRST_POINT first->get_value().get(BLinePoint())
#define CURR_POINT curr->get_value().get(BLinePoint())
prev_point.set_tangent1(iter->t1);
prev_point.set_width(0.01);
prev_point.set_origin(0.5);
prev_point.set_tangent1(iter->t1);
prev_point.set_width(0.01);
prev_point.set_origin(0.5);
ValueNode_Const::Handle curr;
curr=ValueNode_Const::create(ValueBase::TYPE_BLINEPOINT);
{
BLinePoint curr_point(CURR_POINT);
ValueNode_Const::Handle curr;
curr=ValueNode_Const::create(ValueBase::TYPE_BLINEPOINT);
{
BLinePoint curr_point(CURR_POINT);
curr_point.set_tangent1(iter->t2);
curr_point.set_width(0.01);
curr_point.set_origin(0.5);
curr_point.set_tangent1(iter->t2);
curr_point.set_width(0.01);
curr_point.set_origin(0.5);
-
- sinfg::info("index=%d, next_i=%d, prev_i=%d",index,next_i,prev_i);
-
+
+ synfig::info("index=%d, next_i=%d, prev_i=%d",index,next_i,prev_i);
+
etl::hermite<Vector> curve(prev.get_vertex(),next.get_vertex(),prev.get_tangent2(),next.get_tangent1());
etl::derivative< etl::hermite<Vector> > deriv(curve);
etl::hermite<Vector> curve(prev.get_vertex(),next.get_vertex(),prev.get_tangent2(),next.get_tangent1());
etl::derivative< etl::hermite<Vector> > deriv(curve);
bline_point.set_vertex(curve(origin));
bline_point.set_width((next.get_width()-prev.get_width())*origin+prev.get_width());
bline_point.set_tangent1(deriv(origin)*min(1.0-origin,origin));
bline_point.set_tangent2(bline_point.get_tangent1());
bline_point.set_split_tangent_flag(false);
bline_point.set_origin(origin);
bline_point.set_vertex(curve(origin));
bline_point.set_width((next.get_width()-prev.get_width())*origin+prev.get_width());
bline_point.set_tangent1(deriv(origin)*min(1.0-origin,origin));
bline_point.set_tangent2(bline_point.get_tangent1());
bline_point.set_split_tangent_flag(false);
bline_point.set_origin(origin);
for(iter=list.begin();iter!=list.end();++iter,index++)
{
float amount(iter->amount_at_time(t,&rising));
for(iter=list.begin();iter!=list.end();++iter,index++)
{
float amount(iter->amount_at_time(t,&rising));
// This is where the interesting stuff happens
// We need to seek forward in the list to see what the next
// active point is
// This is where the interesting stuff happens
// We need to seek forward in the list to see what the next
// active point is
BLinePoint curr;
BLinePoint begin; // begin of dynamic group
BLinePoint end; // End of dynamic group
Time blend_time;
int dist_from_begin(0), dist_from_end(0);
BLinePoint ret;
BLinePoint curr;
BLinePoint begin; // begin of dynamic group
BLinePoint end; // End of dynamic group
Time blend_time;
int dist_from_begin(0), dist_from_end(0);
BLinePoint ret;
etl::hermite<Vector> curve(begin.get_vertex(),end.get_vertex(),begin.get_tangent2(),end.get_tangent1());
etl::derivative< etl::hermite<Vector> > deriv(curve);
etl::hermite<Vector> curve(begin.get_vertex(),end.get_vertex(),begin.get_tangent2(),end.get_tangent1());
etl::derivative< etl::hermite<Vector> > deriv(curve);
ret.set_vertex(curve(curr.get_origin()));
ret.set_width((end.get_width()-begin.get_width())*curr.get_origin()+begin.get_width());
ret.set_tangent1(deriv(curr.get_origin()));
ret.set_tangent2(deriv(curr.get_origin()));
ret.set_vertex(curve(curr.get_origin()));
ret.set_width((end.get_width()-begin.get_width())*curr.get_origin()+begin.get_width());
ret.set_tangent1(deriv(curr.get_origin()));
ret.set_tangent2(deriv(curr.get_origin()));
-
- //sinfg::info("index_%d:dist_from_begin=%d",index,dist_from_begin);
- //sinfg::info("index_%d:dist_from_end=%d",index,dist_from_end);
-
+
+ //synfig::info("index_%d:dist_from_begin=%d",index,dist_from_begin);
+ //synfig::info("index_%d:dist_from_end=%d",index,dist_from_end);
+
// If we are the next to the begin
if(begin_iter==--std::vector<ListEntry>::const_iterator(iter) || dist_from_begin==1)
{
// If we are the next to the begin
if(begin_iter==--std::vector<ListEntry>::const_iterator(iter) || dist_from_begin==1)
{
BLinePoint next;
next=((*(++std::vector<ListEntry>::const_iterator(iter))->value_node)(t).get(prev));
float origin=next.get_origin()-curr.get_origin();
BLinePoint next;
next=((*(++std::vector<ListEntry>::const_iterator(iter))->value_node)(t).get(prev));
float origin=next.get_origin()-curr.get_origin();
Point begin_cord_sys[2], begin_cord_origin;
Point end_cord_sys[2], end_cord_origin;
Point curr_cord_sys[2], curr_cord_origin;
Point begin_cord_sys[2], begin_cord_origin;
Point end_cord_sys[2], end_cord_origin;
Point curr_cord_sys[2], curr_cord_origin;
{
const Point a((*end_iter->value_node)(begin_time).get(prev).get_vertex());
const Point b((*begin_iter->value_node)(begin_time).get(prev).get_vertex());
{
const Point a((*end_iter->value_node)(begin_time).get(prev).get_vertex());
const Point b((*begin_iter->value_node)(begin_time).get(prev).get_vertex());
curr_cord_origin=(*end_iter->value_node)(t).get(prev).get_vertex();
curr_cord_sys[0]=(
(*begin_iter->value_node)(t).get(prev).get_vertex() -
curr_cord_origin=(*end_iter->value_node)(t).get(prev).get_vertex();
curr_cord_sys[0]=(
(*begin_iter->value_node)(t).get(prev).get_vertex() -
a[0]=tmp*begin_cord_sys[0];
a[1]=tmp*begin_cord_sys[1];
#define COORD_SYS_RADIAL_TAN_INTERP 1
a[0]=tmp*begin_cord_sys[0];
a[1]=tmp*begin_cord_sys[1];
#define COORD_SYS_RADIAL_TAN_INTERP 1
#ifdef COORD_SYS_RADIAL_TAN_INTERP
tmp=ret.get_tangent1()+ret.get_vertex()-begin_cord_origin;
at1[0]=tmp*begin_cord_sys[0];
at1[1]=tmp*begin_cord_sys[1];
#ifdef COORD_SYS_RADIAL_TAN_INTERP
tmp=ret.get_tangent1()+ret.get_vertex()-begin_cord_origin;
at1[0]=tmp*begin_cord_sys[0];
at1[1]=tmp*begin_cord_sys[1];
Point tmp(curr.get_vertex()-end_cord_origin);
b[0]=tmp*end_cord_sys[0];
b[1]=tmp*end_cord_sys[1];
Point tmp(curr.get_vertex()-end_cord_origin);
b[0]=tmp*end_cord_sys[0];
b[1]=tmp*end_cord_sys[1];
#ifdef COORD_SYS_RADIAL_TAN_INTERP
tmp=curr.get_tangent1()+curr.get_vertex()-end_cord_origin;
bt1[0]=tmp*end_cord_sys[0];
#ifdef COORD_SYS_RADIAL_TAN_INTERP
tmp=curr.get_tangent1()+curr.get_vertex()-end_cord_origin;
bt1[0]=tmp*end_cord_sys[0];
#ifdef COORD_SYS_RADIAL_TAN_INTERP
tmp=INTERP_FUNCTION(at1,bt1,amount);
ct1[0]=tmp*curr_cord_sys[0];
ct1[1]=tmp*curr_cord_sys[1];
ct1+=curr_cord_origin;
ct1-=c;
#ifdef COORD_SYS_RADIAL_TAN_INTERP
tmp=INTERP_FUNCTION(at1,bt1,amount);
ct1[0]=tmp*curr_cord_sys[0];
ct1[1]=tmp*curr_cord_sys[1];
ct1+=curr_cord_origin;
ct1-=c;
if(curr.get_split_tangent_flag())
{
tmp=INTERP_FUNCTION(at2,bt2,amount);
if(curr.get_split_tangent_flag())
{
tmp=INTERP_FUNCTION(at2,bt2,amount);
ret.set_split_tangent_flag(curr.get_split_tangent_flag());
if(ret.get_split_tangent_flag())
ret.set_tangent2(radial_interpolation(ret.get_tangent2(),curr.get_tangent2(),amount));
ret.set_split_tangent_flag(curr.get_split_tangent_flag());
if(ret.get_split_tangent_flag())
ret.set_tangent2(radial_interpolation(ret.get_tangent2(),curr.get_tangent2(),amount));
ret.set_origin(curr.get_origin());
ret.set_width((curr.get_width()-ret.get_width())*amount+ret.get_width());
ret.set_origin(curr.get_origin());
ret.set_width((curr.get_width()-ret.get_width())*amount+ret.get_width());
{
assert(i>=0 && (unsigned)i<list.size());
return etl::strprintf(_("Vertex %03d"),i+1);
{
assert(i>=0 && (unsigned)i<list.size());
return etl::strprintf(_("Vertex %03d"),i+1);