The goal is to export texture coordinates with the *.OBJ file.
The US Library of Congress has a definition of the structure of the OBJ file, including color information.
https://www.loc.gov/preservation/digital/formats/fdd/fdd000507.shtml
The US Library of Congress has a definition of the structure of the OBJ file, including color information.
https://www.loc.gov/preservation/digital/formats/fdd/fdd000507.shtml
In[]:=
path=NotebookDirectory[];
In[]:=
listAtomPositions=ChemicalData["Water","AtomPositions"]//QuantityMagnitude;oxgenPosition=listAtomPositions[[1]];listAtomPositions=Map[#-oxgenPosition&,listAtomPositions];
In[]:=
regionOxygen=DiscretizeRegion[Sphere[listAtomPositions[[1]],80],MeshCellStyleRed];regionHydrogenOne=DiscretizeRegion[Sphere[listAtomPositions[[2]],50],MeshCellStyleLightBlue];regionHydrogenTwo=DiscretizeRegion[Sphere[listAtomPositions[[3]],50],MeshCellStyleLightGreen];regionWaterWithColor=BooleanRegion[Or,Flatten[{regionOxygen,regionHydrogenOne,regionHydrogenTwo}]];temp=regionWaterWithColor;TableForm[{{"is region?",RegionQ[temp]},{"embedding dimension",RegionEmbeddingDimension[temp]},{"volume",Volume[temp]},{"bounds",RegionBounds[temp]//Chop},{"mesh count",MeshCellCount[temp]}}];Export[path<>"water_with_colored_atoms.obj",regionWaterWithColor,"OverwriteTarget"True];
In[]:=
objectAfterImport=Import[path<>"water_with_colored_atoms.obj"];temp=objectAfterImport;TableForm[{{"is region?",RegionQ[temp]},{"embedding dimension",RegionEmbeddingDimension[temp]},{"volume",Volume[temp]},{"bounds",RegionBounds[temp]//Chop},{"mesh count",MeshCellCount[temp]}}]Grid[{{Show[regionWaterWithColor,PlotLabel->"(left) Original plot with color"],Show[Region[objectAfterImport],PlotLabel->"(right) After export/import *.obj,\n no color information"]}}]
Out[]//TableForm=
is region? | True | ||||||
embedding dimension | 3 | ||||||
volume | Undefined | ||||||
bounds |
| ||||||
mesh count |
|
Out[]=