@@ -231,21 +231,24 @@ def onRender(self):
231
231
for tri_ in obj .mesh .tri :
232
232
233
233
triProj = elcTriangle ()
234
+ triRoted = elcTriangle ()
234
235
triPosed = elcTriangle ()
235
236
for x in range (3 ):
236
- posTemp = tri_ [x ]+ absPosObj + absPosSelf
237
+ triPosed [x ] = tri_ [x ]+ absPosObj + absPosSelf
238
+ posTemp = eclVector3 (triPosed [x ].x ,triPosed [x ].y ,triPosed [x ].z ) # copy
237
239
posTemp .x , posTemp .z = self .rotate2d ((posTemp .x ,posTemp .z ),absRotObj .x + absRotSelf .x )
238
240
posTemp .y , posTemp .x = self .rotate2d ((posTemp .y ,posTemp .x ),absRotObj .y + absRotSelf .y )
239
241
posTemp .z , posTemp .y = self .rotate2d ((posTemp .z ,posTemp .y ),absRotObj .z + absRotSelf .z )
240
- triPosed [x ] = posTemp
242
+ triRoted [x ] = posTemp
241
243
242
244
for x in range (3 ):
243
245
#posTemp.z, posTemp.x = self.rotate2d((posTemp.z,posTemp.x),absRotObj.y+absRotSelf.y)
244
- triProj [x ] = self ._projection (triPosed [x ])
246
+ triProj [x ] = self ._projection (triRoted [x ])
245
247
246
248
shouldDraw = False
247
249
normal_proj = triProj .calculateNormal ()
248
250
normal_posed = triPosed .calculateNormal ()
251
+ normal_roted = triRoted .calculateNormal ()
249
252
if (dotProduct (normal_proj ,triProj [0 ] - self .transform .position ) > 0 ):shouldDraw = True
250
253
shouldDraw = True
251
254
@@ -255,8 +258,8 @@ def rescale(x,min_,max_):return (x/2+0.5)*(max_+min_)
255
258
color = rescale (dotProduct (normal_posed ,self .light .transform .position ),0 ,255 )
256
259
print (color )
257
260
white = int (color )
258
- tris_sorted .append ([triProj ,[white ,white ,white ],sum (sum (triPosed [j ][i ] for j in range (3 ))** 2 for i in range (3 ))])
259
- print ( "ok" )
261
+ tris_sorted .append ([triProj ,[white ,white ,white ],sum (abs ( sum (triPosed [j ][i ] for j in range (3 ))) for i in range (3 ))])
262
+
260
263
tris_sorted = sorted (tris_sorted ,key = lambda x :x [2 ],reverse = True )
261
264
for tri ,color ,_ in tris_sorted :
262
265
self .draw (elcTriangle (
0 commit comments