Same problem. I just have XP SP3 running under a VM.
A video of the issue might be just as good if you can make one of those easily.
+ (void)initialize
{
static BOOL done = FALSE;
if(done) return;
demos = [[NSArray alloc] initWithObjects:
[OneWay class],
[Tumble class],
[TheoJansen class],
[Springies class],
// [PyramidTopple class],
[Joints class],
[Bounce class],
[PyramidStack class],
[Plink class],
[Planet class],
[Sensors class],
[Tank class],
nil
];
done = TRUE;
}
#import "ChipmunkDemo.h"
static ChipmunkBody *tankBody;
static ChipmunkBody *tankControlBody;
static cpFloat frand(void){return (cpFloat)rand()/(cpFloat)RAND_MAX;}
@implementation Tank
-(void)update
{
for(int i=0; i<refTicks; i++){
// turn the control body based on the angle relative to the actual body
cpVect mouseDelta = cpvsub(mousePoint, tankBody.pos);
cpFloat turn = cpvtoangle(cpvunrotate(tankBody.rot, mouseDelta));
[tankControlBody setAngle: tankBody.angle - turn];
// drive the tank towards the mouse
if(cpvnear(mousePoint, tankBody.pos, 30.0)){
tankControlBody.vel = cpvzero; // stop
} else {
cpFloat direction = (cpvdot(mouseDelta, tankBody.rot) > 0.0 ? 1.0 : -1.0);
tankControlBody.vel = cpvrotate(tankBody.rot, cpv(30.0f*direction, 0.0f));
}
}
[super update];
}
static cpVect
rand_pos(cpFloat radius)
{
cpVect v;
do {
v = cpv(frand()*(640 - 2*radius) - (320 - radius), frand()*(480 - 2*radius) - (240 - radius));
} while(cpvlength(v) < 100.0f);
return v;
}
- (ChipmunkBody*)addBox:(cpFloat) size withMass:(cpFloat) mass
{
cpVect verts[] = {
cpv(-size,-size),
cpv(-size, size),
cpv( size, size),
cpv( size,-size),
};
cpFloat radius = cpvlength(cpv(size, size));
ChipmunkBody *body = [space add:[ChipmunkBody bodyWithMass:mass andMoment: cpMomentForPoly(mass, 4, verts, cpvzero)]];
body.pos = rand_pos(radius);//cpv(frand()*(640 - 2*radius) - (320 - radius), frand()*(480 - 2*radius) - (240 - radius));
ChipmunkShape *shape = [space add:[ChipmunkPolyShape polyWithBody:body count:4 verts:verts offset:cpvzero]];
shape.elasticity = 0.0f; shape.friction = 0.7f;
return body;
}
- (void)setupSpace
{
space = [[ChipmunkSpace alloc] init];
ChipmunkBody *staticBody = [space add:[ChipmunkBody staticBody]];// = cpBodyNew(INFINITY, INFINITY);
[space resizeActiveHashWithDim:30.0f andCount:1000];
space.iterations = 10;
ChipmunkShape *shape;
// Create segments around the edge of the screen.
shape = [space add: [ChipmunkStaticSegmentShape segmentWithBody:staticBody from:cpv(-320,-240) to:cpv(-320,240) radius:0.0f]];
shape.elasticity = 1.0f; shape.friction = 1.0f;
shape.layers = NOT_GRABABLE_MASK;
shape = [space add: [ChipmunkStaticSegmentShape segmentWithBody:staticBody from: cpv(320,-240) to: cpv(320,240) radius:0.0f]];
shape.elasticity = 1.0f; shape.friction = 1.0f;
shape.layers = NOT_GRABABLE_MASK;
shape = [space add: [ChipmunkStaticSegmentShape segmentWithBody:staticBody from: cpv(-320,-240) to: cpv(320,-240) radius:0.0f]];
shape.elasticity = 1.0f; shape.friction = 1.0f;
shape.layers = NOT_GRABABLE_MASK;
shape = [space add: [ChipmunkStaticSegmentShape segmentWithBody:staticBody from: cpv(-320,240) to: cpv(320,240) radius:0.0f]];
shape.elasticity = 1.0f; shape.friction = 1.0f;
shape.layers = NOT_GRABABLE_MASK;
ChipmunkBody* body;
for(int i=0; i<50; i++){
body = [self addBox: 10.0f withMass:1.0f];
ChipmunkConstraint *pivot = [space add:[ChipmunkPivotJoint pivotJointWithBodyA:staticBody bodyB:body anchr1:cpvzero anchr2:cpvzero ]];
pivot.biasCoef = 0.0f; // disable joint correction
pivot.maxForce = 1000.0f; // emulate linear friction
ChipmunkGearJoint *gear = [space add:[ChipmunkGearJoint gearJointWithBodyA:staticBody bodyB:body phase:0.0f ratio:1.0f ]];
gear.biasCoef = 0.0f; // disable joint correction
gear.maxForce = 5000.0f; // emulate angular friction
}
// We joint the tank to the control body and control the tank indirectly by modifying the control body.
tankControlBody = [space add:[ChipmunkBody staticBody]];
tankBody = [self addBox: 15.0f withMass:10.0f];
ChipmunkConstraint *pivot = [space add:[ChipmunkPivotJoint pivotJointWithBodyA:tankControlBody bodyB:tankBody anchr1:cpvzero anchr2:cpvzero ]];
pivot.biasCoef = 0.0f; // disable joint correction
pivot.maxForce = 10000.0f; // emulate linear friction
ChipmunkGearJoint *gear = [space add:[ChipmunkGearJoint gearJointWithBodyA:tankControlBody bodyB:tankBody phase:0.0f ratio:1.0f ]];
gear.biasCoef = 1.0f; // limit angular correction rate
gear.maxBias = 1.0f; // limit angular correction rate
gear.maxForce = 500000.0f; // emulate angular friction
}
@end
Users browsing this forum: Google [Bot] and 2 guests