示例#1
0
bool GLDefish::process( const QList<Effect*> &el, double pts, Frame *src, Profile *p )
{
	Q_UNUSED( src );
	Q_UNUSED( p );
	return el[1]->set_float( "amount", getParamValue( amount, pts ).toDouble() )
		&& el[1]->set_float( "scale", getParamValue( scale, pts ).toDouble() );
}
示例#2
0
bool GLText::process( const QList<Effect*> &el, double pts, Frame *src, Profile *p )
{
    MyTextEffect *e = (MyTextEffect*)el[0];
    bool ok = e->set_float( "left", getParamValue( xOffset, pts ).toDouble() )
              && e->set_float( "top", getParamValue( yOffset, pts ).toDouble() )
              && e->set_float( "opacity", getParamValue( opacity, pts ).toDouble() );

    QString text = getParamValue( editor ).toString();
    if (text.contains("##")) {
        double secs = pts / MICROSECOND;
        int hour = secs / 3600;
        int min =(secs - (hour * 3600)) / 60;
        int sec = secs - (hour * 3600) - (min * 60);
        int img = qRound((secs - (hour * 3600) - (min * 60) - sec) * p->getVideoFrameRate());
        text.replace("##h##", QString("%1").arg(hour));
        text.replace("##hh##", QString("%1").arg(hour,2,10,QChar('0')));
        text.replace("##m##", QString("%1").arg(min));
        text.replace("##mm##", QString("%1").arg(min,2,10,QChar('0')));
        text.replace("##s##", QString("%1").arg(sec));
        text.replace("##ss##", QString("%1").arg(sec,2,10,QChar('0')));
        text.replace("##i##", QString("%1").arg(img));
        text.replace("##ii##", QString("%1").arg(img,2,10,QChar('0')));
    }
    e->setText(text, src->glWidth, src->glHeight);

    if ( ovdEnabled() ) {
        src->glOVD = FilterTransform::TRANSLATE;
        double w = e->getImageWidth(), h = e->getImageHeight();
        src->glOVDRect = QRectF( -w / 2.0, -h / 2.0, w, h );
        src->glOVDTransformList.append( FilterTransform( FilterTransform::TRANSLATE, getParamValue( xOffset, pts ).toDouble(), getParamValue( yOffset, pts ).toDouble() ) );
    }

    return ok;
}
示例#3
0
void MedianFilter::ParseArgument(CommandLineArgModel* arg)
{
	MedianFilterModel* model = new MedianFilterModel();
	model->hasRoi = false;
	model->Window = -1;

	bool hasX = false, hasY = false;

	for (unsigned int index = 0; index < arg->Parameters->size(); index++)
	{
		if (!model->hasRoi)
		{
			Rectangle roi = parseRoi(arg->Parameters->at(index));
			if (roi.Bottom != -1)
			{
				model->hasRoi = true;
				model->Roi = roi;
			}
		}

		if (model->Window < 0)
		{
			string value = getParamValue("window", arg->Parameters->at(index));

			if (value.length())
			{
				model->Window = stoi(trim(value));
			}
		}

		if (!hasX)
		{
			string value = getParamValue("x", arg->Parameters->at(index));

			if (value.length())
			{
				hasX = true;
				model->X = isMatch(value, "true");
			}
		}

		if (!hasY)
		{
			string value = getParamValue("y", arg->Parameters->at(index));

			if (value.length())
			{
				hasY = true;
				model->Y = isMatch(value, "true");
			}
		}
	}

	if (model->Window < 0) model->Window = 5;
	if (!hasX) model->X = true;
	if (!hasY) model->Y = true;

	arg->ParsedModel = model;
}
示例#4
0
bool GLEdge::process( const QList<Effect*> &el, double pts, Frame *src, Profile *p )
{
	Q_UNUSED( src );
	Q_UNUSED( p );
	Effect *e = el[1];
	return el.at(0)->set_float( "radius", getParamValue( blur ).toFloat() )
		&& e->set_float( "amp", getParamValue( amp, pts ).toFloat() )
		&& e->set_float( "depth", 1.0f - getParamValue( depth, pts ).toFloat() )
		&& e->set_float( "opacity", getParamValue( opacity, pts ).toFloat() );
}
示例#5
0
文件: proj15.cpp 项目: dmm/cegis
QString proj15::semiMinor( const int element )
{
     QString returnValue = "";

     if( getParamValue( element ) < 0 )
         returnValue = "Eccentricity squared of the ellipsoid";
     else if( getParamValue( element ) == 0 )
         returnValue = "A spherical form is assumed";
     else
         returnValue = "Semi-minor axis of ellipsoid";

     return returnValue;
}
示例#6
0
文件: proj15.cpp 项目: dmm/cegis
QString proj15::path( const int element )
{
     QString returnValue = "";

     if( getParamValue( element ) >= 1 &&  getParamValue( element ) <= 3 )
         returnValue = "Landsat path number: WRS-1";
     else if( getParamValue( element ) >= 4 &&  getParamValue( element ) <= 6 )
         returnValue = "Landsat path number: WRS-2";
     else
         returnValue = "Landsat path number: undefined";

     return returnValue;
}
bool TColorStyle::operator==(const TColorStyle &cs) const {
  if (getTagId() != cs.getTagId()) return false;

  if (getMainColor() != cs.getMainColor()) return false;

  int paramCount = getParamCount();
  if (paramCount != cs.getParamCount()) return false;

  int colorParamCount = getColorParamCount();
  if (colorParamCount != cs.getColorParamCount()) return false;

  if (m_name != cs.getName()) return false;
  if (m_originalName != cs.getOriginalName()) return false;
  if (m_globalName != cs.getGlobalName()) return false;
  if (m_isEditedFromOriginal != cs.getIsEditedFlag()) return false;
  if (m_pickedPosition != cs.getPickedPosition()) return false;
  if (m_flags != cs.getFlags()) return false;

  for (int p = 0; p < colorParamCount; ++p)
    if (getColorParamValue(p) != cs.getColorParamValue(p)) return false;

  for (int p = 0; p < paramCount; ++p) {
    switch (getParamType(p)) {
    case BOOL:
      if (getParamValue(bool_tag(), p) != cs.getParamValue(bool_tag(), p))
        return false;
      break;
    case INT:
    case ENUM:
      if (getParamValue(int_tag(), p) != cs.getParamValue(int_tag(), p))
        return false;
      break;
    case DOUBLE:
      if (getParamValue(double_tag(), p) != cs.getParamValue(double_tag(), p))
        return false;
      break;
    case FILEPATH:
      if (getParamValue(TFilePath_tag(), p) !=
          cs.getParamValue(TFilePath_tag(), p))
        return false;
      break;
    default:
      assert(false);
    }
  }

  return true;
}
示例#8
0
std::string Parameters::getParam(const std::string& name) {
    return getParamValue(name);
    /*void* Parameters::getParam(const std::string& name) {
      void* paramVal = 0;
      int type = getValueType(name);
      const char* sval = getParamValue(name).c_str();
      switch(type) {
        case kIntValue: {
          int ival = atoi(sval);
          paramVal = (void*)&ival;
          break;
        }
        case kFloatValue: {
          float fval = atof(sval);
          paramVal = (void*)&fval;
          break;
        }
        case kStringValue: {
          paramVal = (void*)sval;
          break;
        }
        case kBoolValue: {
          bool bval = sval == Parameters::kTrueValue ? true : false;
          paramVal = (void*)&bval;
          break;
        }
        default: // --> Parameters::kUndefinedValue
          paramVal = (void*)sval; // will set to Parameters::kNotSetValue
      }
      return paramVal;*/
}
示例#9
0
bool GLHardCut::process( const QList<Effect*> &el, double pts, Frame *first, Frame *second, Profile *p )
{
	Q_UNUSED( first );
	Q_UNUSED( second );
	Q_UNUSED( p );
	return el[0]->set_float( "show_second", getNormalizedTime( pts ) > getParamValue( position ).toDouble() ? 1 : 0 );
}
示例#10
0
void ThresholdFilter::ParseArgument(CommandLineArgModel* arg)
{
	ThresholdFilterModel* model = new ThresholdFilterModel();
	model->hasRoi = false;
	model->Threshold = 128;

	bool hasThreshold = false;

	for (unsigned int index = 0; index < arg->Parameters->size(); index++)
	{
		if (!model->hasRoi)
		{
			Rectangle roi = parseRoi(arg->Parameters->at(index));
			if (roi.Bottom != -1)
			{
				model->hasRoi = true;
				model->Roi = roi;
			}
		}

		if (!hasThreshold)
		{
			string value = getParamValue("threshold", arg->Parameters->at(index));

			if (value.length())
			{
				hasThreshold = true;
				model->Threshold = roundToByte(stod(trim(value)) * 255);
			}
		}
	}
	
	arg->ParsedModel = model;
}
示例#11
0
void CSVObsParamsWidget::editSet()
{
  int CurrentRow = ui->SetsTableWidget->currentRow();

  if (CurrentRow >= 0)
  {
    QString EditedSet = ui->SetsTableWidget->item(CurrentRow,0)->text();

    QStringList SetNames;
    for (auto& Set : m_Sets)
    {
      QString CurrentSet = QString::fromStdString(Set.first);
      if (CurrentSet != EditedSet)
        SetNames << CurrentSet;
    }

    QStringList FormatNames;
    for (auto& Format : m_Formats)
      FormatNames << QString::fromStdString(Format.first);

    QStringList ClassNames = openfluid::tools::toQStringList(mp_Desc->spatialDomain().getClassNames());

    EditSetDialog EditDlg(SetNames,FormatNames,ClassNames,this);

    QString SetStr = "set."+EditedSet+".";


    EditDlg.initialize(EditedSet,
                       getParamValue(SetStr+"format",""),
                       getParamValue(SetStr+"unitsclass",""),
                       getParamValue(SetStr+"unitsIDs","*"),
                       getParamValue(SetStr+"vars","*"));


    if (EditDlg.exec() == QDialog::Accepted)
    {
      removeParamsStartingWith(SetStr);

      openfluid::ware::WareParams_t Params = EditDlg.getSetParams();

      mp_Params->insert(Params.begin(),Params.end());

      update();
      emit changed();
    }
  }
}
示例#12
0
void CSVObsParamsWidget::editFormat()
{
  int CurrentRow = ui->FormatsTableWidget->currentRow();

  if (CurrentRow >= 0)
  {
    QString EditedFormat = ui->FormatsTableWidget->item(CurrentRow,0)->text();

    QStringList FormatNames;

    for (auto& Format : m_Formats)
    {
      QString CurrentFormat = QString::fromStdString(Format.first);
      if (CurrentFormat != EditedFormat)
        FormatNames << CurrentFormat;
    }

    EditFormatDialog EditDlg(FormatNames,this);

    QString FormatStr = "format."+EditedFormat+".";


    EditDlg.initialize(EditedFormat,
                       getParamValue(FormatStr+"header","colnames-as-comment"),
                       getParamValue(FormatStr+"colsep",";"),
                       getParamValue(FormatStr+"date","ISO"),
                       getParamValue(FormatStr+"precision","5"),
                       getParamValue(FormatStr+"commentchar","#"));


    if (EditDlg.exec() == QDialog::Accepted)
    {
      removeParamsStartingWith(FormatStr);

      openfluid::ware::WareParams_t Params = EditDlg.getFormatParams();

      mp_Params->insert(Params.begin(),Params.end());

      update();
      emit changed();
    }
  }
}
示例#13
0
文件: proj15.cpp 项目: dmm/cegis
QString proj15::semiMajor( const int element )
{
     QString returnValue = "";

     if( getParamValue( element ) != 0 )
         returnValue = "Semi-major axis of ellipsoid";
     else
         returnValue = "Clarke 1866 in meters is assumed";

     return returnValue;
}
示例#14
0
文件: proj15.cpp 项目: dmm/cegis
QString proj15::pFlag( const int element )
{
     QString returnValue = "";

     if( getParamValue( element ) == 0 )
         returnValue = "End of path flag for Landsat: start of path";
     else
         returnValue = "End of path flag for Landsat: end of path";

     return returnValue;
}
示例#15
0
文件: proj15.cpp 项目: dmm/cegis
QString proj15::sphere( const int element )
{
     QString returnValue = "";

     if( getParamValue( element ) != 0 )
         returnValue = "Radius of reference sphere";
     else
         returnValue = "6370997 is used";

     return returnValue;
}
示例#16
0
文件: proj15.cpp 项目: dmm/cegis
QString proj15::latZ( const int element )
{
     QString returnValue = "";

     if( getParamValue( element ) != 0 )
         returnValue = "Latitude of any point in UTM zone";
     else
         returnValue = "Not used, a zone code must be specified";

     return returnValue;
}
// linear trajectory 
void cob_cartesian_trajectories::getPriTarget(double dt, KDL::Frame &F_target)
{
    double length;
    double partial_length;
    double pris_dir_x;
    double pris_dir_y;
    double pris_dir_z;
    
    length = getParamValue("length");
    pris_dir_x = getParamValue("prismatic_dir.x");
    pris_dir_y = getParamValue("prismatic_dir.y");
    pris_dir_z = getParamValue("prismatic_dir.z");
    
    partial_length = length * (dt/targetDuration);
    
    F_target.p.x(F_start.p.x() + partial_length*pris_dir_x);
    F_target.p.y(F_start.p.y() + partial_length*pris_dir_y);
    F_target.p.z(F_start.p.z());
    //F_target.p.z(F_start.p.z() + partial_length*pris_dir_z);
    F_target.M = F_start.M; 
    
    std::cout << "F_X: " << F_target.p.x() << " F_Y: " << F_target.p.y() << " F_Z: " << F_target.p.z() << "\n";
}
void sendNotification( PAPIConnection * inConnection, PAPIMessage * inMessage )
{
	PAPIStringList *	theComponentNames =
		getParamValue( inMessage, PAPIParamComponentName );
	PAPIStringList * theTmpList = theComponentNames;
	while ( theComponentNames != 0 )
	{
		PAPIListenerList *	theListenerList;

		if ( lockMutex( inConnection->mListenersMutex ) == 0 )
		{
			theListenerList = inConnection->mListeners;
			while ( theListenerList != 0 )
			{
				int theLen = strlen( theListenerList->mComponentName );
				if ( strcmp( theListenerList->mComponentName,
						     theComponentNames->data ) == 0 				||
					 ( theListenerList->mComponentName[ theLen - 1 ] == '.' &&
					   strncmp( theListenerList->mComponentName,
								theComponentNames->data,
								theLen ) == 0 ) )
				{
					PAPIEventType theEventType;
					switch( inMessage->mName )
					{
						case PAPImodifyNotification:
							theEventType = PAPIComponentModify;
							break;

						case PAPIaddNotification:
							theEventType = PAPIComponentAdd;
							break;

						case PAPIremoveNotification:
							theEventType = PAPIComponentRemove;
							break;
					}
					createNotificationThread( theListenerList->mListener,
											  theEventType,
										  	  theComponentNames->data,
										  	  theListenerList->mUserData);
				}
				theListenerList = theListenerList->mNext;
			}
			theComponentNames = theComponentNames->next;		
			unlockMutex( inConnection->mListenersMutex );
		}
	}
	deleteStringList( theTmpList );
}
示例#19
0
bool Parameters::loadParams(int argc, char ** argv) {
    // load params from commandline args
    //if( argc < 3 ) {
    //  fprintf(stderr, "ERROR: No parameters. Use \"-config\" or \"-f\" to specify configuration file.\n");
    //  return false;
    //}
    bool load_from_file = false;
    std::set<std::string> setParams;
    int jumpBy = 0;
    for( int i = 1; i < argc; i += jumpBy ) {
        std::string param = argv[i];
        if(param[0] != '-') {
            std::cerr << "Unknown parameter: " << param << std::endl;
            return false;
        }
        Utils::ltrim(param, "- ");
        // normalise parameter to long name
        param = normaliseParamName(param);
        // check if valid param name
        if(!isValidParamName(param)) {
            std::cerr << "Unknown param option \"" << param << "\"\n";
            exit(EXIT_FAILURE);
        }
        setParams.insert(param);  // needed to not overwrite param value if file is specified
        //if the parameter is of type booL no corresponding value
        if( getValueType(param) == kBoolValue ) {
            jumpBy = 1;
            assert(setParamValue(param, kTrueValue));
        } else { //not of type bool so must have corresponding value
            assert(i+1 < argc);
            jumpBy = 2;
            std::string val = argv[i+1];
            Utils::trim(val);
            if( param == "config" )
                load_from_file = true;
            if(!setParamValue(param, val)) {
                std::cerr << "Invalid Param name->value " << param << "->" << val << std::endl;
                return false;
            }
        }
    }
    bool success = true;
    // load from file if specified
    if (load_from_file)
        success = loadParams(getParamValue("config"), setParams);
    return success;
}
示例#20
0
SWIGEXPORT jfloat JNICALL Java_com_dsp_1faust_dsp_1faustJNI_getParamValue(JNIEnv *jenv, jclass jcls, jstring jarg1) {
    jfloat jresult = 0 ;
    char *arg1 = (char *) 0 ;
    float result;

    (void)jenv;
    (void)jcls;
    arg1 = 0;
    if (jarg1) {
        arg1 = (char *)jenv->GetStringUTFChars(jarg1, 0);
        if (!arg1) return 0;
    }
    result = (float)getParamValue((char const *)arg1);
    jresult = (jfloat)result;
    if (arg1) jenv->ReleaseStringUTFChars(jarg1, (const char *)arg1);
    return jresult;
}
void HistogramStretch::ParseArgument(CommandLineArgModel* arg)
{
	HistogramStretchModel* model = new HistogramStretchModel();
	bool hasPercentile = false;
	model->hasRoi = false;
	model->Percentile = 0.05;

	for (unsigned int index = 0; index < arg->Parameters->size(); index++)
	{
		if (!model->hasRoi)
		{
			Rectangle roi = parseRoi(arg->Parameters->at(index));
			if (roi.Bottom != -1)
			{
				model->hasRoi = true;
				model->Roi = roi;
			}
		}

		if (!hasPercentile)
		{
			string value = getParamValue("percentile", arg->Parameters->at(index));

			if (value.length())
			{
				hasPercentile = true;
				model->Percentile = stod(trim(value));
				if (model->Percentile > 1.0)
				{
					model->Percentile = 1.0;
				}
				else if (model->Percentile < 0.0)
				{
					model->Percentile = 0.0;
				}
			}
		}
	}

	arg->ParsedModel = model;
}
示例#22
0
 bool Channel::addParam(customKey* key) {
	customKey *curkey = getParamValue(key->name,NULL,0);
	if(key->name[0] == 'b' && key->name[1] == '_') { //broadcast flag
		this->sendToChan(":s 704 %s %s BCAST :\\%s\\%s",getName(),getName(),key->name,key->value);
	}
	if(curkey != NULL) {
		if(key->value[0] == 0) {
			chanKeys.remove(curkey);
			free(curkey);
			return false;
		}
		strcpy(curkey->value,key->value);
		return false;
	}
	customKey *newkey = (customKey *)malloc(sizeof(customKey));
	if(newkey != NULL) {
		memcpy(newkey,key,sizeof(customKey));
		chanKeys.push_back(newkey);
	}
	return true;
}
示例#23
0
bool Channel::addUserParam(customKey* key, chanClient *user) {
	customKey *curkey = getParamValue(key->name,NULL,0);
	if(key->name[0] == 'b' && key->name[1] == '_') {
		void (Channel::*sendmethod)(char *fmt, ...);
		char *nick;
		user->client->getUserInfo(&nick,NULL,NULL,NULL);
		if(user->invisible) {
			sendmethod = &Channel::invisibleSend;
		} else {
			sendmethod = &Channel::sendToChan;
		}
		//:s 702 #gsp!!test #gsp!!test CHC BCAST :\b_lol
		char setval[256];
		memset(&setval,0,sizeof(setval));
		if(key->value[0] != 0) {
			snprintf(setval,sizeof(setval),"\\%s",key->value);
		} else {
			snprintf(setval,sizeof(setval),"\\");
		}
		(*this.*sendmethod)(":s 702 %s %s %s BCAST :\\%s%s",getName(),getName(),nick,key->name,setval);
	}
	if(curkey != NULL) {
		if(key->value[0] == 0) {
			user->userKeys->remove(curkey);
			return false;
		}
		strcpy(curkey->value,key->value);
		return false;
	}
	customKey *newkey = (customKey *)malloc(sizeof(customKey));
	if(newkey != NULL) {
		memcpy(newkey,key,sizeof(customKey));
		user->userKeys->push_back(newkey);
	} else return false;
	return true;
}
void sendInternalNotification( PAPIConnection * inConnection,
							   PAPIMessage *	inMessage )
{
	PAPIMessageName theName = inMessage->mName;
	if ( theName == PAPIaddNotification || theName == PAPIremoveNotification )
	{
		PAPIStringList * theComponentNames	=
			getParamValue( inMessage, PAPIParamComponentName );
		PAPIStringList * theTmpList			= theComponentNames;
		while ( theTmpList != 0 )
		{
			PAPIEvent theEvent;
			theEvent.eventType =
				theName == PAPIaddNotification ?
					PAPIComponentAdd : PAPIComponentRemove;
			theEvent.componentName = theTmpList->data;
			inConnection->mInternalListener(
							&theEvent,
							inConnection->mInternalListenerData );
			theTmpList = theTmpList->next;
		}
		deleteStringList( theComponentNames );
	}
}
示例#25
0
void clq_sep_set_params_parse_cmd_line( CliqueSeparation *clqsp, const int argc, const char **argv )
{
    int i;

#define STR_SIZE 256
    char param[STR_SIZE] = "";
    char paramName[STR_SIZE] = "";
    char paramValue[STR_SIZE] = "";

    for ( i=1 ; ( i<argc ) ; ++i )
    {
        strncpy( param, argv[i], STR_SIZE );
        if ( strstr( param, "=" ) == NULL )
            continue;

        getParamName( paramName, param );
        getParamValue( paramValue, param );

        if ( strcasecmp( CLQ_SEP_STR_MAX_DEPTH, paramName ) == 0 )
        {
            clqsp->maxDepth = atoi( paramValue );
            continue;
        }

        if ( strcasecmp( CLQ_SEP_STR_MAX_PASSES, paramName ) == 0 )
        {
            clqsp->maxPasses = atoi( paramValue );
            continue;
        }

        if ( strcasecmp( CLQ_SEP_STR_MIN_VIOL, paramName ) == 0 )
        {
            clqsp->minViol = atof( paramValue );
            continue;
        }

        if ( strcasecmp( CLQ_SEP_STR_EXTEND, paramName ) == 0 )
        {
            clqsp->extendCliques = atoi( paramValue );
            continue;
        }

        if ( strcasecmp( CLQ_SEP_STR_ENUM, paramName ) == 0 )
        {
            clqsp->enumUsage = atoi( paramValue );
            continue;
        }

        if ( strcasecmp( CLQ_SEP_STR_VERBOSE, paramName ) == 0 )
        {
            clqsp->verbose = atoi( paramValue );
            continue;
        }

        if ( strcasecmp( CLQ_SEP_STR_MAX_CLQE_SIZE, paramName ) == 0 )
        {
            clqe_set_max_clqe_size(clqsp->clqe, atoi( paramValue ));
            continue;
        }
    }
#undef STR_SIZE
}
示例#26
0
 void setCurrentProgram (int newIndex)
 {
     if (plugin != nullptr)
         for (int i = 0; i < parameters.size(); ++i)
             parameterValues[i] = getParamValue (plugin->PortRangeHints [parameters[i]]);
 }
示例#27
0
// Return TRUE if character has to update visual params.
BOOL LLPhysicsMotion::onUpdate(F32 time)
{
        // static FILE *mFileWrite = fopen("c:\\temp\\avatar_data.txt","w");
        
        if (!mParamDriver)
                return FALSE;

        if (!mLastTime)
        {
                mLastTime = time;
                return FALSE;
        }

        ////////////////////////////////////////////////////////////////////////////////
        // Get all parameters and settings
        //

        const F32 time_delta = time - mLastTime;

	// Don't update too frequently, to avoid precision errors from small time slices.
	if (time_delta <= .01)
	{
		return FALSE;
	}
	
	// If less than 1FPS, we don't want to be spending time updating physics at all.
        if (time_delta > 1.0)
        {
                mLastTime = time;
                return FALSE;
        }

        // Higher LOD is better.  This controls the granularity
        // and frequency of updates for the motions.
        const F32 lod_factor = LLVOAvatar::sPhysicsLODFactor;
        if (lod_factor == 0)
        {
                return TRUE;
        }

        LLJoint *joint = mJointState->getJoint();

        const F32 behavior_mass = getParamValue("Mass");
        const F32 behavior_gravity = getParamValue("Gravity");
        const F32 behavior_spring = getParamValue("Spring");
        const F32 behavior_gain = getParamValue("Gain");
        const F32 behavior_damping = getParamValue("Damping");
        const F32 behavior_drag = getParamValue("Drag");
        const BOOL physics_test = FALSE; // Enable this to simulate bouncing on all parts.
        
        F32 behavior_maxeffect = getParamValue("MaxEffect");
        if (physics_test)
                behavior_maxeffect = 1.0f;

	// Normalize the param position to be from [0,1].
	// We have to use normalized values because there may be more than one driven param,
	// and each of these driven params may have its own range.
	// This means we'll do all our calculations in normalized [0,1] local coordinates.
	const F32 position_user_local = (mParamDriver->getWeight() - mParamDriver->getMinWeight()) / (mParamDriver->getMaxWeight() - mParamDriver->getMinWeight());
       	
	//
	// End parameters and settings
	////////////////////////////////////////////////////////////////////////////////
	
	
	////////////////////////////////////////////////////////////////////////////////
	// Calculate velocity and acceleration in parameter space.
	//
        
	//const F32 velocity_joint_local = calculateVelocity_local(time_iteration_step);
	const F32 velocity_joint_local = calculateVelocity_local();
	const F32 acceleration_joint_local = calculateAcceleration_local(velocity_joint_local);
	
	//
	// End velocity and acceleration
	////////////////////////////////////////////////////////////////////////////////
	
	BOOL update_visuals = FALSE;
	
	// Break up the physics into a bunch of iterations so that differing framerates will show
	// roughly the same behavior.
	for (F32 time_iteration = 0; time_iteration <= time_delta; time_iteration += TIME_ITERATION_STEP)
	{
		F32 time_iteration_step = TIME_ITERATION_STEP;
		if (time_iteration + TIME_ITERATION_STEP > time_delta)
		{
			time_iteration_step = time_delta-time_iteration;
		}
		
		// mPositon_local should be in normalized 0,1 range already.  Just making sure...
		const F32 position_current_local = llclamp(mPosition_local,
							   0.0f,
							   1.0f);
		// If the effect is turned off then don't process unless we need one more update
		// to set the position to the default (i.e. user) position.
		if ((behavior_maxeffect == 0) && (position_current_local == position_user_local))
		{
			return update_visuals;
		}

		////////////////////////////////////////////////////////////////////////////////
		// Calculate the total force 
		//

		// Spring force is a restoring force towards the original user-set breast position.
		// F = kx
		const F32 spring_length = position_current_local - position_user_local;
		const F32 force_spring = -spring_length * behavior_spring;

		// Acceleration is the force that comes from the change in velocity of the torso.
		// F = ma
		const F32 force_accel = behavior_gain * (acceleration_joint_local * behavior_mass);

		// Gravity always points downward in world space.
		// F = mg
		const LLVector3 gravity_world(0,0,1);
		const F32 force_gravity = (toLocal(gravity_world) * behavior_gravity * behavior_mass);
                
		// Damping is a restoring force that opposes the current velocity.
		// F = -kv
		const F32 force_damping = -behavior_damping * mVelocity_local;
                
		// Drag is a force imparted by velocity (intuitively it is similar to wind resistance)
		// F = .5kv^2
		const F32 force_drag = .5*behavior_drag*velocity_joint_local*velocity_joint_local*llsgn(velocity_joint_local);

		const F32 force_net = (force_accel + 
				       force_gravity +
				       force_spring + 
				       force_damping + 
				       force_drag);

		//
		// End total force
		////////////////////////////////////////////////////////////////////////////////

        
		////////////////////////////////////////////////////////////////////////////////
		// Calculate new params
		//

		// Calculate the new acceleration based on the net force.
		// a = F/m
		const F32 acceleration_new_local = force_net / behavior_mass;
		static const F32 max_velocity = 100.0f; // magic number, used to be customizable.
		F32 velocity_new_local = mVelocity_local + acceleration_new_local*time_iteration_step;
		velocity_new_local = llclamp(velocity_new_local, 
					     -max_velocity, max_velocity);
        
		// Temporary debugging setting to cause all avatars to move, for profiling purposes.
		if (physics_test)
		{
			velocity_new_local = sin(time*4.0);
		}
		// Calculate the new parameters, or remain unchanged if max speed is 0.
		F32 position_new_local = position_current_local + velocity_new_local*time_iteration_step;
		if (behavior_maxeffect == 0)
			position_new_local = position_user_local;

		// Zero out the velocity if the param is being pushed beyond its limits.
		if ((position_new_local < 0 && velocity_new_local < 0) || 
		    (position_new_local > 1 && velocity_new_local > 0))
		{
			velocity_new_local = 0;
		}
	
		// Check for NaN values.  A NaN value is detected if the variables doesn't equal itself.  
		// If NaN, then reset everything.
		if ((mPosition_local != mPosition_local) ||
		    (mVelocity_local != mVelocity_local) ||
		    (position_new_local != position_new_local))
		{
			position_new_local = 0;
			mVelocity_local = 0;
			mVelocityJoint_local = 0;
			mAccelerationJoint_local = 0;
			mPosition_local = 0;
			mPosition_world = LLVector3(0,0,0);
		}

		const F32 position_new_local_clamped = llclamp(position_new_local,
							       0.0f,
							       1.0f);

		LLDriverParam *driver_param = dynamic_cast<LLDriverParam *>(mParamDriver);
		llassert_always(driver_param);
		if (driver_param)
		{
			// If this is one of our "hidden" driver params, then make sure it's
			// the default value.
			if ((driver_param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE) &&
			    (driver_param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT))
			{
				mCharacter->setVisualParamWeight(driver_param,
								 0,
								 FALSE);
			}
			for (LLDriverParam::entry_list_t::iterator iter = driver_param->mDriven.begin();
			     iter != driver_param->mDriven.end();
			     ++iter)
			{
				LLDrivenEntry &entry = (*iter);
				LLViewerVisualParam *driven_param = entry.mParam;
				setParamValue(driven_param,position_new_local_clamped, behavior_maxeffect);
			}
		}
        
		//
		// End calculate new params
		////////////////////////////////////////////////////////////////////////////////

		////////////////////////////////////////////////////////////////////////////////
		// Conditionally update the visual params
		//
        
		// Updating the visual params (i.e. what the user sees) is fairly expensive.
		// So only update if the params have changed enough, and also take into account
		// the graphics LOD settings.
        
		// For non-self, if the avatar is small enough visually, then don't update.
		const F32 area_for_max_settings = 0.0;
		const F32 area_for_min_settings = 1400.0;
		const F32 area_for_this_setting = area_for_max_settings + (area_for_min_settings-area_for_max_settings)*(1.0-lod_factor);
		const F32 pixel_area = (F32)sqrt(mCharacter->getPixelArea());
        
		const BOOL is_self = (dynamic_cast<LLVOAvatar *>(mCharacter) != NULL && ((LLVOAvatar*)mCharacter)->isSelf());
		if ((pixel_area > area_for_this_setting) || is_self)
		{
			const F32 position_diff_local = llabs(mPositionLastUpdate_local-position_new_local_clamped);
			const F32 min_delta = (1.0001f-lod_factor)*0.4f;
			if (llabs(position_diff_local) > min_delta)
			{
				update_visuals = TRUE;
				mPositionLastUpdate_local = position_new_local;
			}
		}

		//
		// End update visual params
		////////////////////////////////////////////////////////////////////////////////

		mVelocity_local = velocity_new_local;
		mAccelerationJoint_local = acceleration_joint_local;
		mPosition_local = position_new_local;
	}
	mLastTime = time;
	mPosition_world = joint->getWorldPosition();
	mVelocityJoint_local = velocity_joint_local;


        /*
          // Write out debugging info into a spreadsheet.
          if (mFileWrite != NULL && is_self)
          {
          fprintf(mFileWrite,"%f\t%f\t%f \t\t%f \t\t%f\t%f\t%f\t \t\t%f\t%f\t%f\t%f\t%f \t\t%f\t%f\t%f\n",
          position_new_local,
          velocity_new_local,
          acceleration_new_local,

          time_delta,

          mPosition_world[0],
          mPosition_world[1],
          mPosition_world[2],

          force_net,
          force_spring,
          force_accel,
          force_damping,
          force_drag,

          spring_length,
          velocity_joint_local,
          acceleration_joint_local
          );
          }
        */

        return update_visuals;
}
示例#28
0
void LLPhysicsMotion::getString(std::ostringstream &oss)
{
	oss << 
		" mParamDriverName: " << mParamDriverName << std::endl <<
		" mParamControllerName: " << mParamControllerName << std::endl <<
		" mMotionDirectionVec: " << mMotionDirectionVec << std::endl <<
		" mJointName: " << mJointName << std::endl <<
		" mPosition_local: " << mPosition_local << std::endl << 
		" mVelocityJoint_local: " << mVelocityJoint_local << std::endl << 
		" mAccelerationJoint_local: " << mAccelerationJoint_local << std::endl << 
		" mPositionLastUpdate_local: " << mPositionLastUpdate_local << std::endl << 
		" mPosition_world: " << mPosition_world << std::endl << 
		" mVelocity_local: " << mVelocity_local << std::endl;
	if(mParamDriver)
	{
		oss << " <DRIVER>" << std::endl;
		getParamString(2,mParamDriver,oss);
		LLDriverParam *driver_param = dynamic_cast<LLDriverParam *>(mParamDriver);
		if(driver_param)
		{
			for (LLDriverParam::entry_list_t::iterator iter = driver_param->mDriven.begin();
				 iter != driver_param->mDriven.end();++iter)
			{
				oss << "  <DRIVEN>" << std::endl;
				getParamString(3,iter->mParam,oss);
			}
		}
	}
	else
		oss << " mParamDriver: (NULL)" << std::endl;
	oss << " Controllers:" << std::endl;
	for(controller_map_t::const_iterator it = mParamControllers.begin(); it!= mParamControllers.end(); ++it)
	{
		oss << "  mParamControllers[\"" << it->first << "\"] = \"" << it->second << "\" =" << getParamValue(it->first) << std::endl;
	}
}
示例#29
0
bool GLSoftBorder::process( const QList<Effect*> &el, double pts, Frame *src, Profile *p )
{
	Q_UNUSED( p );
	Q_UNUSED( src );
	return el[0]->set_float( "borderSize", getParamValue( borderSize ).toDouble() * src->glHeight / 2.0 / 100.0 );
}
int guMainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: abortInspectProcess(); break;
        case 1: show(); break;
        case 2: onGetSoapResponse(); break;
        case 3: testWebService(); break;
        case 4: loadCover((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 5: onCopyMD5ToClipboard(); break;
        case 6: onOpenCurrentEbook(); break;
        case 7: onSetLibraryForAllBooks(); break;
        case 8: onSetLibraryIssueForAllBooks(); break;
        case 9: onSetPeriodicalForAllBooks(); break;
        case 10: onSetTitleForAllBooks(); break;
        case 11: onSetAuthorsForAllBooks(); break;
        case 12: onSetSeriesForAllBooks(); break;
        case 13: onSetPublisherForAllBooks(); break;
        case 14: onSetSityForAllBooks(); break;
        case 15: onSetUdcForAllBooks(); break;
        case 16: onSetPubYearForAllBooks(); break;
        case 17: onSetBbcForAllBooks(); break;
        case 18: onSetLanguageForAllBooks(); break;
        case 19: onSetOrientationForAllBooks(); break;
        case 20: onSetScanDpiForAllBooks(); break;
        case 21: onSetColorScanForAllBooks(); break;
        case 22: onSetCleanScanForAllBooks(); break;
        case 23: { QString _r = getParamValue((*reinterpret_cast< QDomDocument*(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 24: onSetCategoryForAllBooks(); break;
        case 25: onSetCommentaryForAllBooks(); break;
        case 26: onAbortInspectProcess(); break;
        case 27: onAllEbooksUploaded(); break;
        case 28: onShowAbout(); break;
        case 29: onHelp(); break;
        case 30: initBaseSettings(); break;
        case 31: initSearchFilesSettings(); break;
        case 32: processCheckDublicateReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 33: processFillBibliographyReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 34: processLoadCoverReply((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break;
        case 35: onCurrentFileChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 36: onFilesTreeDoubleClicked((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 37: onAddNewEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< ebook(*)>(_a[2]))); break;
        case 38: onDublicateFinded(); break;
        case 39: onInspectFinished(); break;
        case 40: onStartProcess(); break;
        case 41: onEndProcess(); break;
        case 42: onTimerTimeout(); break;
        case 43: onCurrentCategoryChanged((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 44: onCurrentCategoryChangedFillStr((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QTreeWidgetItem*(*)>(_a[2]))); break;
        case 45: clearEditFields(); break;
        case 46: onInspectFolder(); break;
        case 47: onGetBiblioInfo(); break;
        case 48: onUploadToServer(); break;
        case 49: onFileListRight(); break;
        case 50: onFileListLeft(); break;
        case 51: onGetBiblioForCurrentEbook(); break;
        case 52: setGuiEditForCurrentItem(); break;
        case 53: onSaveChangesForBook(); break;
        case 54: onUploadEbookProgress((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 55: onUploadEbookFinished((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 56: onShowSettingsDialog(); break;
        case 57: onIsbnFieldChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 58: onIsbnsListItemActivated(); break;
        case 59: onAddIsbn(); break;
        case 60: onRemoveIsbn(); break;
        case 61: onAddIsbnToEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 62: onRemoveIsbnFromEbook((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 63: onCommentaryTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 64: onTitleTextChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 65: onAuthorsTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 66: onSeriesTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 67: onPublisherTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 68: onUdcTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 69: onBbcTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 70: onPubYearTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 71: onPageNumTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 72: onIssueTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 73: onVolumeTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 74: onLanguageTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 75: onDescriptionTextChanged(); break;
        case 76: onSityTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 77: onPeriodicalTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 78: onCategoryTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 79: onOrientationIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 80: onBiblioTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 81: onDpiTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 82: onDvdNumTextChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 83: onColorScanStateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 84: onClearScanStateChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 85: onSelectAllToUploadToogled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 86: onSubjectIndexChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 87: onToogleShowDublicates((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 88: onToogleShowUploaded((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 89: onToogleShowWithISBN((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 90: onToogleShowWithBibliography((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 91;
    }
    return _id;
}