POV-Ray : Newsgroups : povray.newusers : Text textures? : Re: Text textures? Server Time
29 Jul 2024 18:17:10 EDT (-0400)
  Re: Text textures?  
From: Giuseppe Bilotta
Date: 19 May 2005 13:39:31
Message: <173usdq3y396e$.1rxmz2uxz6b7k$.dlg@40tude.net>
On Thu, 19 May 2005 14:02:18 +0100, Mike Williams wrote:
> 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.

This is what I came up with in the end, which seems to be a pretty
decent:

#declare big_text = text {
	ttf "tahomabd.ttf"
	"T1"
	1, 0
} ;

#declare text_size = max_extent(big_text)-min_extent(big_text) ;
#declare text_scale_gen = 1/4 ;
#declare text_scale_x = 1 ;
#declare text_scale_y = 1 ;
#declare text_scale_f = (1/text_size.x) ;
#declare text_scale = text_scale_gen * text_scale_f * (
	text_scale_x * x +
	text_scale_y * y) ;

#declare text_obj =	object {
		big_text
			translate -1/2*text_size
			scale text_scale
			//translate (1-text_scale/big_text_ext.y)*y
			//translate (1-text_scale/big_text_ext.x)*x
			translate 1/2*(x+y)
} ;

#declare text_tex = pigment {
	object {
		text_obj
		color .6*Magenta
		color Black
	}
} ;

This is of course very specific, but my guess is that it could be
build into a function or macro which takes a text object plus a few
parameters and returns the pigment ... do you think it's worth doing?

-- 
Giuseppe "Oblomov" Bilotta


"Ma niente: prima si fanno delle cazzate,
 poi si studia che cazzate si sono fatte"
(Altan)
("And what about the history of the human race, dad?"
 "Oh, nothing special: first they make some foolish things,
  then you study what foolish things have been made")


Post a reply to this message

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