POV-Ray : Newsgroups : povray.text.scene-files : Piano keyboard #macro Server Time
28 Jul 2024 14:18:24 EDT (-0400)
  Piano keyboard #macro (Message 1 to 3 of 3)  
From: Fabien Mosen
Subject: Piano keyboard #macro
Date: 2 Jul 2000 01:54:43
Message: <395ED7C1.58167C51@skynet.be>
//====================================================================================================
//       ROUNDED BOX MACRO
//====================================================================================================
#macro RoundedBox(v_SP,v_EP,R)
 union {
               #local vSP=(v_SP)*<1,1,1>;
               #local vEP=(v_EP)*<1,1,1>;
             #if (vSP.x > vEP.x)
               #local tSave=vSP.x;
               #local vSP=<vEP.x,vSP.y,vSP.z>;
               #local vEP=<tSave,vEP.y,vEP.z>;
             #end
             #if (vSP.y > vEP.y)
               #local tSave=vSP.y;
               #local vSP=<vSP.x,vEP.y,vSP.z>;
               #local vEP=<vEP.x,tSave,vEP.z>;
             #end
             #if (vSP.z > vEP.z)
               #local tSave=vSP.z;
               #local vSP=<vSP.x,vSP.y,vEP.z>;
               #local vEP=<vEP.x,vEP.y,tSave>;
             #end

               box {<vSP.x,vSP.y+R,vSP.z+R>,<vEP.x,vEP.y-R,vEP.z-R>}
               box {<vSP.x+R,vSP.y,vSP.z+R>,<vEP.x-R,vEP.y,vEP.z-R>}
               box {<vSP.x+R,vSP.y+R,vSP.z>,<vEP.x-R,vEP.y-R,vEP.z>}

               #local vSP=vSP+R;
               #local vEP=vEP-R;

               sphere { <vSP.x,vSP.y,vSP.z>,R}
               sphere { <vEP.x,vSP.y,vSP.z>,R}
               sphere { <vSP.x,vEP.y,vSP.z>,R}
               sphere { <vEP.x,vEP.y,vSP.z>,R}
               sphere { <vSP.x,vSP.y,vEP.z>,R}
               sphere { <vEP.x,vSP.y,vEP.z>,R}
               sphere { <vSP.x,vEP.y,vEP.z>,R}
               sphere { <vEP.x,vEP.y,vEP.z>,R}

               cylinder { <vSP.x,vSP.y,vSP.z>,<vEP.x,vSP.y,vSP.z>,R }
               cylinder { <vSP.x,vEP.y,vSP.z>,<vEP.x,vEP.y,vSP.z>,R }
               cylinder { <vSP.x,vSP.y,vEP.z>,<vEP.x,vSP.y,vEP.z>,R }
               cylinder { <vSP.x,vEP.y,vEP.z>,<vEP.x,vEP.y,vEP.z>,R }
               cylinder { <vSP.x,vSP.y,vSP.z>,<vSP.x,vEP.y,vSP.z>,R }
               cylinder { <vEP.x,vSP.y,vSP.z>,<vEP.x,vEP.y,vSP.z>,R }
               cylinder { <vSP.x,vSP.y,vEP.z>,<vSP.x,vEP.y,vEP.z>,R }
               cylinder { <vEP.x,vSP.y,vEP.z>,<vEP.x,vEP.y,vEP.z>,R }
               cylinder { <vSP.x,vSP.y,vSP.z>,<vSP.x,vSP.y,vEP.z>,R }
               cylinder { <vEP.x,vSP.y,vSP.z>,<vEP.x,vSP.y,vEP.z>,R }
               cylinder { <vSP.x,vEP.y,vSP.z>,<vSP.x,vEP.y,vEP.z>,R }
               cylinder { <vEP.x,vEP.y,vSP.z>,<vEP.x,vEP.y,vEP.z>,R }
               }
             #end

//====================================================================================================
//       KEY DEFINITIONS
//====================================================================================================
//measures in milimeters

#declare CoteNoire=union {
cylinder {<-10,0,0>,<90,0,0>,1}
box {<-10,0,0>,<90,-10,1>}
}

#declare BlackKey=union {
intersection {
union {
object {CoteNoire rotate x*-10 translate z*4}
object {CoteNoire scale <1,1,-1> rotate x*10 translate z*-4}
}
plane {x,0 rotate z*35 translate <80,1,0>}
}
box {<-10,1,4>,<80,-10,-4>}
intersection {
box {<-1,0,5.75>,<1,-13,-5.75>}
cone {<0,0,0>,4,<0,-13,0>,5.75}
rotate z*35 translate <80,0,0>
}
sphere {<80,0,4>,1}
sphere {<80,0,-4>,1}
cylinder {<80,0,4>,<80,0,-4>,1}
cylinder {<0,0,0>,<0,-13,1.8>,1 rotate z*35 translate <80,0,4>}
cylinder {<0,0,0>,<0,-13,-1.8>,1 rotate z*35 translate <80,0,-4>}
cylinder {<87,-10,5.75>,<87,-25,5.75>,1}
cylinder {<87,-10,-5.75>,<87,-25,-5.75>,1}
box {<-10,-10,-6.75>,<87,-25,6.75>}       
box {<-10,-10,-5.75>,<88,-25,5.75>}       
pigment {rgb <1,.98,.9>*0}
finish {phong .4 reflection .1}
translate <1,9,0> //3.11.0
}

#declare Key_C=union {
RoundedBox (<-10,0,0>,<140-2,-20,22-9>,1)
RoundedBox (<90,0,0>,<140,-2.1,22>,1)
RoundedBox (<90,0,0>,<140-2,-20,22>,1)
}              
#declare Key_D=union {
RoundedBox (<-10,0,3>,<140-2,-20,22-3>,1)
RoundedBox (<90,0,0>,<140,-2.1,22>,1)
RoundedBox (<90,0,0>,<140-2,-20,22>,1)
}
#declare Key_E=object {Key_C scale <1,1,-1> translate z*22}
#declare Key_F=object {Key_C}
#declare Key_G=union {
RoundedBox (<-10,0,3>,<140-2,-20,22-6>,1)
RoundedBox (<90,0,0>,<140,-2.1,22>,1)
RoundedBox (<90,0,0>,<140-2,-20,22>,1)
}
#declare Key_A=object {Key_G scale <1,1,-1> translate z*22}
#declare Key_B=object {Key_E}

//====================================================================================================
//       OCTAVE MACRO
//====================================================================================================
//this creates an octave (7 white keys and 5 black), with
//the white keys top on the XZ plane, the back of the keys
//being on Z axis, keys lying along X direction.  the width
//of a complete octave is 162.75 milimeters (side gaps incl.)
//
//the macro takes 12 parameters, which are the individual
//keys rotations, in degrees.  Max. around 6 degrees.
//usage :  Octave (C,C#,D,Eb,E,F,F#,G,G#,A,Bb,B)

#macro Octave (a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
union {
object {Key_C rotate z*-a1}   
 object {BlackKey rotate z*-a2 translate z*19.625 }
object {Key_D  rotate z*-a3 translate z*23.25}
 object {BlackKey rotate z*-a4 translate z*49.375 }
object {Key_E  rotate z*-a5 translate z*23.25*2}
object {Key_F  rotate z*-a6 translate z*23.25*3}
 object {BlackKey rotate z*-a7 translate z*(3*23.25+19.725)}
object {Key_G  rotate z*-a8 translate z*23.25*4}
 object {BlackKey rotate z*-a9 translate z*(4*23.25+22-6+6.625)}
object {Key_A  rotate z*-a10 translate z*23.25*5} 
 object {BlackKey rotate z*-a11 translate z*(5*23.25+22-3+6.625)}
object {Key_B  rotate z*-a12 translate z*23.25*6}
pigment {rgb <1,.98,.9>*1}
finish {phong .4 specular .3 reflection .05}
}
#end


Post a reply to this message

From: John VanSickle
Subject: Re: Piano keyboard #macro
Date: 2 Jul 2000 15:28:48
Message: <395F97E3.77E2C29@erols.com>
Nice.  What if you're using a 53-note scale instead of a 12-note scale?

-- 
ICQ: 46085459


Post a reply to this message

From: Fabien Mosen
Subject: Re: Piano keyboard #macro
Date: 6 Jul 2000 01:24:01
Message: <396416A0.C383D7D3@skynet.be>
John VanSickle wrote:
> 
> Nice.  What if you're using a 53-note scale instead of a 12-note scale?

I guess you could scale the keyboard by 12/53 on the z axis :-))
Or play violin instead...


Post a reply to this message

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