Material with coloured or distorted texture
-
@unknownuser said:
-
My solution to the first is to check texture.average_color and compare it with the colour of the material, if != then coloured=true? Am I thinking right?.
-
.. I have no solution.. comparing UVs using uv_at and using UVHelper? if == then distorted=false ?
Hey Tomasz,
I would guess that you are right about both 1 and 2. I haven't tried it, but the logic seems right.
I've got a Ruby function written called "Explode Distorted Texture". It works pretty well. It exports the distorted texture with the texture writer (correcting the perspective), creates a new material with that texture, and then applies it back to the original face. The only downside is that it increases the number of materials in your model. However, in many cases, you only have to explode the distorted texture for one face and then you can use the new texture on any faces that face the same direction (e.g. explode the texture for a wall, and apply the same texture to a framed painting on the wall using the ink dropper).Whaat
-
-
On #1, do you want to see if a user has altered the color of the texture, or simply if there's a texture being used? If you want to find an altered-color texture, your suggested solution won't work. face.material.color always equals face.material.texture.average_color, where there is a texture applied to the face. What you could do is create a new material by querying the filename of the attached texture, then compare the average color of the face to the average color of the new material.
I'll have to do some research on #2...
-
Whaat & Rick
I am trying to make SU2KT export distorted textures correctly. It exports coloured textures cos
there is just one texture associated with a material. My script (beta) has problem with recognizing
the first texture getting into texturewritter. When should I use uvHelp? I could use it for all faces, but it would be memory consuming and simply is not necessary.I have also noticed that UV coordinates obtained using UVHelper are affected when the faces are inside
group or component. When exploded, UVs are correct. It is a surprise for me.Whaat, your script is an interesting one, but it is half-solution.
Thanks
Tomasz -
I have found following method:
mat.materialType
Types are not described anywhere in documentation, but are quite easy to figure out:
0 - only colour
1 - texture used
2 - texture coloured
I think I have found a ruby bug. When the texture colour is reset materialType returns still 2.
It can be brought back to 0 when texture is removed.
When the user will reset colour the method is useless cos it returns wrong value.Tomasz
-
Does anyone how why when I query the UVs of distorted texture located within a group or component, I am getting wrong coordinates? I thought UVs are independent of face location. What is the 'nature' of UV_helper? Do I need to apply global transformation of the face to UV_helper object to get correct UVs?
Thanks
Tomasz -
I have sorted out issue #2.
For those interested how: I simply assign a texture to newly created group and write it to TW and then load again a face with the same texture to TW. If texture has been added twice it means it is distorted (photomatched).I still don't know how to get proper UVs for distorted texture within a group.
Tomasz
-
Tomasz,
Would the xml file be considerably bigger if all groups/components were exploded?
-
@gaieus said:
Would the xml file be considerably bigger if all groups/components were exploded?
No. Only groups\components with photomatched textures need to be exploded prior to exporting. The rest of a model can stay untouched.
I want to export correct UVs from groups because it is a proper solution -
Is there way to get inside the group and select face as one can do directly in SU? I know how to add an entity to selection but how I can enter the group(component) to use local coordinates?
I hope someone will be able to help me on the matter.
ThanksTomasz
-
gourp.entites will give you the array of entities in the group. Then run through all the items in the array, and look for your face.
-
Tomasz,
If there is no problem with the size of the xml file when there are groups or not, why don't you just explode all groups during the process? Users (like me) wouldn't find out anyway!
-
Thank you Clark. Unfortunately I am already finding faces as group entities but UVHelper doesn't give correct values or I am doing sth wrong.
Gaieus, I will issue SU2KT 2.3 without support for distorted textures within groups. I don't want to spend months on it. Exploding, exporting UVs and undoing explosion could be a solution!
Tomasz
-
AFAIK the POV-Ray script caused everything to be exploded, but it did create a backup of the skippy before doing so. Maybe you can look into a similar approach until such time as you have the code sorted?
-
@daiku said:
gourp.entites will give you the array of entities in the group. Then run through all the items in the array, and look for your face.
I just want to OPEN a group. I am using group.entities.. but it is not the case. uvHelper behaves different INSIDE.
There is method in model called close_active. But I cannot find make_active. How can I achieve it?
In other words - is there way to do outliner double click in Ruby?Tomasz
Advertisement