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: 

Offset textures on polygon faces?

1 REPLY 1
Reply
Message 1 of 2
hankm
349 Views, 1 Reply

Offset textures on polygon faces?

Hi,

I'm trying to generate a bunch of boxes into an FBX file using the SDK. Each face of the boxes can have a different tiled texture and a different translation or offset coordinate from the default origin. I've figured out how to tile the textures using FbxGeometryElementUV and FBXVector2's but I'm having trouble seeing how the position offset can be applied to the faces of the cube.

 

thanks.

1 REPLY 1
Message 2 of 2
hankm
in reply to: hankm

My current code. The top/bottom of the boxes are not tiled like the side walls.

 

// Create UV for Diffuse channel.
FbxGeometryElementUV* lUVDiffuseElement = lMesh->CreateElementUV("DiffuseUV");
FBX_ASSERT(lUVDiffuseElement != NULL);
lUVDiffuseElement->SetMappingMode(FbxGeometryElement::eByPolygonVertex);
lUVDiffuseElement->SetReferenceMode(FbxGeometryElement::eIndexToDirect);

//Wall vectors
FbxVector2 lVectors0(0, 0);
FbxVector2 lVectors1(1, 0);
FbxVector2 lVectors2(1, 4);
FbxVector2 lVectors3(0, 4);

FbxGeometryElementUV* lUVDiffuseElement = lMesh->CreateElementUV("DiffuseUV");
FBX_ASSERT(lUVDiffuseElement != NULL);
lUVDiffuseElement->SetMappingMode(FbxGeometryElement::eByPolygonVertex);
lUVDiffuseElement->SetReferenceMode(FbxGeometryElement::eIndexToDirect);

//Wall vectors
FbxVector2 lVectors0(0, 0);
FbxVector2 lVectors1(1, 0);
FbxVector2 lVectors2(1, 4);
FbxVector2 lVectors3(0, 4);
//top/bottom vectors
FbxVector2 lVectors4(0, 0);
FbxVector2 lVectors5(1, 0);
FbxVector2 lVectors6(1, 1);
FbxVector2 lVectors7(0, 1);

lUVDiffuseElement->GetDirectArray().Add(lVectors0);
lUVDiffuseElement->GetDirectArray().Add(lVectors1);
lUVDiffuseElement->GetDirectArray().Add(lVectors2);
lUVDiffuseElement->GetDirectArray().Add(lVectors3);
//Vectors for top and bottom faces
lUVDiffuseElement->GetDirectArray().Add(lVectors4);
lUVDiffuseElement->GetDirectArray().Add(lVectors5);
lUVDiffuseElement->GetDirectArray().Add(lVectors6);
lUVDiffuseElement->GetDirectArray().Add(lVectors7);

//FbxGeometryElementUV* lUVElement = lMesh->GetElementUV(0);
//lUVElement->

//Now we have set the UVs as eIndexToDirect reference and in eByPolygonVertex  mapping mode
//we must update the size of the index array.
lUVDiffuseElement->GetIndexArray().SetCount(24);

// Create polygons. Assign texture and texture UV indices.
for (i = 0; i < 6; i++)
	{
	// all faces of the cube have the same texture
	lMesh->BeginPolygon(-1, -1, -1, false);
	if ((i == 0) || (i==2))//Top and bottom
		{
		for (j = 4; j < 8; j++)
			{
			// Control point index
			lMesh->AddPolygon(lPolygonVertices[i * 4 + (j-4)]);
			
			// update the index array of the UVs that map the texture to the face
			lUVDiffuseElement->GetIndexArray().SetAt(i * 4 + (j-4), j);
			}
		}
	else
		{//east,west,north,south
		for (j = 0; j < 4; j++)
			{
			// Control point index
			lMesh->AddPolygon(lPolygonVertices[i * 4 + j]);
			// update the index array of the UVs that map the texture to the face
			lUVDiffuseElement->GetIndexArray().SetAt(i * 4 + j, j);
			}
		}
	

	lMesh->EndPolygon();
	}

 

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

Post to forums  

Autodesk Design & Make Report