File tree 1 file changed +11
-13
lines changed
112_3D_Rendering/Processing/CC_112_3D_Rendering
1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change 1
- // Daniel Shiffman
2
- // http://youtube.com/thecodingtrain
3
- // http://codingtra.in
4
-
1
+ // Daniel Shiffman / Coding Train
5
2
// Coding Challenge #112: 3D Rendering with Rotation and Projection
3
+ // https://thecodingtrain.com/challenges/112-3d-rendering-with-rotation-and-projection
6
4
// https://youtu.be/p4Iz0XJY-Qk
5
+ // p5: https://editor.p5js.org/codingtrain/sketches/r8l8XXD2A
7
6
8
7
float angle = 0 ;
9
8
10
9
PVector [] points = new PVector [8 ];
11
10
12
- float [][] projection = {
13
- {1 , 0 , 0 },
14
- {0 , 1 , 0 }
15
- };
16
-
17
11
void setup () {
18
12
size (600 , 400 );
19
13
@@ -57,6 +51,14 @@ void draw() {
57
51
PVector rotated = matmul(rotationY, v);
58
52
rotated = matmul(rotationX, rotated);
59
53
rotated = matmul(rotationZ, rotated);
54
+
55
+ float distance = 2 ;
56
+ float z = 1 / (distance - rotated. z);
57
+ float [][] projection = {
58
+ {z, 0 , 0 },
59
+ {0 , z, 0 }
60
+ };
61
+
60
62
PVector projected2d = matmul(projection, rotated);
61
63
projected2d. mult(200 );
62
64
projected[index] = projected2d;
@@ -78,10 +80,6 @@ void draw() {
78
80
connect(i, i+ 4 , projected);
79
81
}
80
82
81
-
82
-
83
-
84
-
85
83
angle += 0.03 ;
86
84
}
87
85
You can’t perform that action at this time.
0 commit comments