# [Bf-committers] Re: A little Editface Question

Johnny Matthews johnny.matthews at gmail.com
Thu Jun 9 16:50:07 CEST 2005

```Well, I've put this function in and it is working kind of. I must not
have something exactly right just yet (probably in the quad section) but
it is getting about 1/2 to 2/3rds of the UVs right now in my test cases.
I'll report back later...

Johnny

Ton Roosendaal wrote:

> Hi,
>
> I would sugest a new method. The set_wuv() is a horrible construction
> at the moment. Afaik, Johnny already solved copying pinning flags,
> seam  flags, smooth flags, and so on.
>
> What is needed now is a parametric solution for finding new UVs and
> vertexcolors based on an existing face and a 3d coordinate that lies
> within the plane of that face. That's basically just an interpolation
> function.
>
> Code below was copied from render module, I didn't compile it! But it
> has the ingredients :)
>
>
> /* input efa and co (vector */
> /* output in TFace: uv (2 values) and vcol (4 char values) */
> void set_uv_vcol(EditFace *efa, float *co, float *uv, char *col)
> {
>
>     /* define best projection of face XY, XZ or YZ */
>         xn= fabs(efa->n[0]);
>         yn= fabs(efa->n[1]);
>         zn= fabs(efa->n[2]);
>         if(zn>=xn && zn>=yn) {i= 0; j= 1;}
>         else if(yn>=xn && yn>=zn) {i= 0; j= 2;}
>         else {i= 1; j= 2;}
>
>     /* calculate u and v */
>         v1= efa->v1;
>         v2= efa->v2;
>          v3= efa->v3;
>
>         t00= v3->co[i]-v1->co[i]; t01= v3->co[j]-v1->co[j];
>         t10= v3->co[i]-v2->co[i]; t11= v3->co[j]-v2->co[j];
>
>         detsh= 1.0/(t00*t11-t10*t01);    /* potential danger */
>         t00*= detsh; t01*=detsh;
>         t10*=detsh; t11*=detsh;
>
>         u= (co[i]-v3->co[i])*t11-(co[j]-v3->co[j])*t10;
>         v= (co[j]-v3->co[j])*t00-(co[i]-v3->co[i])*t01;
>
>     /* btw; u and v range from -1 to 0 */
>
>     /* interpolate */
>         l= 1.0+u+v;
>
>         /* pseudocode!!! */
>         /* just fill in colors or UV texture values here */
>
>         new = l*vertex3_val - u*vertex1_val - v*vertex2_val;
>
> }
>
> OK... this now doesn't work yet, since we need to get it working for
> Quads.
>
> That's a simple case as well;
>
>     /* in other triangle */
>     if(efa->v4 && l < 0.0) {
>         /* do it all over, but now with vertex 2 replaced with 4 */
>
>     }
>
>
> So, would this work?
>
> -Ton-
>
>
> On 9 Jun, 2005, at 3:22, Martin Poirier wrote:
>
>> Then, all of the new face will have a different
>> percent value on the cut edge. It's on the original
>> edge anyway, so pretty easy to figure. 1.0/number of
>> cutes * conversion factor to store in short.
>>
>> Martin
>>
>> --- Johnny Matthews <johnny.matthews at gmail.com> wrote:
>>
>>> the problem is that there will be 1 or more cuts per
>>> face (the code
>>> allows for unlimited cuts per edge)
>>>
>>> I'll look at the code you mentioned and see if it
>>> can point me in the
>>> right direction though.
>>>
>>> On 6/8/05, Martin Poirier <theeth at yahoo.com> wrote:
>>>
>>>>
>>>>
>>>> --- Johnny Matthews <johnny.matthews at gmail.com>
>>>
>>> wrote:
>>>
>>>>
>>>>> Ok, This is for any self-professed Mesh Gurus
>>>>
>>> out
>>>
>>>>> there,
>>>>>
>>>>> I am getting very close to having a working
>>>>
>>> version
>>>
>>>>> of the edge-based
>>>>> subdivide with the option of 1 or more even
>>>>
>>> cuts.
>>>
>>>>> The
>>>>> hitch I have is this. I have a function that
>>>>
>>> takes
>>>
>>>>> each new internal
>>>>> face as it is created and copies information
>>>>
>>> from
>>>
>>>>> the parent
>>>>> face kinda like facecopy(EditFace
>>>>
>>> source,EditFace
>>>
>>>>> target), where target
>>>>> is always a subface of source. Can you think of
>>>>
>>> a
>>>
>>>>> way, without passing any more information to the
>>>>> function to extrapolate
>>>>> the UV and Vertcol information from the source
>>>>
>>> face
>>>
>>>>> to the target face.
>>>>
>>>>
>>>> This one's for me.
>>>>
>>>> You'll want to call the function: set_wuv in
>>>> editmesh_tools.c
>>>> First argument is the number of verts (could
>>>
>>> easily be
>>>
>>>> removed).
>>>> Second argument is the new face, then the vertex
>>>
>>> flags
>>>
>>>> (explained in the nice ascii drawing in the
>>>
>>> fonction's
>>>
>>>> body) and then the pinned face (original face
>>>> containing pinned uvs flags and the like).
>>>>
>>>> To use the function correctly, you have to call it
>>>> with the proper vertex flags AND also set the f1
>>>
>>> flag
>>>
>>>> for each edge that is being cut. This sets the
>>>
>>> factor
>>>
>>>> of where the cut is along the edge starting from
>>>
>>> the
>>>
>>>> first vertex in the edge (0.0) to the last (1.0)
>>>> stored in a short (multiplied by 32768).
>>>>
>>>> If you have more questions, you can contact me
>>>> directly.
>>>>
>>>> Martin
>>>>
>>>>
>>>>
>>>> __________________________________
>>>> Discover Yahoo!
>>>> Stay in touch with email, IM, photo sharing and
>>>
>>> more. Check it out!
>>>
>>>> http://discover.yahoo.com/stayintouch.html
>>>> _______________________________________________
>>>> Bf-committers mailing list
>>>> Bf-committers at projects.blender.org
>>>>
>>>
>> http://projects.blender.org/mailman/listinfo/bf-committers
>>
>>>>
>>>
>>>
>>> --  Johnny Matthews
>>> johnny.matthews at gmail.com
>>> _______________________________________________
>>> Bf-committers mailing list
>>> Bf-committers at projects.blender.org
>>>
>> http://projects.blender.org/mailman/listinfo/bf-committers
>>
>>>
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection around
>> http://mail.yahoo.com
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-committers
>>
>>
> ------------------------------------------------------------------------
> --
> Ton Roosendaal  Blender Foundation ton at blender.org
> http://www.blender.org
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers
>

```

More information about the Bf-committers mailing list