Пример #1
0
int ADCController::GetChannelAverage(const unsigned int &Channel, const int &Reads)
{
    if(Reads <= 0)
        return -1;
    int average =0;
    for(int i = 0; i < Reads; i++)
        average += GetChannelValue(Channel);
    //TODO: Throw out values too far away from the mean values.
    return average / Reads;
}
Пример #2
0
//------------------------------------------------------------------------
void CServerSynchedStorage::AddToChannelQueue(int channelId, TSynchedKey key)
{
	SChannel *pChannel = GetChannel(channelId);
	assert(pChannel);

	if(!pChannel || !pChannel->pNetChannel || pChannel->local)
		return;

	SSendableHandle &msgHdl = m_channelQueue[SChannelQueueEnt(channelId, key)];

	TSynchedValue value;
	bool ok=GetChannelValue(channelId, key, value);
	assert(ok);

	if(!ok)
		return;

	CClientSynchedStorage::CSetChannelMsg *pMsg=0;

	switch(value.GetType())
	{
	case eSVT_Bool:
		pMsg=new CClientSynchedStorage::CSetChannelBoolMsg(channelId, this, key, value);
		break;

	case eSVT_Float:
		pMsg=new CClientSynchedStorage::CSetChannelFloatMsg(channelId, this, key, value);
		break;

	case eSVT_Int:
		pMsg=new CClientSynchedStorage::CSetChannelIntMsg(channelId, this, key, value);
		break;

	case eSVT_EntityId:
		pMsg=new CClientSynchedStorage::CSetChannelEntityIdMsg(channelId, this, key, value);
		break;

	case eSVT_String:
		pMsg=new CClientSynchedStorage::CSetChannelStringMsg(channelId, this, key, value);
		break;
	}

	if(pMsg)
		pChannel->pNetChannel->SubstituteSendable(pMsg, 1, &pChannel->lastOrderedMessage, &msgHdl);
	else
	{
		assert(!"Invalid type!");
	}
}
	std::vector<std::shared_ptr<KeyFrameAnimation>> FBXConverter::LoadCurve(FbxAnimLayer* fbxAnimLayer, FbxNode* fbxNode, int32_t frameCount)
	{
		std::vector<std::shared_ptr<KeyFrameAnimation>> ret;
		auto boneName = fbxNode->GetName();
		auto transXCurve = fbxNode->LclTranslation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
		auto transYCurve = fbxNode->LclTranslation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
		auto transZCurve = fbxNode->LclTranslation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);

		auto rotXCurve = fbxNode->LclRotation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
		auto rotYCurve = fbxNode->LclRotation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
		auto rotZCurve = fbxNode->LclRotation.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);

		auto rot = fbxNode->LclRotation.GetCurveNode(fbxAnimLayer);
		auto lclR = fbxNode->LclRotation.Get();
		auto defRotX = lclR[0];
		auto defRotY = lclR[1];
		auto defRotZ = lclR[2];
		if (rot != nullptr)
		{
			for (size_t i = 0; i < rot->GetChannelsCount(); i++)
			{
				auto name = rot->GetChannelName(i);
				if (name == "X")
				{
					defRotX = rot->GetChannelValue(name, defRotX);
				}
				if (name == "Y")
				{
					defRotY = rot->GetChannelValue(name, defRotY);
				}
				if (name == "Z")
				{
					defRotZ = rot->GetChannelValue(name, defRotZ);
				}
			}

		}

		auto sclXCurve = fbxNode->LclScaling.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_X);
		auto sclYCurve = fbxNode->LclScaling.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);
		auto sclZCurve = fbxNode->LclScaling.GetCurve(fbxAnimLayer, FBXSDK_CURVENODE_COMPONENT_Z);

		if (transXCurve != nullptr)
		{
			auto c = LoadCurve(transXCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::TX;
			ret.push_back(c);
		}

		if (transYCurve != nullptr)
		{
			auto c = LoadCurve(transYCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::TY;
			ret.push_back(c);
		}

		if (transZCurve != nullptr)
		{
			auto c = LoadCurve(transZCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::TZ;
			ret.push_back(c);
		}

		if (rotXCurve != nullptr)
		{
			auto c = LoadCurve(rotXCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::RX;
			ret.push_back(c);
		}

		if (rotYCurve != nullptr)
		{
			auto c = LoadCurve(rotYCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::RY;
			ret.push_back(c);
		}

		if (rotZCurve != nullptr)
		{
			auto c = LoadCurve(rotZCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::RZ;
			ret.push_back(c);
		}

		if (sclXCurve != nullptr)
		{
			auto c = LoadCurve(sclXCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::SX;
			ret.push_back(c);
		}

		if (sclYCurve != nullptr)
		{
			auto c = LoadCurve(sclYCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::SY;
			ret.push_back(c);
		}

		if (sclZCurve != nullptr)
		{
			auto c = LoadCurve(sclZCurve, frameCount);
			c->Name = boneName;
			c->Target = AnimationTarget::SZ;
			ret.push_back(c);
		}

		for (auto i = 0; i< fbxNode->GetChildCount(); i++)
		{
			auto kfas = LoadCurve(fbxAnimLayer, fbxNode->GetChild(i), frameCount);

			for (auto a : kfas)
			{
				ret.push_back(a);
			}
		}

		return ret;
	}