std::string InputOutputException::get_message(ModelObject *o) const { std::ostringstream oss; switch (get_entity()) { case DERIVATIVE: if (o->get_model()->get_stage() == BEFORE_EVALUATING) { oss << "Derivatives cannot be read before evaluating."; break; } default: switch (get_operation()) { case GET: oss << "Not in input list."; break; case SET: case ADD: case REMOVE: oss << "Not in output list."; break; default: // should not exist oss << "Unknown read/write error"; } break; }; oss << " Violating object: \"" << o->get_name() << "\"."; if (particle_index_ >= 0) { oss << " Attribute " << get_key_name() << " of particle \"" << o->get_model() ->get_particle(ParticleIndex(get_particle_index())) ->get_name() << "\" with id " << get_particle_index(); } else { oss << "Container \"" << container_name_ << "\"."; } return oss.str(); }
virtual void particleCollision(const ParticleGeometryCollisionEventUnrecPtr ColE) { ParticleSystemRefPtr TheSystem= ColE->getSystem(); UInt32 ParticleIndex(ColE->getParticleIndex()); Vec3f Reflect(TheSystem->getVelocity(ParticleIndex).reflect(ColE->getHitNormal())); TheSystem->setVelocity(Reflect, ParticleIndex); TheSystem->setPosition(ColE->getHitPoint() + (0.00001f*Reflect), ParticleIndex); }
void particleCollision(ParticleGeometryCollisionEventDetails* const details) { ParticleSystemRefPtr TheSystem= details->getSystem(); UInt32 ParticleIndex(details->getParticleIndex()); Real32 phi= osgACos((-TheSystem->getVelocity(ParticleIndex).dot(details->getHitNormal()))/(TheSystem->getVelocity(ParticleIndex).length()*details->getHitNormal().length())); if( phi < osgDegree2Rad(80.0) ) { TheSystem->killParticle(ParticleIndex); } else { //Reflect the Particle Vec3f Reflect(TheSystem->getVelocity(ParticleIndex).reflect(details->getHitNormal())); TheSystem->setVelocity(Reflect, ParticleIndex); TheSystem->setPosition(details->getHitPoint() + (0.00001f*Reflect), ParticleIndex); } }