double terra::PerlinNoise::Noise1D(double X, unsigned int Octaves, double Persistence, double ScalingX){
	// Exit if there are no octaves to process
	if (Octaves == 0)
		return 0.;

	// Fancy math time!
	int TruncatedX = static_cast<int>(X);
	double Left = GetSmooth(TruncatedX);
	double Right = GetSmooth(TruncatedX+1);

	// Handle multiple octaves
	if (Octaves > 1)
		return (Interpolate(Left, Right, X-TruncatedX)+Persistence*Noise1D(ScalingX*X, Octaves-1, Persistence))/(1.+Persistence);
	else
		return Interpolate(Left, Right, X-TruncatedX);
}
Exemple #2
0
void SoundParameter::Recalculate( float _input )
{
    m_input = _input;
    
    switch( m_type )
    {
        case TypeFixedValue:
        {
            m_output = m_outputLower;
            break;
        }

        case TypeRangedRandom:
        {
            float diff = m_outputUpper - m_outputLower;
            float random = frand( diff );
            m_desiredOutput = m_outputLower + random;
			float smooth = GetSmooth();
            m_output = m_desiredOutput * (1.0f-smooth) + m_output * smooth;
            break;
        }

        case TypeLinked:
        {
            if( _input <= m_inputLower &&
                _input <= m_inputUpper ) 
            {
                m_desiredOutput = m_inputLower < m_inputUpper ? m_outputLower : m_outputUpper;
            }
            else if( _input >= m_inputUpper &&
                     _input >= m_inputLower )
            {
                m_desiredOutput = m_inputLower < m_inputUpper ? m_outputUpper : m_outputLower;
            }
            else
            {
                float inputFraction = (_input - m_inputLower) / (m_inputUpper - m_inputLower);
                m_desiredOutput = m_outputLower + inputFraction * (m_outputUpper - m_outputLower);
            }
			float smooth = GetSmooth();
            m_output = m_desiredOutput * (1.0f-smooth) + m_output * smooth;
            break;
        }
    }
}
double terra::PerlinNoise::Noise2D(double X, double Y, unsigned int Octaves, double Persistence, double ScalingX, double ScalingY){
	// Exit if there are no octaves to process
	if (Octaves == 0)
		return 0.;

	// Fancy math time! Now in 2D!
	int TruncatedX = static_cast<int>(X);
	int TruncatedY = static_cast<int>(Y);
	double TopLeft = GetSmooth(TruncatedX, TruncatedY);
	double TopRight = GetSmooth(TruncatedX+1, TruncatedY);
	double BottomLeft = GetSmooth(TruncatedX, TruncatedY+1);
	double BottomRight = GetSmooth(TruncatedX+1, TruncatedY+1);
	double Top = Interpolate(TopLeft, TopRight, X-TruncatedX);
	double Bottom = Interpolate(BottomLeft, BottomRight, X-TruncatedX);

	// Handle multiple octaves
	if (Octaves > 1)
		return (Interpolate(Top, Bottom, Y-TruncatedY)+Persistence*Noise2D(ScalingX*X, ScalingY*Y, Octaves-1, Persistence))/(1.+Persistence);
	else
		return Interpolate(Top, Bottom, Y-TruncatedY);
}
// Update data according to the setting in the UI
void UC_PropertyPagePoint::Update(BOOL bToData)
{
	const GR_DLAttribPtrVect& vAttrib = m_pDLPoint->GetAttribs();
	for(GR_DLAttribPtrVect::const_iterator it = vAttrib.begin(); it != vAttrib.end(); it++)
	{
		GR_DLAttribColor* pDLAttribColor				= dynamic_cast<GR_DLAttribColor*>((*it).GetTarget());
		GR_DLAttribPointSize* pDLAttribPointSize		= dynamic_cast<GR_DLAttribPointSize*>((*it).GetTarget());
		GR_DLAttribPointSmooth* pDLAttribPointSmooth	= dynamic_cast<GR_DLAttribPointSmooth*>((*it).GetTarget());
		if(pDLAttribColor)
			bToData ? pDLAttribColor->SetColor(GetColor()) : SetColor(pDLAttribColor->GetColor());
		else if(pDLAttribPointSize)
			bToData ? pDLAttribPointSize->SetSize(GetSize()) : SetSize(pDLAttribPointSize->GetSize());
		else if(pDLAttribPointSmooth)
			bToData ? pDLAttribPointSmooth->SetSmooth(GetSmooth()) : SetSmooth(pDLAttribPointSmooth->GetSmooth());
	}
}
Exemple #5
0
void LocationDlg::UpdateEnabling()
{
	GetAnimPos()->Enable(m_iAnim != -1);
	GetSaveAnim()->Enable(m_iAnim != -1);
	GetActive()->Enable(m_iAnim != -1);
	GetSpeed()->Enable(m_iAnim != -1);
	GetReset()->Enable(m_iAnim != -1);
	GetPlay()->Enable(m_iAnim != -1);
	GetRecord1()->Enable(m_iAnim != -1);
	GetStop()->Enable(m_iAnim != -1);
	GetLoop()->Enable(m_iAnim != -1);
	GetContinuous()->Enable(m_iAnim != -1);
	GetSmooth()->Enable(m_iAnim != -1 && GetAnim(m_iAnim)->NumPoints() > 2);
	GetPosOnly()->Enable(m_iAnim != -1);

	GetRecordInterval()->Enable(m_iAnim != -1);
	GetRecordLinear()->Enable(m_iAnim != -1);

	GetRecordSpacing()->Enable(m_bRecordInterval);
	GetPlayToDisk()->Enable(m_iAnim != -1);
}
Exemple #6
0
void CModel::Write(CTxtFile* file)
{
	file->Write("$");
	file->Writeln(CAssimilateDoc::GetKeyword(TK_AS_GRABINIT, TABLE_QDT));

	if (!HasGLA())
	{
		if (GetScale() != 1.0f)
		{
			file->Write("$");
			file->Write(CAssimilateDoc::GetKeyword(TK_AS_SCALE, TABLE_QDT)," ");
			file->Writeln(va("%g",GetScale()));
		}

		if (GetKeepMotion())
		{
			file->Write("$");
			file->Writeln(CAssimilateDoc::GetKeyword(TK_AS_KEEPMOTION, TABLE_QDT));
		}

		if (GetRefGLAPath())
		{
			file->Write("$");
			file->Write(CAssimilateDoc::GetKeyword(TK_AS_REF_GLA, TABLE_QDT), " ");
			file->Writeln(va("%s", GetRefGLAPath()));
		}

		for (int iPCJ=0; iPCJ < PCJList_GetEntries(); iPCJ++)
		{
			file->Write("$");
			file->Write(CAssimilateDoc::GetKeyword(TK_AS_PCJ, TABLE_QDT)," ");
			file->Writeln( PCJList_GetEntry(iPCJ) );
		}
	}

	CComment* curComment = m_comments;
	while(curComment != NULL)
	{
		curComment->Write(file);
		curComment = curComment->GetNext();
	}

	bool bFirstSeqWritten = false;
	CSequence* curSequence = m_sequences;
	while(curSequence != NULL)
	{
		curSequence->Write(file, !bFirstSeqWritten && GetPreQuat());
		curSequence = curSequence->GetNext();

		bFirstSeqWritten = true;
	}

	file->Writeln("$", CAssimilateDoc::GetKeyword(TK_AS_GRABFINALIZE, TABLE_QDT));

	if (m_path != NULL)
	{
		file->Write("$", CAssimilateDoc::GetKeyword(GetConvertType(), TABLE_QDT));
		CString path = m_path;
	
		int loc = path.Find("/base");
		if (loc > -1)
		{
			path = path.Right(path.GetLength() - loc - 5);
			loc = path.Find("/");
			path = path.Right(path.GetLength() - loc - 1);
		}
		if (!path.GetLength())	// check that some dopey artist hasn't use the name "base" on the right hand side
		{
			path = m_path;
		}

		file->Write(" ", path, " ");

		// params stuff...

		if (IsGhoul2())
		{
			if	(GetMakeSkin())
			{
				file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_MAKESKIN,	TABLE_CONVERT), " ");
			}
			if	(GetSmooth())
			{
				file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_SMOOTH,	TABLE_CONVERT), " ");
			}
			if (GetLoseDupVerts())
			{
				file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_LOSEDUPVERTS, TABLE_CONVERT), " ");
			}
			if  (GetIgnoreBaseDeviations())
			{
				file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_IGNOREBASEDEVIATIONS, TABLE_CONVERT), " ");
			}
			if	(GetSkew90())
			{
				file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_SKEW90,	TABLE_CONVERT), " ");
			}
			if	(GetNoSkew90())
			{
				file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_NOSKEW90, TABLE_CONVERT), " ");
			}
			if	(GetMakeSkelPath() && strlen(GetMakeSkelPath()))
			{
				file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_MAKESKEL,	TABLE_CONVERT), " ");
				file->Write(GetMakeSkelPath(), " ");
			}

			// params below not used for ghoul2
		}
		else
		{
			if (giLODLevelOverride)
			{
				file->Write(va("-lod %d ",giLODLevelOverride));
			}

			file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_PLAYERPARMS, TABLE_CONVERT), " ");
			file->Write(0);//m_skipStart+1);	// ignore these, but don't want to update parser and have invalid prev files
			file->Space();
			file->Write(0);//m_skipEnd);//max upper frames);
			file->Space();		
		}

		if (m_originx || m_originy || m_originz)
		{
			file->Write("-", CAssimilateDoc::GetKeyword(TK_AS_ORIGIN, TABLE_CONVERT), " ");
			file->Write(m_originx);
			file->Space();
			file->Write(m_originy);
			file->Space();
			file->Write(m_originz);
		}

		file->Writeln();
	}
}