• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cpConstraintInit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cpConstraintInit函数的典型用法代码示例。如果您正苦于以下问题:C++ cpConstraintInit函数的具体用法?C++ cpConstraintInit怎么用?C++ cpConstraintInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cpConstraintInit函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: cpPulleyJointInit

cpPulleyJoint *
cpPulleyJointInit(cpPulleyJoint *joint,
				  cpBody* a, cpBody* b, cpBody* c,
				  cpVect anchor1, cpVect anchor2,
				  cpVect anchor3a, cpVect anchor3b,
				  cpFloat ratio)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->c = c;
	joint->anchr3a = anchor3a;
	joint->anchr3b = anchor3b;
	joint->anchr1 = anchor1;
	joint->anchr2 = anchor2;
	cpVect d1 = cpvsub(cpBodyLocal2World(a, anchor1), cpBodyLocal2World(c, anchor3a));
	cpVect d2 = cpvsub(cpBodyLocal2World(b, anchor2), cpBodyLocal2World(c, anchor3b));
	joint->dist1 = cpvlength(d1);
	joint->dist2 = cpvlength(d2);
	joint->ratio = ratio;
	
	cpAssert(ratio != 0.0f, "Pulley Ratio is Zero");
	
	// Calculate max and constant
	joint->constant = joint->dist1 + ratio * joint->dist2;
	joint->max1 = joint->constant - ratio * cp_min_pulley_len;
	joint->max2 = (joint->constant - cp_min_pulley_len) / joint->ratio;
	
	// Initialize
	joint->jnAcc = 0.0f;
	joint->jnAccLim1 = 0.0f;
	joint->jnAccLim2 = 0.0f;
	
	return joint;
}
开发者ID:Morrok123,项目名称:Toss-Blocks,代码行数:34,代码来源:cpPulleyJoint.c


示例2: cpSimpleMotorInit

cpSimpleMotor *
cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->rate = rate;
	
	joint->jAcc = 0.0f;
	
	return joint;
}
开发者ID:Avizzv92,项目名称:WreckingBall,代码行数:11,代码来源:cpSimpleMotor.c


示例3: cpDampedRotarySpringInit

cpDampedRotarySpring *
cpDampedRotarySpringInit(cpDampedRotarySpring *spring, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping)
{
	cpConstraintInit((cpConstraint *)spring, &cpDampedRotarySpringClass, a, b);
	
	spring->restAngle = restAngle;
	spring->stiffness = stiffness;
	spring->damping = damping;
	
	return spring;
}
开发者ID:galexcode,项目名称:StervoxyTanks,代码行数:11,代码来源:cpDampedRotarySpring.c


示例4: cpRotaryLimitJointInit

cpRotaryLimitJoint *
cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->min = min;
	joint->max  = max;
	
	joint->jAcc = 0.0f;
	
	return joint;
}
开发者ID:Binglin,项目名称:UIKitPlusCocos2dx,代码行数:12,代码来源:cpRotaryLimitJoint.c


示例5: cpPivotJointInit

cpPivotJoint *
cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->anchr1 = anchr1;
	joint->anchr2 = anchr2;
	
	joint->jAcc = cpvzero;
	
	return joint;
}
开发者ID:6311879,项目名称:LearnCocos2D,代码行数:12,代码来源:cpPivotJoint.c


示例6: cpDampedRotarySpringInit

cpDampedRotarySpring *
cpDampedRotarySpringInit(cpDampedRotarySpring *spring, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping)
{
	cpConstraintInit((cpConstraint *)spring, &klass, a, b);
	
	spring->restAngle = restAngle;
	spring->stiffness = stiffness;
	spring->damping = damping;
	spring->springTorqueFunc = (cpDampedRotarySpringTorqueFunc)defaultSpringTorque;
	
	return spring;
}
开发者ID:davidmorford,项目名称:GameBuildKit,代码行数:12,代码来源:cpDampedRotarySpring.c


示例7: cpPivotJointInit

cpPivotJoint *
cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->anchorA = anchorA;
	joint->anchorB = anchorB;
	
	joint->jAcc = cpvzero;
	
	return joint;
}
开发者ID:cxuhua,项目名称:cxengine,代码行数:12,代码来源:cpPivotJoint.c


示例8: cpGearJointInit

cpGearJoint *
cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->phase = phase;
	joint->ratio = ratio;
	joint->ratio_inv = 1.0f/ratio;
	
	joint->jAcc = 0.0f;
	
	return joint;
}
开发者ID:Annovae,项目名称:karakuri,代码行数:13,代码来源:cpGearJoint.c


示例9: cpOscillatingMotorInit

cpOscillatingMotor *
cpOscillatingMotorInit(cpOscillatingMotor *joint, cpBody *a, cpBody *b, cpFloat frequency, cpFloat amplitude, cpFloat phaseShift)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->frequency = frequency;
	joint->amplitude = amplitude;
	joint->phaseShift = phaseShift;
	joint->t = 0.0f;
	joint->jAcc = 0.0f;
	
	return joint;
}
开发者ID:DanGoldbach,项目名称:humperdink,代码行数:13,代码来源:cpOscillatingMotor.c


示例10: cpRatchetJointInit

cpRatchetJoint *
cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->angle = 0.0f;
	joint->phase = phase;
	joint->ratchet = ratchet;
	
	joint->angle = b->a - a->a;
	
	return joint;
}
开发者ID:Avant-Flux,项目名称:chipmunk,代码行数:13,代码来源:cpRatchetJoint.c


示例11: cpSlideJointInit

cpSlideJoint *
cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->anchr1 = anchr1;
	joint->anchr2 = anchr2;
	joint->min = min;
	joint->max = max;
	
	joint->jnAcc = 0.0f;
	
	return joint;
}
开发者ID:johnstorm,项目名称:pur,代码行数:14,代码来源:cpSlideJoint.c


示例12: cpPivotJointInit

cpPivotJoint *
cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
//	joint->anchr1 = cpvunrotate(cpvsub(pivot, a->p), a->rot);
//	joint->anchr2 = cpvunrotate(cpvsub(pivot, b->p), b->rot);
	joint->anchr1 = anchr1;
	joint->anchr2 = anchr2;
	
	joint->jAcc = cpvzero;
	
	return joint;
}
开发者ID:Annovae,项目名称:karakuri,代码行数:14,代码来源:cpPivotJoint.c


示例13: cpRatchetJointInit

cpRatchetJoint *
cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->angle = 0.0f;
	joint->phase = phase;
	joint->ratchet = ratchet;
	
	// STATIC_BODY_CHECK
	joint->angle = (b ? b->a : 0.0f) - (a ? a->a : 0.0f);
	
	return joint;
}
开发者ID:JulianSpillane,项目名称:moai-dev,代码行数:14,代码来源:cpRatchetJoint.c


示例14: cpGrooveJointInit

cpGrooveJoint *
cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->grv_a = groove_a;
	joint->grv_b = groove_b;
	joint->grv_n = cpvperp(cpvnormalize(cpvsub(groove_b, groove_a)));
	joint->anchorB = anchorB;
	
	joint->jAcc = cpvzero;
	
	return joint;
}
开发者ID:cxuhua,项目名称:cxengine,代码行数:14,代码来源:cpGrooveJoint.c


示例15: cpDampedSpringInit

cpDampedSpring *
cpDampedSpringInit(cpDampedSpring *spring, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping)
{
	cpConstraintInit((cpConstraint *)spring, cpDampedSpringGetClass(), a, b);
	
	spring->anchr1 = anchr1;
	spring->anchr2 = anchr2;
	
	spring->restLength = restLength;
	spring->stiffness = stiffness;
	spring->damping = damping;
	spring->springForceFunc = (cpDampedSpringForceFunc)defaultSpringForce;
	
	return spring;
}
开发者ID:presentcreative,项目名称:TI,代码行数:15,代码来源:cpDampedSpring.c


示例16: cpPinJointInit

cpPinJoint *
cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->anchr1 = anchr1;
	joint->anchr2 = anchr2;
	
	// STATIC_BODY_CHECK
	cpVect p1 = (a ? cpvadd(a->p, cpvrotate(anchr1, a->rot)) : anchr1);
	cpVect p2 = (b ? cpvadd(b->p, cpvrotate(anchr2, b->rot)) : anchr2);
	joint->dist = cpvlength(cpvsub(p2, p1));

	joint->jnAcc = 0.0f;
	
	return joint;
}
开发者ID:ccjimmy,项目名称:TweeJump4wp8,代码行数:17,代码来源:cpPinJoint.c


示例17: cpPinJointInit

cpPinJoint *
cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB)
{
	cpConstraintInit((cpConstraint *)joint, &klass, a, b);
	
	joint->anchorA = anchorA;
	joint->anchorB = anchorB;
	
	// STATIC_BODY_CHECK
	cpVect p1 = (a ? cpTransformPoint(a->transform, anchorA) : anchorA);
	cpVect p2 = (b ? cpTransformPoint(b->transform, anchorB) : anchorB);
	joint->dist = cpvlength(cpvsub(p2, p1));
	
	cpAssertWarn(joint->dist > 0.0, "You created a 0 length pin joint. A pivot joint will be much more stable.");

	joint->jnAcc = 0.0f;
	
	return joint;
}
开发者ID:00dazam,项目名称:FlappyBird-SpriteBuilder,代码行数:19,代码来源:cpPinJoint.c


示例18: cpPinJointInit

cpPinJoint *
cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2)
{
    cpConstraintInit((cpConstraint *)joint, &klass, a, b);
    
    joint->anchr1 = anchr1;
    joint->anchr2 = anchr2;
    
    // STATIC_BODY_CHECK
    cpVect p1 = (a ? cpvadd(a->p, cpvrotate(anchr1, a->rot)) : anchr1);
    cpVect p2 = (b ? cpvadd(b->p, cpvrotate(anchr2, b->rot)) : anchr2);
    joint->dist = cpvlength(cpvsub(p2, p1));
    
    cpAssertWarn(joint->dist > 0.0, "You created a 0 length pin joint. A pivot joint will be much more stable.");

    joint->jnAcc = 0.0f;
    
    return joint;
}
开发者ID:haiweizhang,项目名称:MyCocos2d-xV2.0,代码行数:19,代码来源:cpPinJoint.c



注:本文中的cpConstraintInit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cpSegmentShapeNew函数代码示例发布时间:2022-05-30
下一篇:
C++ cpCircleShapeNew函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap