示例#1
0
LightSource::LightSource(GLenum number) {
    _num = number;
    setPosition(0,0,1.0,1.0);
    //setDirection(Vector3(0,0,1));
    setAmbient(0.0, 0.0, 0.0, 1.0);
    setDiffuse(1.0, 1.0, 1.0, 1.0);
    setSpecular(1.0, 1.0, 1.0, 1.0);
    setState(true);
    setExponent(0);
    setCutOff(180);
}
示例#2
0
Spotlight::Spotlight(GLenum number, Vector4 position, Vector4 ambientLight, Vector4 DiffuseLight, Vector4 SpecularLight, GLfloat cutoff, GLfloat exponent, Vector3 direction):
	LightSource(number, position, ambientLight, DiffuseLight, SpecularLight)
{
	setCutOff(cutoff);
	setExponent(exponent);
	setDirection(direction);
	glLightf(GL_LIGHT0 + number, GL_SPOT_CUTOFF, _cut_off);
	glLightf(GL_LIGHT0 + number, GL_SPOT_EXPONENT, _exponent);
	glLightfv(GL_LIGHT0 + number, GL_SPOT_DIRECTION, _direction);

	glLightf(GL_LIGHT0 + number, GL_CONSTANT_ATTENUATION, 0.05);
	glLightf(GL_LIGHT0 + number, GL_LINEAR_ATTENUATION, 0.005);
	glLightf(GL_LIGHT0 + number, GL_QUADRATIC_ATTENUATION, 0.005);
}
示例#3
0
void MainWindow::initializeQMLComponent()
{
    QDeclarativeContext *context = m_view->rootContext();

#if defined(Q_WS_MAEMO_5) || defined(QT_NO_OPENGL)
    // Set UI to low performance mode for Maemo5 and Symbian^1. This mainly
    // disables antialiasing on some performance costly elements.
    context->setContextProperty("lowPerf", true);
#else
    context->setContextProperty("lowPerf", false);
#endif

#ifdef Q_OS_SYMBIAN
    context->setContextProperty("sampleFolder", "file:");
#else
    context->setContextProperty("sampleFolder", QString("file:/") +
                                QDir::currentPath());
#endif

#ifdef Q_WS_MAEMO_6
    // Hide the exit button in Harmattan
    context->setContextProperty("exitButtonVisible", false);
#else
    context->setContextProperty("exitButtonVisible", true);
#endif

    m_view->setSource(QUrl("qrc:/qml/Main.qml"));

    // Create Qt settings object to load / store app settings
    m_settings = new QSettings("Nokia", "DJTurntable");

    // Create Qt objects to handle Turntable and Drum machine
    m_turntable = new Turntable(m_settings, this);
    m_drumMachine = new DrumMachine(m_settings, this);
    m_turntable->addAudioSource(m_drumMachine);

    // Find out the interesting Qt objects of the QML elements
    QObject *turntableQML = dynamic_cast<QObject*>(m_view->rootObject());
    QObject *sampleSelectorQML =
            m_view->rootObject()->findChild<QObject*>("sampleSelector");
    QObject *drumMachineQML =
            m_view->rootObject()->findChild<QObject*>("drumMachine");

    // If there are errors in QML code and the elements does not exist,
    // they won't be found Qt side either, check existance of the elements.
    if (!turntableQML || !sampleSelectorQML || !drumMachineQML) {
        QMessageBox::warning(NULL, "Warning",
                             "Failed to resolve QML elements in main.cpp");
        return;
    }

    // Turntable connections
    connect(turntableQML, SIGNAL(start()),
            m_turntable, SLOT(start()));
    connect(turntableQML, SIGNAL(stop()),
            m_turntable, SLOT(stop()));
    connect(turntableQML, SIGNAL(diskAimSpeed(QVariant)),
            m_turntable, SLOT(setDiscAimSpeed(QVariant)));
    connect(turntableQML, SIGNAL(diskSpeed(QVariant)),
            m_turntable, SLOT(setDiscSpeed(QVariant)));
    connect(turntableQML, SIGNAL(cutOff(QVariant)),
            m_turntable, SLOT(setCutOff(QVariant)));
    connect(turntableQML, SIGNAL(resonance(QVariant)),
            m_turntable, SLOT(setResonance(QVariant)));
    connect(turntableQML, SIGNAL(seekToPosition(QVariant)),
            m_turntable, SLOT(seekToPosition(QVariant)));
    connect(m_turntable, SIGNAL(audioPosition(QVariant)),
            turntableQML, SLOT(audioPosition(QVariant)));
    connect(m_turntable, SIGNAL(powerOff()),
            turntableQML, SLOT(powerOff()));

    // SampleSelector connections
    connect(sampleSelectorQML, SIGNAL(sampleSelected(QVariant)),
            m_turntable, SLOT(setSample(QVariant)));
    connect(sampleSelectorQML, SIGNAL(defaultSample()),
            m_turntable, SLOT(openDefaultSample()));
    connect(m_turntable, SIGNAL(sampleOpened(QVariant)),
            sampleSelectorQML, SLOT(setCurrentSample(QVariant)));
    connect(m_turntable, SIGNAL(error(QVariant, QVariant)),
            sampleSelectorQML, SLOT(showError(QVariant, QVariant)));

    // DrumMachine connections
    connect(drumMachineQML, SIGNAL(startBeat()),
            m_drumMachine, SLOT(startBeat()));
    connect(drumMachineQML, SIGNAL(stopBeat()),
            m_drumMachine, SLOT(stopBeat()));
    connect(drumMachineQML, SIGNAL(setBeat(QVariant)),
            m_drumMachine, SLOT(setBeat(QVariant)));
    connect(drumMachineQML,
            SIGNAL(drumButtonToggled(QVariant, QVariant, QVariant)),
            m_drumMachine,
            SLOT(drumButtonToggled(QVariant, QVariant, QVariant)));
    connect(drumMachineQML, SIGNAL(drumMachineSpeed(QVariant)),
            m_drumMachine, SLOT(setBeatSpeed(QVariant)));
    connect(m_drumMachine,
            SIGNAL(drumButtonState(QVariant, QVariant, QVariant)),
            drumMachineQML,
            SLOT(setDrumButton(QVariant, QVariant, QVariant)));
    connect(m_drumMachine, SIGNAL(tickChanged(QVariant)),
            drumMachineQML, SLOT(highlightTick(QVariant)));

    // Framework connections
    connect((QObject*)m_view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
#ifndef QT_NO_OPENGL
    // Create Qt accelerometer objects
    m_accelerometer = new QAccelerometer(this);
    m_accelerometerFilter = new AccelerometerFilter;
    // Does not take the ownership of the filter
    m_accelerometer->addFilter(m_accelerometerFilter);

    m_accelerometer->setDataRate(50);

    // Create Qt objects for accessing profile information
    m_deviceInfo = new QSystemDeviceInfo(this);
    m_turntable->profile(m_deviceInfo->currentProfile());

    connect(m_accelerometerFilter, SIGNAL(rotationChanged(QVariant)),
            turntableQML, SLOT(inclination(QVariant)));
    connect(m_deviceInfo,
            SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),
            m_turntable,
            SLOT(profile(QSystemDeviceInfo::Profile)));

    // Begin the measuring of the accelerometer sensor
    m_accelerometer->start();
#endif
#endif

    m_turntable->openLastSample();
    m_drumMachine->setBeat(0);
}
SubRouteRequestPacket::SubRouteRequestPacket(const DriverPref* driverPref,
                                             const SubRouteVector* origs,
                                             const OrigDestInfoList* dests,
                                             const OrigDestInfoList* allDests,
                                             bool routeToOneDest,
                                             uint32 cutOff,
                                             int levelDelta,
                                             const DisturbanceVector*
                                             disturbances,
                                             bool calcCostSums,
                                             bool dontSendSubRoutes,
                                             const DisturbanceVector*
                                             infoModuleDists )
{   
   mc2dbg4 << "SubRouteRequestPacket::SubRouteRequestPacket" << endl;
   setPriority(DEFAULT_PACKET_PRIO);
   // Calculate size of request
   // Origins and destinations
  
   // Do something about the listtype
   if ( driverPref->getVehicleRestriction() != ItemTypes::pedestrian ) {
      setListType(SubRouteListTypes::LOWER_LEVEL);
   } else {
      // Pedestrian
      setListType(SubRouteListTypes::LOWER_LEVEL_WALK); // Lower level walk
   }

   uint32 reqSize = SUBROUTE_REQUEST_HEADER_SIZE;

   // The number of subroutes
   int nbrSubRoutes = origs->getSize() +
      // Add the destinations for HIGHER_LEVEL too
    ((getListType() == SubRouteListTypes::HIGHER_LEVEL) ? dests->size() : 0);

   
   // Origin. Will probably be removed
   if ( origs != NULL &&
        getListType() == SubRouteListTypes::HIGHER_LEVEL )
      reqSize += origs->size() * ORIG_DEST_SIZE;
   // Destinations 
   if ( dests != NULL )
      reqSize += dests->size() * ORIG_DEST_SIZE;
   // Subroutes.
   for(uint32 i=0; i < origs->size() ; i++ ) {
      reqSize += SUB_ROUTE_SIZE +
         SUB_ROUTE_CONNECTION_SIZE * 1;
   }

   // Compensate for disturbances
   // Length
   reqSize += 4;
   if ( disturbances != NULL ) {
      reqSize += DISTURBANCE_SIZE*disturbances->size();
   }
   reqSize += 4;
   if ( infoModuleDists != NULL ) {
      reqSize += 8 * infoModuleDists->size();
   }

   if ( reqSize > getBufSize() ) {
      mc2dbg2 << "SubRouteRequestPacket - buffer too small reallocing"
              << endl;
      byte* temp = MAKE_UINT32_ALIGNED_BYTE_BUFFER( reqSize * 2);
      memcpy(temp, this->buffer, SUBROUTE_REQUEST_HEADER_SIZE);      
      delete [] this->buffer;
      this->buffer = temp;
      this->bufSize = reqSize * 2;
   }

   // First request? Won't exactly work all the time...
   bool original = origs->front()->getPrevSubRouteID() == MAX_UINT32;

   if ( levelDelta == 1 ) {
      // Higher level routing - do some tricks
      setMapID( FIRST_OVERVIEWMAP_ID  );
      setListType(SubRouteListTypes::HIGHER_LEVEL);
   }

   //setOriginIP(leaderIP);
   //setOriginPort(leaderPort);
   setSubType(Packet::PACKETTYPE_SUBROUTEREQUEST);
   // Get mapid from one of the origins
   setMapID(origs->front()->getNextMapID() );
   // Setting the extra vehicle to avoid toll roads.
   uint32 extraVehicle = 0;
   if ( driverPref->avoidTollRoads() ) {
      extraVehicle |= ItemTypes::avoidTollRoad;
   }
   if ( driverPref->avoidHighways() ) {
      extraVehicle |= ItemTypes::avoidHighway;
   }
   setVehicleRestrictions( driverPref->getVehicleRestriction() |
                           extraVehicle );
                                                  
   setRoutingCosts(driverPref->getRoutingCosts());
   setUseTurnCost(driverPref->useUturn());
   setTime(driverPref->getTime());
   setMinWaitTime(driverPref->getMinWaitTime());

   // Some flags.
   setRouteToAll(! routeToOneDest );
   setDontSendSubRoutes( dontSendSubRoutes );
   setCalcCostSums( calcCostSums );
      
   setRouteID(0);  // Don't know what it should be. Seems to be the same
                   // as the request id, but for the RouteReader.
   setCutOff(cutOff);
   
   setIsOriginalRequest(original);
   
   // Add the origins that belongs to this mapID and only the first time.
   setNbrOrigins(0);
   int pos = SUBROUTE_REQUEST_HEADER_SIZE;

   if ( original ) {
      for(uint32 i=0; i < origs->getSize(); i++) {
         const SubRoute* curSubRoute = origs->getSubRouteAt(i);
         // Destinations are origins in next route.
         const OrigDestInfo* orig = curSubRoute->getDestInfo();
         addOrigin(*orig, pos);
//           addOrigin(curSubRoute->getNextMapID(),
//                     curSubRoute->getDestNodeID(),
//                     curSubRoute->getDestOffset(),
//                     MAX_UINT32,
//                     MAX_UINT32,
//                     pos);
      }
   }
   
   // Add all destinations ( not allDests, they aren't used yet)
   setNbrDestinations(0);
   OrigDestInfoList::const_iterator it;
   it = dests->begin();
   while ( it != dests->end() ) {
      addDestination(*it, pos);
      it++;
   }

   setNbrSubRoutes( nbrSubRoutes );
   for (uint32 i = 0; i < origs->getSize(); i++) {
      SubRoute* subRoute = (*origs)[i];
      if (subRoute != NULL) {
         addSubRoute(subRoute, pos);
      }
   }

   if ( getListType() == SubRouteListTypes::HIGHER_LEVEL ) {
      OrigDestInfoList::const_iterator it(dests->begin());
      for(uint32 i=0; i < dests->size() ; ++i ) {
         SubRoute subRoute(*it, *it);
         ++it;
         // Add backward subroute for each destination.
         // The routemodule uses them as destinations later.
         addSubRoute(&subRoute, pos, false);
      }
   }
   
   addDisturbances(pos, disturbances);
   // Add info module disturbances using the more compact format.
   addInfoModDisturbances( pos, infoModuleDists );
   setLength(pos);
   
   if ( true || pos > (int)reqSize || (reqSize - pos) > 65536 ) {
      mc2dbg2 << "SubRouteRequestPacket - calcSize = " << reqSize 
           << "real size = " << pos << endl;
   }
} // Constructor