Could someone tell me the lines of code I need to copy the UVs from one model to another (which have identical topology) in Swift?
Or how to export a UVSet from Autodesk Maya and apply it to a 3D model in Scenekit?
Could someone tell me the lines of code I need to copy the UVs from one model to another (which have identical topology) in Swift?
Or how to export a UVSet from Autodesk Maya and apply it to a 3D model in Scenekit?
Texture coordinates are stored in SCNGeometrySource
instances. To copy a source to another geometry you'll have to combine them and create a new geometry using the geometryWithSources:elements:
constructor.
Here's a MEL code for getting .OBJ
geometry and its corresponding .MTL
texture from Maya:
// select poly object
select -r pSphereShape1 ;
// shift-select a procedural texture (assigned as Blinn) in Hypershade
select -tgl blinn1 ;
// assign "Edit – Convert to file texture..." command in Hypershade
convertSolidTx -resolutionX 1024 -resolutionY 1024 -fileFormat "jpg" ramp1.outColor pSphere1 ;
// This results in "file2" in Hypershade
// select new shader
select -r blinn2 ;
// "File – Export Selected Network" command in Hypershade
file -op "groups=1; ptgroups=1; materials=1; smoothing=1; normals=1; " -typ "OBJexport" -pr -es "/Users/swift/Desktop/texture.obj" ;
/*
This results in:
/Users/swift/Desktop/texture.obj
/Users/swift/Desktop/texture.mtl
*/
Read here: How To Apply .MTL File on .OBJ 3d Model via SceneKit & Model I/O.