当前位置: 首页>>代码示例>>C++>>正文


C++ ControlPoint::getPosition方法代码示例

本文整理汇总了C++中ControlPoint::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlPoint::getPosition方法的具体用法?C++ ControlPoint::getPosition怎么用?C++ ControlPoint::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ControlPoint的用法示例。


在下文中一共展示了ControlPoint::getPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: stretchControlPoints

	void FFTSplineControl::stretchControlPoints(float factor)
	{
		for(unsigned int i = 0; i < controlPoints.size(); i++)
		{
			ControlPoint *cp = controlPoints[i];
			assert(cp != NULL);

			float x = cp->getPosition().getX();
			x *= factor;
			cp->getPosition().setX(x);
		}
	}
开发者ID:jonathanhook,项目名称:Waves,代码行数:12,代码来源:FFTSplineControl.cpp

示例2: getValueFromControlPoint

	float SplineControl::getValueFromControlPoint(ControlPoint &cp)
	{
		float legendHeight = height * LEGEND_DIM;
		float legendlessHeight = height - (legendHeight * 2.0f);
		float cpy = 1.0f - ((cp.getPosition().getY() - legendHeight) / legendlessHeight);
		cpy = constrainYVal(cpy);

		return cpy;
	}
开发者ID:jonathanhook,项目名称:Waves,代码行数:9,代码来源:SplineControl.cpp

示例3: snapControlPoint

	void SplineControl::snapControlPoint(ControlPoint &cp)
	{
		float cpx = cp.getPosition().getX();
		float cpy = cp.getPosition().getY();

		// clamp x
		if(cpx < 0.0f) cpx = 0.0f;
		else if(cpx > width) cpx = width;

		// clamp y
		float legendDim = (height * LEGEND_DIM);
		if(cpy < legendDim) cpy = legendDim;
		else if(cpy > height - legendDim) cpy = (height - legendDim);

		// snap
		float snapIncrement = InterfaceManager::getBeatLength() / (float)BEAT_SNAP;
		float divs = floorf((cpx + (snapIncrement * 0.5f)) / snapIncrement);
		cpx = snapIncrement * divs;

		cp.getPosition().setX(cpx);
		cp.getPosition().setY(cpy);
	}
开发者ID:jonathanhook,项目名称:Waves,代码行数:22,代码来源:SplineControl.cpp

示例4: renderSplineControl

	/*
	void SplineControl::renderSplineControl(float SplineControlWidth)
	{
		glPushAttrib(GL_LINE_BIT | GL_CURRENT_BIT);
		
		glColor4f(1.0f, 1.0f, 1.0, 1.0f);
		glLineWidth(getLineWidth(2.0f));
		
		glEnable(GL_LINE_SMOOTH);
		glBegin(GL_LINE_STRIP);
			float increment = InterfaceManager::getBeatLength() / (float)InterfaceManager::VALUES_PER_BEAT;
			for(float f = 0.0; f <= SplineControlWidth; f+= (increment / (float)UPSAMPLE_FACTOR))
			{		
				float legendlessHeight = height - ((height * LEGEND_DIM) * 2.0f);
				float value = getValue(f);
				float vx = f;
				float vy = (value * legendlessHeight) + (height * LEGEND_DIM);
				glVertex3f(vx, height - vy, 0.0f);
			}
		glEnd();
		glDisable(GL_LINE_SMOOTH);

		glPopAttrib();
	}
	*/
	void SplineControl::savePreset(unsigned int presetType)
	{
		WavesGlobalState *wavesGlobalState = WavesGlobalState::getInstance();
		assert(wavesGlobalState != NULL);

		std::map<unsigned int, SplinePreset *> &splinePresets = wavesGlobalState->getSplinePresets();

		unsigned int numControlPoints = controlPoints.size();
		if(numControlPoints > 0)
		{
			std::vector<const Point2f> points;
			for(unsigned int i = 0; i < numControlPoints; i++)
			{
				ControlPoint *cp = controlPoints[i];
				assert(cp != NULL);

				const Point2f &cPos = cp->getPosition();
				
				float sx = cPos.getX() / width;
				float sy = cPos.getY() / height;
				Point2f sp(sx, sy);
				points.push_back(sp);
			}	
			
			// HACK : assume that if saved and Id in particular range, it must be a default and so save an altered copy
			if((!presetSaved && numControlPoints > 0) || (presetSaved && presetId >= 0 && presetId <= 5))
			{
				unsigned int pId = SplinePreset::generateId();
				
				SplinePreset *preset = new SplinePreset(pId, points, width, (SplinePreset::PresetType)presetType);	
				assert(preset != NULL);

				splinePresets[pId] = preset;
				
				preset->save();
				presetId = pId;
				presetSaved = true;
			}
			else
			{				
				SplinePreset *preset = splinePresets[presetId];
				assert(preset != NULL);

				preset->setPoints(points);
				preset->save();
			}
		}
	}
开发者ID:jonathanhook,项目名称:Waves,代码行数:73,代码来源:SplineControl.cpp

示例5: getValue

	float FFTSplineControl::getValue(float beat)
	{
		float position = beat;
		int size = controlPoints.size();

		if(size <= 0) return 0.5f;
		else if(size <= 1) 
		{
			return getValueFromControlPoint(*controlPoints[0]);
		}
		else
		{
			for(int i = 0; i < size; i++)
			{
				ControlPoint *cp = controlPoints[i];
				assert(cp != NULL);

				if(cp->getPosition().getX() >= position)
				{
					int index0 = i - 2;
					int index1 = i - 1;
					int index3 = i + 1;
					
					if(index0 < 0) index0 = i;
					if(index1 < 0) index1 = i;
					if(index3 >= size) index3 = i;

					float y0 = getValueFromControlPoint(*controlPoints[index0]);
					float y1 = getValueFromControlPoint(*controlPoints[index1]);
					float y2 = getValueFromControlPoint(*controlPoints[i]);
					float y3 = getValueFromControlPoint(*controlPoints[index3]);

					ControlPoint *cpi = controlPoints[index1];
					assert(cpi != NULL);

					float x0 = constrainXVal(index1 == i ? 0.0f : cpi->getPosition().getX());
					float x1 = constrainXVal(cp->getPosition().getX());

					// in case of a wrap around		
					float mu = 1.0f; 
					
					// guard against / 0
					if(x0 != x1) 
					{
						mu = (position - x0) / (x1 - x0);
					}

					if(x0 > x1)
					{
						float interval = x1 + (width - x0);
						mu = (position + (width - x0)) / interval;
					}	

					float returnVal = Interpolator::hermiteInterpolate(y0, y1, y2, y3, mu, Interpolator::DEFAULT_TENSION, 0.0f);
					return constrainYVal(returnVal);
				}
			}
			
			unsigned int index0 = size - 2;
			unsigned int index1 = size - 1;
			if(index0 < 0) index0 = size - 1;

			// for last segment
			float y0 = getValueFromControlPoint(*controlPoints[index0]);
			float y1 = getValueFromControlPoint(*controlPoints[index1]);
			float y2 = getValueFromControlPoint(*controlPoints[index1]);
			float y3 = getValueFromControlPoint(*controlPoints[index1]);

			ControlPoint *cpi = controlPoints[index1];
			assert(cpi != NULL);

			float x0 = constrainXVal(cpi->getPosition().getX());
			float x1 = constrainXVal(width);

			float interval = x1 + (width - x0);
			float mu = (position - x0) / interval;
		
			float returnVal = Interpolator::hermiteInterpolate(y0, y1, y2, y3, mu, Interpolator::DEFAULT_TENSION, 0.0f);
			return constrainYVal(returnVal);
		}
	}
开发者ID:jonathanhook,项目名称:Waves,代码行数:81,代码来源:FFTSplineControl.cpp


注:本文中的ControlPoint::getPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。