POV-Ray : Newsgroups : povray.text.scene-files : Bottle macro Server Time
25 Dec 2024 01:01:03 EST (-0500)
  Bottle macro (Message 1 to 3 of 3)  
From: Paul Hewson
Subject: Bottle macro
Date: 10 Nov 1999 00:43:59
Message: <3829061f@news.povray.org>
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

From: Dave Cook
Subject: Re: Bottle macro
Date: 11 Nov 1999 00:06:10
Message: <382a4ec2@news.povray.org>
Thanks for posting (and writing) this Paul! Any chance you might post an
example .pov for us?

TIA, Dave

Paul Hewson <pau### [at] vifcom> wrote in message
news:3829061f@news.povray.org...
> Here is the source of the bottle macro.  Any comments appreciated.


Post a reply to this message

From: Paul Hewson
Subject: Re: Bottle macro
Date: 11 Nov 1999 09:30:38
Message: <382ad30e@news.povray.org>
Dave Cook <nos### [at] homecom> wrote in message
news:382a4ec2@news.povray.org...
> Thanks for posting (and writing) this Paul! Any chance you might post an
> example .pov for us?
>
> TIA, Dave
>

No problem, here is a modified version of the demo render.

// <source follows>

// Persistence of Vision Ray Tracer Scene Description File
// File: b3.pov
// Vers: 3.1
// Desc: Sample bottle file
// Date: 11/10/99
// Auth: Paul H.
//

/*----------------------------------------------
  Makes some sample bottles from the macro
  Designed for UVPov patch (whatever the current
  version is. Comment out the global photon block
  and the photon statement in each object
  to render in 3.1g.
===============================================*/



#version 3.1

#include "colors.inc"
#include "glass.inc"
#include "bottle.inc"


#declare phd=1;

// If you don't want to use photons
// comment out the following line.

#declare Use_Photons = yes;


global_settings
{
  max_trace_level 45
#ifdef (Use_Photons)
  photons
  {
    gather 20, 100
    radius 0.1*phd, 2, 2//, 0.1*phd
    autostop 0
    jitter .4
    expand_thresholds 0.2, 40
  }
#end
}




//
file://-------------------Textures (from Stones.inc)
//

#declare P_Grnt0 =

pigment
 {
  granite
  turbulence 0.4
  color_map
   {
    [0.000, 0.153   color rgbf <0.729, 0.502, 0.451, 0.000>
                    color rgbf <0.769, 0.686, 0.592, 0.000>]
    [0.153, 0.398   color rgbf <0.769, 0.686, 0.592, 0.000>
                    color rgbf <0.843, 0.753, 0.718, 0.000>]
    [0.398, 0.559   color rgbf <0.843, 0.753, 0.718, 0.000>
                    color rgbf <0.780, 0.667, 0.561, 0.000>]
    [0.559, 0.729   color rgbf <0.780, 0.667, 0.561, 0.000>
                    color rgbf <0.741, 0.659, 0.576, 0.000>]
    [0.729, 1.001   color rgbf <0.741, 0.659, 0.576, 0.000>
                    color rgbf <0.729, 0.502, 0.451, 0.000>]
   }
 }


file://----- Creamy Whites with yellow & light gray
#declare P_Grnt1 =

pigment
 {granite
  turbulence 0.6
  color_map
   {
    [0.000, 0.212   color rgbf <0.898, 0.898, 0.851, 0.000>
                    color rgbf <0.969, 0.980, 0.875, 0.000>]
    [0.212, 0.424   color rgbf <0.969, 0.980, 0.875, 0.000>
                    color rgbf <0.859, 0.859, 0.859, 0.000>]
    [0.424, 0.627   color rgbf <0.859, 0.859, 0.859, 0.000>
                    color rgbf <0.992, 0.922, 0.659, 0.000>]
    [0.627, 0.881   color rgbf <0.992, 0.922, 0.659, 0.000>
                    color rgbf <0.937, 0.965, 0.902, 0.000>]
    [0.881, 1.001   color rgbf <0.937, 0.965, 0.902, 0.000>
                    color rgbf <0.898, 0.898, 0.851, 0.000>]
   }
 }



// ----------------------------------------
camera
{
  location  <0.0, 5, -18.0>
  direction 1.5*z
  right     4/3*x
  look_at   <0, 4.5,  0.0>
}

// Set a color of the background (sky)
background { color red 0.1 green 0.3 blue 0.8 }

light_source
{
  0*x // light's position (translated below)
  color red 1.0  green 1.0  blue 1.0  // light's color
  translate <-10, 30, -30>
}

// ----------------------------------------


object
{
  Bottle_Macro (1, .35, 3.5, .47, 6.3, 5, 1.25, T_Glass3 )
#ifdef (Use_Photons)
  photons
  {
    separation 0.02*phd
    refraction on
    reflection on
    ignore_photons
  }
#end
  rotate <0,45,0>

}

/*----------------------------------------------

// More bottles
object
{
  Bottle_Macro (2, .5, 2, 1.4, 8.5, 7, 1.5, T_Dark_Green_Glass )
  photons
  {
    separation 0.02*phd
    refraction on
    reflection on
    file://ignore_photons
  }
  rotate <0,120,0>
  translate 5*x
}

object
{

  Bottle_Macro (.2, .35, 2, .6, 5, 4, 1, T_Glass4 )

  photons
  {
    separation 0.02*phd
    refraction on
    reflection on
    ignore_photons
  }
  rotate <0,95,0> translate -5*x

}

==============================================*/

//  Box in the background
box
{
  <20, 20, 10>  //  one corner position <X1 Y1 Z1>
  < -20,  -1,  11>  //  other corner position <X2 Y2 Z2>
  texture
  {
    pigment
    {
      checker
      pigment {P_Grnt0}
      pigment {P_Grnt1}
    }


    scale 3

  }

}

//  box to stand bottles on
box
{
  <-20, -3, -10>  // one corner position <X1 Y1 Z1>
  < 20,  0,  10>  // other corner position <X2 Y2 Z2>
  texture
  {
    pigment
    {
      checker
      pigment {P_Grnt0}
      pigment {P_Grnt1}
    }


    scale 3

  }

}


Post a reply to this message

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