Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GetPolygonVertexUV returns UV's outside of 0.0 - 1.0 range ...

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
1501 Views, 4 Replies

GetPolygonVertexUV returns UV's outside of 0.0 - 1.0 range ...

Hello,

I am using the FBX SDK's GetPolygonVertexUV() function which supplies UV coordinates as shown below.

 

Note that these coordinates are not in the range of 0.0 - 1.0

Therefore the textures aren't mapping properly and the end results suck. Here is a code snippet to show you how I am using the function.

 

boollUnmappedUV;

boolSuccessFail = false;

SuccessFail = pMesh->GetPolygonVertexUV(lPolygonIndex,lVerticeIndex,lUVName,lCurrentUV,lUnmappedUV);

lUVs[lVertexCount*UV_STRIDE]=static_cast<float>(lCurrentUV[0]);

lUVs[lVertexCount*UV_STRIDE+1]=static_cast<float>(lCurrentUV[1]);

 

In the code above "SuccessFail" comes out to true and "lUnmappedUV" is false.

 

The Geometry comes out fine as the model's vertices and indices come out the way they are supposed to from the SDK.

 

What am I missing?

 

Thank you for your time.

 

Here is a sample of the resultant UV coordinates that GetPolygonVertexUV() returns:

 

-------------------------------------------------------------------------------------------------------

 

UV Point: S: -53.0558 T: -15.3896
UV Point: S: 5.99937 T: -15.3896
UV Point: S: -3.84315 T: 2.00539
UV Point: S: -3.84315 T: 2.00539
UV Point: S: 5.99937 T: -15.3896
UV Point: S: 5.99937 T: 2.00539
UV Point: S: -53.0558 T: -15.3896
UV Point: S: -3.84315 T: 2.00539
UV Point: S: -53.0558 T: 4.29541
UV Point: S: -3.84315 T: 4.29541
UV Point: S: -53.0558 T: 4.29541
UV Point: S: -3.84315 T: 2.00539
UV Point: S: -3.84315 T: -2.00539
UV Point: S: -53.0558 T: -4.29541
UV Point: S: -3.84315 T: -4.29541
UV Point: S: -3.84315 T: -2.00539
UV Point: S: 5.99937 T: 15.3896
UV Point: S: -53.0558 T: 15.3896
UV Point: S: 5.99937 T: 15.3896
UV Point: S: -3.84315 T: -2.00539
UV Point: S: 5.99937 T: -2.00539
UV Point: S: -3.84315 T: -2.00539
UV Point: S: -53.0558 T: 15.3896
UV Point: S: -53.0558 T: -4.29541
UV Point: S: -2.00539 T: -0.492126
UV Point: S: 15.3896 T: -0.492126
UV Point: S: 15.3896 T: 3.75462e^-009
UV Point: S: 15.3896 T: 3.75462e^-009
UV Point: S: -2.00539 T: 3.75462e^-009
UV Point: S: -2.00539 T: -0.492126
UV Point: S: -3.84315 T: -0.492126
UV Point: S: 5.99937 T: -0.492126
UV Point: S: 5.99937 T: 3.75462e^-009
UV Point: S: 5.99937 T: 3.75462e^-009
UV Point: S: -3.84315 T: 3.75462e^-009
UV Point: S: -3.84315 T: -0.492126
UV Point: S: -4.29541 T: -0.492126
UV Point: S: -2.00539 T: -0.492126
UV Point: S: -2.00539 T: 3.75462e^-009
UV Point: S: -2.00539 T: 3.75462e^-009
UV Point: S: -4.29541 T: 3.75462e^-009
UV Point: S: -4.29541 T: -0.492126
UV Point: S: -53.0557 T: -0.492126
UV Point: S: -3.84315 T: -0.492126
UV Point: S: -53.0557 T: 3.75462e^-009
UV Point: S: -3.84315 T: 3.75462e^-009
UV Point: S: -53.0557 T: 3.75462e^-009
UV Point: S: -3.84315 T: -0.492126
UV Point: S: -15.3896 T: -0.492126
UV Point: S: 4.29541 T: -0.492126
UV Point: S: 4.29541 T: 3.75462e^-009
UV Point: S: 4.29541 T: 3.75462e^-009
UV Point: S: -15.3896 T: 3.75462e^-009
UV Point: S: -15.3896 T: -0.492126
UV Point: S: 5.99937 T: 0.492126
UV Point: S: -53.0558 T: 0.492126
UV Point: S: -53.0558 T: -3.75462e^-009
UV Point: S: -53.0558 T: -3.75462e^-009
UV Point: S: 5.99937 T: -3.75462e^-009
UV Point: S: 5.99937 T: 0.492126

4 REPLIES 4
Message 2 of 5
SAlundra
in reply to: Anonymous

I use the same way and I have good texcoord from FBX :

bool Unmapped;
FbxVector2 FBXTexcoord;
if( FBXMesh->GetPolygonVertexUV( p, PolygonVertexOrder[ pv ], ElementUVLayer->GetName(), FBXTexcoord, Unmapped ) )
{
  // Check if the vertex is mapped.
  if( Unmapped == false )
  {
    const DE::CVector2 DETexcoord = ConvertVector2( FBXTexcoord );
    NewVertexTexcoord = DE::CVector2( DETexcoord.x, 1.0f - DETexcoord.y );
  }
}

Message 3 of 5
Anonymous
in reply to: SAlundra

Thank you for the post; I noticed that you use this function ConvertVector2( FBXTexcoord );

 

Does that simply create a vector out of two float values or is there a mathematical operation happening.

 

Also, is that an AutoDESK FBX function?

Message 4 of 5
SAlundra
in reply to: Anonymous

it's just an helper function to convert to my engine vector :

DE::CVector2 ConvertVector2( const FbxVector2& InputVector )
{
  DE::CVector2 OutputVector;
  OutputVector.x = static_cast< float >( InputVector[ 0 ] );
  OutputVector.y = static_cast< float >( InputVector[ 1 ] );
  return OutputVector;
}

DE::CVector4 ConvertVector4( const FbxVector4& InputVector )
{
  DE::CVector4 OutputVector;
  OutputVector.x = static_cast< float >( InputVector[ 0 ] );
  OutputVector.y = static_cast< float >( InputVector[ 1 ] );
  OutputVector.z = static_cast< float >( InputVector[ 2 ] );
  OutputVector.w = static_cast< float >( InputVector[ 3 ] );
  return OutputVector;
}

I set 1.0f-Texcoord.y because I use Direct3D coord who is : origin = top-left.

Message 5 of 5
samsonite151
in reply to: Anonymous


@Anonymous wrote:

Hello,

I am using the FBX SDK's GetPolygonVertexUV() function which supplies UV coordinates as shown below.

 

Note that these coordinates are not in the range of 0.0 - 1.0

Therefore the textures aren't mapping properly and the end results suck.



I hope you realize that UVs outside 0 to 1 are tiled or repeated.  Nothing wrong about that.
You might want to learn how UVs work first before making bad assumptions.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report