-
Notifications
You must be signed in to change notification settings - Fork 0
/
how.txt
132 lines (96 loc) · 3.43 KB
/
how.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
so first:
get started with processing!
make the cube, play round with it,
have some fun :)
notes:
the points are vectors
the vectors are in whatever space you want (3d here)
then things are moved around in 3d space with matrix
transforms. This works for rotations because the cube
because it's centered around the origin.
the vectors are then multed by a 2x3 matrix to get them
into 2d space
you can then take these points and draw lines between
them. You could do this in 3d space, but that's just
more work in this case.
Then:
So rendering for the console seems to be doable with
this weird command:
echo -e "\x1B[5;10H<something>"
where <something> is what you want to print
to the console
it seems like the console letters are 2 tall and 1
wide, so our 2d projection matrix needs to scale width
by half
because our image is centered on zero when processing
we need to move it up and right when putting it onto
the console
with this what we need to do is:
make a grid that is our picture
render our picture
subtract the two
print what is different between them
profit?
so lets start out with baby steps:
a 500 x 500 grid of nothing
just blank out the console
then:
put the cube into the console.
then:
put the square into a square class
make a tetrahedron class
done
make surfaces
make shape classes
transfer everything over to being triangles?
you then need to have points->triangels/squares->shapes
get the surface normals for shapes
see if they're dot product with z+ is positive
if it it display it
as for displaying:
make a render function to rasterize a triangle or a
square (fill between points with a character)
to make shading:
make a lighting direction vector
dot product that with the surface normal to get shade
use that number as how you select the shade of a surface.
---------------------------------------------
so we're where we wanted to get to. it took much less time than we
thought it would. so what do next?
- make it run faster - done
research triange rastering. cprofile says it's way slow.
- store the screen non-flattened
so you're not always translating back and forth
- make the environment a class?
holds the objects and spins them and asks for all triangles
to be rendered
- add shadows?
lord know's how, but you could probably just project the rotated
shape down and get a shadow, but then you would need a surface
and depth perception
- clean the existing code
make the functions smaller
rename to clearer variables
---------------------------------------------
Cleaning
rotation matrixes:
so what's really happening with these rotation matrixes
we have an object that's defined by it's points
when we multiply those points by a rotation matrix we get
the current rotated object
step by step:
object
rotation matrix
sort of a rotation matrix.
what we really have is:
something that hold a matrix
a function that makes the correct matrix
so what we really want is
functions to make the rotation matricies for x y and z
a current_rotation matrix that these will all be multiplied to make
that can just be called rotation_matrix
I'm unhappy with how render.py is looking right now.
I think I want a triangle class, but I can't seem to figure
out how to best have it interact with the render class.
maybe call it 'renderTriangle' that returns an iterable?
but that doesn't really help much either does it...