コード例 #1
0
MBFrameGenerator::MBFrameGenerator(CMandelbrotDlg *dlg, const String &dirName)
: m_dlg(*dlg)
, m_dirName(dirName)
, m_finalRect(dlg->getBigRealTransformation().getFromRectangle())
, m_frameSize(dlg->getWindowSize())
, m_frameReady(0)
{
  DigitPool *dp = getDigitPool();
  m_dlg.initScale();
  m_startRect       = m_dlg.getBigRealTransformation().getFromRectangle();
  m_totalFrameCount = findTotalFrameCount(m_startRect, m_finalRect);
  m_frameIndex      = 0;
  BigRealInterval frameInterval(dp), zoomInterval(dp), unitInterval(dp);
  frameInterval     = RealInterval(0,m_totalFrameCount);
  zoomInterval      = RealInterval(1,getReal(m_finalRect.getWidth())/getReal(m_startRect.getWidth()));
  unitInterval      = IntInterval( 1,0);
  m_expTransform    = new ExpTransformation(frameInterval, zoomInterval, dp); TRACE_NEW(m_expTransform);
  m_linearTransform = new BigRealLinearTransformation(m_expTransform->getToInterval(), unitInterval,AUTOPRECISION,dp);
  TRACE_NEW(m_linearTransform);

  HDC screenDC = getScreenDC();
  m_dc = CreateCompatibleDC(screenDC);
  m_bm = CreateCompatibleBitmap(screenDC, m_frameSize.cx, m_frameSize.cy);
  DeleteDC(screenDC);

  m_imageListThread  = new ImageListThread(this); TRACE_NEW(m_imageListThread);
  m_imageListThread->start();
}
コード例 #2
0
ファイル: field.cpp プロジェクト: dmitriyushakov/Tetris
void Field::cleanLines(){
    int clearedCount=0;
    for(int y=_height-1;y>=0;y--){
        bool fully=true;
        for(int x=0;x<_width;x++){
            if(getReal(x,y)==NoneCell){
                fully=false;
                break;
            }
        }
        if(fully){
            for(int cy=y-1;cy>=0;cy--){
                for(int x=0;x<_width;x++){
                    set(x,cy+1,getReal(x,cy));
                }
            }
            for(int x=0;x<_width;x++){
                set(x,0,NoneCell);
            }
            y++;
            clearedCount++;
        }
    }
    emit cleared(clearedCount);
}
コード例 #3
0
ファイル: AspCell.C プロジェクト: DanIverson/OpenVnmrJ
double AspCell::mm2pix(int dim, double mm) {
   double mmwd = getReal("wc",100.0);
   double mmht = getReal("wc2",100.0);
   double mm2pixX = 1;
   if(mmwd > 0 && pwd > 0) mm2pixX = pwd/mmwd;
   double mm2pixY = 1;
   if(mmht > 0 && pht > 0) mm2pixY = pht/mmht;

   if(dim == VERT) return (mmht-mm) * mm2pixY;
   else return (mm) * mm2pixX;
}
	//-----------------------------------------------------------------------
	bool SphereColliderTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node)
	{
		PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get());
		ParticleAffector* af = any_cast<ParticleAffector*>(prop->parent->context);
		SphereCollider* affector = static_cast<SphereCollider*>(af);

		if (prop->name == token[TOKEN_RADIUS])
		{
			// Property: radius
			if (passValidateProperty(compiler, prop, token[TOKEN_RADIUS], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setRadius(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_SPHERE_COLLIDER_RADIUS])
		{
			// Property: sphere_collider_radius (Deprecated; replaced by radius)
			if (passValidateProperty(compiler, prop, token[TOKEN_SPHERE_COLLIDER_RADIUS], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setRadius(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_INNER_COLLISION])
		{
			// Property: inner_collision
			if (passValidateProperty(compiler, prop, token[TOKEN_INNER_COLLISION], VAL_BOOL))
			{
				bool val;
				if(getBoolean(prop->values.front(), &val))
				{
					affector->setInnerCollision(val);
					return true;
				}
			}
		}
		else
		{
			// Parse the BaseCollider
			BaseColliderTranslator baseColliderTranslator;
			return baseColliderTranslator.translateChildProperty(compiler, node);
		}

		return false;
	}
コード例 #5
0
ファイル: AspCell.C プロジェクト: DanIverson/OpenVnmrJ
// Note, mm starts from lower left corner
// pix starts from upper left corner
double AspCell::pix2mm(int dim, double pix) {
   double mmwd = getReal("wc",100.0);
   double mmht = getReal("wc2",100.0);
   double pix2mmX = 1;
   if(mmwd > 0 && pwd > 0) pix2mmX = mmwd/pwd;
   double pix2mmY = 1;
   if(mmht > 0 && pht > 0) pix2mmY = mmht/pht;

   if(dim == VERT) return mmht - (pix) * pix2mmY;
   else return (pix) * pix2mmX;
}
コード例 #6
0
PlanetDescriptor PlanetMovableFactory::getDefaultDescriptor() {
    PlanetDescriptor descriptor;

    descriptor.seed = getInt("planet.seed");
    descriptor.brushes = getInt("planet.brushes");
    descriptor.radius = getReal("planet.radius");
    descriptor.height = getReal("planet.height");
    descriptor.lodLimit = getInt("planet.lodLimit");

    return descriptor;
}
コード例 #7
0
ファイル: tedstd.cpp プロジェクト: BackupTheBerlios/toped-svn
void laydata::TEDfile::read() {
   if (tedf_DESIGN != getByte()) throw EXPTNreadTDT("Expecting DESIGN record");
   std::string name = getString();
   real         DBU = getReal();
   real          UU = getReal();
   tell_log(console::MT_DESIGNNAME, name);
   _design = new tdtdesign(name,_created, _lastUpdated, DBU,UU);
   _design->read(this);
   //Design end marker is read already in tdtdesign so don't search it here
   //byte designend = getByte(); 
}
コード例 #8
0
bool SettingsFileParser::addOption(Ogre::String sectionName, Ogre::String optionName, Ogre::String optionValue)
{
    if(equals(optionName, "Restore Config")) {
        mRestoreConfig = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Grab Mouse")) {
        mLockMouse = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Debug Draw")) {
        mDebugDraw = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Human Characters")) {
        mHumanChars = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Obstacles")) {
        mObstacles = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Single Navmesh")) {
        mSingleNavmesh = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Raycast Scene")) {
        mRaycastScene = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Temp Obstacle Steering")) {
        mTempObstacleSteering = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Complex Obstacles")) {
        mComplexObstacles = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Terrain Demo")) {
        mTerrain = getBool(optionValue);
        return true;
    } else if(equals(optionName, "Paged Crowds Demo")) {
        mPaged = getBool(optionValue);
        return true;


    } else if(equals(optionName, "Terrain Tiles X")) {
        mTerrainTilesX = (int) getReal(optionValue);
    } else if(equals(optionName, "Terrain Tiles Z")) {
        mTerrainTilesZ = (int) getReal(optionValue);
    } else if(equals(optionName, "Terrain Tile Size")) {
        mTerrainTileSize = getReal(optionValue);
    } else if(equals(optionName, "Terrain Height Scale")) {
        mTerrainHeightScale = getReal(optionValue);
    } else if(equals(optionName, "Terrain Tile Resolution")) {
        mTerrainTileResolution = getReal(optionValue);
    }


    std::cout << "Warning: Unknown option \"" << optionName << "\" specified in " << mFilePath << " file." << std::endl;
    return false;
}
コード例 #9
0
ファイル: AspRoi.C プロジェクト: DanIverson/OpenVnmrJ
// assume c1 is downfield cursor (bigger ppm) and 
// c2 is upfield cursor (smaller ppm, i.e.,cr-delta).
AspRoi::AspRoi(spAspCursor_t c1, spAspCursor_t c2, int i) {
    id=i;
    label="";
    cursor1=c1;
    cursor2=c2;
    color=(int)getReal("aspPref",1,-1);
    opaque=(int)getReal("aspPref",2,-1);
    height=(int)getReal("aspPref",3,-1);
    selected=false;
    mouseOver=NOSELECT;
    show=true;
}
コード例 #10
0
ファイル: AspRoi.C プロジェクト: DanIverson/OpenVnmrJ
// aspPref[1] color id
// aspPref[2] transparent to opaque, 0-100% opaque, default 10
// aspPref[3] 1D Roi height, 0-100% of wc2, default 70
void AspRoi::draw(spAspCell_t cell) {

    if(cell == nullAspCell) return;

    double px,py,pw,ph;
    if(!getRoiBox(cell,px,py,pw,ph)) return;

    int op;
    if(opaque<0) op = (int)getReal("aspPref",2,20);
    else op = opaque;
    int color = getColor();
    if(opaque > 0) 
      set_background_region((int)px, (int)py, (int)pw, (int)ph, color, op);
/*
    if(selected) {
      AspUtil::drawBox(px,py,pw,ph,SELECT_COLOR);
    } else {
*/
      AspUtil::drawBox(px,py,pw,ph,color);
 //   }

    // highlight selection
    if(mouseOver==BOXSELECT) {
      AspUtil::drawBox(px,py,pw,ph,ACTIVE_COLOR);
    } else if(mouseOver>=LINE1 && mouseOver<=LINE4) {
      AspUtil::drawBorderLine(mouseOver,px,py,pw,ph,ACTIVE_COLOR);
    } else if(mouseOver>=HANDLE1 && mouseOver<=HANDLE4) {
      AspUtil::drawHandle(mouseOver,px,py,pw,ph,ACTIVE_COLOR);
    }
}
コード例 #11
0
ファイル: Lexer.cpp プロジェクト: promicr/Toaster-VM
void getConstant(const std::string & str, const unsigned stringStart, Token & token)
{
    switch (str[stringStart])
    {
    case '\'':
        if ((str.size() != stringStart + 3) || (str[stringStart + 2] != '\''))
            throw(std::runtime_error("Lexer::getConstant: Invalid character constant given"));
        token.type = Token::T_OPERAND_CONST_CHAR;
        token.charData = str[stringStart + 1];
        break;

    case 'T':
    case 'F':
        if (str.size() != stringStart + 1)
            throw(std::runtime_error("Lexer::getConstant: Invalid boolean constant given"));
        token.type = Token::T_OPERAND_CONST_BOOL;
        token.booleanData = (str[stringStart] == 'T');
        break;

    default:
        if (!isdigit(str[stringStart]) && (str[stringStart] != '-'))
            throw(std::runtime_error("Lexer::getConstant: Invalid constant given"));
        if (str.find('.') != std::string::npos) getReal(str, stringStart, token);
        else getInteger(str, stringStart, token);
    }
}
コード例 #12
0
fmiStatus fmiGetDerivatives(fmiComponent c, fmiReal derivatives[], size_t nx)
{
  unsigned int i=0;
  ModelInstance* comp = (ModelInstance *)c;
  threadData_t *threadData = comp->threadData;
  if (invalidState(comp, "fmiGetDerivatives", not_modelError))
    return fmiError;
  if (invalidNumber(comp, "fmiGetDerivatives", "nx", nx, NUMBER_OF_STATES))
    return fmiError;
  if (nullPointer(comp, "fmiGetDerivatives", "derivatives[]", derivatives))
    return fmiError;

  /* try */
  MMC_TRY_INTERNAL(simulationJumpBuffer)

    comp->fmuData->callback->functionODE(comp->fmuData, comp->threadData);
  #if (NUMBER_OF_STATES>0)
    for (i=0; i<nx; i++) {
      fmiValueReference vr = vrStatesDerivatives[i];
      derivatives[i] = getReal(comp, vr); // to be implemented by the includer of this file
      if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
          "fmiGetDerivatives: #r%d# = %.16g", vr, derivatives[i]);
    }
  #endif
    return fmiOK;

  /* catch */
  MMC_CATCH_INTERNAL(simulationJumpBuffer)

    comp->functions.logger(c, comp->instanceName, fmiError, "error", "fmiGetDerivatives: terminated by an assertion.");
    return fmiError;
}
コード例 #13
0
/**
 * \brief Getter function for reals.
 *
 * Used by OMSIC or OMSICpp library.
 *
 * \param [in]  omsu    Central data structure containing all informations.
 * \param [in]  vr      Array of value references for real variables to get.
 * \param [in]  nvr     Length of array `vr`.
 * \param [out] value   Contains asked reals.
 * \return              `omsi_status omsi_ok` if successful <br>
 *                      `omsi_status omsi_error` if something went wrong.
 */
omsi_status omsi_get_real(omsi_t*                   omsu,
                          const omsi_unsigned_int*  vr,
                          omsi_unsigned_int         nvr,
                          omsi_real*                value){

    /* Variables */
    omsi_unsigned_int i;
    omsi_int index;

    if (!model_variables_allocated(omsu, "fmi2GetReal")) {
        return omsi_error;
    }

    if (nvr > 0 && vr==NULL) {
        filtered_base_logger(global_logCategories, log_statuserror, omsi_error,
                "fmi2GetReal: Invalid argument vr[] = NULL.");
        return omsi_error;
    }
    if (nvr > 0 && value==NULL) {
        filtered_base_logger(global_logCategories, log_statuserror, omsi_error,
                "fmi2GetReal: Invalid argument value[] = NULL.");
      return omsi_error;
    }

    /* Get reals */
    for (i = 0; i < nvr; i++) {
        /* Check for negated alias */
        index = omsi_get_negated_index(&omsu->model_data->model_vars_info[vr[i]], vr[i]);

        if (index < 0) {
            if (omsi_vr_out_of_range(omsu, "fmi2GetReal", -index, omsu->sim_data->model_vars_and_params->n_reals)) {
                return omsi_error;
            }
            value[i] =getReal(omsu, -index);
        } else {
            if (omsi_vr_out_of_range(omsu, "fmi2GetReal", index, omsu->sim_data->model_vars_and_params->n_reals)) {
                return omsi_error;
            }
            value[i] =getReal(omsu, index);
        }
        filtered_base_logger(global_logCategories, log_all, omsi_ok,
            "fmi2GetReal: vr = %i, value = %f", vr[i], value[i]);
    }
    return omsi_ok;
}
コード例 #14
0
ファイル: tedstd.cpp プロジェクト: BackupTheBerlios/toped-svn
void laydata::TEDfile::read() {
   // Get the leading string 
   std::string _leadstr = getString();
   if (TED_LEADSTRING != _leadstr) throw EXPTNreadTDT();
   // Get format revision
   getRevision();
   // Get file time stamps
   getTime();
//   checkIntegrity();
   if (tedf_DESIGN != getByte()) throw EXPTNreadTDT();
   std::string name = getString();
   real         DBU = getReal();
   real          UU = getReal();
   tell_log(console::MT_DESIGNNAME, name.c_str());
   _design = new tdtdesign(name,_created, _lastUpdated, DBU,UU);
   _design->read(this);
   //Design end marker is read already in tdtdesign so don't search it here
   //byte designend = getByte(); 
}
コード例 #15
0
	//-----------------------------------------------------------------------
	bool OnTimeObserverTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node)
	{
		PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get());
		ParticleObserver* ob = any_cast<ParticleObserver*>(prop->parent->context);
		OnTimeObserver* observer = static_cast<OnTimeObserver*>(ob);

		if (prop->name == token[TOKEN_ONTIME])
		{
			// Property: on_time
			if (passValidatePropertyNumberOfValues(compiler, prop, token[TOKEN_ONTIME], 2))
			{
				String compareType;
				Real val = 0.0f;
				AbstractNodeList::const_iterator i = prop->values.begin();
				if(getString(*i, &compareType))
				{
					if (compareType == token[TOKEN_LESS_THAN])
					{
						observer->setCompare(CO_LESS_THAN);
					}
					else if (compareType == token[TOKEN_GREATER_THAN])
					{
						observer->setCompare(CO_GREATER_THAN);
					}
					else if (compareType == token[TOKEN_EQUALS])
					{
						observer->setCompare(CO_EQUALS);
					}
					++i;
					if(getReal(*i, &val))
					{
						observer->setThreshold(val);
						return true;
					}
				}
			}
		}
		else if (prop->name == token[TOKEN_SINCE_START_SYSTEM])
		{
			// Property: since_start_system
			if (passValidateProperty(compiler, prop, token[TOKEN_SINCE_START_SYSTEM], VAL_BOOL))
			{
				bool val;
				if(getBoolean(prop->values.front(), &val))
				{
					observer->setSinceStartSystem(val);
					return true;
				}
			}
		}

		return false;
	}
コード例 #16
0
	//-------------------------------------------------------------------------
	bool ScriptTranslator::passValidatePropertyValidReal(Ogre::ScriptCompiler* compiler, 
		Ogre::PropertyAbstractNode* prop)
	{
		Ogre::Real val = 0.0f;
		if(getReal(prop->values.front(), &val))
		{
			return true;
		}

		compiler->addError(Ogre::ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line,
			"PU Compiler: " + prop->values.front()->getValue() + " is not a valid Real");
		return false;
	}
コード例 #17
0
	//-----------------------------------------------------------------------
	bool JetAffectorTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node)
	{
		PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get());
		ParticleAffector* af = any_cast<ParticleAffector*>(prop->parent->context);
		JetAffector* affector = static_cast<JetAffector*>(af);

		if (prop->name == token[TOKEN_ACCELERATION])
		{
			// Property: acceleration
			if (passValidateProperty(compiler, prop, token[TOKEN_ACCELERATION], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					DynamicAttributeFixed* dynamicAttributeFixed = PU_NEW_T(DynamicAttributeFixed, MEMCATEGORY_SCENE_OBJECTS)();
					dynamicAttributeFixed->setValue(val);
					affector->setDynAcceleration(dynamicAttributeFixed);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_JET_ACCELERATION])
		{
			// Property: jet_aff_accel (deprecated and replaced by 'acceleration')
			if (passValidateProperty(compiler, prop, token[TOKEN_JET_ACCELERATION], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					DynamicAttributeFixed* dynamicAttributeFixed = PU_NEW_T(DynamicAttributeFixed, MEMCATEGORY_SCENE_OBJECTS)();
					dynamicAttributeFixed->setValue(val);
					affector->setDynAcceleration(dynamicAttributeFixed);
					return true;
				}
			}
		}

		return false;
	}
コード例 #18
0
    PlanetFilter::PlanetFilter(int face, int lod, int x, int y, int size, int border) : SimpleRenderable() {
        initRenderOp();
        initVertexData(lod, x, y, size, border);

        Real height = getReal("planet.height");
        Real radius = getReal("planet.radius");
        
        setMaterial("BaseWhiteNoLighting");
        
        // SampleDistance
        setCustomParameter(1, Vector4(1.0 / (size + border), 0, 0, 0));
        // inverseSampleDistance
        setCustomParameter(2, Vector4(((border + size) << lod) * .25, 0, 0, 0));
        // heightScale
        setCustomParameter(3, Vector4(height / radius, 0, 0, 0));

        // Something weird here with vertical axis mapping.
        Matrix3 faceTransform = PlanetCube::getFaceTransform(face);
        setCustomParameter(4, Vector4(faceTransform[0][0], faceTransform[1][0], faceTransform[2][0], 0));
        setCustomParameter(5, Vector4(-faceTransform[0][1],-faceTransform[1][1],-faceTransform[2][1], 0));
        setCustomParameter(6, Vector4(faceTransform[0][2], faceTransform[1][2], faceTransform[2][2], 0));
    }
コード例 #19
0
void* sending (void * callerobj){
	std::cout<<"sending thread online"<<std::endl;
	static const float nonstricttimeoutseconds=ACKTIMEOUTSECONDS;
	sender* senderobj = reinterpret_cast<sender*>(callerobj);
	if ( senderobj != nullptr ) {
		while ( senderobj->isSending || !senderobj->bufferIsEmpty()){
			for(int i=0;i<senderobj->windowsize;i++){
				int j = (senderobj->windowposition + i)%(senderobj->bufsize_sender);
				if (senderobj->buffered[j])
				if (!senderobj->sent[j]){
					size_t sentBytes;
					//kirim salah atau benar
					if (rand()%100<PROBSALAHPERCENT){
						std::string tempstr (senderobj->buffer[j].getPointerToBytes(),senderobj->buffer[j].getBytesLength());
						tempstr[rand()%tempstr.length()]++;
						sentBytes=sendto(senderobj->s, tempstr.c_str(),tempstr.length(),0,(struct sockaddr*) &senderobj->si_other ,sizeof(senderobj->si_other));
					}else{
						sentBytes=sendto(senderobj->s, senderobj->buffer[j].getPointerToBytes(),senderobj->buffer[j].getBytesLength(),0,(struct sockaddr*) &senderobj->si_other ,sizeof(senderobj->si_other));
					}
					senderobj->sent[j] = true;
					senderobj->timesent[j]=clock();
					std::cout<<"sent frame "<<senderobj->buffer[j].getFrameNumber()<<std::endl;
				} else if (senderobj->sent[j] && !senderobj->acked[j]
					&& (float(clock()-senderobj->timesent[j]))/CLOCKS_PER_SEC>nonstricttimeoutseconds){//tidak menerima ack atau menerima nak setelah timeout
					size_t sentBytes;
					//kirim salah atau benar
					if (rand()%100<PROBSALAHPERCENT){
						std::string tempstr (senderobj->buffer[j].getPointerToBytes(),senderobj->buffer[j].getBytesLength());
						tempstr[rand()%tempstr.length()]++;
						sentBytes=sendto(senderobj->s, tempstr.c_str(),tempstr.length(),0,(struct sockaddr*) &senderobj->si_other ,sizeof(senderobj->si_other));
					}else{
						sentBytes=sendto(senderobj->s, senderobj->buffer[j].getPointerToBytes(),senderobj->buffer[j].getBytesLength(),0,(struct sockaddr*) &senderobj->si_other ,sizeof(senderobj->si_other));
					}
					senderobj->sent[j] = true;
					senderobj->timesent[j]=clock();
					std::cout<<"timeout, retry, sent frame "<<senderobj->buffer[j].getFrameNumber()<<std::endl;
				} else if (j==senderobj->windowposition && senderobj->sent[j] && senderobj->acked[j]){
					senderobj->geserJendela(1);
					senderobj->sent[j]=false;
					senderobj->acked[j]=false;
					senderobj->buffered[j]=false;
				}
			}
		}
	}
	std::cout<<"sending thread offline"<<std::endl;
	std::cout<<getReal(status)<<std::endl;
}
コード例 #20
0
ファイル: tedstd.cpp プロジェクト: BackupTheBerlios/toped-svn
CTM laydata::TEDfile::getCTM() 
{
   real _a  = getReal();
   real _b  = getReal();
   real _c  = getReal();
   real _d  = getReal();
   real _tx = getReal();
   real _ty = getReal();
   return CTM(_a, _b, _c, _d, _tx, _ty);
}
コード例 #21
0
	//-----------------------------------------------------------------------
	bool DoScaleEventHandlerTranslator::translateChildProperty(Ogre::ScriptCompiler* compiler, const Ogre::AbstractNodePtr &node)
	{
		Ogre::PropertyAbstractNode* prop = reinterpret_cast<Ogre::PropertyAbstractNode*>(node.get());
		ParticleEventHandler* evt = Ogre::any_cast<ParticleEventHandler*>(prop->parent->context);
		DoScaleEventHandler* handler = static_cast<DoScaleEventHandler*>(evt);

		if (prop->name == token[TOKEN_DOSCALE_FRACTION])
		{
			// Property: scale_fraction
			if (passValidateProperty(compiler, prop, token[TOKEN_DOSCALE_FRACTION], VAL_REAL))
			{
				Ogre::Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					handler->setScaleFraction(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_DOSCALE_TYPE])
		{
			// Property: scale_type
			if (passValidateProperty(compiler, prop, token[TOKEN_DOSCALE_TYPE], VAL_STRING))
			{
				Ogre::String val;
				if(getString(prop->values.front(), &val))
				{
					if (val == token[TOKEN_TIME_TO_LIVE] || val == token[TOKEN_DOSCALE_TIME_TO_LIVE])
					{
						handler->setScaleType(DoScaleEventHandler::ST_TIME_TO_LIVE);
						return true;
					}
					else if (val == token[TOKEN_VELOCITY] || val == token[TOKEN_DOSCALE_VELOCITY])
					{
						handler->setScaleType(DoScaleEventHandler::ST_VELOCITY);
						return true;
					}
				}
			}
		}

		return false;
	}
コード例 #22
0
ファイル: ofxFftw.cpp プロジェクト: dopuskh3/ofx-projects
float* ofxFftw::fft(float* input, fftMode mode) {
	memcpy(fftIn, input, sizeof(float) * signalSize);
	runWindow(fftIn);

	fftwf_execute(fftPlan);

	// explanation of halfcomplex format:
	// http://www.fftw.org/fftw3_doc/The-Halfcomplex_002dformat-DFT.html
	setReal(fftOut); // will only copy the first half
	imag[0] = 0;
	for(int i = 1; i < bins; i++)
		imag[i] = fftOut[signalSize - i];
	cartesianReady = true;
	polarReady = false;
	if(mode == OF_FFT_CARTESIAN)
		return getReal();
	else if(mode == OF_FFT_POLAR)
		return getAmplitude();
}
コード例 #23
0
ファイル: fmuOthers.c プロジェクト: andyed2003/aegit2
fmiStatus fmiGetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[]) {
	ModelInstance* comp = (ModelInstance*)c;
    if (invalidState(comp, "fmiGetReal", not_modelError))
        return fmiError;
    if (nvr>0 && nullPointer(comp, "fmiGetReal", "vr[]", vr))
         return fmiError;
    if (nvr>0 && nullPointer(comp, "fmiGetReal", "value[]", value))
         return fmiError;
#if NUMBER_OF_REALS>0
    int i;
    for (i=0; i<nvr; i++) {
        if (vrOutOfRange(comp, "fmiGetReal", vr[i], NUMBER_OF_REALS))
            return fmiError;
        value[i] = getReal(comp, vr[i]); // to be implemented by the includer of this file
//        if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
//                "fmiGetReal: #r%u# = %.16g", vr[i], value[i]);
    }
#endif
    return fmiOK;
}
コード例 #24
0
fmiStatus fmiGetContinuousStates(fmiComponent c, fmiReal states[], size_t nx)
{
  unsigned int i=0;
  ModelInstance* comp = (ModelInstance *)c;
  if (invalidState(comp, "fmiGetContinuousStates", not_modelError))
    return fmiError;
#if NUMBER_OF_STATES>0
  if (invalidNumber(comp, "fmiGetContinuousStates", "nx", nx, NUMBER_OF_STATES))
    return fmiError;
  if (nullPointer(comp, "fmiGetContinuousStates", "states[]", states))
    return fmiError;
  for (i=0; i<nx; i++) {
    fmiValueReference vr = vrStates[i];
    states[i] = getReal(comp, vr); // to be implemented by the includer of this file
    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
        "fmiGetContinuousStates: #r%u# = %.16g", vr, states[i]);
  }
#endif
  return fmiOK;
}
	//-----------------------------------------------------------------------
	bool CollisionAvoidanceAffectorTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node)
	{
		PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get());
		ParticleAffector* af = any_cast<ParticleAffector*>(prop->parent->context);
		CollisionAvoidanceAffector* affector = static_cast<CollisionAvoidanceAffector*>(af);

		if (prop->name == token[TOKEN_AVOIDANCE_RADIUS])
		{
			if (passValidateProperty(compiler, prop, token[TOKEN_AVOIDANCE_RADIUS], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setRadius(val);
					return true;
				}
			}
		}

		return false;
	}
コード例 #26
0
fmiStatus fmiGetReal(fmiComponent c, const fmiValueReference vr[], size_t nvr, fmiReal value[])
{
  unsigned int i=0;
  ModelInstance* comp = (ModelInstance *)c;
  if (invalidState(comp, "fmiGetReal", not_modelError))
    return fmiError;
  if (nvr>0 && nullPointer(comp, "fmiGetReal", "vr[]", vr))
    return fmiError;
  if (nvr>0 && nullPointer(comp, "fmiGetReal", "value[]", value))
    return fmiError;
#if NUMBER_OF_REALS>0
  for (i=0; i<nvr; i++) {
    if (vrOutOfRange(comp, "fmiGetReal", vr[i], NUMBER_OF_REALS+NUMBER_OF_STATES))
      return fmiError;
    value[i] = getReal(comp, vr[i]);
    if (comp->loggingOn) comp->functions.logger(c, comp->instanceName, fmiOK, "log",
        "fmiGetReal: #r%u# = %.16g", vr[i], value[i]);
  }
  return fmiOK;
#else
  return fmiOK;
#endif
}
コード例 #27
0
ファイル: Complex.cpp プロジェクト: jmc734/OpenEaagles
//------------------------------------------------------------------------------
// serialize() -- print the value of this object to the output stream sout.
//------------------------------------------------------------------------------
std::ostream& Complex::serialize(std::ostream& sout, const int i, const bool slotsOnly) const
{
    int j = 0;
    if ( !slotsOnly ) {
        sout << "( " << getFactoryName() << std::endl;
        j = 4;
    }

    BaseClass::serialize(sout,i+j,true);

    indent(sout,i+j);
    sout << "value:   " << getReal() << std::endl;

    indent(sout,i+j);
    sout << "imag: " << getImag() << std::endl;

    if ( !slotsOnly ) {
        indent(sout,i);
        sout << ")" << std::endl;
    }

    return sout;
}
	//-----------------------------------------------------------------------
	bool ParticleFollowerTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node)
	{
		PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get());
		ParticleAffector* af = any_cast<ParticleAffector*>(prop->parent->context);
		ParticleFollower* affector = static_cast<ParticleFollower*>(af);

		if (prop->name == token[TOKEN_MIN_DISTANCE])
		{
			// Property: min_distance
			if (passValidateProperty(compiler, prop, token[TOKEN_MIN_DISTANCE], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMinDistance(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_FOLLOW_MIN_DISTANCE])
		{
			// Property: follower_min_distance (deprecated and replaced by 'min_distance')
			if (passValidateProperty(compiler, prop, token[TOKEN_FOLLOW_MIN_DISTANCE], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMinDistance(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_MAX_DISTANCE])
		{
			// Property: max_distance
			if (passValidateProperty(compiler, prop, token[TOKEN_MAX_DISTANCE], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMaxDistance(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_FOLLOW_MAX_DISTANCE])
		{
			// Property: follower_max_distance (deprecated and replaced by 'TOKEN_MAX_DISTANCE')
			if (passValidateProperty(compiler, prop, token[TOKEN_FOLLOW_MAX_DISTANCE], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMaxDistance(val);
					return true;
				}
			}
		}

		return false;
	}
コード例 #29
0
	//-----------------------------------------------------------------------
	bool RandomiserTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node)
	{
		PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get());
		ParticleAffector* af = any_cast<ParticleAffector*>(prop->parent->context);
		Randomiser* affector = static_cast<Randomiser*>(af);

		if (prop->name == token[TOKEN_MAX_DEVIATION_X])
		{
			// Property: max_deviation_x
			if (passValidateProperty(compiler, prop, token[TOKEN_MAX_DEVIATION_X], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMaxDeviationX(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_RND_MAX_DEVIATION_X])
		{
			// Property: rand_aff_max_deviation_x (depreacted and replaced by 'max_deviation_x')
			if (passValidateProperty(compiler, prop, token[TOKEN_RND_MAX_DEVIATION_X], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMaxDeviationX(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_MAX_DEVIATION_Y])
		{
			// Property: max_deviation_y
			if (passValidateProperty(compiler, prop, token[TOKEN_MAX_DEVIATION_Y], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMaxDeviationY(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_RND_MAX_DEVIATION_Y])
		{
			// Property: rand_aff_max_deviation_y (deprecated and replaced by 'max_deviation_y')
			if (passValidateProperty(compiler, prop, token[TOKEN_RND_MAX_DEVIATION_Y], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMaxDeviationY(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_MAX_DEVIATION_Z])
		{
			// Property: max_deviation_z
			if (passValidateProperty(compiler, prop, token[TOKEN_MAX_DEVIATION_Z], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMaxDeviationZ(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_RND_MAX_DEVIATION_Z])
		{
			// Property: rand_aff_max_deviation_z (deprecated and replaced by 'max_deviation_z')
			if (passValidateProperty(compiler, prop, token[TOKEN_RND_MAX_DEVIATION_Z], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setMaxDeviationZ(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_TIME_STEP])
		{
			// Property: time_step
			if (passValidateProperty(compiler, prop, token[TOKEN_TIME_STEP], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setTimeStep(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_RND_TIME_STEP])
		{
			// Property: rand_aff_time_step (deprecated and replaced by 'time_step')
			if (passValidateProperty(compiler, prop, token[TOKEN_RND_TIME_STEP], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					affector->setTimeStep(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_USE_DIRECTION])
		{
			// Property: use_direction
			if (passValidateProperty(compiler, prop, token[TOKEN_USE_DIRECTION], VAL_BOOL))
			{
				bool val;
				if(getBoolean(prop->values.front(), &val))
				{
					affector->setRandomDirection(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_RND_DIRECTION])
		{
			// Property: rand_aff_direction (deprecated and replaced by 'use_direction')
			if (passValidateProperty(compiler, prop, token[TOKEN_RND_DIRECTION], VAL_BOOL))
			{
				bool val;
				if(getBoolean(prop->values.front(), &val))
				{
					affector->setRandomDirection(val);
					return true;
				}
			}
		}

		return false;
	}
コード例 #30
0
	//-----------------------------------------------------------------------
	bool VortexAffectorTranslator::translateChildProperty(ScriptCompiler* compiler, const AbstractNodePtr &node)
	{
		PropertyAbstractNode* prop = reinterpret_cast<PropertyAbstractNode*>(node.get());
		ParticleAffector* af = any_cast<ParticleAffector*>(prop->parent->context);
		VortexAffector* affector = static_cast<VortexAffector*>(af);

		if (prop->name == token[TOKEN_ROTATION_AXIS])
		{
			// Property: rotation_axis
			if (passValidateProperty(compiler, prop, token[TOKEN_ROTATION_AXIS], VAL_VECTOR3))
			{
				Vector3 val;
				if(getVector3(prop->values.begin(), prop->values.end(), &val))
				{
					affector->setRotationVector(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_VORTEX_ROTATION_VECTOR])
		{
			// Property: vortex_aff_vector (deprecated and replaced by 'rotation_axis')
			if (passValidateProperty(compiler, prop, token[TOKEN_VORTEX_ROTATION_VECTOR], VAL_VECTOR3))
			{
				Vector3 val;
				if(getVector3(prop->values.begin(), prop->values.end(), &val))
				{
					affector->setRotationVector(val);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_ROTATION_SPEED])
		{
			// Property: rotation_speed
			if (passValidateProperty(compiler, prop, token[TOKEN_ROTATION_SPEED], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					DynamicAttributeFixed* dynamicAttributeFixed = PU_NEW_T(DynamicAttributeFixed, MEMCATEGORY_SCENE_OBJECTS)();
					dynamicAttributeFixed->setValue(val);
					affector->setRotationSpeed(dynamicAttributeFixed);
					return true;
				}
			}
		}
		else if (prop->name == token[TOKEN_VORTEX_ROTATION_SPEED])
		{
			// Property: vortex_aff_speed (deprecated and replaced by 'rotation_speed')
			if (passValidateProperty(compiler, prop, token[TOKEN_VORTEX_ROTATION_SPEED], VAL_REAL))
			{
				Real val = 0.0f;
				if(getReal(prop->values.front(), &val))
				{
					DynamicAttributeFixed* dynamicAttributeFixed = PU_NEW_T(DynamicAttributeFixed, MEMCATEGORY_SCENE_OBJECTS)();
					dynamicAttributeFixed->setValue(val);
					affector->setRotationSpeed(dynamicAttributeFixed);
					return true;
				}
			}
		}

		return false;
	}