POV-Ray : Newsgroups : povray.newusers : Text textures? : Re: Text textures? Server Time
29 Jul 2024 18:18:54 EDT (-0400)
  Re: Text textures?  
From: Mike Williams
Date: 19 May 2005 09:02:49
Message: <4v6d0DAa5IjCFwO8@econym.demon.co.uk>
Wasn't it Giuseppe Bilotta who wrote:
>On Thu, 19 May 2005 10:13:29 +0100, Mike Williams wrote:
>
>> Wasn't it Giuseppe Bilotta who wrote:
>>>Hello all,
>>>
>>>I definitively qualify as a newuser (heard about POV-Ray for the first
>>>time last summer on a conference on TeX), so I might have missed
>>>something obvious in the documentation, but for the heart of me I
>>>can't find a simple, immediate way to "stamp" some text on an object,
>>>esp. a curved one. For example: how would you write some text on a
>>>spherical surface?
>> 
>> For objects that can be uv-mapped, you can create an object pattern and
>> uv-map that pattern onto the curved surface. 
>> 
>>   camera {location  <0,0,-20> look_at <0,0,0> angle 30}
>>   light_source {<-30, 100, -30> color rgb 1}
>> 
>>   #declare TEXT = text { ttf "crystal.ttf", "POV-Ray", 2, 0
>>                          scale 0.1 translate <0.57,0.6,-0.1> }
>>                                                 
>>   #declare P = pigment { object {TEXT rgb <1,0,0> rgb <1,1,0>}}
>> 
>>   sphere {0,3 uv_mapping pigment {P}} 
>
>Thank you very much, I think I see the idea.
>
>Am I right in saying that I should always scale the text so that it
>fits within the unit box? (At least for spheres) I'm not sure what's
>the purpose of the translation, though.

Uv_mapping takes the pigment from the square <0,0,0><1,1,0> and maps it
onto a surface. That's not the unit cube, it's a z-plane slice through
the positive quadrant of the unit cube. It doesn't matter whether it's
for a sphere or for any other uv_mappable surface (except that uv-mapped
cubes use only parts of the square).

The x and y parts of the translation were just there to move the text to
the front of the sphere. I just judged them by eye until they looked
right. In this default orientation of the sphere, the left half of the
square [<0,0,0><0.5,1,0>] maps to the back of the sphere, and I chose to
put the text on the front and a little over half way up. 

Note that text objects are initially positioned with the bottom left
front corner of the text at the origin.

The z part of the translation copes with the fact that the front face of
the text starts off being at z=0, so when you grab the object pattern
from the z-plane slice you get something similar to a coincident surface
situation, and parts of the text go missing. Moving the object slightly
forwards ensures that the z-plane cuts cleanly through the body of the
text instead of skipping over the front face.


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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