Exemple #1
0
// Bake light properties.
bool LightCache::Initialize(const FbxLight * pLight, FbxAnimLayer * pAnimLayer)
{
	mType = pLight->LightType.Get();

	FbxPropertyT<FbxDouble3> lColorProperty = pLight->Color;
	FbxDouble3 lLightColor = lColorProperty.Get();
	mColorRed.mValue = static_cast<float>(lLightColor[0]);
	mColorGreen.mValue = static_cast<float>(lLightColor[1]);
	mColorBlue.mValue = static_cast<float>(lLightColor[2]);

	if (pAnimLayer)
	{
		mColorRed.mAnimCurve = lColorProperty.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COLOR_RED);
		mColorGreen.mAnimCurve = lColorProperty.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COLOR_GREEN);
		mColorBlue.mAnimCurve = lColorProperty.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COLOR_BLUE);
	}

	if (mType == FbxLight::eSpot)
	{
		FbxPropertyT<FbxDouble> lConeAngleProperty = pLight->InnerAngle;
		mConeAngle.mValue = static_cast<GLfloat>(lConeAngleProperty.Get());
		if (pAnimLayer)
			mConeAngle.mAnimCurve = lConeAngleProperty.GetCurve(pAnimLayer);
	}

	return true;
}
Exemple #2
0
void ofxFBXScene::parseRotationCurve(ofxFBXNode & node, FbxAnimLayer * pAnimLayer, FbxNode* fbxNode, FbxPropertyT<FbxDouble3> &rotation){
	node.originalRotation = ofQuaternion(rotation.Get().mData[0], ofVec3f(1, 0, 0), rotation.Get().mData[1], ofVec3f(0, 1, 0), rotation.Get().mData[2], ofVec3f(0, 0, 1));
	node.getNode().setOrientation(node.originalRotation);
	ofLogVerbose("ofxFBXScene") << "original rotation " << endl << node.originalRotation << endl;

	if(!rotation.GetCurve(pAnimLayer)) return;
	FbxAnimCurve* lAnimCurveX = rotation.GetCurve(pAnimLayer,"X");
	FbxAnimCurve* lAnimCurveY = rotation.GetCurve(pAnimLayer,"Y");
	FbxAnimCurve* lAnimCurveZ = rotation.GetCurve(pAnimLayer,"Z");


    int xKeyCount = lAnimCurveX ? lAnimCurveX->KeyGetCount() : 0;
    int yKeyCount = lAnimCurveY ? lAnimCurveY->KeyGetCount() : 0;
    int zKeyCount = lAnimCurveZ ? lAnimCurveZ->KeyGetCount() : 0;

	FbxTime   lKeyTime;
	int     lCount;
	FbxTime lXKeyTime,lYKeyTime,lZKeyTime;
	for(lCount = 0; lCount < max(max(xKeyCount,yKeyCount),zKeyCount); lCount++)
	{
		if(lCount<xKeyCount){
			lXKeyTime  = lAnimCurveX->KeyGetTime(lCount);
		}
		if(lCount<yKeyCount){
			lYKeyTime  = lAnimCurveY->KeyGetTime(lCount);
		}
		if(lCount<zKeyCount){
			lZKeyTime  = lAnimCurveZ->KeyGetTime(lCount);
		}
		lKeyTime = min(min(lXKeyTime,lYKeyTime),lZKeyTime);
		lKeyTime = lXKeyTime;

		FbxAMatrix & matrix = fbxNode->EvaluateLocalTransform(lKeyTime);
		ofxFBXKey<ofQuaternion> key;
		ofVec3f t,s;
		ofQuaternion so;
		ofMatrix4x4 m = toOf(matrix);
		m.decompose(t,key.value,s,so);
		key.timeMillis = lKeyTime.GetMilliSeconds();
		node.rotationKeys.push_back(key);
	}
}
Exemple #3
0
void ofxFBXScene::parsePositionCurve(ofxFBXNode & node, FbxAnimLayer * pAnimLayer, FbxPropertyT<FbxDouble3> &position){
	node.originalPosition = toOf(position.Get());
	node.getNode().setPosition(node.originalPosition);
	ofLogVerbose("ofxFBXScene") << "original position " << node.originalPosition << endl;


	if(!position.GetCurve(pAnimLayer)) return;
	FbxAnimCurve* lAnimCurveX = position.GetCurve(pAnimLayer,"X");
	FbxAnimCurve* lAnimCurveY = position.GetCurve(pAnimLayer,"Y");
	FbxAnimCurve* lAnimCurveZ = position.GetCurve(pAnimLayer,"Z");

    FbxTime   lKeyTime;
    int     lCount;

    int xKeyCount = lAnimCurveX? lAnimCurveX->KeyGetCount() : 0;
    int yKeyCount = lAnimCurveY? lAnimCurveY->KeyGetCount() : 0;
    int zKeyCount = lAnimCurveZ? lAnimCurveZ->KeyGetCount() : 0;

    ofxFBXKey<float> key;
    for(lCount = 0; lCount < xKeyCount; lCount++)
    {
    	key.value = lAnimCurveX->KeyGetValue(lCount);
        lKeyTime  = lAnimCurveX->KeyGetTime(lCount);
        key.timeMillis = lKeyTime.GetMilliSeconds();
        node.xKeys.push_back(key);
    }
    for(lCount = 0; lCount < yKeyCount; lCount++)
    {
    	key.value = lAnimCurveY->KeyGetValue(lCount);
        lKeyTime  = lAnimCurveY->KeyGetTime(lCount);
        key.timeMillis = lKeyTime.GetMilliSeconds();
        node.yKeys.push_back(key);
    }
    for(lCount = 0; lCount < zKeyCount; lCount++)
    {
    	key.value = lAnimCurveZ->KeyGetValue(lCount);
        lKeyTime  = lAnimCurveZ->KeyGetTime(lCount);
        key.timeMillis = lKeyTime.GetMilliSeconds();
        node.zKeys.push_back(key);
    }
}