// Method definitions BridgeDemo::BridgeDemo() : MassAggregateApplication(12), cables(0), supports(0), rods(0), massPos(0,0,0.5f) { // Create the masses and connections. for (unsigned i = 0; i < 12; i++) { unsigned x = (i%12)/2; particleArray[i].setPosition( cyclone::real(i/2)*2.0f-5.0f, 4, cyclone::real(i%2)*2.0f-1.0f ); particleArray[i].setVelocity(0,0,0); particleArray[i].setDamping(0.9f); particleArray[i].setAcceleration(cyclone::Vector3::GRAVITY); particleArray[i].clearAccumulator(); } // Add the links cables = new cyclone::ParticleCable[CABLE_COUNT]; for (unsigned i = 0; i < 10; i++) { cables[i].particle[0] = &particleArray[i]; cables[i].particle[1] = &particleArray[i+2]; cables[i].maxLength = 1.9f; cables[i].restitution = 0.3f; world.getContactGenerators().push_back(&cables[i]); } supports = new cyclone::ParticleCableConstraint[SUPPORT_COUNT]; for (unsigned i = 0; i < SUPPORT_COUNT; i++) { supports[i].particle = particleArray+i; supports[i].anchor = cyclone::Vector3( cyclone::real(i/2)*2.2f-5.5f, 6, cyclone::real(i%2)*1.6f-0.8f ); if (i < 6) supports[i].maxLength = cyclone::real(i/2)*0.5f + 3.0f; else supports[i].maxLength = 5.5f - cyclone::real(i/2)*0.5f; supports[i].restitution = 0.5f; world.getContactGenerators().push_back(&supports[i]); } rods = new cyclone::ParticleRod[ROD_COUNT]; for (unsigned i = 0; i < 6; i++) { rods[i].particle[0] = &particleArray[i*2]; rods[i].particle[1] = &particleArray[i*2+1]; rods[i].length = 2; world.getContactGenerators().push_back(&rods[i]); } updateAdditionalMass(); }
// Method definitions PlatformDemo::PlatformDemo() : MassAggregateApplication(6), rods(0), massPos(0,0,0.5f) { // Create the masses and connections. particleArray[0].setPosition(0,0,1); particleArray[1].setPosition(0,0,-1); particleArray[2].setPosition(-3,2,1); particleArray[3].setPosition(-3,2,-1); particleArray[4].setPosition(4,2,1); particleArray[5].setPosition(4,2,-1); for (unsigned i = 0; i < 6; i++) { particleArray[i].setMass(BASE_MASS); particleArray[i].setVelocity(0,0,0); particleArray[i].setDamping(0.9f); particleArray[i].setAcceleration(cyclone::Vector3::GRAVITY); particleArray[i].clearAccumulator(); } rods = new cyclone::ParticleRod[ROD_COUNT]; rods[0].particle[0] = &particleArray[0]; rods[0].particle[1] = &particleArray[1]; rods[0].length = 2; rods[1].particle[0] = &particleArray[2]; rods[1].particle[1] = &particleArray[3]; rods[1].length = 2; rods[2].particle[0] = &particleArray[4]; rods[2].particle[1] = &particleArray[5]; rods[2].length = 2; rods[3].particle[0] = &particleArray[2]; rods[3].particle[1] = &particleArray[4]; rods[3].length = 7; rods[4].particle[0] = &particleArray[3]; rods[4].particle[1] = &particleArray[5]; rods[4].length = 7; rods[5].particle[0] = &particleArray[0]; rods[5].particle[1] = &particleArray[2]; rods[5].length = 3.606; rods[6].particle[0] = &particleArray[1]; rods[6].particle[1] = &particleArray[3]; rods[6].length = 3.606; rods[7].particle[0] = &particleArray[0]; rods[7].particle[1] = &particleArray[4]; rods[7].length = 4.472; rods[8].particle[0] = &particleArray[1]; rods[8].particle[1] = &particleArray[5]; rods[8].length = 4.472; rods[9].particle[0] = &particleArray[0]; rods[9].particle[1] = &particleArray[3]; rods[9].length = 4.123; rods[10].particle[0] = &particleArray[2]; rods[10].particle[1] = &particleArray[5]; rods[10].length = 7.28; rods[11].particle[0] = &particleArray[4]; rods[11].particle[1] = &particleArray[1]; rods[11].length = 4.899; rods[12].particle[0] = &particleArray[1]; rods[12].particle[1] = &particleArray[2]; rods[12].length = 4.123; rods[13].particle[0] = &particleArray[3]; rods[13].particle[1] = &particleArray[4]; rods[13].length = 7.28; rods[14].particle[0] = &particleArray[5]; rods[14].particle[1] = &particleArray[0]; rods[14].length = 4.899; for (unsigned i = 0; i < ROD_COUNT; i++) { world.getContactGenerators().push_back(&rods[i]); } updateAdditionalMass(); }
void BridgeDemo::update() { MassAggregateApplication::update(); updateAdditionalMass(); }
void PlatformDemo::update() { MassAggregateApplication::update(); updateAdditionalMass(); }