POV-Ray : Newsgroups : povray.newusers : Round box Server Time
26 Dec 2024 06:43:28 EST (-0500)
  Round box (Message 1 to 3 of 3)  
From: Cabesa
Subject: Round box
Date: 4 Jan 2022 09:15:00
Message: <web.61d456094a0b1748f03b8bcfe998140@news.povray.org>
Ive been trying to use the round_box shape but i dont really understand how to.
If someone is willing to explain the way the shapes and the "macro?" idrk what
it is, id appreciate it a lot.


Post a reply to this message

From: Alain Martel
Subject: Re: Round box
Date: 4 Jan 2022 10:40:27
Message: <61d46a6b$1@news.povray.org>
Le 2022-01-04 à 09:13, Cabesa a écrit :
> Ive been trying to use the round_box shape but i dont really understand how to.
> If someone is willing to explain the way the shapes and the "macro?" idrk what
> it is, id appreciate it a lot.
> 

You use it pretty much as a regular box, but with the hard edges 
replaced with cylinders and spheres at the vertex. The faces are at the 
same position as for a regular box.

The first two parameters are two 3D vectors that define the opposite 
corners of the box in the exact same way as the two corners of the 
regular box primitive. Those points are actually outside the final shape.

The third one is the radius of the edges, or, the size of the rounded 
part. This is a single float value. If this value is to large, a warning 
will be issued, and the radius adjusted to the actual size. To large 
being more than half the smallest dimension of the box.
If you have this :
round_box( <2,1,1>, <-2,-1,-1>, 1, 0)
You end up with a cylinder capped by two half spheres.
Using those corners, ANY radius larger than 1 will result in the same 
final shape.

The last one determine whether an union or a merge is to be used. UNLESS 
your round_box is transparent or you are using SSLT, you should use the 
union option. So, set this to zero. Using the union option renders faster.

Normal box:
box{ Corner_One, Corner_Two texture{ Some_Texture} }
The equivalent round box :
object{round_box( Corner_One, Corner_Two, radius, 0) texture{ 
Some_Texture} }

The object wrapper is needed to add a texture and to allow some 
transform : rotation, scaling and translate.
The flat faces of the two objects are at the same location.
Those faces are connected using cylinders tangent with the adjacent faces.
Spheres tangent with the adjacent cylinders are used to fill the corners.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Round box
Date: 4 Jan 2022 15:15:00
Message: <web.61d4a9b8b1626a3251748ca189db30a9@news.povray.org>
"Cabesa" <adr### [at] gmailcom> wrote:
> Ive been trying to use the round_box shape but i dont really understand how to.
> If someone is willing to explain the way the shapes and the "macro?" idrk what
> it is, id appreciate it a lot.

I suggest that you read these pages:

    "HowTo:Use macros and loops"
    https://wiki.povray.org/content/HowTo:Use_macros_and_loops

    "Reference:Shapes.inc"
    https://wiki.povray.org/content/Reference:Shapes.inc

    "2.2.2.8 User Defined Macros"
    https://www.povray.org/documentation/view/3.7.0/243/

    "2.7.12.1 shapes.inc"
    http://www.povray.org/documentation/view/3.7.1/468/

- and then you can try this:

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.7;

global_settings { assumed_gamma 1.0 }

#include "colors.inc"
#include "shapes.inc" // For the Round_Box() macro

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare pA = <-2,  0, -1>;  // A corner
#declare pB = <+2, +1, +1>;  // The opposite corner
#declare EdgeAndcornerRadius = 0.25;
#declare UseMerge = false;

object {
    Round_Box(pA, pB, EdgeAndcornerRadius, UseMerge)
    texture {
        pigment { color DarkSlateBlue }
        normal {
            radial
            sine_wave
            frequency 30
            scale 0.25*<1, 1, 1>
        }
        finish { phong 0.5 }
    }
    rotate -35*y
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color Gray30 + Cyan/5 }

light_source {
    100*<-5, 20, -10>
    color White
}

camera {
    location <0, 3, -5>
    look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

--
Tor Olav


Post a reply to this message

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