当前位置: 首页>>代码示例>>C++>>正文


C++ cpConstraintInit函数代码示例

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


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


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