void HerosSprite::animate(float elapsedTime)
{
    updateAnimation(elapsedTime);

    reInit();
}
Example #2
0
/**
 * Record a trace, this is a blocking function.
 * Use the ext interupt 0 and 1.
 * Use the timer 1.
 */
uchar* recordTrace(int *size) {
    uchar charIndex = 0;
    uchar charBuffer;

    uint state = STATE_BEGINING;

    uchar i = 0;
    uchar t0 = (uchar) 0x00;
    uint tmpEtu = NO_ETU_CHANGE;
    uchar protocol;
    uchar convention;

    convention = CONVENTION_DIRECTE;
    protocol = PROTOCOL_T0;

    initialiseInterupt();

    if(!waitForIO())
    {
        reInit();
        return NULL;
    }

    /* Configure the interupt on IO to answer on each falling edge*/
    ConfigINT2(EXT_INT_ENABLE | FALLING_EDGE_INT | EXT_INT_PRI_1);

    /* Configure the warm reset to trigger on falling edge*/
    ConfigINT1(EXT_INT_ENABLE | FALLING_EDGE_INT | EXT_INT_PRI_1);

    while( (STATE_TERMINATED != state))
    {
        state = getState();
        if( (isData() > 0) && dataIndex < DATA_SIZE)
        {
            charBuffer = 0x00;
            for(charIndex = 0 ; charIndex < 8 ; charIndex++ )
            {
                if(CONVENTION_INVERSE == convention)
                {
                    charBuffer ^= (getAcq() << (7-charIndex));
                }
                else if(CONVENTION_DIRECTE == convention)
                {
                    charBuffer ^= (getAcq() << charIndex);
                }
            }
            if(CONVENTION_INVERSE == convention)
            {
                charBuffer = 0xff ^ charBuffer;
            }
            dataArray[dataIndex] = charBuffer;

            dataIndex++;
            clearFlag();

            if(STATE_TS == state)
            {
                if((uchar) 0x3b == charBuffer)
                {
                    convention = CONVENTION_DIRECTE;
                }

                /* 0x03 is the way the byte 3f will be read with the tool
                 * For information, by default the Direct convention is used
                 * so we don't see directly the byte 3F but the byte 3f coded
                 * in direct convention = 0x03 */
                if((uchar) 0x03 == charBuffer)
                {
                    convention = CONVENTION_INVERSE;
                    dataArray[dataIndex-1] = 0x3f;
                }

                setState(STATE_T0);
            }
            else if(STATE_T0 == state)
            {
                t0 = charBuffer;
                setState(STATE_ATR);
            } /*Then we treats TAx, TBx, TCx, TDx,... and finaly hist bytes */
            else if(0 < (t0 & 0x10) )
            {
                t0 = t0 ^ 0x10;
                /* It's a TAx */
                if(0 == i) /* It's Ta1*/
                {
                    /*Configuring the new ATR value*/
                    tmpEtu = computeEtu(charBuffer);
                }
            }
            else if(0 < (t0 & 0x20) )
            {
                /*It's a TBx*/
                t0 = t0 ^ 0x20;
            }
            else if(0 < (t0 & 0x40) )
            {
                /*It's a TCx*/
                t0 = t0 ^ 0x40;
            }
            else if(0 < (t0 & 0x80) )
            {
                /*It's a TDx*/
                t0 = t0 ^ 0x80;
                /* t0 is only compose of the historical bytes We verify if
                 the TD bytes implies other bytes*/
                t0 ^= (charBuffer & 0xf0);
                i++;

                /* We also verify if it's a T=1 protocol */
                if( ((uchar) 0x01) == ((uchar) charBuffer ^ 0x01) )
                {
                    /*It's a t=1 card set the value to T=1*/
                    protocol = PROTOCOL_T1;
                }

            }
            else if(0 < (t0 & 0x0F))
            {
                /* This is historical bytes */
                t0--;
                if(t0 == 0)
                {
                    if(PROTOCOL_T1 == protocol)
                    {
                        setState(STATE_ATR_CRC);
                    }
                    else
                    {
                        setState(STATE_PROCESSING);
                        fixEtu(tmpEtu);
                    }
                }
            }
            else if(STATE_ATR_CRC == state) {
                setState(STATE_PROCESSING);
                fixEtu(tmpEtu);
            }
        }/*end of if(isData() > 0 )*/
        else if(STATE_RESET == getState()) {
            charIndex = 0;
            convention = CONVENTION_DIRECTE;
            warmAtrOffset = dataIndex;
            t0 = 0x00;
            setState(STATE_BEGINING);
        }
        if( !isData() && !PIN_VCC )
        {
            setState(STATE_TERMINATED);
        }
        if(dataIndex >= DATA_SIZE )
        {
#ifdef DEBUG
            sendDataBuffer("Array overflow\n");
#endif
            setState(STATE_TERMINATED);
        }
    }//End of while

    /* Stop the interupt on IO */
    ConfigINT0(EXT_INT_DISABLE);

    /* Stop the warm reset */
    ConfigINT1(EXT_INT_DISABLE);

#ifdef DEBUG
    sendDataBuffer("Trace recorded : \n");
#endif

    /* End of debug information */
    *size = dataIndex;
    reInit();
    return dataArray;
}
// Initialize the localization module based on data from the LocalizationBlock
void LocalizationModule::initFromMemory() {
  reInit();
}
Example #4
0
void PCSSShadowMap::render(DrawEnv *pEnv)
{
    Window  *win = pEnv->getWindow();
    initialize(win);

    if(!_useGLSL || !_useShadowExt)
        _shadowVP->Viewport::render(pEnv->getAction());
    else
    {
        glPushAttrib(GL_ENABLE_BIT);

        if(!_initTexturesDone)
            initTextures(win);

        if(_useFBO)
        {
            if(!initFBO(pEnv))
                printf("ERROR with FBOBJECT\n");
        }

        GLfloat globalAmbient[] =
        {
            0.0, 0.0, 0.0, 1.0
        };
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient);
        _firstRun = 1;

#if 0
        for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
        {
            {
                _shadowVP->_texChunks[i]->setMinFilter(GL_NEAREST);
                _shadowVP->_texChunks[i]->setMagFilter(GL_NEAREST);
            }
        }
#endif

        if(_shadowVP->getPixelWidth() != _width ||
           _shadowVP->getPixelHeight() != _height)
        {
            _width = _shadowVP->getPixelWidth();
            _height = _shadowVP->getPixelHeight();

            if(_useNPOTTextures)
            {
                _colorMapImage->set(GL_RGB, _width, _height);

                _shadowFactorMapImage->set(GL_RGB, _width, _height);

                reInit(pEnv);
            }
            else
            {
                if(_width > _height)
                    _widthHeightPOT = osgNextPower2(_width - 1);
                else
                    _widthHeightPOT = osgNextPower2(_height - 1);

                _colorMapImage->set(GL_RGB, _widthHeightPOT, _widthHeightPOT);

                _shadowFactorMapImage->set(GL_RGB, _widthHeightPOT,
                                           _widthHeightPOT);
            }
        }

        commitChanges();

        if(_shadowVP->getMapAutoUpdate())
        {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
            if(_useFBO && _useNPOTTextures)
                createColorMapFBO(pEnv);
            else
#endif
                createColorMap(pEnv);

            //deactivate transparent Nodes
            for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                _shadowVP->_transparent[t]->setTravMask(0);

            if(_useFBO)
                createShadowMapsFBO(pEnv);
            else
                createShadowMaps(pEnv);

            // switch on all transparent geos
            for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                _shadowVP->_transparent[t]->setTravMask(TypeTraits<UInt32>::BitsSet);

            for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
            {
                if(_shadowVP->_lightStates[i] != 0)
                {
                    if(_shadowVP->getGlobalShadowIntensity() != 0.0 ||
                       _shadowVP->_lights[i].second->getShadowIntensity() != 0.0)
                    {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                        if(_useFBO && _useNPOTTextures)
                            createShadowFactorMapFBO(pEnv, i);
                        else
#endif
                            createShadowFactorMap(pEnv, i);
                        //_firstRun = 0;
                    }
                }
            }
        }
        else
        {
            if(_shadowVP->_trigger_update)
            {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                if(_useFBO && _useNPOTTextures)
                    createColorMapFBO(pEnv);
                else
#endif
                    createColorMap(pEnv);

                //deactivate transparent Nodes
                for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                    _shadowVP->_transparent[t]->setTravMask(0);

                if(_useFBO)
                    createShadowMapsFBO(pEnv);
                else
                    createShadowMaps(pEnv);

                // switch on all transparent geos
                for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                    _shadowVP->_transparent[t]->setTravMask(TypeTraits<UInt32>::BitsSet);

                for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
                {
                    if(_shadowVP->_lightStates[i] != 0)
                    {
                        if(_shadowVP->getGlobalShadowIntensity() != 0.0 ||
                           _shadowVP->_lights[i].second->getShadowIntensity() != 0.0)
                        {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                            if(_useFBO && _useNPOTTextures)
                                createShadowFactorMapFBO(pEnv, i);
                            else
#endif
                                createShadowFactorMap(pEnv, i);
                        }
                    }
                }
                _shadowVP->_trigger_update = false;
            }
        }

        drawCombineMap(pEnv);

        glPopAttrib();
        // render the foregrounds.
        for(UInt16 i = 0;i < _shadowVP->getMFForegrounds()->size();++i)
        {
            _shadowVP->getForegrounds(i)->draw(pEnv, _shadowVP);
        }
    }
}
Example #5
0
void ToolBarIcons::resizeIcon(int size) {
	reInit(size);
};
// Perform startup initialization such as allocating memory
void LocalizationModule::initSpecificModule() {
  reInit();
}
Example #7
0
bool MGMap::runConsoleCommand(const char *c, MGFramework *w, MGSymbolTable *s)
{
	char cmd[MGF_SCRIPTLINE_MAXLENGTH];
	strcpy(cmd, c);
	std::vector<std::string> cmdvec = MGFramework::split(cmd, " ");

	switch(detectMGComponentConsoleCommand(cmdvec))
	{
		case MGComponent_UNDEFINED:
			MGFLOG_ERROR("MGMap::runConsoleCommand received MGComponent_UNDEFINED from MGMap::detectMGComponentConsoleCommand"); 
			break;

		case MGComponent_MAP_HELP:
		{
			std::cout << "-----------------------------------------------------------------------------" << std::endl << std::endl;
			std::cout << "map help - Displays help information for console commands implemented in the" << std::endl;
			std::cout << "           map object." << std::endl;
			return true;
		}

		case MGComponent_MAP_PATH_INT_INT_INT_INT:
		{
			int x1 = w->toInt(cmdvec[2], s);
			int y1 = w->toInt(cmdvec[3], s);
			int x2 = w->toInt(cmdvec[4], s);
			int y2 = w->toInt(cmdvec[5], s);
			MGFLOG_INFO("Calculating closest path from (" << x1 << "," << y1 << ") to (" << x2 << "," << y2 << ").");
			calculatePath(MGFBASICPATH1, x1, y1, x2, y2);
			return true;
		}

		case MGComponent_MAP_SETSIZE_INT_INT_INT_INT:
		{
			int x = w->toInt(cmdvec[2], s);
			int y = w->toInt(cmdvec[3], s);
			int tx = w->toInt(cmdvec[4], s);
			int ty = w->toInt(cmdvec[5], s);
			reInit(x, y, tx, ty);
			return true;
		}

		case MGComponent_MAP_LOGGING_ON:
		{
			enableLogging();
			MGFLOG_INFO("Logging enabled.");
			return true;
		}

		case MGComponent_MAP_LOGGING_OFF:
		{
			disableLogging();
			MGFLOG_INFO("Logging disabled.");
			return true;
		}

		default:
			MGFLOG_ERROR("MGMap::detectComponentConsoleCommand returned a bad value"); 
			return true;
	}

	std::cout << "Unknown command" << std::endl;
	return true;
}
Example #8
0
void PCSSShadowMap::render(RenderActionBase *action)
{
    Window  *win = action->getWindow();
    initialize(win);

    if(!_useGLSL || !_useShadowExt)
        _shadowVP->Viewport::render(action);
    else
    {
        glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT);

        if(!_initTexturesDone)
            initTextures(win);

        if(_useFBO)
        {
            if(!initFBO(win))
                printf("ERROR with FBOBJECT\n");
        }

        GLfloat globalAmbient[] =
        {
            0.0, 0.0, 0.0, 1.0
        };
        glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient);
        _firstRun = 1;

        for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
        {
            beginEditCP(_shadowVP->_texChunks[i]);
            {
                _shadowVP->_texChunks[i]->setMinFilter(GL_NEAREST);
                _shadowVP->_texChunks[i]->setMagFilter(GL_NEAREST);
            }
            endEditCP(_shadowVP->_texChunks[i]);
        }

        if(_shadowVP->getPixelWidth() != _width ||
           _shadowVP->getPixelHeight() != _height)
        {
            _width = _shadowVP->getPixelWidth();
            _height = _shadowVP->getPixelHeight();

            if(_useNPOTTextures)
            {
                beginEditCP(_colorMap);
                beginEditCP(_colorMapImage);
                _colorMapImage->set(COLORMAP_FORMAT, _width, _height);
                endEditCP(_colorMapImage);
                endEditCP(_colorMap);

                beginEditCP(_shadowFactorMap);
                beginEditCP(_shadowFactorMapImage);
                _shadowFactorMapImage->set(GL_RGB, _width, _height);
                endEditCP(_shadowFactorMapImage);
                endEditCP(_shadowFactorMap);

                reInit(win);
            }
            else
            {
                if(_width > _height)
                    _widthHeightPOT = osgnextpower2(_width - 1);
                else
                    _widthHeightPOT = osgnextpower2(_height - 1);

                beginEditCP(_colorMap);
                beginEditCP(_colorMapImage);
                _colorMapImage->set(COLORMAP_FORMAT, _widthHeightPOT, _widthHeightPOT);
                endEditCP(_colorMapImage);
                endEditCP(_colorMap);

                beginEditCP(_shadowFactorMap);
                beginEditCP(_shadowFactorMapImage);
                _shadowFactorMapImage->set(GL_RGB, _widthHeightPOT,
                                           _widthHeightPOT);
                endEditCP(_shadowFactorMapImage);
                endEditCP(_shadowFactorMap);
            }
        }
		
		// need possibility to tell cores like billboard not to change state
		RenderAction *rAct = dynamic_cast<RenderAction*>(action);
		bool effectsPassSave = rAct ? rAct->getEffectsPass() : false;

        if(_shadowVP->getMapAutoUpdate())
        {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
            if(_useFBO && _useNPOTTextures)
                createColorMapFBO(action);
            else
#endif
                createColorMap(action);

            //deactivate transparent Nodes
            for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                _shadowVP->_transparent[t]->setActive(false);
			
			rAct->setEffectsPass(true);

            if(_useFBO)
                createShadowMapsFBO(action);
            else
                createShadowMaps(action);

            // switch on all transparent geos
            for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                _shadowVP->_transparent[t]->setActive(true);

            for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
            {
                if(_shadowVP->_lightStates[i] != 0)
                {
                    if(_shadowVP->getGlobalShadowIntensity() != 0.0 ||
                       _shadowVP->_lights[i].second->getShadowIntensity() != 0.0)
                    {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                        if(_useFBO && _useNPOTTextures)
                            createShadowFactorMapFBO(action, i);
                        else
#endif
                            createShadowFactorMap(action, i);
                        //_firstRun = 0;
                    }
                }
            }
        }
        else
        {
            if(_shadowVP->_trigger_update)
            {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                if(_useFBO && _useNPOTTextures)
                    createColorMapFBO(action);
                else
#endif
                    createColorMap(action);

                //deactivate transparent Nodes
                for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                    _shadowVP->_transparent[t]->setActive(false);
				
				rAct->setEffectsPass(true);

                if(_useFBO)
                    createShadowMapsFBO(action);
                else
                    createShadowMaps(action);

                // switch on all transparent geos
                for(UInt32 t = 0;t < _shadowVP->_transparent.size();++t)
                    _shadowVP->_transparent[t]->setActive(true);

                for(UInt32 i = 0;i < _shadowVP->_lights.size();i++)
                {
                    if(_shadowVP->_lightStates[i] != 0)
                    {
                        if(_shadowVP->getGlobalShadowIntensity() != 0.0 ||
                           _shadowVP->_lights[i].second->getShadowIntensity() != 0.0)
                        {
#ifdef USE_FBO_FOR_COLOR_AND_FACTOR_MAP
                            if(_useFBO && _useNPOTTextures)
                                createShadowFactorMapFBO(action, i);
                            else
#endif
                                createShadowFactorMap(action, i);
                        }
                    }
                }
                _shadowVP->_trigger_update = false;
            }
        }
		
		rAct->setEffectsPass(effectsPassSave);

        drawCombineMap(action);

        glPopAttrib();
        // render the foregrounds.
        for(UInt16 i = 0;i < _shadowVP->getMFForegrounds()->size();++i)
        {
            _shadowVP->getForegrounds(i)->draw(action, _shadowVP);
        }
    }
}
void DesignInterface::on_clear_button_clicked()
{
    reInit();
    this->update();
}
void DesignInterface::on_radioButton_7_7_clicked()
{
    game.gameFormat=7;
    reInit();
    this->update();
}
void DesignInterface::on_back_button_clicked()
{
    switcher.showInterface("welcome","menuback");
    reInit();
    this->update();
}