|
|
>On Thu, 14 Feb 2002 15:14:43 +0200, "Hershel Robinson" <her### [at] yahoocom>
>wrote:
>> I would like to model a column with words engraved or carved into or out of
>> (i.e. protruding from) the column. I don't know how to create 3D letters
>> which are curved to match the column, however.
>>
>> The hard way would be to use Chris Colefax's Bend include file. Hard in
>> terms of render time--I have more than one column with unique text. I would
>> like to ask if anyone knows of an easier way to accomplish this.
>
>If you want bend text but each letter can stay as is then you can use this
>method:
>
>1. split text into letters
>2. measure width of each letter
>3. create spline along column
>4. walk along spline and measure distance to its origin
>5. put every next letter when the measured distance = width of previous letter
>
>note: remember to reorient letter according to current dirrection of spline
>
>something similiar was done in circle_text macro in 3.5
It's quite easy to grab a copy of circle_text and just flip the letters
the right way out. If you want the individual letters to actually have
bent surfaces, then invoke the Cylinder_Text macro with a slightly
larger Radius value, and then trim it by intersecting with a cylinder of
the required radius.
#include "shapes.inc"
/* Cylinder_Text( Font, Text, Size, Spacing, Thickness, Radius,
Inverted, Justification, Angle )
Creates a text object with the bottom (or top) of the character cells
aligned with all or part of a circle. This macro should be used inside
an object{...} block.
Font: The font to use (see the documentation for the text object)
Text: The text string to be created
Size: The height of the text string, as you would use to scale a
standard text object
Spacing: The amount of space to add between the letters.
Thickness: The thickness of the letters (see the documentation for
the text object)
Radius: The radius of the cylinder along which the letters are
aligned
Inverted: If this parameter is nonzero, the tops of the letters
will point downwards (not really much point doing that,
I just copied it from Circle_text)
Justification: One of the constants Align_Left, Align_Right, or
Align_Center
Angle: The point on the circle from which rendering will begin.
The +x direction is 0 and the -z direction is 90 */
#macro Cylinder_Text(F, T, S, Sp, Th, R, I, J, A)
#local FW = Text_Width(F, T, S, Sp);
#local TO = text {ttf F T 1 0 scale<S, S, 1>}
#local TH = max_extent(TO).y;
#local C = array[strlen(T)]
#if(FW > 2*pi*R)
#error concat("\n\n**** Text string \"", T,
"\" is too long for a circle of the specified radius.\n\n\n")
#end
#local AW = -FW*180/pi/R;
#local SA = A;
#local EA = A + AW;
#if(((J = Align_Right) & !I)|((J = Align_Left) & I))
#local SA = A - AW;
#local EA = A;
#else
#if(J = Align_Center)
#local SA = A - AW/2;
#local EA = A + AW/2;
#end
#end
#local CI = 1;
#while(CI <= strlen(T))
#local OE = Text_Width(F, substr(T,CI,1), S, Sp);
#local LW = Text_Width(F, substr(T,1,CI), S, Sp) - OE;
#local LA = SA + AW*LW/FW + OE/2/FW*AW;
#if(I)
#local LA = EA - (LA - SA);
#end
#local TO = text {ttf F substr(T, CI, 1) Th 0 scale<S,S,1>}
#if(I)
#local C[CI-1] =
object {TO
rotate 180*z
translate <OE/2, TH, 0>
rotate -90*y
translate R*x
rotate LA*y
}
#else
#local C[CI-1] =
object {TO
translate -OE/2*x
rotate -90*y
translate R*x
rotate LA*y
}
#end
#local CI = CI + 1;
#end
//Create the final object, a union of individual text object letters.
union {
#local CI=0;
#while(CI < strlen(T))
object {C[CI]}
#local CI = CI + 1;
#end
}
#end
// End of macro - start of example code
camera { location <0, 1, -4> look_at <0, 0, 0>}
light_source {<0,200,-100> colour rgb 1}
#declare Radius = 2;
object {
//intersection {
Cylinder_Text("arial.ttf", "This is a test", 1, -0.1, 1, Radius, 0,
Align_Left, 150)
//cylinder {-y,y,Radius}
//}
pigment {rgb 1}
}
cylinder {-y,1.5*y,Radius-0.05 pigment {rgb 1}}
Post a reply to this message
|
|