Skip to content

Commit 75c6d28

Browse files
committedJun 14, 2016
Piece generator for cubes with stickers is added.
1 parent 958e67e commit 75c6d28

6 files changed

+70
-0
lines changed
 

‎doc/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,17 @@ rubik_cube_generate_cube(
240240
array[2] {Red, White} // Piece generator parameter.
241241
)
242242
```
243+
244+
245+
#### Predefined Piece Generators
246+
247+
There are two piece generators provided with the library:
248+
- *[rubik-cube-generator-cube.inc](../rubik-cube-generator-cube.inc)*
249+
[default] — generates cubes without stickers.
250+
251+
![](simple-cube/simple-cube.png)
252+
253+
- *[rubik-cube-generator-with-stickers.inc](../rubik-cube-generator-with-stickers.inc)* —
254+
generates cubes with stickers.
255+
256+
![](piece-generators/with-stickers.png)
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Input_File_Name=with-stickers.pov
2+
Library_Path=../..
3+
Width=320
4+
Height=240
5+
Antialias=true
17.2 KB
Loading
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "../doc-scene.inc"
2+
#include "rubik-cube.inc"
3+
4+
rubik_cube_to_object(
5+
rubik_cube_generate_cube(
6+
<3, 3, 3>,
7+
"rubik-cube-generator-with-stickers.inc",
8+
array[6] {
9+
pigment { Green },
10+
pigment { Red },
11+
pigment { Yellow },
12+
pigment { Blue },
13+
pigment { Orange},
14+
pigment { White }
15+
}
16+
)
17+
)
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Generates a piece of cube with stickers.
2+
//
3+
// gen_param - array of six textures to be applied for the cube
4+
// stickers. Textures are ordered in the following way: right face
5+
// (0); top face (1); back face (2); left face (3); bottom face (4);
6+
// front face (5).
7+
// Note. Interiors are just colored in black.
8+
9+
union {
10+
// Piece.
11+
#local piece_edge_radius = 0.06;
12+
13+
object {
14+
Round_Box(<-0.5, -0.5, -0.5>, <0.5, 0.5, 0.5>, piece_edge_radius, 1)
15+
pigment { Black }
16+
}
17+
18+
// Stickers.
19+
#local thickness_ = 0.01; // Thickness of the sticker. (outer part)
20+
#local bt = thickness_ + 0.5; // Thickness of the block used for sticker creation.
21+
#local s = 0.5 - piece_edge_radius; // Sticker size (a half of it, actually).
22+
#local ser = 0.05; // Sticker edge radius.
23+
24+
#if (pos.x = dim.x - 1) object { Round_Box(< bt, -s, -s>, <0, s, s>, ser, 1) texture { gen_param[0] }} #end
25+
#if (pos.y = dim.y - 1) object { Round_Box(< -s, bt, -s>, <s, 0, s>, ser, 1) texture { gen_param[1] }} #end
26+
#if (pos.z = dim.z - 1) object { Round_Box(< -s, -s, bt>, <s, s, 0>, ser, 1) texture { gen_param[2] }} #end
27+
28+
#if (pos.x = 0) object { Round_Box(<-bt, -s, -s>, <0, s, s>, ser, 1) texture { gen_param[3] }} #end
29+
#if (pos.y = 0) object { Round_Box(< -s, -bt, -s>, <s, 0, s>, ser, 1) texture { gen_param[4] }} #end
30+
#if (pos.z = 0) object { Round_Box(< -s, -s, -bt>, <s, s, 0>, ser, 1) texture { gen_param[5] }} #end
31+
32+
translate 0.5
33+
}

‎test/tests

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
../doc/layers-rotation/layers-rotation-3x3x3.ini
55
../doc/notation/notation.ini
66
../doc/piece-generators/sphere.ini
7+
../doc/piece-generators/with-stickers.ini
78
../doc/simple-cube/simple-cube.ini

0 commit comments

Comments
 (0)
Please sign in to comment.