Example #1
0
FbxNode *WccToFbxExporter::createSphere(FbxScene *pScene, const char *pName, float size)
{
    FbxNurbs* lNurbs = FbxNurbs::Create(pScene,pName);
    // Set nurbs properties.
    lNurbs->SetOrder(4, 4);
    lNurbs->SetStep(2, 2);
    lNurbs->InitControlPoints(8, FbxNurbs::ePeriodic, 7, FbxNurbs::eOpen);
    double lUKnotVector[] = { -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0 };
    memcpy(lNurbs->GetUKnotVector(), lUKnotVector, lNurbs->GetUKnotCount()*sizeof(double));
    double lVKnotVector[] = { 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 4.0, 4.0, 4.0 };
    memcpy(lNurbs->GetVKnotVector(), lVKnotVector, lNurbs->GetVKnotCount()*sizeof(double));
    FbxVector4* lVector4 = lNurbs->GetControlPoints();
    int i, j;
    double lPi = 3.14159;
    double lYAngle[] = { 90.0, 90.0, 52.0, 0.0, -52.0, -90.0, -90.0 };
    double lRadius[] = { 0.0, 0.283, 0.872, 1.226, 0.872, 0.283, 0.0};
    for (i = 0; i < 7; i++)
    {
        for (j = 0; j < 8; j++)
        {
            double lX = size * lRadius[i] * cos(lPi/4*j);
            double lY = size * sin(2*lPi/360*lYAngle[i]);
            double lZ = size * lRadius[i] * sin(lPi/4*j);
            double lWeight = 1.0;
            lVector4[8*i + j].Set(lX, lY, lZ, lWeight);
        }
    }
    FbxNode* lNode = FbxNode::Create(pScene,pName);
    lNode->SetNodeAttribute(lNurbs);
    lNode->LclTranslation.Set(FbxVector4(0.0, 0.0, 0.0));
    lNode->LclRotation.Set(FbxVector4(0.0, 0.0, 0.0));
    lNode->LclScaling.Set(FbxVector4(1.0, 1.0, 1.0));
    return lNode;
}
Example #2
0
void Tools::DisplayNURB::DisplayNURB( FbxNode *i_node )
{
	DisplayCommon::DisplayString( "\n\n--------------------\nNURB\n--------------------" );

	FbxNurbs* NURBs = (FbxNurbs*) i_node->GetNodeAttribute ();
	int i;

	DisplayCommon::DisplayString( "Nurb Name: ", (char *) i_node->GetName() );
	DisplayCommon::DisplayMetaDataConnections( NURBs );

	const char* surfaceModes[] = { "Raw", "Low No Normals", "Low", "High No Normals", "High" };

	DisplayCommon::DisplayString( "    Surface Mode: ", surfaceModes[NURBs->GetSurfaceMode()] );

	int controlPointsCount = NURBs->GetControlPointsCount();
	FbxVector4 *controlPoints = NURBs->GetControlPoints();

	for( i = 0; i < controlPointsCount; i++ )
	{
		DisplayCommon::DisplayInt( "    Control Point ", i );
		DisplayCommon::Display3DVector( "        Coordinates: ", controlPoints[i] );
		DisplayCommon::DisplayDouble( "        Weight: ", controlPoints[i][3] );
	}

	const char* NURBTypes[] = { "Periodic", "Closed", "Open" };

	DisplayCommon::DisplayString( "    Nurb U Type: ", NURBTypes[NURBs->GetNurbsUType()] );
	DisplayCommon::DisplayInt( "    U Count: ", NURBs->GetUCount() );
	DisplayCommon::DisplayString( "    Nurb V Type: ", NURBTypes[NURBs->GetNurbsVType()] );
	DisplayCommon::DisplayInt( "    V Count: ", NURBs->GetVCount() );
	DisplayCommon::DisplayInt( "    U Order: ", NURBs->GetUOrder() );
	DisplayCommon::DisplayInt( "    V Order: ", NURBs->GetVOrder() );
	DisplayCommon::DisplayInt( "    U Step: ", NURBs->GetUStep() );
	DisplayCommon::DisplayInt( "    V Step: ", NURBs->GetVStep() );

	FbxString string;
	int UKnotCount = NURBs->GetUKnotCount();
	int VKnotCount = NURBs->GetVKnotCount();
	int UMultiplicityCount = NURBs->GetUCount();
	int VMultiplicityCount = NURBs->GetVCount();
	double* UKnotVector = NURBs->GetUKnotVector();
	double* VKnotVector = NURBs->GetVKnotVector();
	int* UMultiplicityVector = NURBs->GetUMultiplicityVector();
	int* VMultiplicityVector = NURBs->GetVMultiplicityVector();

	string = "    U Knot Vector: ";

	for( i = 0; i < UKnotCount; i++ )
	{
		string += (float) UKnotVector[i];

		if(i < UKnotCount - 1)
		{
			string += ", ";
		}
	}

	DisplayCommon::DisplayString( string );
	string += "\n";
	FBXSDK_printf( string );

	string = "    V Knot Vector: ";

	for( i = 0; i < VKnotCount; i++ )
	{
		string += (float) VKnotVector[i];

		if( i < VKnotCount - 1 )
		{
			string += ", ";
		}
	}

	DisplayCommon::DisplayString( string );
	string += "\n";
	FBXSDK_printf(string);

	string = "    U Multiplicity Vector: ";

	for( i = 0; i < UMultiplicityCount; i++ )
	{
		string += UMultiplicityVector[i];

		if( i < UMultiplicityCount - 1 )
		{
			string += ", ";
		}
	}

	DisplayCommon::DisplayString( string );
	string += "\n";
	FBXSDK_printf(string);

	string = "    V Multiplicity Vector: ";

	for( i = 0; i < VMultiplicityCount; i++ )
	{
		string += VMultiplicityVector[i];

		if( i < VMultiplicityCount - 1 )
		{
			string += ", ";
		}
	}

	DisplayCommon::DisplayString( string );
	string += "\n";
	FBXSDK_printf( string );

	//DisplayString( "" );

	DisplayTexture::DisplayTexture( NURBs );
	DisplayMaterial::DisplayMaterial( NURBs );
	DisplayLink::DisplayLink( NURBs );
	DisplayShape::DisplayShape( NURBs );
}