void HapticDevice::resetThrow(){ m_Thrown = NULL; m_thrownObjects = NULL; m_thrownRigids = NULL; m_caught = NULL; clearTrajectory(); m_selectedDistance = Distance_max*2; m_freeT = false; }
//Calculate the trajectory from the positon of this spaceship to the global point void Spaceship::calculateTrajectory(sf::Vector2f globalTarget, sf::Time dt, sf::Time maxTime) { sf::Vector2f target = globalTarget - getWorldPosition(); this->target = globalTarget; sf::Vector2f position(0, 0); sf::Vector2f velocity = getVelocity(); sf::Time accumulatedTime = sf::Time::Zero; clearTrajectory(); trajectory->add(getWorldPosition()); //Integrate the trajectory while(accumulatedTime < maxTime) { sf::Vector2f diff = target-position; velocity += normalize((target-position))*deltaV*dt.asSeconds(); if(sqrt(velocity.x*velocity.x+velocity.y*velocity.y) > maxV) velocity = normalize(velocity)*maxV; position += velocity*dt.asSeconds(); trajectory->add(getWorldPosition()+position); accumulatedTime += dt; } }
void initializeTrajectory(void) { clearTrajectory(); }
void initializeTrajectory() { width = WHEELS_DISTANCE; clearTrajectory(); }