Exporting textured materials


#1

During an export process, textures are read from the face using the texturewriter object and written to disk. I need a way to read a texture when the face material is nil, but the group or component is painted with a textured material.
@thomthom, as discussed.


#2

I’ll respond in more depth tomorrow, but meanwhile you can look at my OBJ
exporter as reference. It solves the same issues :
https://bitbucket.org/thomthom/quadface-tools/src/13230587eea5d5437979c25610a31583bdf59bed/src/TT_QuadFaceTools/exporter_obj.rb?at=1.0&fileviewer=file-view-default


#3

Thanks ThomThom!

I looked at your code and it appears to also solve the much more difficult issue of the texture being mangled when the W component of the texture coordinates (UVW) is not 1. Which is resolved by creating a new group and applying the texture.

My issue turns out to be that I didn’t realise the textureWriter can pull textures from a group, I thought it only worked on a face.

The next issue appears to be that I can’t seem to get proper UV texture coordinates from the face, but I will plod on and see what I can do.


#4

With SU2018 one can use ImageRep to write files directly without adding to texture writer. (Though that limit compatibility)

My OBJ exporter might not take that into account… (I rarely apply textures like that - mainly occupationally colors.)
But it’s possible to handle that. When a face doesn’t have a texture directly applied, you get default UV coords. If the texture you inherit from a parent group is set to be 1"x1" (Texture#width. Texture#height) then you could use the UVs directly. But if #width and #height is anything else (which they usually are), you need to scale the UVs accordingly.

I don’t recall exactly the logic, but I’ll see if I can improve my OBJ exporter to handle it - then use that as an example. https://bitbucket.org/thomthom/quadface-tools/issues/112/obj-export-not-handling-textures-inherited


#5

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.