[tuhopuu-devel] suggestion for UV mapping calculation

BjornMose tuhopuu-devel@blender.org
Sat, 20 Dec 2003 13:09:51 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C3C6FA.8DBB6CA0
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

hi all

i posted a suggestion at the blender forum (interface section)
about UV calculation in the faceedit 3d window. it was about=20
the static orientation of the sphere and cylinder mapping.

torq suggested to use the current view to determine of the=20
projection sphere / cylinder like the "from window" option does.

Well, i did some coding to see if it would work.

the attached patch applies to uv_autocalc_tface() in faceedit.c and =
does:

1. append two options (from window to sphere ..cylinder) to the UV =
calculation popup

2. inserts two new cases to the corresponding switch statement

3. the code in this cases=20
a. cares for the around settings of the 3D view (bounding box and cursor =
work)
b. calculates a rotation matrix such that the orgigin of the=20
polar/spherical coordinate system points out of the screen
c. in the cylinder case pops up a fbutton to read the radius of the =
projection cylinder.
d. calculates the new UV coordinates for the selected faces.

notes=20
the code that gets the rotaion from the view is a little hacky, may be =
this can be done better.
it did compile with MSVC 6, have no other compiler working yet

bjornmose

grabbed it from the wincvs result window so may be wrong CFLFs
(is there a way to pipe wincvs output to a file ? no tcl installed)

Index: source/blender/src/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.1.1.2
diff -r1.1.1.2 editface.c
613a614,618
> /* +++insert here BM */
> #define UV_CYL_EX 32
> #define UV_SPHERE_EX 34
> /* ---insert here BM */
>=20
642d646
< =20
655c659,663
<                MENUSTRING("From Window",   UV_WINDOW_MAPPING) );
---
>                MENUSTRING("From Window",   UV_WINDOW_MAPPING) "|"
> /* +++insert here BM */
>                MENUSTRING("From Window To Sphere",  UV_SPHERE_EX) "|"
>                MENUSTRING("From Window To Cylinder",  UV_CYL_EX)  );
> /* ---insert here BM */
885a894,1041
> /* +++insert here BM */
>  case UV_CYL_EX:
>  case UV_SPHERE_EX:
>    {
>     float rotup[4][4];
>     float rotside[4][4];
>     float viewmatrix[4][4];
>     float finalmatrix[4][4];
>     float tempmatrix[4][4];
>     int k,l;
>     float upangle =3D 0.0;
>     float sideangle =3D 0.0;
>     static float radius =3D 1.0;
>     static float upangledeg =3D 90.0;
>     static float sideangledeg =3D 0.0;
>     short centermode;
>=20
>    =20
>     centermode =3D G.vd->around;
>     /* check if we can do this */
>     switch (centermode)
>     {
>     case  0 : /*bounding box center*/=20
>     case  1 : /*cursor center*/  {break;} /* is ok */
>     default : /* other modes are not supported yet */
>      /* say something to the user if we can't*/
>      okee("this operation center does not work here!");
>      return;=20
>     }
>     if (centermode =3D=3D 0) /* calculate bounding box */
>     {
>      INIT_MINMAX(min, max);
>     =20
>      tface=3D me->tface;
>      mface=3D me->mface;
>      for(a=3D0; a<me->totface; a++, mface++, tface++) {
>       if(tface->flag & TF_SELECT) {
>        if(mface->v3=3D=3D0) continue; /* this is not realy a face */
>       =20
>        DO_MINMAX( (me->mvert+mface->v1)->co, min, max);
>        DO_MINMAX( (me->mvert+mface->v2)->co, min, max);
>        DO_MINMAX( (me->mvert+mface->v3)->co, min, max);
>        if(mface->v4) DO_MINMAX( (me->mvert+mface->v3)->co, min, max);
>       }
>      }
>     =20
>      VecMidf(cent, min, max);
>     }
>     else /* center is the current 3d cursor */
>     {=20
>     =20
>      float *cursx;
>      cursx=3D give_cursor();
>      /* shift to objects world */
>      cent[0]=3D cursx[0]-ob->obmat[3][0];
>      cent[1]=3D cursx[1]-ob->obmat[3][1];
>      cent[2]=3D cursx[2]-ob->obmat[3][2];
>     =20
>     }
>=20
>     if(mode=3D=3DUV_CYL_EX){
>      if (fbutton(&radius, 0.1, 90.0, "radius") =3D=3D 0) return;=20
>     }
>     else radius =3D 1.0;
>=20
>     /* get the current view matrix */
>                 Mat4CpyMat4(viewmatrix,G.vd->viewmat);
>     /* but shifting */
>     for( k=3D 0; k< 4; k++)
>     {
>      viewmatrix[3][k] =3D0.0;
>     }
>                 /* never assume local variables to be zeroed */
>     Mat4Clr(rotup);
>     Mat4Clr(rotside);
>=20
>     /* need this to compensate front/side.. against opengl x,y,z world =
definition */
>     /* this is "kanonen gegen spatzen" i know, a few plus minus 1 will =
do here */
>     /* i wanted to keep the reason here, so we're rotating*/
>     /*if (fbutton(&sideangledeg, -180.0, 180, "Side angle") =3D=3D0) =
return;*/
>     sideangle =3D M_PI * (sideangledeg + 180.0) /180.0;=20
>     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[2][2] =3D 1.0;
>    =20
>     /* if (fbutton(&upangledeg, -90.0, 90.0, "Up angle") =3D=3D0) =
return;*/
>     upangle =3D M_PI * upangledeg /180.0;=20
>     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[0][0] =3D 1.0/radius;
>     Mat4MulMat4(tempmatrix,viewmatrix,rotup);
>     Mat4MulMat4(finalmatrix,tempmatrix,rotside);
>     /* now finalmatrix holds what we want */=20
>    =20
>    =20
>     tface=3D me->tface;
>     mface=3D me->mface;
>     for(a=3D0; a<me->totface; a++, mface++, tface++) {   /* go for all =
faces of the given mesh */
>      if(tface->flag & TF_SELECT) { /* if this face is selected in UI =
*/
>       if(mface->v3=3D=3D0) continue; /* must be ploygon with more than =
2 vertices */
>       /* repeating this for all 3(4) vertices sucks. better make =
function*/
>       VecSubf(no, (me->mvert+mface->v1)->co, cent); /* shift to make =
cent the origin */=20
>       Mat4MulVecfl(finalmatrix, no);
>       if(mode=3D=3DUV_CYL_EX) tubemap(no[0], no[1], no[2], =
tface->uv[0], &tface->uv[0][1]);
>       else spheremap(no[0], no[1], no[2], tface->uv[0], =
&tface->uv[0][1]);
>      =20
>       VecSubf(no, (me->mvert+mface->v2)->co, cent);
>       Mat4MulVecfl(finalmatrix, no);
>       if(mode=3D=3DUV_CYL_EX) tubemap(no[0], no[1], no[2], =
tface->uv[1], &tface->uv[1][1]);
>       else spheremap(no[0], no[1], no[2], tface->uv[1], =
&tface->uv[1][1]);
>      =20
>       VecSubf(no, (me->mvert+mface->v3)->co, cent);
>       Mat4MulVecfl(finalmatrix, no);
>       if(mode=3D=3DUV_CYL_EX) tubemap(no[0], no[1], no[2], =
tface->uv[2], &tface->uv[2][1]);
>       else spheremap(no[0], no[1], no[2], tface->uv[2], =
&tface->uv[2][1]);
>       n =3D 3;
>      =20
>       if(mface->v4) {
>       =20
>        VecSubf(no, (me->mvert+mface->v4)->co, cent);
>        Mat4MulVecfl(finalmatrix, no);
>        if(mode=3D=3DUV_CYL_EX) tubemap(no[0], no[1], no[2], =
tface->uv[3], &tface->uv[3][1]);
>        else spheremap(no[0], no[1], no[2], tface->uv[3], =
&tface->uv[3][1]);
>        n =3D 4;
>       }
>       mi =3D 0; /* maximum index */
>      =20
>       for (i =3D 1; i < n; i++)
>       {
>        if (tface->uv[i][0] > tface->uv[mi][0]) mi =3D i;
>       }
>       for (i =3D 0; i < n; i++)
>       {
>        if (i !=3D mi) {
>         dx =3D tface->uv[mi][0] - tface->uv[i][0];
>         if (dx > 0.5) {
>          tface->uv[i][0] +=3D 1.0;
>         }=20
>        }=20
>       }=20
>      }
>     }
>    =20
>    }
>   =20
>    break;
> /* ---insert here BM */
>=20



------=_NextPart_000_001B_01C3C6FA.8DBB6CA0
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</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>i posted a suggestion at the blender =
forum=20
(interface section)<BR>about UV calculation in the faceedit 3d window. =
it was=20
about <BR>the static orientation of the sphere and cylinder=20
mapping.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>torq suggested to use the current view =
to determine=20
of the <BR>projection sphere / cylinder like the "from window" option=20
does.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Well, i did some coding to see if it =
would=20
work.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>the attached patch applies to =
uv_autocalc_tface()=20
in faceedit.c and does:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>1. append two options (from window to =
sphere=20
..cylinder) to the UV calculation popup</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>2. inserts two new cases to the =
corresponding=20
switch statement</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>3. the code in this cases <BR>a. cares =
for the=20
around settings of the 3D view (bounding box and cursor work)<BR>b. =
calculates a=20
rotation matrix such that the orgigin of the <BR>polar/spherical =
coordinate=20
system points out of the screen<BR>c. in the cylinder case pops up a =
fbutton to=20
read the radius of the projection cylinder.<BR>d. calculates the new UV=20
coordinates for the selected faces.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>notes <BR>the code that gets the =
rotaion from the=20
view is a little hacky, may be this can be done better.<BR>it did =
compile with=20
MSVC 6, have no other compiler working yet</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>bjornmose</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>grabbed it from the wincvs result =
window so may be=20
wrong CFLFs<BR>(is there a way to pipe wincvs output to a file ? no tcl=20
installed)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Index:=20
source/blender/src/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.1.1.2<BR>diff -r1.1.1.2 editface.c<BR>613a614,618<BR>&gt; /*=20
+++insert here BM */<BR>&gt; #define UV_CYL_EX 32<BR>&gt; #define =
UV_SPHERE_EX=20
34<BR>&gt; /* ---insert here BM */<BR>&gt; <BR>642d646<BR>&lt;=20
&nbsp;<BR>655c659,663<BR>&lt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
MENUSTRING("From Window",&nbsp;&nbsp; UV_WINDOW_MAPPING) =
);<BR>---<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
MENUSTRING("From Window",&nbsp;&nbsp; UV_WINDOW_MAPPING) "|"<BR>&gt; /*=20
+++insert here BM */<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
MENUSTRING("From Window To Sphere",&nbsp; UV_SPHERE_EX) "|"<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;=20
MENUSTRING("From Window To Cylinder",&nbsp; UV_CYL_EX)&nbsp; );<BR>&gt; =
/*=20
---insert here BM */<BR>885a894,1041<BR>&gt; /* +++insert here BM =
*/<BR>&gt;=20
&nbsp;case UV_CYL_EX:<BR>&gt; &nbsp;case UV_SPHERE_EX:<BR>&gt;=20
&nbsp;&nbsp;&nbsp;{<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;float =
rotup[4][4];<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;float rotside[4][4];<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;float viewmatrix[4][4];<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;float finalmatrix[4][4];<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;float tempmatrix[4][4];<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;int k,l;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;float =
upangle =3D=20
0.0;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;float sideangle =3D 0.0;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;static float radius =3D 1.0;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;static float upangledeg =3D 90.0;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;static float sideangledeg =3D 0.0;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;short centermode;<BR>&gt; <BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;centermode =3D=20
G.vd-&gt;around;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;/* check if we can do =
this=20
*/<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;switch (centermode)<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;case&nbsp; 0 : =

/*bounding box center*/ <BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;case&nbsp; 1 : =
/*cursor=20
center*/&nbsp; {break;} /* is ok */<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;default : /*=20
other modes are not supported yet */<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*=20
say something to the user if we can't*/<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;okee("this operation center does not work=20
here!");<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;if (centermode =
=3D=3D 0)=20
/* calculate bounding box */<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;{<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INIT_MINMAX(min, max);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tface=3D=20
me-&gt;tface;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mface=3D =
me-&gt;mface;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(a=3D0; a&lt;me-&gt;totface; a++, =
mface++,=20
tface++) {<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(tface-&gt;flag =
&amp;=20
TF_SELECT) {<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(mface-&gt;v3=3D=3D0) =
continue; /* this=20
is not realy a face */<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DO_MINMAX(=20
(me-&gt;mvert+mface-&gt;v1)-&gt;co, min, max);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DO_MINMAX(=20
(me-&gt;mvert+mface-&gt;v2)-&gt;co, min, max);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DO_MINMAX(=20
(me-&gt;mvert+mface-&gt;v3)-&gt;co, min, max);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(mface-&gt;v4) DO_MINMAX(=20
(me-&gt;mvert+mface-&gt;v3)-&gt;co, min, max);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VecMidf(cent, min, max);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;else /* center =
is the=20
current 3d cursor */<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float=20
*cursx;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursx=3D =
give_cursor();<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* shift to objects world */<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cent[0]=3D =
cursx[0]-ob-&gt;obmat[3][0];<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cent[1]=3D =
cursx[1]-ob-&gt;obmat[3][1];<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cent[2]=3D =
cursx[2]-ob-&gt;obmat[3][2];<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt; =

<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;if(mode=3D=3DUV_CYL_EX){<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (fbutton(&amp;radius, 0.1, 90.0, =
"radius") =3D=3D=20
0) return; <BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;else radius =3D 1.0;<BR>&gt; <BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;/* get the current view matrix=20
*/<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Mat4CpyMat4(viewmatrix,G.vd-&gt;viewmat);<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;/* but=20
shifting */<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;for( k=3D 0; k&lt; 4; =
k++)<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;viewmatrix[3][k]=20
=3D0.0;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
/* never assume local variables to be zeroed */<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;Mat4Clr(rotup);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;Mat4Clr(rotside);<BR>&gt; <BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;/* need this to compensate front/side.. against =
opengl=20
x,y,z world definition */<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;/* this is =
"kanonen=20
gegen spatzen" i know, a few plus minus 1 will do here */<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;/* i wanted to keep the reason here, so we're=20
rotating*/<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;/*if =
(fbutton(&amp;sideangledeg,=20
-180.0, 180, "Side angle") =3D=3D0) return;*/<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;sideangle =3D M_PI * (sideangledeg + 180.0) =
/180.0;=20
<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;rotside[0][0] =3D=20
cos(sideangle);&nbsp;&nbsp;rotside[0][1] =3D sin(sideangle);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;rotside[1][0] =3D=20
-sin(sideangle);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotside[1][1] =3D=20
cos(sideangle);<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;rotside[2][2] =3D =
1.0;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;/* if=20
(fbutton(&amp;upangledeg, -90.0, 90.0, "Up angle") =3D=3D0) =
return;*/<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;upangle =3D M_PI * upangledeg /180.0; <BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;rotup[1][1] =3D=20
cos(upangle)/radius;&nbsp;&nbsp;rotup[1][2] =3D =
sin(upangle)/radius;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;rotup[2][1] =3D=20
-sin(upangle)/radius;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotup[2][2] =3D=20
cos(upangle)/radius;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;rotup[0][0] =3D=20
1.0/radius;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;Mat4MulMat4(tempmatrix,viewmatrix,rotup);<BR>&gt;=
=20
&nbsp;&nbsp;&nbsp;&nbsp;Mat4MulMat4(finalmatrix,tempmatrix,rotside);<BR>&=
gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;/* now finalmatrix holds what we want */ =
<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;tface=3D me-&gt;tface;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;mface=3D me-&gt;mface;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;for(a=3D0; a&lt;me-&gt;totface; a++, mface++, =
tface++) {=20
&nbsp;&nbsp;/* go for all faces of the given mesh */<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(tface-&gt;flag &amp; TF_SELECT) { /* if =
this=20
face is selected in UI */<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(mface-&gt;v3=3D=3D0) continue; /* =
must be=20
ploygon with more than 2 vertices */<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* repeating this for all 3(4) =
vertices=20
sucks. better make function*/<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VecSubf(no,=20
(me-&gt;mvert+mface-&gt;v1)-&gt;co, cent); /* shift to make cent the =
origin */=20
<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mat4MulVecfl(finalmatrix,=20
no);<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(mode=3D=3DUV_CYL_EX) =

tubemap(no[0], no[1], no[2], tface-&gt;uv[0], =
&amp;tface-&gt;uv[0][1]);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else spheremap(no[0], no[1], no[2],=20
tface-&gt;uv[0], &amp;tface-&gt;uv[0][1]);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VecSubf(no,=20
(me-&gt;mvert+mface-&gt;v2)-&gt;co, cent);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mat4MulVecfl(finalmatrix, =
no);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(mode=3D=3DUV_CYL_EX) =
tubemap(no[0], no[1],=20
no[2], tface-&gt;uv[1], &amp;tface-&gt;uv[1][1]);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else spheremap(no[0], no[1], no[2],=20
tface-&gt;uv[1], &amp;tface-&gt;uv[1][1]);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VecSubf(no,=20
(me-&gt;mvert+mface-&gt;v3)-&gt;co, cent);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mat4MulVecfl(finalmatrix, =
no);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(mode=3D=3DUV_CYL_EX) =
tubemap(no[0], no[1],=20
no[2], tface-&gt;uv[2], &amp;tface-&gt;uv[2][1]);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else spheremap(no[0], no[1], no[2],=20
tface-&gt;uv[2], &amp;tface-&gt;uv[2][1]);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n =3D 3;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(mface-&gt;v4) {<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VecSubf(no,=20
(me-&gt;mvert+mface-&gt;v4)-&gt;co, cent);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mat4MulVecfl(finalmatrix, =
no);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(mode=3D=3DUV_CYL_EX) =
tubemap(no[0],=20
no[1], no[2], tface-&gt;uv[3], &amp;tface-&gt;uv[3][1]);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else spheremap(no[0], no[1], =
no[2],=20
tface-&gt;uv[3], &amp;tface-&gt;uv[3][1]);<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n =3D 4;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mi =3D 0; /* maximum index =
*/<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i =3D 1; i &lt; n; i++)<BR>&gt; =

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (tface-&gt;uv[i][0] &gt;=20
tface-&gt;uv[mi][0]) mi =3D i;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (i =3D 0; i &lt; n; i++)<BR>&gt; =

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (i !=3D mi) {<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dx =3D =
tface-&gt;uv[mi][0] -=20
tface-&gt;uv[i][0];<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if=20
(dx &gt; 0.5) {<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tface-&gt;uv[i][0] =
+=3D=20
1.0;<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt; =
&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&gt;=20
&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; &nbsp;&nbsp;&nbsp;}<BR>&gt;=20
&nbsp;&nbsp;&nbsp;<BR>&gt; &nbsp;&nbsp;&nbsp;break;<BR>&gt; /* ---insert =
here BM=20
*/<BR>&gt; </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_001B_01C3C6FA.8DBB6CA0--