Thanks BotR - (Get VertexData V not U)
` Load the object
Load Object "In.dbo", 1
` Clone the object
Clone Object 2, 1
` Copy the UV layer on limb zero
CopyObjectUVLayer(2,0,1,0,0,1)
` Save
Save Object "Out.dbo",2
End
//==================================================
Function CopyObjectUVLayer(targetObject,targetLimb,sourceObject,sourceLimb,targetUVLayer,sourceUVLayer)
` Lock source limb for vertex access
Lock VertexData For Limb targetObject, targetLimb
` Store length of vertices (count minus 1)
Local vertLength : vertLength = Get Vertexdata Vertex Count() - 1
Local v
` Create arrays of UV coordinates for assignment to the target limb
Local Dim u#(vertLength)
Local Dim v#(vertLength)
For v = 0 to vertLength
u#(v) = Get VertexData U(v, sourceUVLayer)
v#(v) = Get VertexData V(v, sourceUVLayer)
Next v
` Unlock source limb
Unlock VertexData
` Lock target limb for vertex access in full overwrite mode 2
Lock VertexData For Limb targetObject, targetLimb, 2
` Write the coordinates to the target layer
For v = 0 to vertLength
Set VertexData UV v, targetUVLayer, u#(v), v#(v)
Next v
` Update the target
Unlock VertexData
EndFunction
Quote: "Yes, I just need the UV2 in a separate model."
In that case, use the UV coordinates on stage 2 to write to all of the layers in the new model like so
For targetStage = 0 to 7
` Copy the UV layer on limb zero
CopyObjectUVLayer(2,0,1,0,targetStage,1)
Next
Now in the new model, any applied shader and textures will use the same UV data from UV2. Assuming that there is only one limb in the object.