[tuhopuu-devel] uv auto calculation "from window to shere", "from window to cylinder" bug found and fixed.

BjornMose tuhopuu-devel@blender.org
Sat, 27 Dec 2003 21:17:51 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C3CCBE.E2A4A780
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

hi all, hi theeth
/* sorry for the double post. this time i hope without thoose strange =
linefeeds */
uv auto calculation "from window to shere", "from window to cylinder" =
bug found and fixed.

did test=20
switching, rotating 3d view, works;
tranformations (shift,rotation) in object mode, works; =20
parented to empty (shift,rotate), works;
parented to armature does not produce desired result, but "from window" =
does not also,
so i think that's the limit to be reached this way.

the tempmatrix finalmatrix acrobatics became obsolete,
because i found the function Mat4MulSerie(target,m1..m8).
helped me very much to find that the tranformation bug was because of =
wrong LA operations order.
(BTW evil trap: Mat3MulSerie(target,m1..m8) applies operations the other =
way round!)

may be i did not point it out that clear, but there are TWO fairly =
distinct features i've been am working on.
1. goes with uv auto calculation.=20
my code adding two new projection modes had a bug and the patch will fix =
it.

2. goes with the uv editor window. where i did add a little selection =
modifier. =20

the updated http://mitglied.lycos.de/mosebjorn/uvmapping/ may show?=20


theeth (about the featurelist.txt thing)
never was a hero in prosa/lyrics and i'm not native english but i'll =
give it a try

*** bjornmose: added =20
 two new options to uv auto calculation:
 "from window to shere", "from window to cylinder".
 the differences to sphere/cylinder mapping as is:=20
 1. the around settings of the 3D view sets the projection center
 2. the origin of the polar/spherical coordinate system always points =
out of the screen.
 so the rotation of the view affects mapping.
 3. in the cylinder case the radius of the projection cylinder is read =
by a popup button.

*** bjornmose: added =20
 a new feature that offers the possibility to select all nodes in the uv =
map that refer=20
 to the same vertex in the mesh. it is activated by pressing the CTRL =
key (without pressing
 the SHIFT for multiple select) when selecting a uv node with RMB.=20

 this feature is usefull when uv calculations generated "folded" maps.
 so some faces are occluding each other and we want to "unfold" the mesh =
projection.
 (the generic nose / ear / mouth problem uv texturing a head)

 N.B. uv coordinates (nodes) are assigned to faces and faces only hold =
indices to vertices.
 The uv editor as it is does not care about thoose (face to vertex) =
relations.=20
 This keeps the uv editor more flexible and i'd like to stick to this =
concept in genaral.


/* wheee... see if someone understands what i wrote */    =20

bjornmose=20
mailto:bjornmose@gmx.net

the patch:
cvs diff editface.c (in directory =
E:\bleCVS\tuhopuu2\source\blender\src\)
Index: editface.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/tuhopuu/tuhopuu2/source/blender/src/editface.c,v
retrieving revision 1.3
diff -r1.3 editface.c
892c892
<   float rotup[4][4], rotside[4][4], viewmatrix[4][4], =
finalmatrix[4][4], tempmatrix[4][4];
---
>   float rotup[4][4],rotside[4][4], viewmatrix[4][4], =
finalmatrix[4][4],rotobj[4][4] ;
894,895c894,895
<   float upangle =3D 0.0, sideangle =3D 0.0;
<   static float radius =3D 1.0, upangledeg =3D 90.0, sideangledeg =3D =
0.0;
---
>   float upangle =3D 0.0, sideangle =3D 0.0, radius =3D 1.0;
>   static float upangledeg =3D 90.0, sideangledeg =3D 0.0;
899c899
<   /* check if we can do this and do it otherways tell the user we =
can't*/
---
>   /* check if we can do this, do it, otherways tell the user we can't =
and quit */
902,903d901
<   case  0 : /*bounding box center*/
<    INIT_MINMAX(min, max);
904a903,904
>   case  V3D_CENTRE : /*bounding box center*/
>    INIT_MINMAX(min, max);
916a917
>   =20
919c920,921
<   case  1 : /*cursor center*/
---
>   =20
>   case  V3D_CURSOR : /*cursor center*/=20
929c931,934
<   case  2 : /*object center*/
---
>=20
>   case  V3D_LOCAL : /*object center*/=20
>   case  V3D_CENTROID : /*median refers to multiple objects centers. =
only one object here*/=20
>    {
930a936,937
>=20
>    }
932c939,940
<   default : /* other modes are not supported yet */
---
>   =20
>   default : /* covered all known modes, but if there was a new one */
939c947,949
<    if (fbutton(&radius, 0.1, 90.0, "radius") =3D=3D 0) return;
---
>    static float cylradius =3D 1.0; /* static to remeber last user =
response */
>    if (fbutton(&cylradius, 0.1, 90.0, "radius") =3D=3D 0) return;
>    radius =3D cylradius;
941d950
<   else radius =3D 1.0;
943c952
<   /* get the current view matrix */
---
>   /* get rotation of the current view matrix */
946,947c955
<   for( k=3D 0; k< 4; k++)
<   {
---
>   for( k=3D 0; k< 4; k++){
949a958,965
>=20
>   /* get rotation of the current object matrix */
>   Mat4CpyMat4(rotobj,ob->obmat);
>   /* but shifting */
>   for( k=3D 0; k< 4; k++){
>    rotobj[3][k] =3D0.0;
>   }
>  =20
957c973
<   /*if (fbutton(&sideangledeg, -180.0, 180, "Side angle") =3D=3D0) =
return;*/
---
>   /* debug helper if (fbutton(&sideangledeg, -180.0, 180, "Side =
angle") =3D=3D0) return; */
959,960c975,976
<   rotside[0][0] =3D cos(sideangle);  rotside[0][1] =3D sin(sideangle);
<   rotside[1][0] =3D -sin(sideangle);       rotside[1][1] =3D =
cos(sideangle);
---
>   rotside[0][0] =3D cos(sideangle);  rotside[0][1] =3D =
-sin(sideangle);
>   rotside[1][0] =3D sin(sideangle);       rotside[1][1] =3D =
cos(sideangle);
963c979
<   /* if (fbutton(&upangledeg, -90.0, 90.0, "Up angle") =3D=3D0) =
return;*/
---
>   /* debug helper if (fbutton(&upangledeg, -90.0, 90.0, "Up angle") =
=3D=3D0) return; */
965,966c981,982
<   rotup[1][1] =3D cos(upangle)/radius;  rotup[1][2] =3D =
sin(upangle)/radius;
<   rotup[2][1] =3D -sin(upangle)/radius;      rotup[2][2] =3D =
cos(upangle)/radius;
---
>   rotup[1][1] =3D cos(upangle)/radius;  rotup[1][2] =3D =
-sin(upangle)/radius;
>   rotup[2][1] =3D sin(upangle)/radius;      rotup[2][2] =3D =
cos(upangle)/radius;
968,971c984,986
<   /* calculate transforms */
<   Mat4MulMat4(finalmatrix,viewmatrix,rotup);
<   Mat4MulMat4(tempmatrix,finalmatrix,rotside);
<   Mat4MulMat4(finalmatrix,tempmatrix,ob->obmat);
---
>=20
>   /* calculate transforms*/
>   =
Mat4MulSerie(finalmatrix,rotup,rotside,viewmatrix,rotobj,NULL,NULL,NULL,N=
ULL);



------=_NextPart_000_0007_01C3CCBE.E2A4A780
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>hi all, hi theeth<BR>/* sorry for the =
double post.=20
this time i hope without thoose strange linefeeds */<BR>uv auto =
calculation=20
"from window to shere", "from window to cylinder" bug found and=20
fixed.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>did test <BR>switching, rotating 3d =
view,=20
works;<BR>tranformations (shift,rotation) in object mode, works;&nbsp;=20
<BR>parented to empty (shift,rotate), works;<BR>parented to armature =
does not=20
produce desired result, but "from window" does not also,<BR>so i think =
that's=20
the limit to be reached this way.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>the tempmatrix finalmatrix acrobatics =
became=20
obsolete,<BR>because i found the function =
Mat4MulSerie(target,m1..m8).<BR>helped=20
me very much to find that the tranformation bug was because of wrong LA=20
operations order.<BR>(BTW evil trap: Mat3MulSerie(target,m1..m8) applies =

operations the other way round!)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>may be i did not point it out that =
clear, but there=20
are TWO fairly distinct features i've been am working on.<BR>1. goes =
with uv=20
auto calculation. <BR>my code adding two new projection modes had a bug =
and the=20
patch will fix it.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>2. goes with the uv editor window. =
where i did add=20
a little selection modifier.&nbsp; </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>the updated <A=20
href=3D"http://mitglied.lycos.de/mosebjorn/uvmapping/">http://mitglied.ly=
cos.de/mosebjorn/uvmapping/</A>=20
may show? </FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=3DArial size=3D2>
<DIV><BR>theeth (about the featurelist.txt thing)<BR>never was a hero in =

prosa/lyrics and i'm not native english but i'll give it a try</DIV>
<DIV>&nbsp;</DIV>
<DIV>*** bjornmose: added&nbsp; <BR>&nbsp;two new options to uv auto=20
calculation:<BR>&nbsp;"from window to shere", "from window to=20
cylinder".<BR>&nbsp;the differences to sphere/cylinder mapping as is:=20
<BR>&nbsp;1. the around settings of the 3D view sets the projection=20
center<BR>&nbsp;2. the origin of the polar/spherical coordinate system =
always=20
points out of the screen.<BR>&nbsp;so the rotation of the view affects=20
mapping.<BR>&nbsp;3. in the cylinder case the radius of the projection =
cylinder=20
is read by a popup button.</DIV>
<DIV>&nbsp;</DIV>
<DIV>*** bjornmose: added&nbsp; <BR>&nbsp;a new feature that offers the=20
possibility to select all nodes in the uv map that refer <BR>&nbsp;to =
the same=20
vertex in the mesh. it is activated by pressing the CTRL key (without=20
pressing<BR>&nbsp;the SHIFT for multiple select) when selecting a uv =
node with=20
RMB. </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;this feature is usefull when uv calculations generated =
"folded"=20
maps.<BR>&nbsp;so some faces are occluding each other and we want to =
"unfold"=20
the mesh projection.<BR>&nbsp;(the generic nose / ear / mouth problem uv =

texturing a head)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;N.B. uv coordinates (nodes) are assigned to faces and faces =
only hold=20
indices to vertices.<BR>&nbsp;The uv editor as it is does not care about =
thoose=20
(face to vertex) relations. <BR>&nbsp;This keeps the uv editor more =
flexible and=20
i'd like to stick to this concept in genaral.</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>/* wheee... see if someone understands what i wrote=20
*/&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>bjornmose <BR><A=20
href=3D"mailto:bjornmose@gmx.net">mailto:bjornmose@gmx.net</A></DIV>
<DIV>&nbsp;</DIV>
<DIV>the patch:<BR>cvs diff editface.c (in directory=20
E:\bleCVS\tuhopuu2\source\blender\src\)<BR>Index:=20
editface.c<BR>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<BR>RCS=
=20
file: =
/cvsroot/tuhopuu/tuhopuu2/source/blender/src/editface.c,v<BR>retrieving=20
revision 1.3<BR>diff -r1.3 editface.c<BR>892c892<BR>&lt; =
&nbsp;&nbsp;float=20
rotup[4][4], rotside[4][4], viewmatrix[4][4], finalmatrix[4][4],=20
tempmatrix[4][4];<BR>---<BR>&gt; &nbsp;&nbsp;float =
rotup[4][4],rotside[4][4],=20
viewmatrix[4][4], finalmatrix[4][4],rotobj[4][4] =
;<BR>894,895c894,895<BR>&lt;=20
&nbsp;&nbsp;float upangle =3D 0.0, sideangle =3D 0.0;<BR>&lt; =
&nbsp;&nbsp;static=20
float radius =3D 1.0, upangledeg =3D 90.0, sideangledeg =3D =
0.0;<BR>---<BR>&gt;=20
&nbsp;&nbsp;float upangle =3D 0.0, sideangle =3D 0.0, radius =3D =
1.0;<BR>&gt;=20
&nbsp;&nbsp;static float upangledeg =3D 90.0, sideangledeg =3D=20
0.0;<BR>899c899<BR>&lt; &nbsp;&nbsp;/* check if we can do this and do it =

otherways tell the user we can't*/<BR>---<BR>&gt; &nbsp;&nbsp;/* check =
if we can=20
do this, do it, otherways tell the user we can't and quit=20
*/<BR>902,903d901<BR>&lt; &nbsp;&nbsp;case&nbsp; 0 : /*bounding box=20
center*/<BR>&lt; &nbsp;&nbsp;&nbsp;INIT_MINMAX(min, =
max);<BR>904a903,904<BR>&gt;=20
&nbsp;&nbsp;case&nbsp; V3D_CENTRE : /*bounding box center*/<BR>&gt;=20
&nbsp;&nbsp;&nbsp;INIT_MINMAX(min, max);<BR>916a917<BR>&gt;=20
&nbsp;&nbsp;&nbsp;<BR>919c920,921<BR>&lt; &nbsp;&nbsp;case&nbsp; 1 : =
/*cursor=20
center*/<BR>---<BR>&gt; &nbsp;&nbsp;&nbsp;<BR>&gt; =
&nbsp;&nbsp;case&nbsp;=20
V3D_CURSOR : /*cursor center*/ <BR>929c931,934<BR>&lt; =
&nbsp;&nbsp;case&nbsp; 2=20
: /*object center*/<BR>---<BR>&gt; <BR>&gt; &nbsp;&nbsp;case&nbsp; =
V3D_LOCAL :=20
/*object center*/ <BR>&gt; &nbsp;&nbsp;case&nbsp; V3D_CENTROID : =
/*median refers=20
to multiple objects centers. only one object here*/ <BR>&gt;=20
&nbsp;&nbsp;&nbsp;{<BR>930a936,937<BR>&gt; <BR>&gt;=20
&nbsp;&nbsp;&nbsp;}<BR>932c939,940<BR>&lt; &nbsp;&nbsp;default : /* =
other modes=20
are not supported yet */<BR>---<BR>&gt; &nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;default : /* covered all known modes, but if there was a new =
one=20
*/<BR>939c947,949<BR>&lt; &nbsp;&nbsp;&nbsp;if (fbutton(&amp;radius, =
0.1, 90.0,=20
"radius") =3D=3D 0) return;<BR>---<BR>&gt; &nbsp;&nbsp;&nbsp;static =
float cylradius=20
=3D 1.0; /* static to remeber last user response */<BR>&gt; =
&nbsp;&nbsp;&nbsp;if=20
(fbutton(&amp;cylradius, 0.1, 90.0, "radius") =3D=3D 0) return;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;radius =3D cylradius;<BR>941d950<BR>&lt; =
&nbsp;&nbsp;else radius=20
=3D 1.0;<BR>943c952<BR>&lt; &nbsp;&nbsp;/* get the current view matrix=20
*/<BR>---<BR>&gt; &nbsp;&nbsp;/* get rotation of the current view matrix =

*/<BR>946,947c955<BR>&lt; &nbsp;&nbsp;for( k=3D 0; k&lt; 4; k++)<BR>&lt; =

&nbsp;&nbsp;{<BR>---<BR>&gt; &nbsp;&nbsp;for( k=3D 0; k&lt; 4;=20
k++){<BR>949a958,965<BR>&gt; <BR>&gt; &nbsp;&nbsp;/* get rotation of the =
current=20
object matrix */<BR>&gt; =
&nbsp;&nbsp;Mat4CpyMat4(rotobj,ob-&gt;obmat);<BR>&gt;=20
&nbsp;&nbsp;/* but shifting */<BR>&gt; &nbsp;&nbsp;for( k=3D 0; k&lt; 4; =

k++){<BR>&gt; &nbsp;&nbsp;&nbsp;rotobj[3][k] =3D0.0;<BR>&gt; =
&nbsp;&nbsp;}<BR>&gt;=20
&nbsp;&nbsp;<BR>957c973<BR>&lt; &nbsp;&nbsp;/*if =
(fbutton(&amp;sideangledeg,=20
-180.0, 180, "Side angle") =3D=3D0) return;*/<BR>---<BR>&gt; =
&nbsp;&nbsp;/* debug=20
helper if (fbutton(&amp;sideangledeg, -180.0, 180, "Side angle") =
=3D=3D0) return;=20
*/<BR>959,960c975,976<BR>&lt; &nbsp;&nbsp;rotside[0][0] =3D =
cos(sideangle);&nbsp;=20
rotside[0][1] =3D sin(sideangle);<BR>&lt; &nbsp;&nbsp;rotside[1][0] =3D=20
-sin(sideangle);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotside[1][1] =3D=20
cos(sideangle);<BR>---<BR>&gt; &nbsp;&nbsp;rotside[0][0] =3D =
cos(sideangle);&nbsp;=20
rotside[0][1] =3D -sin(sideangle);<BR>&gt; &nbsp;&nbsp;rotside[1][0] =3D =

sin(sideangle);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotside[1][1] =3D=20
cos(sideangle);<BR>963c979<BR>&lt; &nbsp;&nbsp;/* if =
(fbutton(&amp;upangledeg,=20
-90.0, 90.0, "Up angle") =3D=3D0) return;*/<BR>---<BR>&gt; =
&nbsp;&nbsp;/* debug=20
helper if (fbutton(&amp;upangledeg, -90.0, 90.0, "Up angle") =3D=3D0) =
return;=20
*/<BR>965,966c981,982<BR>&lt; &nbsp;&nbsp;rotup[1][1] =3D=20
cos(upangle)/radius;&nbsp; rotup[1][2] =3D sin(upangle)/radius;<BR>&lt;=20
&nbsp;&nbsp;rotup[2][1] =3D =
-sin(upangle)/radius;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
rotup[2][2] =3D cos(upangle)/radius;<BR>---<BR>&gt; =
&nbsp;&nbsp;rotup[1][1] =3D=20
cos(upangle)/radius;&nbsp; rotup[1][2] =3D -sin(upangle)/radius;<BR>&gt; =

&nbsp;&nbsp;rotup[2][1] =3D =
sin(upangle)/radius;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
rotup[2][2] =3D cos(upangle)/radius;<BR>968,971c984,986<BR>&lt; =
&nbsp;&nbsp;/*=20
calculate transforms */<BR>&lt;=20
&nbsp;&nbsp;Mat4MulMat4(finalmatrix,viewmatrix,rotup);<BR>&lt;=20
&nbsp;&nbsp;Mat4MulMat4(tempmatrix,finalmatrix,rotside);<BR>&lt;=20
&nbsp;&nbsp;Mat4MulMat4(finalmatrix,tempmatrix,ob-&gt;obmat);<BR>---<BR>&=
gt;=20
<BR>&gt; &nbsp;&nbsp;/* calculate transforms*/<BR>&gt;=20
&nbsp;&nbsp;Mat4MulSerie(finalmatrix,rotup,rotside,viewmatrix,rotobj,NULL=
,NULL,NULL,NULL);</DIV>
<DIV>&nbsp;</DIV>
<DIV></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0007_01C3CCBE.E2A4A780--