本文整理汇总了C++中CGESTUREptr::endpt_vec方法的典型用法代码示例。如果您正苦于以下问题:C++ CGESTUREptr::endpt_vec方法的具体用法?C++ CGESTUREptr::endpt_vec怎么用?C++ CGESTUREptr::endpt_vec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGESTUREptr
的用法示例。
在下文中一共展示了CGESTUREptr::endpt_vec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trim_line_cb
int
SWEEP_BASE::line_cb(CGESTUREptr& g, DrawState*& s)
{
// Activity occurred to extend the deadline for fading away:
reset_timeout();
static bool debug =
Config::get_var_bool("DEBUG_SWEEP_LINE_CB",false) || debug_all;
err_adv(debug, "SWEEP_BASE::line_cb");
// If gesture aligns with guideline:
// if it starts near the end and extends past the end, extend
// if it starts near the beginning, do uniform sweep
// If it's across the gesture, trim
// If it's a trim stroke, it has to be short and run
// across the guideline.
const double TRIM_MAX_LEN = 65;
if (g->length() < TRIM_MAX_LEN) {
const double TRIM_ANGLE_THRESH = 80; // degrees
double angle = line_angle(g->endpt_vec(), pix_line().direction());
if (rad2deg(angle) > TRIM_ANGLE_THRESH) {
// Nice angle. But did it cross?
if (g->endpt_line().intersect_segs(pix_line()))
return trim_line_cb(g, s);
}
}
// do uniform sweep if straight gesture starts at sweep origin
// and ends near the guideline:
if (from_center(g)) {
if (hits_line(g->end()))
return do_uniform_sweep(project_to_guideline(g->end()) - sweep_origin());
return stroke_cb(g,s);
}
// extend the guideline if straight gesture starts near guideline end
// and is nearly parallel:
const double ALIGN_ANGLE_THRESH = 15; // degrees
if (pix_line().endpt().dist(g->start()) < DIST_THRESH_PIXELS &&
rad2deg(g->endpt_vec().angle(pix_line().direction())) < ALIGN_ANGLE_THRESH)
return extend_line_cb(g, s);
return stroke_cb(g,s);
}
示例2: VEXEL
int
INFLATE::stroke_cb(CGESTUREptr& gest, DrawState*& s)
{
err_adv(debug, "INFLATE::stroke_cb");
reset_timeout();
// Verify that we have a starting face
if ( _orig_face ) {
Bface* face = 0;
// Check that the stroke is straight enough to represent a line
if (!(gest->straightness() > 0.8)) {
err_adv(debug, "INFLATE::stroke_cb: gesture not straight");
return false;
}
// Check that the gesture starts on the mesh
Bsurface::hit_ctrl_surface(gest->start(), 1, &face);
if (!(face)) {
err_adv(debug, "INFLATE::stroke_cb: can't get hit face");
return false;
}
// create VEXELs for the gesture and the face normal
VEXEL fvec = VEXEL(face->v1()->loc(), face->norm());
VEXEL fgest = gest->endpt_vec();
// If gesture nearly parallel to normal:
double a = rad2deg(line_angle(fvec,fgest));
err_adv(debug, "INFLATE::stroke_cb: angle: %f %s",
a, (a > 15) ? "(bad)" : "(good)");
if (a > 15) {
// Fail if angle is too extreme
WORLD::message("Bad angle");
return 0;
}
// calculate extrude width
double dist = fgest.length()/fvec.length();
err_adv(debug, "INFLATE::stroke_cb: strong_edge_len: %f, gest_len: %f, \
fvect_len: %f", avg_strong_edge_len(face), fgest.length(), fvec.length() );
// Convert to relative to local edge length
dist /= avg_strong_edge_len(face);
if (fvec*fgest<0)
dist=-dist; // Get the sign right
// Store the new inflate distance
_preview_dist = dist;
}
return 1; // we used up the gesture...
}