@@ -17,6 +17,7 @@ def __init_grid(self):
17
17
"""
18
18
Initialise the grid along the x, y, z axes.
19
19
"""
20
+ # TODO base off user input?
20
21
num_squares = 10 # Length of the grid in each direction (in units)
21
22
relative_cam = True # Whether the grid follows the camera rotation and movement
22
23
@@ -125,6 +126,14 @@ def __create_grid_objects(self, bool_camera_relative, num_squares):
125
126
return grid
126
127
127
128
def __move_grid_objects (self , bool_camera_relative , num_squares ):
129
+ """
130
+ Reusing the current assets, move the planes to the new origins.
131
+
132
+ :param bool_camera_relative: Whether to draw the axes at the camera focus point or at (0, 0, 0).
133
+ :type bool_camera_relative: bool
134
+ :param num_squares: How many unit squares to draw along the axis.
135
+ :type num_squares: int
136
+ """
128
137
camera_axes = self .camera_axes
129
138
# Locate centre of axes
130
139
if bool_camera_relative :
@@ -155,6 +164,7 @@ def __move_grid_objects(self, bool_camera_relative, num_squares):
155
164
min_z_coord = z_origin + int (- (num_squares / 2 ) + (sign (camera_axes .z ) * - 1 ) * (num_squares / 2 ))
156
165
max_z_coord = z_origin + int ((num_squares / 2 ) + (sign (camera_axes .z ) * - 1 ) * (num_squares / 2 ))
157
166
167
+ # Compound origins are in the middle of the bounding boxes. Thus new pos will be between max and min.
158
168
x_middle = (max_x_coord + min_x_coord ) / 2
159
169
y_middle = (max_y_coord + min_y_coord ) / 2
160
170
z_middle = (max_z_coord + min_z_coord ) / 2
@@ -180,9 +190,7 @@ def __move_grid_objects(self, bool_camera_relative, num_squares):
180
190
def update_grid (self ):
181
191
"""
182
192
Update the grid axes and numbers if the camera position/rotation has changed.
183
-
184
193
"""
185
-
186
194
# Obtain the new camera settings
187
195
new_camera_pos = scene .camera .pos
188
196
new_camera_axes = scene .camera .axis
@@ -197,6 +205,7 @@ def update_grid(self):
197
205
self .camera_axes = new_camera_axes
198
206
199
207
# Update grid
208
+ # TODO base off user input?
200
209
num_squares = 10 # Length of the grid in each direction (in units)
201
210
relative_cam = True # Whether the grid follows the camera rotation and movement
202
211
self .__move_grid_objects (relative_cam , num_squares )
0 commit comments