|
|
I'm having problems implementing the tesselation routine call inside
a mesh block, and it seems to be related to the UV-coordinates.
Examining the UV code I noticed something strange (perhaps a bug?).
At the beginning of Parse_Mesh() three UV-vectors are created:
UV_VECT UV1, UV2, UV3;
They are not initialized anywhere. The next time they are used is when
reading a triangle:
Parse_Three_UVCoords(UV1,UV2,UV3);
Triangles[number_of_triangles].UV1 = Mesh_Hash_UV(&number_of_uvcoords,
&max_uvcoords, &UVCoords,UV1);
Triangles[number_of_triangles].UV2 = Mesh_Hash_UV(&number_of_uvcoords,
&max_uvcoords, &UVCoords,UV2);
Triangles[number_of_triangles].UV3 = Mesh_Hash_UV(&number_of_uvcoords,
&max_uvcoords, &UVCoords,UV3);
This means, as I understand it, that it reads three UV coordinates from
the input and then adds them to the current triangle.
Examining Parse_Three_UVCoords function we see that the vectors are not
initialized if there are no UV-coordinates in that triangle:
int Parse_Three_UVCoords(UV_VECT UV1, UV_VECT UV2, UV_VECT UV3)
{
int Return_Value;
EXPECT
CASE(UV_VECTORS_TOKEN)
#ifdef UnofficialBlocking
parseUnofficialFeature(30);
#endif
Parse_UV_Vect(UV1); Parse_Comma();
Parse_UV_Vect(UV2); Parse_Comma();
Parse_UV_Vect(UV3);
Return_Value = 1;
EXIT
END_CASE
OTHERWISE
Return_Value = 0;
UNGET
EXIT
END_CASE
END_EXPECT
return(Return_Value);
}
This would mean that if there are no uv-coordinates in a triangle, the
previous value (either an unassigned value, which is most probably random,
or the value of a previous uv-definition) is used.
Somehow I don't think this is what was intended. Specially using
unassigned values as uv-coordinates. It would also mean that the coloring
of non-uv triangles will depend on the declaration order with respect to
uv-triangles in the same mesh.
--
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););} /*- Warp -*/
Post a reply to this message
|
|
|
|
"Warp" <war### [at] tagpovrayorg> wrote...
>
> Parse_Three_UVCoords(UV1,UV2,UV3);
> Triangles[number_of_triangles].UV1 =
Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords,UV1);
> Triangles[number_of_triangles].UV2 =
Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords,UV2);
> Triangles[number_of_triangles].UV3 =
Mesh_Hash_UV(&number_of_uvcoords, &max_uvcoords, &UVCoords,UV3);
I think there should be an "if" in there to check the value that is returned
from Parse_Three_UVCoords (it returns zero if nothing is parsed). Either
that or the vectors should be initialized to zero before they are parsed.
-Nathan
Post a reply to this message
|
|