Пример #1
0
static void PI4D_SetFraction(GF_Node *node, GF_Route *route)
{
	u32 i;
	Fixed frac;
	M_PositionInterpolator4D *_this = (M_PositionInterpolator4D *)node;

	if (! _this->key.count) return;
	if (_this->keyValue.count != _this->key.count) return;

	// The given fraction is less than the specified range
	if (_this->set_fraction < _this->key.vals[0]) {
		_this->value_changed = _this->keyValue.vals[0];
	} else if (_this->set_fraction >= _this->key.vals[_this->key.count-1]) {
		_this->value_changed = _this->keyValue.vals[_this->keyValue.count-1];
	} else {
		for (i=1; i<_this->key.count; i++) {
			// Find the key values the fraction lies between
			if (_this->set_fraction < _this->key.vals[i-1]) continue;
			if (_this->set_fraction >= _this->key.vals[i]) continue;

			frac = GetInterpolateFraction(_this->key.vals[i-1], _this->key.vals[i], _this->set_fraction);
			_this->value_changed.x = Interpolate(_this->keyValue.vals[i-1].x, _this->keyValue.vals[i].x, frac);
			_this->value_changed.y = Interpolate(_this->keyValue.vals[i-1].y, _this->keyValue.vals[i].y, frac);
			_this->value_changed.z = Interpolate(_this->keyValue.vals[i-1].z, _this->keyValue.vals[i].z, frac);
			_this->value_changed.q = Interpolate(_this->keyValue.vals[i-1].q, _this->keyValue.vals[i].q, frac);
			break;
		}
	}
	gf_node_event_out(node, 3);//"value_changed"
}
Пример #2
0
///==========================================================================================================================================
/// Friend Functions
///==========================================================================================================================================
inline const AABB3D Interpolate(const AABB3D& start, const AABB3D& end, float fractionFromStartToEnd){
	const Vec3 interpolatedMins = Interpolate(start.mins, end.mins, fractionFromStartToEnd);
	const Vec3 interpolatedMaxs = Interpolate(start.maxs, end.maxs, fractionFromStartToEnd);

	AABB3D interpolation(interpolatedMins, interpolatedMaxs);
	return interpolation;
}
Пример #3
0
void CBulletTime::Update()
{
	if (!(g_pGameCVars->bt_speed || g_pGameCVars->bt_ironsight) || gEnv->bMultiplayer)
		return;

	// normalized frametime
	float frameTime = gEnv->pTimer->GetFrameTime();
	float normFrameTime = frameTime;
	float timeScale = gEnv->pTimer->GetTimeScale();
	if (timeScale < 1.0f)
	{
		timeScale = max(0.0001f, timeScale);
		normFrameTime = frameTime/timeScale;
	}

	if (m_active)
	{
		Interpolate(m_energy, 0.0f, g_pGameCVars->bt_energy_decay, normFrameTime);
		// deactivate when we run out of energy
		if (m_energy < 0.001f)
		{
			Activate(false);
		}
	}
	else
	{
		Interpolate(m_energy, g_pGameCVars->bt_energy_max, g_pGameCVars->bt_energy_regen, normFrameTime);
	}

	Interpolate(m_timeScaleCurrent, m_timeScaleTarget, 2.0f, normFrameTime);
	gEnv->pTimer->SetTimeScale(m_timeScaleCurrent);
}
Пример #4
0
void PosInt_SetFraction(SFNode *node)
{
	u32 i;
	Float frac;
	M_PositionInterpolator *_this = (M_PositionInterpolator *)node;

	if (! _this->key.count) return;
	if (_this->keyValue.count != _this->key.count) return;
	
	// The given fraction is less than the specified range
	if (_this->set_fraction < _this->key.vals[0]) {
		_this->value_changed = _this->keyValue.vals[0];
	} else if (_this->set_fraction >= _this->key.vals[_this->key.count-1]) {
		_this->value_changed = _this->keyValue.vals[_this->keyValue.count-1];
	} else {
		for (i=1; i<_this->key.count; i++) {
			// Find the key values the fraction lies between
			if (_this->set_fraction < _this->key.vals[i-1]) continue;
			if (_this->set_fraction >= _this->key.vals[i]) continue;

			frac = GetInterpolateFraction(_this->key.vals[i-1], _this->key.vals[i], _this->set_fraction);
			_this->value_changed.x = Interpolate(_this->keyValue.vals[i-1].x, _this->keyValue.vals[i].x, frac);
			_this->value_changed.y = Interpolate(_this->keyValue.vals[i-1].y, _this->keyValue.vals[i].y, frac);
			_this->value_changed.z = Interpolate(_this->keyValue.vals[i-1].z, _this->keyValue.vals[i].z, frac);
			break;
		}
	}
	Node_OnEventOutSTR(node, "value_changed");
}
Пример #5
0
/**
This function allows to get the prediction of an non IDR picture. 
//8.4.2.2


@param DpbLuma Table of the reference decoded picture buffer.
@param DpbCb Table of the reference decoded picture buffer.
@param DpbCr Table of the reference decoded picture buffer.
@param Luma_l0 Table of current frame.
@param Luma_l1 Table of current frame.
@param Chroma_Cb_l0 Table of current frame.
@param Chroma_Cb_l1 Table of current frame.
@param Chroma_Cr_l0 Table of current frame.
@param Chroma_Cr_l1 Table of current frame.
@param mvL0 The motion vector are stocked for each 4x4 block of each macroblock.
@param mvL1 The motion vector are stocked for each 4x4 block of each macroblock.
@param ref_cache_l0 A cache table where the reference is stocked for each 4x4 block of each macroblock.
@param ref_cache_l1 A cache table where the reference is stocked for each 4x4 block of each macroblock.
@param x X-coordinate.
@param y Y-coordinate.
@param PicWidthInPix Width in pixel of the current frame.
@param PicHeightInPix Height in pixel of the current frame.
@prama RefPicListL0 List l0 of reference image.
@prama RefPicListL1 List l1 of reference image.
@param interpol Function pointer of 4x4 interpoaltion.
*/
void sample_interpolation_main(unsigned char *DpbLuma, unsigned char *DpbCb,unsigned char *DpbCr, 
							   unsigned char *Luma_l0, unsigned char *Luma_l1 , unsigned char *Chroma_Cb_l0, 
							   unsigned char *Chroma_Cb_l1, unsigned char *Chroma_Cr_l0 , unsigned char *Chroma_Cr_l1, 
							   short mvL0[][2], short mvL1[][2], short *ref_cache_l0, short *ref_cache_l1, short x, short y,
							   const short PicWidthInPix, const short PicHeightInPix , const LIST_MMO *RefPicListL0, 
							   const LIST_MMO * RefPicListL1, const interpol_4x4 *interpol)
{

	int i;


	for( i = 0; i < 16; i++){
		short index8 = SCAN8(i);
		const short Currentx = x + LOCX(i);
		const short Currenty = y + LOCY(i);

		if ( ref_cache_l0[index8] >= 0){
			 Interpolate(ref_cache_l0[index8], Currentx, Currenty, &mvL0[index8][0], 4, PicWidthInPix, PicHeightInPix, RefPicListL0, 
				 &Luma_l0[i << 4], &Chroma_Cb_l0[i << 2], &Chroma_Cr_l0[i << 2], DpbLuma, DpbCb, DpbCr, interpol);
		}

		if ( ref_cache_l1[index8] >= 0){
			 Interpolate(ref_cache_l1[index8], Currentx, Currenty, &mvL1[index8][0], 4, PicWidthInPix, PicHeightInPix, RefPicListL1, 
				 &Luma_l1[i << 4], &Chroma_Cb_l1[i << 2], &Chroma_Cr_l1[i << 2], DpbLuma, DpbCb, DpbCr, interpol);
		}
	}	
}
Пример #6
0
inline const Vector4< primitiveType > Interpolate( const Vector4< primitiveType >& start, const Vector4< primitiveType >& end, primitiveType fractionFromStartToEnd )
{
    primitiveType xInterpolated = Interpolate( start.x, end.x, fractionFromStartToEnd );
    primitiveType yInterpolated = Interpolate( start.y, end.y, fractionFromStartToEnd );
    primitiveType zInterpolated = Interpolate( start.z, end.z, fractionFromStartToEnd );
    primitiveType wInterpolated = Interpolate( start.w, end.w, fractionFromStartToEnd );
    return Vector4< primitiveType >( xInterpolated, yInterpolated, zInterpolated, wInterpolated );
}
Пример #7
0
inline Color Interpolate(Color val1, Color val2, double dDelta)
{
   return Color(
      Interpolate(val1.m_color[Color::red],    val2.m_color[Color::red],    dDelta),
      Interpolate(val1.m_color[Color::green],  val2.m_color[Color::green],  dDelta),
      Interpolate(val1.m_color[Color::blue],   val2.m_color[Color::blue],   dDelta),
      Interpolate(val1.m_color[Color::alpha],  val2.m_color[Color::alpha],  dDelta));
}
Пример #8
0
inline RGBA Interpolate(const RGBA& start, const RGBA& end, float fractionComplete) {
	RGBA interpRGBA;
	interpRGBA.r() = Interpolate(start.r(), end.r(), fractionComplete);
	interpRGBA.g() = Interpolate(start.g(), end.g(), fractionComplete);
	interpRGBA.b() = Interpolate(start.b(), end.b(), fractionComplete);
	interpRGBA.a() = Interpolate(start.a(), end.a(), fractionComplete);
	return interpRGBA;
}
Пример #9
0
	Vector3 Interpolate(const Vector3 &v1, const Vector3 &v2, float f)
	{
		Vector3 _v = v1 ;
		_v.x = Interpolate(_v.x, v2.x, f) ;
		_v.y = Interpolate(_v.y, v2.y, f) ;
		_v.z = Interpolate(_v.z, v2.z, f) ;
		return _v ;
	}
Пример #10
0
void FFMODListener::UpdateCurrentInteriorSettings()
{
	// Store the interpolation value, not the actual value
	InteriorVolumeInterp = Interpolate( InteriorEndTime );
	ExteriorVolumeInterp = Interpolate( ExteriorEndTime );
	InteriorLPFInterp = Interpolate( InteriorLPFEndTime );
	ExteriorLPFInterp = Interpolate( ExteriorLPFEndTime );
}
Пример #11
0
global func InterpolateRGBa(RGBa_1,RGBa_2,x1,x2,x3)
{
  var r = Interpolate(GetRGBaValue(RGBa_1,1),GetRGBaValue (RGBa_2,1),x1,x2,x3);
  var g = Interpolate(GetRGBaValue(RGBa_1,2),GetRGBaValue (RGBa_2,2),x1,x2,x3);
  var b = Interpolate(GetRGBaValue(RGBa_1,3),GetRGBaValue (RGBa_2,3),x1,x2,x3);
  var a = Interpolate(GetRGBaValue(RGBa_1,0),GetRGBaValue (RGBa_2,0),x1,x2,x3);

  return(RGBa(r,g,b,a));
}
Пример #12
0
int main(void) {
    int i = 24332;
    float x = 432.321;
    std::string str1("foo");
    //Works
    std::cout << Interpolate(R"(goo % goo % goo)", i, x) << std::endl;
    // Does not work, even though I'm not actually doing anything with the string argument
    std::cout << Interpolate(R"(goo %)", str1) << std::endl;
}
Пример #13
0
//----------------------------------------------------------------//
float USInterpolate::Interpolate ( u32 mode, float x0, float x1, float t, float w ) {

	float v0 = Interpolate ( mode, x0, x1, t );
	
	if ( w == 1.0f ) {
		return v0;
	}
	float v1 = Interpolate ( kLinear, x0, x1, t );
	return Interpolate ( kLinear, v1, v0, w );
}
Пример #14
0
void PressureTable::LookupSelectedCoeff(double &RoM,  double &T0,    double &E0,
                                        double &Gam0, double &a_Gam, double P,
                                        double Zm,    double Zvar,   double C) {
  InterpolatePoint(P, Zm, Zvar, C);
  RoM      = Interpolate(0);
  T0       = Interpolate(1);
  E0       = Interpolate(2);
  Gam0     = Interpolate(3);
  a_Gam    = Interpolate(4);
}
Пример #15
0
double Noise::Generate(double x, double y)
{
	double s, t, u, v;
	s = FindNoise(floor(x), floor(y));
	t = FindNoise(ceil(x), floor(y));
	u = FindNoise(floor(x), ceil(y));//Get the surrounding pixels to calculate the transition.
	v = FindNoise(ceil(x), ceil(y));
	double y1 = Interpolate(s, t, x - floorf(x));//Interpolate between the values.
	double y2 = Interpolate(u, v, x - floorf(x));//Here we use x-floorx, to get 1st dimension. Don't mind the x-floorx thingie, it's part of the cosine formula.
	return Interpolate(y1, y2, y - floorf(y));//Here we use y-floory, to get the 2nd dimension.
}
Пример #16
0
	virtual void GetInterpolatedPosition2D(float frameOffset, float& x, float& z, float& rotY)
	{
		if (!m_InWorld)
		{
			LOGERROR(L"CCmpPosition::GetInterpolatedPosition2D called on entity when IsInWorld is false");
			return;
		}

		x = Interpolate(m_LastX.ToFloat(), m_X.ToFloat(), frameOffset);
		z = Interpolate(m_LastZ.ToFloat(), m_Z.ToFloat(), frameOffset);

		rotY = m_InterpolatedRotY;
	}
Пример #17
0
void Voice::RenderAudio() {

    switch (this->PlaybackState) {

        case playback_state_ram: {
                Interpolate((sample_t*) pSample->GetCache().pStart);
                if (DiskVoice) {
                    // check if we reached the allowed limit of the sample RAM cache
                    if (Pos > MaxRAMPos) {
                        dmsg(("Voice: switching to disk playback (Pos=%f)\n", Pos));
                        this->PlaybackState = playback_state_disk;
                    }
                }
                else if (Pos >= pSample->GetCache().Size / pSample->FrameSize) {
                    this->PlaybackState = playback_state_end;
                }
            }
            break;

        case playback_state_disk: {
                if (!DiskStreamRef.pStream) {
                    // check if the disk thread created our ordered disk stream in the meantime
                    DiskStreamRef.pStream = pDiskThread->AskForCreatedStream(DiskStreamRef.OrderID);
                    if (!DiskStreamRef.pStream) {
                        std::cout << stderr << "Disk stream not available in time!" << std::endl << std::flush;
                        pDiskThread->OrderDeletionOfStream(&DiskStreamRef);
                        this->Active = false;
                        return;
                    }
                    DiskStreamRef.pStream->IncrementReadPos(pSample->Channels * (double_to_int(Pos) - MaxRAMPos));
                    Pos -= double_to_int(Pos);
                }

                // add silence sample at the end if we reached the end of the stream (for the interpolator)
                if (DiskStreamRef.State == Stream::state_end && DiskStreamRef.pStream->GetReadSpace() < (OutputBufferSize << MAX_PITCH) / pSample->Channels) {
                    DiskStreamRef.pStream->WriteSilence((OutputBufferSize << MAX_PITCH) / pSample->Channels);
                    this->PlaybackState = playback_state_end;
                }

                sample_t* ptr = DiskStreamRef.pStream->GetReadPtr(); // get the current read_ptr within the ringbuffer where we read the samples from
                Interpolate(ptr);
                DiskStreamRef.pStream->IncrementReadPos(double_to_int(Pos) * pSample->Channels);
                Pos -= double_to_int(Pos);
            }
            break;

        case playback_state_end:
            this->Active = false; // free voice
            break;
    }
}
Пример #18
0
  GeoVector 
  GetVector(fixed time) const
  {
    assert(Ready());

    if (!positive(p[2].t-p[1].t)) {
      return GeoVector(fixed_zero, Angle::zero());
    }

    const Record r0 = Interpolate(time - fixed(0.05));
    const Record r1 = Interpolate(time + fixed(0.05));
    return GeoVector(p[1].loc.distance(p[2].loc)/
                     (p[2].t-p[1].t), r0.loc.bearing(r1.loc));
  }
Пример #19
0
void Bone::ScaleForFrame(int32 f, double* x, double* y) const {
    const Frame* frame = NULL, * prevFrame = NULL, * nextFrame = NULL;
	GetFrame(f, &frame, &prevFrame, &nextFrame);

	if ( frame != NULL ) {
		*x = frame->GetScaleX();
		*y = frame->GetScaleY();
	} else if ( prevFrame != NULL  &&  nextFrame != NULL ) {
		*x = Interpolate(f, prevFrame->GetId(), nextFrame->GetId(), prevFrame->GetScaleX(), nextFrame->GetScaleX());
		*y = Interpolate(f, prevFrame->GetId(), nextFrame->GetId(), prevFrame->GetScaleY(), nextFrame->GetScaleY());
	} else {
		*x = *y = 0;
	}
}
Пример #20
0
const Rgba Interpolate(const Rgba& start, const Rgba& end, float fractionFromStartToEnd) {

	float lerpedR = Interpolate(start.fR(), end.fR(), fractionFromStartToEnd);
	float lerpedG = Interpolate(start.fG(), end.fG(), fractionFromStartToEnd);
	float lerpedB = Interpolate(start.fB(), end.fB(), fractionFromStartToEnd);
	float lerpedA = Interpolate(start.fA(), end.fA(), fractionFromStartToEnd);

	unsigned char lerpedCR = Rgba::cR(lerpedR);
	unsigned char lerpedCG = Rgba::cG(lerpedG);
	unsigned char lerpedCB = Rgba::cB(lerpedB);
	unsigned char lerpedCA = Rgba::cA(lerpedA);

	return Rgba(lerpedCR, lerpedCG, lerpedCB, lerpedCA);
}
Пример #21
0
CFrameAnimation::CFrameAnimation(CWnd* pWnd,
	int iStartX1,int iStartY1,int iStartX2,int iStartY2,
	int iEndX1,int iEndY1,int iEndX2,int iEndY2)
{
	CClientDC dc(pWnd);

	for(int i=0;i<=NUMFRAMES+1;i++)
	{
		// Remove last frame
		if(i!=0)
			InvertHollowRect(dc,
				Interpolate(iStartX1,iEndX1,i-1),
				Interpolate(iStartY1,iEndY1,i-1),
				Interpolate(iStartX2,iEndX2,i-1),
				Interpolate(iStartY2,iEndY2,i-1));

		// If we've just undrawn final frame, break out
		if(i==NUMFRAMES+1) break;

		// Draw this frame
		InvertHollowRect(dc,
			Interpolate(iStartX1,iEndX1,i),
			Interpolate(iStartY1,iEndY1,i),
			Interpolate(iStartX2,iEndX2,i),
			Interpolate(iStartY2,iEndY2,i));

		// Pause some so that user gets to see it
		Sleep(150/NUMFRAMES);
	}
}
Пример #22
0
	double InterpolatedNoise(double x, double y){
		int int_X, int_Y;
		double fractional_X, fractional_Y, v1, v2, v3, v4, i1, i2;
		int_X = (int)floor(x); //不要问我为毛用floor,c++默认居然TM的是向零取整的
		fractional_X = x - int_X;
		int_Y = (int)floor(y);
		fractional_Y = y - int_Y;
		v1 = SmoothedNoise(int_X, int_Y);
		v2 = SmoothedNoise(int_X + 1, int_Y);
		v3 = SmoothedNoise(int_X, int_Y + 1);
		v4 = SmoothedNoise(int_X + 1, int_Y + 1);
		i1 = Interpolate(v1, v2, fractional_X);
		i2 = Interpolate(v3, v4, fractional_X);
		return Interpolate(i1, i2, fractional_Y);
	}
Пример #23
0
static void CI4D_SetFraction(GF_Node *n, GF_Route *route)
{
	Fixed frac;
	u32 numElemPerKey, i, j;
	M_CoordinateInterpolator4D *_this = (M_CoordinateInterpolator4D *) n;

	if (! _this->key.count) return;
	if (_this->keyValue.count % _this->key.count) return;

	numElemPerKey = _this->keyValue.count / _this->key.count;
	//set size
	if (_this->value_changed.count != numElemPerKey)
		gf_sg_vrml_mf_alloc(&_this->value_changed, GF_SG_VRML_MFVEC4F, numElemPerKey);


	if (_this->set_fraction < _this->key.vals[0]) {
		for (i=0; i<numElemPerKey; i++)
			_this->value_changed.vals[i] = _this->keyValue.vals[i];
	} else if (_this->set_fraction > _this->key.vals[_this->key.count - 1]) {
		for (i=0; i<numElemPerKey; i++)
			_this->value_changed.vals[i] = _this->keyValue.vals[(_this->keyValue.count) - numElemPerKey + i];
	} else {
		for (j = 1; j < _this->key.count; j++) {
			// Find the key values the fraction lies between
			if ( _this->set_fraction < _this->key.vals[j-1]) continue;
			if (_this->set_fraction >= _this->key.vals[j]) continue;

			frac = GetInterpolateFraction(_this->key.vals[j-1], _this->key.vals[j], _this->set_fraction);
			for (i=0; i<numElemPerKey; i++) {
				_this->value_changed.vals[i].x = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].x,
				                                 _this->keyValue.vals[(j)*numElemPerKey + i].x,
				                                 frac);
				_this->value_changed.vals[i].y = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].y,
				                                 _this->keyValue.vals[(j)*numElemPerKey + i].y,
				                                 frac);
				_this->value_changed.vals[i].z = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].z,
				                                 _this->keyValue.vals[(j)*numElemPerKey + i].z,
				                                 frac);
				_this->value_changed.vals[i].q = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].q,
				                                 _this->keyValue.vals[(j)*numElemPerKey + i].q,
				                                 frac);
			}
			break;
		}
	}
	//invalidate
	gf_node_event_out(n, 3);//"value_changed"
}
Пример #24
0
void CI4D_SetFraction(SFNode *n)
{
	Float frac;
	u32 numElemPerKey, i, j;
	M_CoordinateInterpolator4D *_this = (M_CoordinateInterpolator4D *) n;

	if (! _this->key.count) return;
	if (_this->keyValue.count % _this->key.count) return;
	
	numElemPerKey = _this->keyValue.count / _this->key.count;
	//set size
	if (_this->value_changed.count != numElemPerKey)
		VRML_MF_Alloc(&_this->value_changed, FT_MFVec4f, numElemPerKey);


	if (_this->set_fraction < _this->key.vals[0]) {
		for (i=0; i<numElemPerKey; i++)
			_this->value_changed.vals[i] = _this->keyValue.vals[i];
	} else if (_this->set_fraction > _this->key.vals[_this->key.count - 1]) {
		for (i=0; i<numElemPerKey; i++)
			_this->value_changed.vals[i] = _this->keyValue.vals[(_this->keyValue.count) - numElemPerKey + i];
	} else {
		for (j = 1; j < _this->key.count; j++) {
			// Find the key values the fraction lies between
			if ( _this->set_fraction < _this->key.vals[j-1]) continue;
			if (_this->set_fraction >= _this->key.vals[j]) continue;

			frac = GetInterpolateFraction(_this->key.vals[j-1], _this->key.vals[j], _this->set_fraction);
			for (i=0; i<numElemPerKey; i++) {
				_this->value_changed.vals[i].x = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].x,
															_this->keyValue.vals[(j)*numElemPerKey + i].x, 
															frac);
				_this->value_changed.vals[i].y = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].y,
															_this->keyValue.vals[(j)*numElemPerKey + i].y,
															frac);
				_this->value_changed.vals[i].z = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].z,
															_this->keyValue.vals[(j)*numElemPerKey + i].z,
															frac);
				_this->value_changed.vals[i].q = Interpolate(_this->keyValue.vals[(j-1)*numElemPerKey + i].q,
															_this->keyValue.vals[(j)*numElemPerKey + i].q,
															frac);
			}
			break;
		}
	}
	//invalidate
	Node_OnEventOutSTR(n, "value_changed");
}
Пример #25
0
  GeoVector 
  GetVector(fixed time) const
  {
    if (!Ready())
      return fixed_zero;

    if (!positive(p[2].t-p[1].t)) {
      return GeoVector(fixed_zero, Angle::native(fixed_zero));
    }
    fixed alt, palt;
    GeoPoint p0, p1;
    Interpolate(time-fixed(0.05), p0, alt, palt);
    Interpolate(time+fixed(0.05), p1, alt, palt);
    return GeoVector(p[1].loc.distance(p[2].loc)/
                     (p[2].t-p[1].t), p0.bearing(p1));
  }
Пример #26
0
Ang3 CCinematicInput::UpdateAdditiveCameraInputWithController( const SUpdateContext& updateCtx, const Ang3& rawControllerInput )
{
	if (updateCtx.m_recenter)
	{
		Ang3 finalControllerAnglesLimited = rawControllerInput;

		//Yaw angle (Z axis)
		finalControllerAnglesLimited.z = -clamp_tpl((float)fsel(finalControllerAnglesLimited.z, finalControllerAnglesLimited.z * updateCtx.m_lookRightLimit, finalControllerAnglesLimited.z * updateCtx.m_lookLeftLimit), -updateCtx.m_lookLeftLimit, updateCtx.m_lookRightLimit);		

		//Pitch angle (X axis)
		finalControllerAnglesLimited.x *= (g_pGameCVars->cl_invertController == 0) ? 1.0f : -1.0f;
		finalControllerAnglesLimited.x = clamp_tpl((float)fsel(finalControllerAnglesLimited.x, finalControllerAnglesLimited.x * updateCtx.m_lookUpLimit, finalControllerAnglesLimited.x * updateCtx.m_lookDownLimit), -updateCtx.m_lookDownLimit, updateCtx.m_lookUpLimit);

		//No roll allowed
		finalControllerAnglesLimited.y = 0.0f;

		Interpolate(m_controllerAccumulatedAngles, finalControllerAnglesLimited, 2.5f, updateCtx.m_frameTime);
	}
	else
	{
		Ang3 finalControllerAnglesLimited = m_controllerAccumulatedAngles;

		finalControllerAnglesLimited.x += ( (rawControllerInput.x * updateCtx.m_frameTime * 1.5f) * ((g_pGameCVars->cl_invertController == 0) ? 1.0f : -1.0f) );
		finalControllerAnglesLimited.z -= (rawControllerInput.z * updateCtx.m_frameTime * 1.5f);

		finalControllerAnglesLimited.x = clamp_tpl(finalControllerAnglesLimited.x, -updateCtx.m_lookDownLimit, updateCtx.m_lookUpLimit);
		finalControllerAnglesLimited.z = clamp_tpl(finalControllerAnglesLimited.z, -updateCtx.m_lookLeftLimit, updateCtx.m_lookRightLimit);

		finalControllerAnglesLimited.y = 0.0f;

		m_controllerAccumulatedAngles = finalControllerAnglesLimited;
	}

	return m_controllerAccumulatedAngles;
}
Пример #27
0
void CGradientEditor::OnMouseMove(int x, int y)
{
	COLORREF colorHere = gradient->ColorAtPoint(Interpolate(x, clientRect->left, clientRect->right, 0.0, 1.0));
	tstring colorStr; ColorToHTML(colorHere, colorStr);
	display->SetHelpText(TEXT("Click (and optionally drag) to add a new step to the gradient. [color here: ") + colorStr + TEXT("]"));
	CCompoundDispItem::OnMouseMove(x, y);
}
Пример #28
0
CGradientEditor::CStepHandle *CGradientEditor::AddGradientStep(int x)
{
	double pos = Interpolate(x, clientRect->left, clientRect->right, 0.0, 1.0);
	unsigned int index = gradient->AddStep(pos, gradient->ColorAtPoint(pos));
	SetGradient(gradient);
	return stepHandles[index];
}
Пример #29
0
void CGradientEditor::OnDraw(HDC hDC, const LPRECT clientRect)
{
	this->clientRect = clientRect;

	for (int x = clientRect->left; x < clientRect->right; x++) {
		double point = Interpolate(x, clientRect->left, clientRect->right, 0.0, 1.0);
		COLORREF color = MultiplyColors(tint, gradient->ColorAtPoint(point));
		SelectObject(hDC, GetStockObject(DC_PEN));
		SetDCPenColor(hDC, color);
		MoveToEx(hDC, x, clientRect->bottom - 23, NULL);
		LineTo(hDC, x, clientRect->bottom);
		SetPixel(hDC, x, clientRect->bottom - 24, InterpolateColor(color, 0xFFFFFF, 0.125));
	}

	SetTextColor(hDC, 0xFFFFFF);
	int count = bitmap.GetCellCount();
	for (int i = 1; i < count; i++) {
		int x = i * (clientRect->right - clientRect->left) / count;
		BitBlt(hDC, x - 3, clientRect->bottom - 4, 7, 4, cellMarkerBmpDC, 0, 0, SRCINVERT);
	}

	for (std::vector<CStepHandle*>::iterator i = stepHandles.begin(); i != stepHandles.end(); i++) {
		(*i)->SetPositioningInfo(clientRect->left, clientRect->right, clientRect->bottom - 24);
	}

	CCompoundDispItem::OnDraw(hDC, clientRect);
}
Пример #30
0
double CAAInterpolate::Extremum(double Y1, double Y2, double Y3, double Y4, double Y5, double& nm)
{
  double A = Y2 - Y1;
  double B = Y3 - Y2;
  double C = Y4 - Y3;
  double D = Y5 - Y4;
  double E = B - A;
  double F = C - B;
  double G = D - C;
  double H = F - E;
  double J = G - F;
  double K = J - H;

  bool bRecalc = true;
  double nmprev = 0;
  nm = nmprev;
  while (bRecalc)
  {
    double NMprev2 = nmprev*nmprev;
    double NMprev3 = NMprev2*nmprev;
    nm = (6*B + 6*C - H - J +3*NMprev2*(H+J) + 2*NMprev3*K) / (K - 12*F);

    bRecalc = (fabs(nm - nmprev) > 1E-12);
    if (bRecalc)
      nmprev = nm;
  }

  return Interpolate(nm, Y1, Y2, Y3, Y4, Y5);
}