LightTrail::LightTrail(std::shared_ptr<World> _world,
                       std::shared_ptr<const Shader> _shader,
                       glm::vec3 _colour,
                       TurnDirection turning,
                       Accelerating accelerating)
    : world(_world), shader(_shader), colour(_colour),
      stopping(false), isStopped(false)
{
    state = calculateState(turning, accelerating);
}
Exemple #2
0
void CalBone::setCoreState()
{
   // set the bone to the initial skeleton state
   setCoreTransformStateVariables();

   // set the appropriate weights
   m_accumulatedWeightAbsolute = 1.0f;
   m_accumulatedWeight = 1.0f ;

   calculateState() ;
}
Exemple #3
0
void CalBone::setCoreState()
{
   // set the bone to the initial skeleton state
   m_translation = m_pCoreBone->getTranslation();
   m_rotation = m_pCoreBone->getRotation();

   // set the appropriate weights
   m_accumulatedWeightAbsolute = 1.0f;
   m_accumulatedWeight = 1.0f ;

   calculateState() ;
}
Exemple #4
0
void CalBone::setCoreStateRecursive()
{
  // set the bone to the initial skeleton state
  m_translation = m_pCoreBone->getTranslation();
  m_rotation = m_pCoreBone->getRotation();

  // set the appropriate weights
  m_accumulatedWeightAbsolute = 1.0f;
  m_accumulatedWeight = 1.0f ;

  // set core state for all child bones
  std::list<int>::iterator iteratorChildId;
  for(iteratorChildId = m_pCoreBone->getListChildId().begin(); iteratorChildId != m_pCoreBone->getListChildId().end(); ++iteratorChildId)
  {
    m_pSkeleton->getBone(*iteratorChildId)->setCoreStateRecursive();
  }

  calculateState() ;
}
void LightTrail::update(TurnDirection turning, Accelerating accelerating, float speed, glm::vec3 currentLocation, float currentAngleRads)
{
    // are we stopping? if so fade down until we are dead
    if (stopping)
    {
#ifndef DEBUG_STOP_TRAILS_FADING
        bool changedSomething = false;
        for (auto &v : lightTrailMeshData.vertices)
        {
            if (v.y > 0.05f)
            {
                v.y -= 0.05f;
                changedSomething = true;
            }
        }
        if (!changedSomething)
        {
            isStopped = true;
        }

        // nothing more to do, as we are stopping
        lightTrailObjData->updateMesh(lightTrailMeshData);
        lightTrailObjData->updateBuffers();
#endif
        return;
    }

    // check if we have an object and object data ptrs
    // if not create them and the initial face
    if (!lightTrailObjData || !lightTrailObj)
    {
        createObject(currentLocation, currentAngleRads);
    }

    // create initial path segment if needed
    if (pathSegments.size() == 0)
    {
        createNewPathSegment(speed, currentLocation, currentAngleRads);
    }

    // deal with turning
    // this creates new faces and sorts out normals
    // so that our curves are smooth
    if (turning != NO_TURN)
    {
        turn(currentAngleRads, (state == STATE_STRAIGHT));
    }
    else if (state != STATE_STRAIGHT)
    {
        stopTurning();
    }

    // update last vertices to be current bike location
    updateLastVertices(currentLocation);

    // calculate new state
    State newState = calculateState(turning, accelerating);

    // update current path segment
    pathSegments.back()->update(glm::vec2(currentLocation.x, currentLocation.z), currentAngleRads);

    if (state != newState)
    {
        state = newState;
        createNewPathSegment(speed, currentLocation, currentAngleRads);
    }

    lightTrailObjData->updateMesh(lightTrailMeshData);
    lightTrailObjData->updateBuffers();
}