CharacterPoint::CharacterPoint( Vec3f _pos, MSA::Physics::World3D * _physics, int _pID ) {
    
    mParticleID     = _pID;
    mPhysic         = _physics;
    mParticle       = NULL;
    
    mParent         = NULL;
    
    mEndOfLine     = true;
    mActive        = false;
    
    mParticleControllerID = -1;
    mStandBondID          = -1;
    
    savePosition    = _pos;
    
    mPosition       = _pos;
    mAnimPos        = mPosition;
    
    mSpacers.clear();
    mChilds.clear();
    mBondIDs.clear();
    
    Physics::Particle3D* p = mPhysic->makeParticle(_pos);        
    p->setMass(4.0f)->setBounce(0.5f)->setRadius(5.0f)->enableCollision()->makeFree();
    
    setParticle();
    calcShellRadius();
    
    mSuperParent = NULL;
    
}
示例#2
0
void initScene() {
	// clear all particles and springs etc
	physics.clear();
	
	// you can add your own particles to the physics system
	physics.addParticle(&mouseNode);
	mouseNode.makeFixed();
	mouseNode.setMass(MIN_MASS);
	mouseNode.moveTo(Vec3f(0, 0, 0));
	mouseNode.setRadius(NODE_MAX_RADIUS);
	
	// or tell the system to create and add particles
	physics.makeParticle(Vec3f(-width/4, 0, -width/4), MIN_MASS)->makeFixed();		// create a node in top left back and fix
	physics.makeParticle(Vec3f( width/4, 0, -width/4), MIN_MASS)->makeFixed();		// create a node in top right back and fix
	physics.makeParticle(Vec3f(-width/4, 0,  width/4), MIN_MASS)->makeFixed();		// create a node in top left front and fix
	physics.makeParticle(Vec3f( width/4, 0,  width/4), MIN_MASS)->makeFixed();		// create a node in top right front and fix
}
示例#3
0
void addRandomParticle() {
	float posX		= ofRandom(-width/2, width/2);
	float posY		= ofRandom(0, height);
	float posZ		= ofRandom(-width/2, width/2);
	float mass		= ofRandom(MIN_MASS, MAX_MASS);
	float bounce	= ofRandom(MIN_BOUNCE, MAX_BOUNCE);
	float radius	= ofMap(mass, MIN_MASS, MAX_MASS, NODE_MIN_RADIUS, NODE_MAX_RADIUS);
	
	// physics.makeParticle returns a particle pointer so you can customize it
	Physics::Particle3D *p = physics.makeParticle(Vec3f(posX, posY, posZ));
	
	// and set a bunch of properties (you don't have to set all of them, there are defaults)
	p->setMass(mass)->setBounce(bounce)->setRadius(radius)->enableCollision()->makeFree();
	
	// add an attraction to the mouseNode
	if(mouseAttract) physics.makeAttraction(&mouseNode, p, ofRandom(MIN_ATTRACTION, MAX_ATTRACTION));
}
示例#4
0
//--------------------------------------------------------------
void testApp::keyPressed  (int key){
	switch(key) {
		case 'a': toggleMouseAttract(); break;
		case 'p': for(int i=0; i<100; i++) addRandomParticle(); break;
		case 'P': for(int i=0; i<100; i++) killRandomParticle(); break;
		case 's': addRandomSpring(); break;
		case 'S': killRandomSpring(); break;
		case 'c': physics.isCollisionEnabled() ? physics.disableCollision() : physics.enableCollision(); break;
		case 'C': killRandomConstraint(); break;
		case 'r': doRender ^= true; break;
		case 'f': addRandomForce(FORCE_AMOUNT); break;
		case 'F': addRandomForce(FORCE_AMOUNT * 3); break;
		case 'l': lockRandomParticles(); break;
		case 'u': unlockRandomParticles(); break;
		case ' ': initScene(); break;
		case 'x': doMouseXY = true; break;
		case 'z': doMouseYZ = true; break;
		case ']': rotSpeed += 0.01f; break;
		case '[': rotSpeed -= 0.01f; break;
		case '+': mouseNode.setMass(mouseNode.getMass() +0.1); break;
		case '-': mouseNode.setMass(mouseNode.getMass() -0.1); break;
		case 'm': mouseNode.hasCollision() ? mouseNode.disableCollision() : mouseNode.enableCollision();
	}
}