本文整理汇总了C++中VPoint类的典型用法代码示例。如果您正苦于以下问题:C++ VPoint类的具体用法?C++ VPoint怎么用?C++ VPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HitTest
bool VRect::HitTest (const VPoint& inPoint) const
{
return ((inPoint.GetX() - fX) > -kREAL_PIXEL_PRECISION
&& (inPoint.GetX() - GetRight()) < kREAL_PIXEL_PRECISION
&& (inPoint.GetY() - fY) > -kREAL_PIXEL_PRECISION
&& (inPoint.GetY() - GetBottom()) < kREAL_PIXEL_PRECISION);
}
示例2: ScaledHitTest
// JM 201206
Boolean VGraphicPath::ScaledHitTest(const VPoint& inPoint, GReal scale) const
{
#if ENABLE_D2D
if (fPathD2D != NULL)
{
BOOL bContains = FALSE;
fPathD2D->StrokeContainsPoint( D2D1::Point2F(inPoint.GetX(), inPoint.GetY()),
4*scale,
NULL,
NULL,
&bContains);
return bContains == TRUE;
}
#endif
#if !GRAPHIC_MIXED_GDIPLUS_D2D
if (!VWinD2DGraphicContext::IsAvailable())
{
#endif
Gdiplus::Color black_default_color(0,0,0);
Gdiplus::Pen p(black_default_color);
p.SetWidth(4 * scale);
return fPath->IsOutlineVisible((Gdiplus::REAL)inPoint.GetX(), (Gdiplus::REAL)inPoint.GetY(), &p );
#if !GRAPHIC_MIXED_GDIPLUS_D2D
}
#endif
return false;
}
示例3: ccpDistance
void VRope::createRope(cocos2d::CCPoint pointA, cocos2d::CCPoint pointB, float ropeLenght) {
float distance;
if (ropeLenght < 0) {
distance = ccpDistance(pointA,pointB);
}else{
distance = ropeLenght;
}
int segmentFactor = RopeSegmentFactor; //increase value to have less segments per rope, decrease to have more segments
numPoints = distance/segmentFactor;
mRopeLength = segmentFactor * numPoints;
CCPoint diffVector = ccpSub(pointB,pointA);
float multiplier = distance / (numPoints-1);
antiSagHack = 0.1f; //HACK: scale down rope points to cheat sag. set to 0 to disable, max suggested value 0.1
for(int i=0;i<numPoints;i++) {
CCPoint tmpVector = ccpAdd(pointA, ccpMult(ccpNormalize(diffVector),multiplier*i*(1-antiSagHack)));
VPoint* tmpPoint = new VPoint;
tmpPoint->setPos(tmpVector.x, tmpVector.y);
vPoints.insert(vPoints.end(), tmpPoint);
}
for(int i=0;i<numPoints-1;i++) {
VStick tmpStick;
tmpStick.initWith(vPoints[i], vPoints[i+1]);
vSticks.insert(vSticks.end(), tmpStick);
}
if(spriteSheet!=NULL) {
for(int i=0;i<numPoints-1;i++) {
VPoint* point1 = vSticks[i].getPointA();
VPoint* point2 = vSticks[i].getPointB();
CCPoint stickVector = ccpSub(ccp(point1->x,point1->y),ccp(point2->x,point2->y));
float stickAngle = ccpToAngle(stickVector);
CCTexture2D* texture = spriteSheet->getTexture();
RecordSprite* tmpSprite = new RecordSprite;
tmpSprite->setTag(Tag_Box_RopeBatchSprite);
tmpSprite->autorelease();
tmpSprite->initWithTexture(texture, CCRectMake(0,0,multiplier,texture->getContentSize().height));
ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT};
tmpSprite->getTexture()->setTexParameters(¶ms);
tmpSprite->setPosition(ccpMidpoint(ccp(point1->x,point1->y),ccp(point2->x,point2->y)));
tmpSprite->setRotation(-1 * CC_RADIANS_TO_DEGREES(stickAngle));
spriteSheet->addChild(tmpSprite);
ropeSprites.insert(ropeSprites.end(), tmpSprite);
}
//// LiFeng 添加
//ropeSprites[ropeSprites.size()-1]->setOpacity(100);
}else{
CCAssert(false, "not init");
}
}
示例4: newRopeSticks
VRope* VRope::cutRopeInStick(int nPoint, VStick* stick, b2Body* newBodyA, b2Body* newBodyB) {
auto range = NSRange{nPoint, numPoints-nPoint-1};
std::vector< VStick *> newRopeSticks( vSticks.begin() + range.location, vSticks.begin() + range.location + range.length );
vSticks.erase(vSticks.begin() + range.location, vSticks.begin() + range.location + range.length);
std::vector<Sprite*> newRopeSprites(ropeSprites.begin() + range.location, ropeSprites.begin() + range.location + range.length);
ropeSprites.erase(ropeSprites.begin() + range.location, ropeSprites.begin() + range.location + range.length);
range.length += 1;
std::vector<VPoint*> newRopePoints(vPoints.begin() + range.location, vPoints.begin() + range.location + range.length);
vPoints.erase(vPoints.begin() + range.location, vPoints.begin() + range.location + range.length);
VPoint *pointOfBreak = newRopePoints.at(0);
VPoint *newPoint = new VPoint();
newPoint->setPos(pointOfBreak->x, pointOfBreak->y);
vPoints.push_back(newPoint);
VStick *lastStick = vSticks.back();
lastStick->setPointB(newPoint);
float cutRatio = (float)nPoint / (numPoints - 1);
numPoints = nPoint + 1;
b2Vec2 newBodiesPosition = b2Vec2(pointOfBreak->x / PTM_RATIO, pointOfBreak->y / PTM_RATIO);
b2World *world = newBodyA->GetWorld();
b2RopeJointDef jd;
jd.bodyA = joint->GetBodyA();
jd.bodyB = newBodyB;
jd.localAnchorA = joint->GetLocalAnchorA();
jd.localAnchorB = b2Vec2(0, 0);
jd.maxLength = joint->GetMaxLength() * cutRatio;
newBodyB->SetTransform(newBodiesPosition, 0.0);
b2RopeJoint *newJoint1 = (b2RopeJoint *)world->CreateJoint(&jd); //create joint
jd.bodyA = newBodyA;
jd.bodyB = joint->GetBodyB();
jd.localAnchorA = b2Vec2(0, 0);
jd.localAnchorB = joint->GetLocalAnchorB();
jd.maxLength = joint->GetMaxLength() * (1 - cutRatio);
newBodyA->SetTransform(newBodiesPosition, 0.0);
b2RopeJoint *newJoint2 = (b2RopeJoint *)world->CreateJoint(&jd);
world->DestroyJoint(joint);
joint = newJoint1;
VRope* newRope = new VRope(newJoint2,spriteSheet,newRopePoints,newRopeSticks,newRopeSprites);
return newRope;
}
示例5: showpath
void showpath()
{
for(VPoint::iterator it = path.begin(); it != path.end(); ++it)
{
highlightCube(it->x, it->y, true);
pause(50);
}
pause(250);
for(VPoint::iterator it = path.begin(); it != path.end(); ++it)
highlightCube(it->x, it->y, false);
}
示例6: while
/*!If more than one logical operatoin has to be executed over the input shapes
the raw data #_shape1 and #_shape2 can be reused, but has to be recycled beforehand
This method is traversing both fields and invokes VPoint::reset_visited() in
order to reinitialize the CPoint::_visited fields*/
void logicop::logic::reset_visited() {
VPoint* centinel = _shape1;
VPoint* looper = centinel;
do {
looper->reset_visited();
looper = looper->next();
} while (centinel != looper);
centinel = _shape2;
looper = centinel;
do {
looper->reset_visited();
looper = looper->next();
} while (centinel != looper);
}
示例7: testPoint
Boolean VRegion::HitTest (const VPoint& inPoint) const
{
if (fRegion == NULL) return false;
#if !USE_GDIPLUS
VPoint testPoint(inPoint);
testPoint -= fOffset;
if (testPoint.GetX() > kMAX_GDI_RGN_COORD || testPoint.GetY() > kMAX_GDI_RGN_COORD)
return false;
else
return (::PtInRegion(fRegion, testPoint.GetX(), testPoint.GetY()) != 0);
#else
return fRegion->IsVisible((INT)inPoint.GetX(), (INT)inPoint.GetY());
#endif
}
示例8: _segl0
pointlist* logicop::logic::hole2simple(const pointlist& outside, const pointlist& inside) {
segmentlist _segl0(outside,0);
segmentlist _segl1(inside,1);
EventQueue* _eq = new EventQueue(_segl0, _segl1); // create the event queue
SweepLine _sl;
BindCollection BC;
_eq->swipe4bind(_sl, BC);
BindSegment* sbc = BC.get_highest();
//insert 2 crossing points and link them
BPoint* cpsegA = _segl0.insertbindpoint(sbc->poly0seg(), sbc->poly0pnt());
BPoint* cpsegB = _segl1.insertbindpoint(sbc->poly1seg(), sbc->poly1pnt());
cpsegA->linkto(cpsegB);
cpsegB->linkto(cpsegA);
// normalize the segment lists
_segl0.normalize(outside);
_segl1.normalize(inside);
// dump the new polygons in VList terms
VPoint* outshape = _segl0.dump_points();
_segl1.dump_points();
// traverse and form the resulting shape
VPoint* centinel = outshape;
pointlist *shgen = new pointlist();
bool direction = true; /*next*/
VPoint* pickup = centinel;
VPoint* prev = centinel->prev();
bool modify = false;
do {
shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y()));
modify = (-1 == prev->visited());
prev = pickup;
pickup = pickup->follower(direction, modify);
} while (pickup != centinel);
// Validate the resulting polygon
laydata::valid_poly check(*shgen);
// delete shgen;
if (!check.valid()) {
std::ostringstream ost;
ost << ": Resulting shape is invalid - " << check.failtype();
tell_log(console::MT_ERROR, ost.str().c_str());
}
else {
if (laydata::shp_OK != check.status())
*shgen = check.get_validated();
}
return shgen;
}
示例9: VPoint
void VGraphicPath::BeginSubPathAt(const VPoint& inLocalPoint)
{
#if !GRAPHIC_MIXED_GDIPLUS_D2D
if (!VWinD2DGraphicContext::IsAvailable())
{
#endif
fLastPoint = VPoint((GReal)inLocalPoint.GetX(), (GReal)inLocalPoint.GetY());
fPath->StartFigure();
#if !GRAPHIC_MIXED_GDIPLUS_D2D
}
#endif
#if ENABLE_D2D
if (VWinD2DGraphicContext::IsAvailable())
{
if (!fGeomSink)
{
Begin();
if (!fGeomSink)
return;
}
if (!fFigureIsClosed)
//do not forget to close current figure before opening new figure to prevent really nasty artifacts...
fGeomSink->EndFigure( D2D1_FIGURE_END_OPEN);
fGeomSink->BeginFigure( D2D1::Point2F( inLocalPoint.GetX(), inLocalPoint.GetY()),
D2D1_FIGURE_BEGIN_FILLED);
fFigureIsClosed = false;
}
#endif
fPolygon.AddPoint(inLocalPoint);
if (fComputeBoundsAccurate)
_addPointToBounds( inLocalPoint);
_ComputeBounds();
if (fCreateStorageForCrispEdges)
fDrawCmds.push_back( VGraphicPathDrawCmd( GPDCT_BEGIN_SUBPATH_AT, inLocalPoint));
}
示例10: ccpSub
void VRope::createRope(const CCPoint& pointA, const CCPoint& pointB, float distance)
{
// float distance = ccpDistance(pointA,pointB);
int segmentFactor = 12; // 16; //12; //increase value to have less segments per rope, decrease to have more segments
numPoints = (int) distance/segmentFactor;
CCPoint diffVector = ccpSub(pointB,pointA);
float multiplier = distance / (numPoints-1);
antiSagHack = 0.1f; //HACK: scale down rope points to cheat sag. set to 0 to disable, max suggested value 0.1
for(int i=0;i<numPoints;i++) {
CCPoint tmpVector = ccpAdd(pointA, ccpMult(ccpNormalize(diffVector), multiplier*i*(1-antiSagHack)));
VPoint *tmpPoint = new VPoint();
tmpPoint->setPos(tmpVector.x, tmpVector.y);
vPoints.push_back(tmpPoint);
}
for(int i=0;i<numPoints-1;i++) {
VStick* tmpStick = new VStick(vPoints[i], vPoints[i+1]);
vSticks.push_back(tmpStick);
}
if(spriteSheet) {
for(int i=0;i<numPoints-1;i++) {
VPoint* point1 = vSticks[i]->getPointA();
VPoint* point2 = vSticks[i]->getPointB();
CCPoint stickVector = ccpSub(ccp(point1->x,point1->y),ccp(point2->x,point2->y));
float stickAngle = ccpToAngle(stickVector);
float f = spriteSheet->getTextureAtlas()->getTexture()->getPixelsHigh() / CC_CONTENT_SCALE_FACTOR();
CCRect r = CCRectMake(0, 0, multiplier, f);
Sprite* tmpSprite = Sprite::createWithTexture(spriteSheet->getTexture(), r);
Texture2D::TexParams params = {GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
tmpSprite->getTexture()->setTexParameters(¶ms);
tmpSprite->setPosition(ccpMidpoint(ccp(point1->x, point1->y), ccp(point2->x, point2->y)));
tmpSprite->setRotation(-1 * CC_RADIANS_TO_DEGREES(stickAngle));
spriteSheet->addChild(tmpSprite);
ropeSprites.push_back(tmpSprite);
}
}
}
示例11: AddLineTo
void VGraphicPath::AddLineTo(const VPoint& inDestPoint)
{
#if !GRAPHIC_MIXED_GDIPLUS_D2D
if (!VWinD2DGraphicContext::IsAvailable())
{
#endif
Gdiplus::PointF d = Gdiplus::PointF(inDestPoint.GetX(), inDestPoint.GetY());
fPath->AddLine(Gdiplus::PointF(fLastPoint.x,fLastPoint.y), d);
fLastPoint.x = d.X;
fLastPoint.y = d.Y;
#if !GRAPHIC_MIXED_GDIPLUS_D2D
}
#endif
#if ENABLE_D2D
if (VWinD2DGraphicContext::IsAvailable())
{
if (!fGeomSink)
{
Begin();
if (!fGeomSink)
return;
}
fGeomSink->AddLine( D2D1::Point2F( inDestPoint.GetX(), inDestPoint.GetY()));
}
#endif
fPolygon.AddPoint(inDestPoint);
if (fComputeBoundsAccurate)
_addPointToBounds( inDestPoint);
_ComputeBounds();
if (fCreateStorageForCrispEdges)
fDrawCmds.push_back( VGraphicPathDrawCmd( GPDCT_ADD_LINE_TO, inDestPoint));
}
示例12: getFirstOutside
/*!The method uses #_shape1 and #_shape2 structure as an input data and produces
one or more polygons representing the result of the logical ANDNOT between the
input polygons. Method returns false if no output shapes are generated, and
true otherwise*/
bool logicop::logic::ANDNOT(pcollection& plycol) {
bool result = false;
VPoint* centinel = NULL;
if (0 == _crossp) {
// If there are no crossing points found, this still does not mean
// that the operation will fail. Polygons might be overlapping...
// if poly1 is inside poly2, or both are non overlapping ->
// resulting shape is null
// if poly2 is inside poly1, then we have to generate a polygon
// combining both shapes
if (_shape2->inside(_poly1)) {
plycol.push_back(hole2simple(_poly1, _poly2));
return true;
}
else return false;
}
//if crossing points exists, get first external and non crossing point
bool direction;
centinel = getFirstOutside(_poly1, _shape2);
if (NULL == centinel) {
centinel = getFirstOutside(_poly2, _shape1);
direction = false; /*prev*/
}
else direction = true; /*next*/
assert(centinel);
//
VPoint* collector = centinel;
do {
if (0 == collector->visited()) {
pointlist *shgen = new pointlist();
VPoint* pickup = collector;
do {
pickup = pickup->follower(direction, true);
shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y()));
} while (pickup != collector);
plycol.push_back(shgen);
result = true;
}
collector = collector->prev();
} while (collector != centinel);
return result;
}
示例13: IsEqual
/** Returns VTRUE if an existing VPoint object has the same
coordinates as this point, VFALSE otherwise.*/
VBOOL IsEqual(VPoint const& pt) const
{
return (pt.GetX() == m_Point.x && pt.GetY() == m_Point.y)
? VTRUE
: VFALSE;
}
示例14: AddBezierTo
void VGraphicPath::AddBezierTo(const VPoint& inStartControl, const VPoint& inDestPoint, const VPoint& inDestControl)
{
#if !GRAPHIC_MIXED_GDIPLUS_D2D
if (!VWinD2DGraphicContext::IsAvailable())
{
#endif
Gdiplus::PointF d = Gdiplus::PointF(inDestPoint.GetX(), inDestPoint.GetY());
Gdiplus::PointF c1 = Gdiplus::PointF(inStartControl.GetX(), inStartControl.GetY());
Gdiplus::PointF c2 = Gdiplus::PointF(inDestControl.GetX(), inDestControl.GetY());
fPath->AddBezier(Gdiplus::PointF(fLastPoint.x,fLastPoint.y), c1, c2, d);
fLastPoint.x = d.X;
fLastPoint.y = d.Y;
#if !GRAPHIC_MIXED_GDIPLUS_D2D
}
#endif
#if ENABLE_D2D
if (VWinD2DGraphicContext::IsAvailable())
{
if (!fGeomSink)
{
Begin();
if (!fGeomSink)
return;
}
D2D1_POINT_2F c1 = D2D1::Point2F(inStartControl.GetX(), inStartControl.GetY());
D2D1_POINT_2F c2 = D2D1::Point2F(inDestControl.GetX(), inDestControl.GetY());
D2D1_POINT_2F d = D2D1::Point2F(inDestPoint.GetX(), inDestPoint.GetY());
fGeomSink->AddBezier( D2D1::BezierSegment(c1, c2, d));
}
#endif
fPolygon.AddPoint(inDestPoint);
if (fComputeBoundsAccurate)
_addBezierToBounds( inStartControl, inDestControl, inDestPoint);
_ComputeBounds();
fHasBezier = true;
if (fCreateStorageForCrispEdges)
fDrawCmds.push_back( VGraphicPathDrawCmd( GPDCT_ADD_BEZIER_TO, inStartControl, inDestPoint, inDestControl));
}
示例15: inLargeArcFlag
/* add arc to the specified graphic path
@param inCenter
arc ellipse center
@param inDestPoint
dest point of the arc
@param inRX
arc ellipse radius along x axis
@param inRY
arc ellipse radius along y axis
if inRY <= 0, inRY = inRX
@param inLargeArcFlag (default false)
true for draw largest arc
@param inXAxisRotation (default 0.0f)
arc x axis rotation in degree
@remarks
this method add a arc starting from current pos to the dest point
use MeasureArc method to get start & end point from ellipse start & end angle in degree
*/
void VGraphicPath::AddArcTo(const VPoint& inCenter, const VPoint& inDestPoint, GReal _inRX, GReal _inRY, bool inLargeArcFlag, GReal inXAxisRotation)
{
//we need double precision here
Real inRx = _inRX, inRy = _inRY;
Real inX = fLastPoint.x, inY = fLastPoint.y;
Real inEX = inDestPoint.GetX(), inEY = inDestPoint.GetY();
Real sin_th, cos_th;
Real a00, a01, a10, a11;
Real x0, y0, x1, y1, xc, yc;
Real d, sfactor, sfactor_sq;
Real th0, th1, th_arc;
sLONG i, n_segs;
Real dx, dy, dx1, dy1, Pr1, Pr2, Px, Py, check;
inRx = fabs(inRx);
inRy = fabs(inRy);
sin_th = sin(inXAxisRotation * (PI / 180.0));
cos_th = cos(inXAxisRotation * (PI / 180.0));
dx = (inX - inEX) / 2.0;
dy = (inY - inEY) / 2.0;
dx1 = cos_th * dx + sin_th * dy;
dy1 = -sin_th * dx + cos_th * dy;
Pr1 = inRx * inRx;
Pr2 = inRy * inRy;
Px = dx1 * dx1;
Py = dy1 * dy1;
/* Spec : check if radii are large enough */
check = Px / Pr1 + Py / Pr2;
if (check > 1) {
inRx = inRx * sqrt(check);
inRy = inRy * sqrt(check);
}
a00 = cos_th / inRx;
a01 = sin_th / inRx;
a10 = -sin_th / inRy;
a11 = cos_th / inRy;
x0 = a00 * inX + a01 * inY;
y0 = a10 * inX + a11 * inY;
x1 = a00 * inEX + a01 * inEY;
y1 = a10 * inEX + a11 * inEY;
xc = a00 * inCenter.GetX() + a01 * inCenter.GetY();
yc = a10 * inCenter.GetX() + a11 * inCenter.GetY();
/* (x0, y0) is current point in transformed coordinate space.
(x1, y1) is new point in transformed coordinate space.
(xc, yc) is new center in transformed coordinate space.
The arc fits a unit-radius circle in this space.
*/
/*
d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
sfactor_sq = 1.0 / d - 0.25;
if (sfactor_sq < 0) sfactor_sq = 0;
sfactor = sqrt(sfactor_sq);
if (inSweepFlag == inLargeArcFlag) sfactor = -sfactor;
xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);
*/
/* (xc, yc) is center of the circle. */
th0 = atan2(y0 - yc, x0 - xc);
th1 = atan2(y1 - yc, x1 - xc);
th_arc = th1 - th0;
if (th0 <= 0.0 && th1 > 0.0 && fabs(th_arc-PI) <= 0.00001)
th_arc = -th_arc; //ensure we draw counterclockwise if angle delta = 180°
else if (fabs(th_arc)-PI > 0.00001 && !inLargeArcFlag)
{
if (th_arc > 0)
th_arc -= 2 * PI;
else
th_arc += 2 * PI;
}
else if (fabs(th_arc) <= PI && inLargeArcFlag)
{
//.........这里部分代码省略.........