|
|
I have developed the following macro for a U-bar. However I want to
develop it further to allow for any other angles on the corners.
UBar( width, height, leftangle, rightangle,
cross-section-radius, corner-radius )
This will allow for Ubars that look like this:
|
| /
| /
| /
\___/
It's easy to get the right angle on everything ... slicing the corner
toruses (torii?) at the right angle and positioning the side bar at the
right angle ... however, I cant work out how to position the side bar.
Any help would be greatly appreciated.
Cheers!
Rick
__SCENE__
#include "colors.inc"
camera {
location <0.0, 0.5, -4.0>
direction 1.5*z
right x*image_width/image_height
look_at <0.0, 0.0, 0.0>
}
sky_sphere {
pigment {
gradient y
color_map {
[0.0 rgb <0.6,0.7,1.0>]
[0.7 rgb <0.0,0.1,0.8>]
}
}
}
light_source {
<0, 0, 0> // light's position (translated below)
color rgb <1, 1, 1> // light's color
translate <-30, 30, -30>
}
// ----------------------------------------
#macro ubar( Bwidth, Bheight, barradius, curveradius)
union {
// Bar on the bottom of the U
cylinder {
<(Bwidth * -0.5) + (barradius) + curveradius,
(barradius), 0>
<(Bwidth * +0.5) - (barradius) - curveradius,
(barradius), 0>
barradius
}
// Left bar
cylinder {
<(Bwidth * -0.5) + (barradius), (barradius) +
curveradius, 0>
<(Bwidth * -0.5) + (barradius), Bheight,
0>
barradius
}
// Left bar
cylinder {
<(Bwidth * +0.5) - (barradius), (barradius) +
curveradius, 0>
<(Bwidth * +0.5) - (barradius), Bheight,
0>
barradius
}
// Lower left curve
intersection {
torus {
curveradius
barradius
rotate <90, 0, 0>
translate < (Bwidth * -0.5) + (barradius) +
curveradius, (barradius) + curveradius, 0>
}
box {
<(Bwidth * -0.5) -0.1,
(barradius) + curveradius, barradius * -1 - 0.1>
<(Bwidth * -0.5) + (barradius) + curveradius,
-0.01, barradius * +1 + 0.1>
}
}
// Lower right curve
intersection {
torus {
curveradius
barradius
rotate <90, 0, 0>
translate < (Bwidth * -0.5) + (barradius) +
curveradius, (barradius) + curveradius, 0>
}
box {
<(Bwidth * -0.5) -0.1,
(barradius) + curveradius, barradius * -1 - 0.1>
<(Bwidth * -0.5) + (barradius) + curveradius,
-0.01, barradius * +1 + 0.1>
}
rotate <0, 180, 0>
}
}
#end
object {
ubar( 2, 1, 0.012, 0.12 )
texture {
pigment { White }
finish { reflection 0.25 }
}
}
Post a reply to this message
|
|
|
|
Tim Nikias wrote:
> Well, you could use vrotate(A,B), which rotates the vector A about the axis
> B. Use it on the base and end point of the second cylinder. If you've got
> the angle, the remaining bit is just trivial arithmetic.
Thanks Tim ... I did it another way though. However I might still look
into your idea. I moved the object so the torii were at <0,0,0> then put
the vertical pipe at <torus_radius,0,0>. As rotations apply to the
zero-point, the pipe rotates to the correct location.
Here's my shopping trolley (which is the purpose of writing this macro,
although I'll save it in an inc, ready for next time)
[BTW: Anyone who reads this, feel free to explain why rendering time
went through the roof once I put in the intersection to trim the top off
the vertical bars]
__SCENE__
#version 3.5;
#include "colors.inc"
#include "metals.inc"
global_settings {
assumed_gamma 1.0
}
// ----------------------------------------
camera {
location <-20.0, 20, -10>
direction 1.5*z
right x*image_width/image_height
look_at <0.0, 4.5, -3>
}
sky_sphere {
pigment {
gradient y
color_map {
[0.0 rgb <0.6,0.7,1.0>]
[0.7 rgb <0.0,0.1,0.8>]
}
}
}
light_source {
<0, 0, 0> // light's position (translated below)
color rgb <1, 1, 1> // light's color
translate <-30, 30, -30>
}
// ----------------------------------------
plane {
y, -1
pigment { White * 2 }
}
#macro ubar( Bwidth, Bheight, lAngle, rAngle, barradius, curveradius)
union {
union {
// Bar on the bottom of the U
cylinder {
<(Bwidth * -1) + curveradius * 2, curveradius *
1, 0>
<0, curveradius *
-1, 0>
barradius
}
// Right Torus
intersection {
torus {
curveradius
barradius
rotate <90, 0, 0>
}
intersection {
plane {
y,
0
rotate <0,0,90>
}
plane {
y,
0
rotate <0,0,-90+rAngle>
}
}
}
// Bar on the right
cylinder {
<curveradius,0,0>
<curveradius,Bheight - curveradius,0>
barradius
rotate <0,0,-90+rAngle>
}
translate <(Bwidth - curveradius * 2), 0, 0>
}
// Left Torus
intersection {
torus {
curveradius
barradius
rotate <90, 0, 0>
}
intersection {
plane {
y,
0
rotate <0,0,-90>
}
plane {
y,
0
rotate <0,0,90-lAngle>
}
}
}
// Bar on the left
cylinder {
<0-curveradius,0,0>
<0-curveradius,Bheight - curveradius,0>
barradius
rotate <0,0,90-lAngle>
}
translate <(Bwidth - (curveradius * 2)) * -0.5, curveradius, 0>
}
#end
#macro wheel( Wradius, Wthickness )
union {
cylinder {
<Wthickness * -0.51, Wradius, 0>
<Wthickness * +0.51, Wradius, 0>
Wradius * 0.95
texture {
pigment { White }
finish { reflection 0.05 }
}
}
cylinder {
<Wthickness * -0.50, Wradius, 0>
<Wthickness * +0.50, Wradius, 0>
Wradius
texture {
pigment { Black }
finish { reflection 0.05 }
}
}
torus {
Wradius * 0.9
Wradius / 10
rotate <0,0,90>
translate < Wthickness * -0.5, Wradius, 0>
texture {
pigment { Black }
finish { reflection 0.05 }
}
}
torus {
Wradius * 0.9
Wradius / 10
rotate <0,0,90>
translate < Wthickness * +0.5, Wradius, 0>
texture {
pigment { Black }
finish { reflection 0.05 }
}
}
}
#end
union {
#declare barradius = 0.025;
#declare basketangle = 5;
union {
// /* Uncomment these comments to remove the intersection that
slows it down .. there's more below too. I think I've marked the right
places ;)
intersection {
// */
union {
#declare Index = 1;
#while( Index <= 30 )
object {
ubar( 5, 6, 90, 90, barradius,
0.15 )
rotate <-1*basketangle,0,0>
translate <0, 0, Index * 0.25 -
(15 * 0.25)>
}
#declare Index = Index + 1;
#end
#declare Index = -2.25;
#while( Index <= 2.25 )
object {
ubar( 7.5 + 0.3, 6,
90+basketangle, 90-basketangle, barradius, 0.15 )
rotate <0, 90, 0>
translate <Index, barradius *
-1, 0>
}
#declare Index = Index + 0.25;
#end
rotate <basketangle,0,0>
}
// /*
box {
<-5, -1, -5>
<5, 5, 5>
}
}
// */
#declare Index = 0.5;
#while( Index < 5 )
object {
ubar( 5+barradius*2, 7.5+barradius+0.3, 90, 90,
barradius, 0.15 )
rotate <90, 0, 0>
translate <0, Index, -3.75-0.15-barradius>
}
#declare Index = Index + 0.5;
#end
object {
ubar( 5+barradius*2, 7.5+barradius+0.3, 90, 90,
barradius*2, 0.15 )
rotate <90, 0, 0>
translate <0, Index, -3.75-0.15-barradius>
}
translate <0, 3, -3.75-0.15-barradius>
}
difference {
union {
object {
ubar(7, 8, 90, 90, 0.2, 0.5)
rotate <0, 90, 0>
translate <-2.55, 0, -3.3>
}
object {
ubar(7, 8, 90, 90, 0.2, 0.5)
rotate <0, 90, 0>
translate <2.55, 0, -3.3>
}
}
box {
<-3.0, -0.1, -6.0>
<+3.0, 10.4, -7.7>
}
}
//front bumper
object {
ubar( 2.55*2, 2, 90, 90, 0.2, 0.5)
rotate <90, 0, 0>
translate <0, 0.0, -7.5>
}
//handle
object {
ubar( 2.55*2, 2, 90, 90, 0.2, 0.5)
rotate <180, 0, 0>
translate <0, 9.0, barradius+0.15>
}
translate <0, 1.6, 0>
texture {
T_Chrome_2A
finish { reflection 0.5 }
}
}
//handlebar
cylinder {
<-2.0, 10.6, barradius+0.15>
<+2.0, 10.6, barradius+0.15>
0.25
texture {
pigment { Red }
finish { reflection 0.25 }
}
}
object {
wheel(0.8, 0.25)
translate <-2.55, 0, -0.5>
}
object {
wheel(0.8, 0.25)
translate < 2.55, 0, -0.5>
}
object {
wheel(0.8, 0.25)
translate <-2.55, 0, -6.5>
}
object {
wheel(0.8, 0.25)
translate < 2.55, 0, -6.5>
}
__END__
Post a reply to this message
|
|