POV-Ray : Newsgroups : povray.newusers : Image mapping on triangles : Re: Image mapping on triangles Server Time
8 Jul 2024 00:54:00 EDT (-0400)
  Re: Image mapping on triangles  
From: Chris B
Date: 3 Nov 2009 11:48:48
Message: <4af05ef0$1@news.povray.org>
"solanb" <nomail@nomail> wrote in message 
news:web.4af0563fa22773f2cf0bfa9c0@news.povray.org...
>
>> If you collect your triangles into a mesh or mesh2, you can use
>> uv_mapping.
>>
>> --
>> Mike Williams
>> Gentleman of Leisure
>
> Ok, but then how to define the uv_vector corresponding to each triangle?
>
> My image to be mapped consists of spots of a given dimension (eg. 1cm 
> diameter),

> are
> also in cm. And I want to keep the scale of my image when I project it on 
> the
> scene's triangles.
> Using uv_mapping without uv_vector doesn't produce what I expect but the
> definition uv_vector is not clear for me.
>
> Thanks in advance!
> Benoit
>


If all of your leaves are the same basic shape then it's relatively easy to 
work out uv_vectors and reuse them on all of your leaves.

In the example below I've created a simple shape using 6 vertices to create 
4 triangular faces aligned roughly to the plane y=0. I've added uv_mapping 
coordinates that  map the brick pigment using the x and z coordinates of the 
vertices. Because the shape is not totally flat you can see (when you render 
it) that there's some stretching of the pigment, but, in this position you 
can fairly easily adjust the uv_mapping until you've taken account of that.

Once you've got this uv-mapping you can use it for any other mesh2 object of 
the same shape, although the vertex coordinates may be different because the 
leaf would be at a different position and orientation in 3D space. The 
uv_mapping takes the part of the pigment that crosses the plane z=0 and map 
it to the vertices as specified.


camera {location <0.4,1,0.4> look_at <0.5,0,0.5>}
light_source {<-3, 16,-10> color rgb 1}

mesh2 {
  vertex_vectors{
    6
    <0.5 ,-0.1,0  >
    <0.1 ,-0.1,0.5>
    <0.35, 0  ,0.4>
    <0.5 , 0  ,1  >
    <0.65, 0  ,0.4>
    <0.9 ,-0.1,0.5>
  }
  uv_vectors{
    6
    <0.5 ,0  >
    <0.1 ,0.5>
    <0.35,0.4>
    <0.5 ,1  >
    <0.65,0.4>
    <0.9 ,0.5>
  }
  face_indices{
    4
    <0,1,2>
    <0,2,3>
    <0,3,4>
    <0,4,5>
  }
  pigment {uv_mapping brick scale 0.01 }
}

Hope this helps,

Regards,
Chris B.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.