[tuhopuu-devel] Re: [tuhopuu-cvs] CVS commit: tuhopuu2/source/blender/src editface.c

BjornMose tuhopuu-devel@blender.org
Sat, 27 Dec 2003 01:03:42 +0100


hi all, hi theeth

uv auto calculation "from window to shere", "from window to cylinder" bug
found and fixed.

did test
switching, rotating 3d view, works;
tranformations (shift,rotation) in object mode, works;
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.

patch:
cvs diff editface.c (in directory E:\bleCVS\tuhopuu2\source\blender\src\)
Index: editface.c
===================================================================
RCS file: /cvsroot/tuhopuu/tuhopuu2/source/blender/src/editface.c,v
retrieving revision 1.3
diff -r1.3 editface.c
2c2
<  * $Id: editface.c,v 1.3 2003/12/23 19:43:44 theeth Exp $
---
>  * $Id: editface.c,v 1.2 2003/12/22 03:41:43 theeth Exp $
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 = 0.0, sideangle = 0.0;
<   static float radius = 1.0, upangledeg = 90.0, sideangledeg = 0.0;
---
>   float upangle = 0.0, sideangle = 0.0, radius = 1.0;
>   static float upangledeg = 90.0, sideangledeg = 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);
910c910
<
---
>
916a917
>
918,932c919,940
<   break;
<   case  1 : /*cursor center*/
<   {
<    float *cursx;
<    cursx= give_cursor();
<    /* shift to objects world */
<    cent[0]= cursx[0]-ob->obmat[3][0];
<    cent[1]= cursx[1]-ob->obmat[3][1];
<    cent[2]= cursx[2]-ob->obmat[3][2];
<   }
<   break;
<   case  2 : /*object center*/
<    cent[0]= cent[1]= cent[2]= 0.0;
<   break;
<   default : /* other modes are not supported yet */
---
>    break;
>
>   case  V3D_CURSOR : /*cursor center*/
>    {
>     float *cursx;
>     cursx= give_cursor();
>     /* shift to objects world */
>     cent[0]= cursx[0]-ob->obmat[3][0];
>     cent[1]= cursx[1]-ob->obmat[3][1];
>     cent[2]= cursx[2]-ob->obmat[3][2];
>    }
>    break;
>
>   case  V3D_LOCAL : /*object center*/
>   case  V3D_CENTROID : /*median refers to multiple objects centers. only
one object here*/
>    {
>     cent[0]= cent[1]= cent[2]= 0.0;
>
>    }
>    break;
>
>   default : /* covered all known modes, but if there was a new one */
935c943
<   return;
---
>    return;
937c945
<
---
>
939c947,949
<    if (fbutton(&radius, 0.1, 90.0, "radius") == 0) return;
---
>    static float cylradius = 1.0; /* static to remeber last user response
*/
>    if (fbutton(&cylradius, 0.1, 90.0, "radius") == 0) return;
>    radius = cylradius;
941d950
<   else radius = 1.0;
943c952
<   /* get the current view matrix */
---
>   /* get rotation of the current view matrix */
946,947c955
<   for( k= 0; k< 4; k++)
<   {
---
>   for( k= 0; k< 4; k++){
949a958,965
>
>   /* get rotation of the current object matrix */
>   Mat4CpyMat4(rotobj,ob->obmat);
>   /* but shifting */
>   for( k= 0; k< 4; k++){
>    rotobj[3][k] =0.0;
>   }
>
957c973
<   /*if (fbutton(&sideangledeg, -180.0, 180, "Side angle") ==0) return;*/
---
>   /* debug helper if (fbutton(&sideangledeg, -180.0, 180, "Side angle")
==0) return; */
959,960c975,976
<   rotside[0][0] = cos(sideangle);  rotside[0][1] = sin(sideangle);
<   rotside[1][0] = -sin(sideangle);       rotside[1][1] = cos(sideangle);
---
>   rotside[0][0] = cos(sideangle);  rotside[0][1] = -sin(sideangle);
>   rotside[1][0] = sin(sideangle);       rotside[1][1] = cos(sideangle);
963c979
<   /* if (fbutton(&upangledeg, -90.0, 90.0, "Up angle") ==0) return;*/
---
>   /* debug helper if (fbutton(&upangledeg, -90.0, 90.0, "Up angle") ==0)
return; */
965,966c981,982
<   rotup[1][1] = cos(upangle)/radius;  rotup[1][2] = sin(upangle)/radius;
<   rotup[2][1] = -sin(upangle)/radius;      rotup[2][2] =
cos(upangle)/radius;
---
>   rotup[1][1] = cos(upangle)/radius;  rotup[1][2] = -sin(upangle)/radius;
>   rotup[2][1] = sin(upangle)/radius;      rotup[2][2] =
cos(upangle)/radius;
968,971c984,986
<   /* calculate transforms */
<   Mat4MulMat4(finalmatrix,viewmatrix,rotup);
<   Mat4MulMat4(tempmatrix,finalmatrix,rotside);
<   Mat4MulMat4(finalmatrix,tempmatrix,ob->obmat);
---
>
>   /* calculate transforms*/
>
Mat4MulSerie(finalmatrix,rotup,rotside,viewmatrix,rotobj,NULL,NULL,NULL,NULL
);
***end of patch


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.
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.

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
 two new options to uv auto calculation:
 "from window to shere", "from window to cylinder".
 the differences to sphere/cylinder mapping as is:
 1. the around settings of the 3D view sets the projection center
 2. the orgigin 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
 a new feature that offers the possibility to select all nodes in the uv map
that refer
 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.

 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.
 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 */

bjornmose

----- Original Message -----
From: "BjornMose" <bjornmose@gmx.net>
To: <tuhopuu-devel@blender.org>
Sent: Wednesday, December 24, 2003 1:02 AM
Subject: [tuhopuu-devel] Re: [tuhopuu-cvs] CVS commit:
tuhopuu2/source/blender/src editface.c


> hi all, hello theeth
> very, very,..... sorry about this, but the transformation matrix does not
> work properly in some cases.
> need to track down  this in datail. (almost got it, but want to be sure)
> BTW it is x-mas and my kids want me to do other things, so please be
> patient.(i was not  i know)
>