[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> </DIV>
<DIV><FONT face=3DArial size=3D2>did test <BR>switching, rotating 3d =
view,=20
works;<BR>tranformations (shift,rotation) in object mode, works; =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> </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> </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> </DIV>
<DIV><FONT face=3DArial size=3D2>2. goes with the uv editor window. =
where i did add=20
a little selection modifier. </FONT></DIV>
<DIV> </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> </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> </DIV>
<DIV>*** bjornmose: added <BR> two new options to uv auto=20
calculation:<BR> "from window to shere", "from window to=20
cylinder".<BR> the differences to sphere/cylinder mapping as is:=20
<BR> 1. the around settings of the 3D view sets the projection=20
center<BR> 2. the origin of the polar/spherical coordinate system =
always=20
points out of the screen.<BR> so the rotation of the view affects=20
mapping.<BR> 3. in the cylinder case the radius of the projection =
cylinder=20
is read by a popup button.</DIV>
<DIV> </DIV>
<DIV>*** bjornmose: added <BR> a new feature that offers the=20
possibility to select all nodes in the uv map that refer <BR> to =
the same=20
vertex in the mesh. it is activated by pressing the CTRL key (without=20
pressing<BR> the SHIFT for multiple select) when selecting a uv =
node with=20
RMB. </DIV>
<DIV> </DIV>
<DIV> this feature is usefull when uv calculations generated =
"folded"=20
maps.<BR> so some faces are occluding each other and we want to =
"unfold"=20
the mesh projection.<BR> (the generic nose / ear / mouth problem uv =
texturing a head)</DIV>
<DIV> </DIV>
<DIV> N.B. uv coordinates (nodes) are assigned to faces and faces =
only hold=20
indices to vertices.<BR> The uv editor as it is does not care about =
thoose=20
(face to vertex) relations. <BR> This keeps the uv editor more =
flexible and=20
i'd like to stick to this concept in genaral.</DIV>
<DIV> </DIV>
<DIV><BR>/* wheee... see if someone understands what i wrote=20
*/ </DIV>
<DIV> </DIV>
<DIV>bjornmose <BR><A=20
href=3D"mailto:bjornmose@gmx.net">mailto:bjornmose@gmx.net</A></DIV>
<DIV> </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>< =
float=20
rotup[4][4], rotside[4][4], viewmatrix[4][4], finalmatrix[4][4],=20
tempmatrix[4][4];<BR>---<BR>> float =
rotup[4][4],rotside[4][4],=20
viewmatrix[4][4], finalmatrix[4][4],rotobj[4][4] =
;<BR>894,895c894,895<BR><=20
float upangle =3D 0.0, sideangle =3D 0.0;<BR>< =
static=20
float radius =3D 1.0, upangledeg =3D 90.0, sideangledeg =3D =
0.0;<BR>---<BR>>=20
float upangle =3D 0.0, sideangle =3D 0.0, radius =3D =
1.0;<BR>>=20
static float upangledeg =3D 90.0, sideangledeg =3D=20
0.0;<BR>899c899<BR>< /* check if we can do this and do it =
otherways tell the user we can't*/<BR>---<BR>> /* check =
if we can=20
do this, do it, otherways tell the user we can't and quit=20
*/<BR>902,903d901<BR>< case 0 : /*bounding box=20
center*/<BR>< INIT_MINMAX(min, =
max);<BR>904a903,904<BR>>=20
case V3D_CENTRE : /*bounding box center*/<BR>>=20
INIT_MINMAX(min, max);<BR>916a917<BR>>=20
<BR>919c920,921<BR>< case 1 : =
/*cursor=20
center*/<BR>---<BR>> <BR>> =
case =20
V3D_CURSOR : /*cursor center*/ <BR>929c931,934<BR>< =
case 2=20
: /*object center*/<BR>---<BR>> <BR>> case =
V3D_LOCAL :=20
/*object center*/ <BR>> case V3D_CENTROID : =
/*median refers=20
to multiple objects centers. only one object here*/ <BR>>=20
{<BR>930a936,937<BR>> <BR>>=20
}<BR>932c939,940<BR>< default : /* =
other modes=20
are not supported yet */<BR>---<BR>> <BR>>=20
default : /* covered all known modes, but if there was a new =
one=20
*/<BR>939c947,949<BR>< if (fbutton(&radius, =
0.1, 90.0,=20
"radius") =3D=3D 0) return;<BR>---<BR>> static =
float cylradius=20
=3D 1.0; /* static to remeber last user response */<BR>> =
if=20
(fbutton(&cylradius, 0.1, 90.0, "radius") =3D=3D 0) return;<BR>>=20
radius =3D cylradius;<BR>941d950<BR>< =
else radius=20
=3D 1.0;<BR>943c952<BR>< /* get the current view matrix=20
*/<BR>---<BR>> /* get rotation of the current view matrix =
*/<BR>946,947c955<BR>< for( k=3D 0; k< 4; k++)<BR>< =
{<BR>---<BR>> for( k=3D 0; k< 4;=20
k++){<BR>949a958,965<BR>> <BR>> /* get rotation of the =
current=20
object matrix */<BR>> =
Mat4CpyMat4(rotobj,ob->obmat);<BR>>=20
/* but shifting */<BR>> for( k=3D 0; k< 4; =
k++){<BR>> rotobj[3][k] =3D0.0;<BR>> =
}<BR>>=20
<BR>957c973<BR>< /*if =
(fbutton(&sideangledeg,=20
-180.0, 180, "Side angle") =3D=3D0) return;*/<BR>---<BR>> =
/* debug=20
helper if (fbutton(&sideangledeg, -180.0, 180, "Side angle") =
=3D=3D0) return;=20
*/<BR>959,960c975,976<BR>< rotside[0][0] =3D =
cos(sideangle); =20
rotside[0][1] =3D sin(sideangle);<BR>< rotside[1][0] =3D=20
-sin(sideangle); rotside[1][1] =3D=20
cos(sideangle);<BR>---<BR>> rotside[0][0] =3D =
cos(sideangle); =20
rotside[0][1] =3D -sin(sideangle);<BR>> rotside[1][0] =3D =
sin(sideangle); rotside[1][1] =3D=20
cos(sideangle);<BR>963c979<BR>< /* if =
(fbutton(&upangledeg,=20
-90.0, 90.0, "Up angle") =3D=3D0) return;*/<BR>---<BR>> =
/* debug=20
helper if (fbutton(&upangledeg, -90.0, 90.0, "Up angle") =3D=3D0) =
return;=20
*/<BR>965,966c981,982<BR>< rotup[1][1] =3D=20
cos(upangle)/radius; rotup[1][2] =3D sin(upangle)/radius;<BR><=20
rotup[2][1] =3D =
-sin(upangle)/radius; =20
rotup[2][2] =3D cos(upangle)/radius;<BR>---<BR>> =
rotup[1][1] =3D=20
cos(upangle)/radius; rotup[1][2] =3D -sin(upangle)/radius;<BR>> =
rotup[2][1] =3D =
sin(upangle)/radius; =20
rotup[2][2] =3D cos(upangle)/radius;<BR>968,971c984,986<BR>< =
/*=20
calculate transforms */<BR><=20
Mat4MulMat4(finalmatrix,viewmatrix,rotup);<BR><=20
Mat4MulMat4(tempmatrix,finalmatrix,rotside);<BR><=20
Mat4MulMat4(finalmatrix,tempmatrix,ob->obmat);<BR>---<BR>&=
gt;=20
<BR>> /* calculate transforms*/<BR>>=20
Mat4MulSerie(finalmatrix,rotup,rotside,viewmatrix,rotobj,NULL=
,NULL,NULL,NULL);</DIV>
<DIV> </DIV>
<DIV></FONT> </DIV></BODY></HTML>
------=_NextPart_000_0007_01C3CCBE.E2A4A780--