Beispiel #1
0
void Compressor::buildCodeTable(Node *root)
{
    if (root->hasChild())
    {
        code.push_back(0);
        buildCodeTable(root->getChild(true));
        code.pop_back();

        code.push_back(1);
        buildCodeTable(root->getChild(false));
        code.pop_back();
    } else {
        codeTable[root->getLetter()] = code;
    }
}
Beispiel #2
0
void Compressor::compress(const char *filename)
{
    buildCharMap();
    buildCharTree();
    buildCodeTable(charTree);

    ofstream out(filename, ios::out | ios::binary);

    dumpCharMap(out);
    int count = 0, codeSize, i;
    char buf = 0;
    while (!inputFile.eof())
    {
        Code code = codeTable[inputFile.get()];
        codeSize = (int) code.size();
        for(i = 0; i < codeSize; i++)
        {
            buf |= code[i] << (7 - count);
            if (++count == 8)
            {
                out << buf;
                count = buf = NULL;
            }
        }
    }
    if(count > 0) {
        out << buf;
    }
    out.close();
}
Beispiel #3
0
OculusVRDevice::OculusVRDevice()
{
   // From IInputDevice
   dStrcpy(mName, "oculusvr");
   mDeviceType = INPUTMGR->getNextDeviceType();

   //
   mEnabled = false;
   mActive = false;

   // We don't current support scaling of the input texture.  The graphics pipeline will
   // need to be modified for this.
   mScaleInputTexture = false;

   mDeviceManager = NULL;
   mListener = NULL;

   buildCodeTable();
}
LeapMotionDevice::LeapMotionDevice()
{
   // From IInputDevice
   dStrcpy(mName, "leapmotion");
   mDeviceType = INPUTMGR->getNextDeviceType();

   mController = NULL;
   mListener = NULL;
   mActiveMutex = Mutex::createMutex();

   //
   mEnabled = false;
   mActive = false;

   for(U32 i=0; i<2; ++i)
   {
      mDataBuffer[i] = new LeapMotionDeviceData();
   }
   mPrevData = mDataBuffer[0];

   buildCodeTable();
}