Parametric object already operates on uv coordinates but for some reason this space is not available for mapping textures on it. Here is comparision what uv_mapping gives for simple twisted tape.
| No UV Mapping | Default UV Mapping | UV Mapping follow UV coordinates |
|---|---|---|
![]() |
![]() |
![]() |
#version 3.5;
#declare minor=3;
#declare major=9;
#declare rotor=5;
#declare Corner=(major*<1,1,0>)+minor;
parametric{
function{sin(2*u)*(cos(rotor*u)*v+major)}
function{cos(2*u)*(cos(rotor*u)*v+major)}
function{sin(rotor*u)*v}
<0,-minor><pi,minor>
contained_by{box{-Corner Corner}}
precompute 18,x,y,z
uv_mapping
pigment{checker rgb 0 rgb 1}
translate 3*z*major
}
light_source{-9-9*z 1}
background{1}
camera{up y right x}
Implementation was pretty easy. I can not worry
about calculating UV coordinates becouse they are already calculated
for normal method during intersection test. They are stored in fields
of object. All I need was
open file fpmetric.cpp and find definition of
Parametric_Methods (Local variables section)
and replace there Default_UVCoord
with Parametric_UVCoord.
Method Parametric_UVCoord has to be defined so in section
Static functions we have to add line:
static void Parametric_UVCoord (UV_VECT Result, OBJECT *Object, INTERSECTION *Inter);and add this function at end of file:
/*****************************************************************************
*
* FUNCTION
*
* Parametric_UVCoord
*
* INPUT
*
* As for all UVCoord methods object and interstcion structure
*
* OUTPUT
*
* As for all UVCoord methods 2D vector with UV coordinates
*
* RETURNS
*
* AUTHOR
*
* ABX (abx@abx.art.pl)
*
* DESCRIPTION
*
* I'm not sure if last_u and last_v fields are safe place for storing
* uv coordinates but they are used for normal calculations. I hope
* tests will confirm it.
*
* CHANGES
*
* 2002.Aug.07 - initial version
*
******************************************************************************/
static void Parametric_UVCoord(UV_VECT Result, OBJECT *Object, INTERSECTION *Inter)
{
PARAMETRIC * Par = (PARAMETRIC *)Object;
Result[U] = Par->last_u;
Result[V] = Par->last_v;
}
I'm not sure that storing UV coordinates in fields is safe and personaly I preffered storing on intersection stack as it was done in MegaPOV. But I'm sure this replacement was considered during bulding of 3.5 and I trust the POV-Team :-) (but see my notes in UV Mapping for Torus Object)