|
|
Here is the source of the bottle macro. Any comments appreciated.
--
Paul Hewson
pau### [at] vifcom
-----------
One never knows, do one?
// <Source starts here.>
// File: bottle.inc
// Vers: 3.1
// Desc: Parameterized bottle include
// Date: Nov 6, 1999
// Auth: Paul Hewson
/*--------------------------------------------------------------------------
-----------
The macro takes the following parameters
NH The neck height
NR The neck radius
SH The shoulder height (the shoulder is the curved piece that joins
body to neck)
UDPx User defined point x
UDPy User defined point y
These allow you to pull the shoulder into different shapes by
adding a point
to the lathe.
BH The height of the body cylinder
BR The radius of the body
Glass_Texture I found I had to add the texture to each component,
because the normal
would interfere otherwise. If someone sees a better way,
please let
me know.
============================================================================
=============*/
#macro Bottle_Macro (NH, NR, SH, UDPx, UDPy, BH, BR, Glass_Texture)
#declare Glass_Thickness = .05;
// Neck parameters
#declare Neck_Height = NH;
#declare Neck_Radius = NR;
// Shoulder parameters
//
// Shoulder is a lathe object with end points joining the neck to body
#declare Shoulder_Height = SH;
#declare p1x = UDPx;
#declare p1y = UDPy;
// #declare p2 =
// Body parameters
#declare Body_Height = BH;
#declare Body_Radius = BR;
// Base parameters
#declare Base_Torus_Radius = .15
// Textures inner and outer
#declare Bottle_Texture = texture { Glass_Texture }
#declare Bottle_interior = interior { I_Glass }
#declare Bottle_Normal = normal {radial frequency 2 scale 3 }
// #declare <>;
// Base
#declare Base =
merge
{
torus
{
Body_Radius - Base_Torus_Radius , //
Base_Torus_Radius // Minor
// pigment {rg
bt 1}
}
intersection
{
cylinder
{
<0,0,0> // base point
<0,Base_Torus_Radius*2 + Glass_Thickness*2,0> // Cap
Base_Torus_Radius*2 + Glass_Thickness*2
Body_Radius
}
difference
{
sphere
{
<0,0,0> , 1
scale <Body_Radius, Base_Torus_Radius + Glass_Thickness*2,
Body_Radius>
}
sphere
{
<0,0,0> , 1
scale <Body_Radius - Base_Torus_Radius*2, Base_Torus_Radius ,
Body_Radius - Base_Torus_Radius*2>
}
}
//
} // End of intersection
texture {Bottle_Texture} interior {Bottle_interior}
} // End of merge
// Body
#declare Body =
difference
{
cylinder
{
<0,0,0> // Base
<0, Body_Height, 0>
Body_Radius
texture {Bottle_Texture} interior {Bottle_interior}
}
cylinder
{
<0,-0.1,0> // Base
<0, Body_Height+ .1, 0>
Body_Radius - Glass_Thickness
texture {Bottle_Texture}
normal{Bottle_Normal}
}
}
// Shoulder--------------------------------------------
#declare Shoulder =
union
{
lathe
{
cubic_spline
5
<Body_Radius, Body_Height - (Shoulder_Height )> // Control point
<Body_Radius, Body_Height-.001> // End point meets body
<p1x, p1y> // User defined point
<Neck_Radius, Body_Height + Shoulder_Height + .0001> // End point meets neck
<Neck_Radius, Body_Height + Shoulder_Height * 2> // Control point
texture {Bottle_Texture} interior {Bottle_interior}
}
lathe
{
cubic_spline
5
<Body_Radius - Glass_Thickness,Body_Height - (Shoulder_Height )> // Control
point
<Body_Radius - Glass_Thickness, Body_Height -.001> // End point meets body
<p1x - Glass_Thickness, p1y> // User defined point
<Neck_Radius - Glass_Thickness, Body_Height + Shoulder_Height+ .0001> // End
point meets neck
<Neck_Radius
- Glass_Thickness, Body_Height + Shoulder_Height * 2> // Control point
texture {Bottle_Texture} // interior {Bottle_interior}
normal{Bottle_Normal}
}
} // End of difference
// End of Shoulder--------------------------------------------
// Neck
#declare Neck =
difference
{
cylinder
{
<0,Shoulder_Height + Body_Height,0> file://Base
<0, Neck_Height + Shoulder_Height + Body_Height, 0>
Neck_Radius
texture {Bottle_Texture} interior {Bottle_interior}
}
cylinder
{
<0,Shoulder_Height + Body_Height - 0.1,0> file://Base
<0, Neck_Height + Shoulder_Height + Body_Height + .1, 0>
Neck_Radius - Glass_Thickness
texture {Bottle_Texture} file://interior {Bottle_interior}
normal{Bottle_Normal}
}
}
file://Lip
#declare Lip =
difference
{
cylinder
{
<0, Shoulder_Height + Body_Height + Neck_Height - .2, 0> file://Base
<0, Shoulder_Height + Body_Height + Neck_Height, 0>
Neck_Radius + .1
}
cylinder
{
<0, Shoulder_Height + Body_Height + Neck_Height - .21, 0>
<0, Shoulder_Height + Body_Height + Neck_Height+ .01, 0>
Neck_Radius - Glass_Thickness
}
texture {Bottle_Texture} interior {Bottle_interior}
}
// #declare Bottle =
object
{
merge
{
object {Base}
object {Body}
object {Shoulder}
object {Neck}
object {Lip}
// object {}
}
}
#end
Post a reply to this message
|
|