I'm going to ask this question redundantly, in a few different ways,
because it's hard to explain without pictures what I'm wanting to do,
though the concept it pretty simple. Regardless of the simplicity of
the concept, I can't work out how to do it without a LOT of complex
work in ImageMagick (specifically using PerlMagick, but I can
generally 'translate' from convert options to get it right).

First explanation -- raw form:

I want to select a specific polygon (in this case, simply a triangle
since I'm dealing with 3d models textures, and they ae imited to tris
and quads) and 'lift' it out of the image so I can stick it into
another image and distort it before making it part of the other image.
I know how to do the distortion with the Distort() method (equivalent
to the -distort directive for convert). What I don't know is how to
'select' the polygon to 'cut and paste' into the new image.

Second explanation -- reason why I want to do this form:

I'm wanting to be able to convert textures for 3D models between two
separate sets of UV mappings. If I can "grab" pieces of texture and
then distort them and drop them into place, I will have a new texture
tat fits the other mapping. The reasoning is this: There are a number
of 3D models of humans that have 'wide' support in certain 3D
communities.

These figures have a lot of texture artists making photorealistic
textures, bumpmaps etc. for them. There are other figures which have
almost *no* support. While it's relatively easy to remap the latter
figures to "take" the former ones textures, sometimes the companies
selling the former figures try to (falsely) claim copyright on the
texture coordinates themselves.

A desire to avoid  getting into a legal argument, particularly in
court where they have more money than I do to blow on lawyers even
though I am right, has inspired the need to make a simple texture
converter. While some such texture converters exist, they are limited
in the scope of the number of figures they support. I'd like to
support more, particularly the human I'm making myself right now.

Since it's a relatively simple process to remap my figure to take
their textures, I can just do this *once* to get the affine transform
coordinates for the actual adjustment of each triangle (and each quad
is simply two triangles back to back, so I can treat everything as
triangulated) a texture itself to the new coordinates. While this will
introduce some artifacts and blurring, it's acceptable because the
textures in question are generally produced at much higher resolution
than is ever really necessary anyway (I've seen 2000x2000 maps for
*teeth*).

I'd like to include such a converter for free with my figure. I have
already planned out a semi-automated system for converting conforming
clothing for the figures, and the textures and morphs are the only
blockers. Morphs are, in addition, easy because I can use the
"mapped-the-same" figure to generate a simple matrix of the vertices
in my figure and which morph deltas to interpolate with barycentric
weighting to calculate the new morph. The textures are the only
blocker, and I know how to do it *conceptually* -- just not within the
IM API.

Explanation 3: The "Photoshop equivalent" explanation

In Photoshop, I can use the polygonal lasso tool to select a triangle,
then copy it and paste it into a new image, and then distort it to fit
a new triangle on the new image, then flatten and repeat for each
triangle. Of course, doing this manually in Photoshop would be tedious
and take weeks and be prone to human error in my selections. Moreover,
I could not distribute the new texture since it's a complete
derivative work of the original texture. However, if I automated this
procedure into a script, I could very easily instruct the user on how
to run the script to convert textures themselves for their own use on
my figure.

Since I already know how to do the distortion (and it is, in fact,
better in ImageMagick because I can transform a triangle, instead of
transforming a bounding box containing a triangle, allowing for more
precision), I only need to know how to do the equivalent of:

- Select triangle polygon
- Copy it
- Paste it into a new image

After this I can easily enough distort it, and then position it on the
new image (by padding the top and left with transparent pixels to put
it in place, and then flatten the "layer" onto the new image.

If anyone can explain in IM how I go about this, I would so greatly
appreciate it!

-- 
Sean 'Dodger' Cannon
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to