TurtleGL-3d 1.4.1__tar.gz → 1.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {turtlegl_3d-1.4.1/src/TurtleGL_3d.egg-info → turtlegl_3d-1.4.2}/PKG-INFO +1 -1
  2. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/pyproject.toml +1 -1
  3. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/setup.py +1 -1
  4. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2/src/TurtleGL_3d.egg-info}/PKG-INFO +1 -1
  5. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/src/camera.py +16 -36
  6. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/src/ray.py +13 -0
  7. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/LICENSE +0 -0
  8. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/README.md +0 -0
  9. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/setup.cfg +0 -0
  10. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/TurtleGL_3d.egg-info/SOURCES.txt +0 -0
  11. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/TurtleGL_3d.egg-info/dependency_links.txt +0 -0
  12. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/TurtleGL_3d.egg-info/requires.txt +0 -0
  13. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/TurtleGL_3d.egg-info/top_level.txt +0 -0
  14. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/__init__.py +0 -0
  15. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/airplane_game.py +0 -0
  16. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/christmas tree/turtleGL_christmas_tree_example.py +0 -0
  17. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/racing_game.py +0 -0
  18. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/texture example/turtleGL_texture_example.py +0 -0
  19. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_anime_example.py +0 -0
  20. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_cabin_example.py +0 -0
  21. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_cube_example.py +0 -0
  22. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_focal_example.py +0 -0
  23. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_from_file_example.py +0 -0
  24. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_grating_example.py +0 -0
  25. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_light_example.py +0 -0
  26. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_obj_example.py +0 -0
  27. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_plot3D_example.py +0 -0
  28. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/example/turtleGL_volume_example.py +0 -0
  29. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/src/plot3d.py +0 -0
  30. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/src/scene.py +0 -0
  31. {turtlegl_3d-1.4.1 → turtlegl_3d-1.4.2}/src/turtleGL/src/volume.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TurtleGL-3d
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: A 3D grafics library based on turtle
5
5
  Home-page: https://github.com/MichaelHyan/turtleGL
6
6
  Author: Han Yan
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "TurtleGL-3d"
7
- version = "1.4.1"
7
+ version = "1.4.2"
8
8
  authors = [
9
9
  {name = "Han Yan", email = "3367461801@qq.com"}
10
10
  ]
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="TurtleGL-3d",
8
- version="1.4.1",
8
+ version="1.4.2",
9
9
  author="Han Yan",
10
10
  author_email="3367461801@qq.com",
11
11
  description="A 3D grafics library based on turtle",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TurtleGL-3d
3
- Version: 1.4.1
3
+ Version: 1.4.2
4
4
  Summary: A 3D grafics library based on turtle
5
5
  Home-page: https://github.com/MichaelHyan/turtleGL
6
6
  Author: Han Yan
@@ -649,8 +649,7 @@ class camera():
649
649
  intersection_point = ray_origin + t * ray_direction
650
650
  return True, intersection_point[0], intersection_point[2], intersection_point[1]
651
651
 
652
- def grating(self,face,ray):
653
- raylight = ray.sunlight[0][0]
652
+ def grating(self,face,ray_object):
654
653
  if self.rend == 0:
655
654
  total = (self.grating_size[0]//self.grating_length)*(self.grating_size[1]//self.grating_length)
656
655
  c = 0
@@ -680,37 +679,27 @@ class camera():
680
679
  for k in face:
681
680
  a,t,u,v = self.ray_triangle_intersect(self.camera_position,ray,k[0])
682
681
  if a:
683
- if self.normalvect(raylight,k[0][0],k[0][1],k[0][2]) > 0:
684
- rect_r = [-x for x in raylight]
685
- mark = 0
682
+ factor = -1
683
+ rays = ray_object.get_ray([t,u,v])
684
+ for rayl in rays:
685
+ raylight = rayl[0]
686
+ rect_r = [x for x in raylight]
686
687
  for m in face:
687
688
  b,o,p,q = self.ray_triangle_intersect([t,u,v],rect_r,m[0])
688
689
  if b and (m != k):
689
- mark = 1
690
+ factor += rayl[1]
690
691
  continue
691
- else:
692
- pass
693
- if mark == 1:
694
- color = self.multiply(k[1],self.normalvect(raylight,k[0][0],k[0][1],k[0][2]))
695
- else:
696
- color = self.multiply(k[1],self.normalvect(raylight,k[0][0],k[0][1],k[0][2])**0.5)
692
+ color = self.multiply(k[1],factor if factor <= 1 else 1)
697
693
  for xi in range(self.grating_length):
698
694
  for yi in range(self.grating_length):
699
695
  turtle.goto(i+xi,j+yi)
700
696
  turtle.dot(2,color)
701
- else:
702
- for xi in range(self.grating_length):
703
- for yi in range(self.grating_length):
704
- turtle.goto(i+xi,j+yi)
705
- turtle.dot(2,self.multiply(k[1],self.normalvect(raylight,k[0][0],k[0][1],k[0][2])))
706
- continue
707
697
  else:
708
698
  pass
709
699
  c += 1
710
700
  self.bar(c,total)
711
701
 
712
- def grating_cv2(self,face,ray):
713
- raylight = ray.sunlight[0][0]
702
+ def grating_cv2(self,face,ray_object):
714
703
  if self.rend == 0:
715
704
  total = (self.grating_size[0]//self.grating_length)*(self.grating_size[1]//self.grating_length)
716
705
  c = 0
@@ -740,30 +729,21 @@ class camera():
740
729
  for k in face:
741
730
  a,t,u,v = self.ray_triangle_intersect(self.camera_position,ray,k[0])
742
731
  if a:
743
- if self.normalvect(raylight,k[0][0],k[0][1],k[0][2]) < 0:
732
+ factor = -1
733
+ rays = ray_object.get_ray([t,u,v])
734
+ for rayl in rays:
735
+ raylight = rayl[0]
744
736
  rect_r = [-x for x in raylight]
745
- mark = 0
746
737
  for m in face:
747
738
  b,o,p,q = self.ray_triangle_intersect([t,u,v],rect_r,m[0])
748
739
  if b and (m != k):
749
- mark = 1
740
+ factor += rayl[1]
750
741
  continue
751
- else:
752
- pass
753
- if mark == 1:
754
- color = self.multiply(k[1],self.normalvect(raylight,k[0][0],k[0][1],k[0][2])**2)
755
- else:
756
- color = self.multiply(k[1],self.normalvect(raylight,k[0][0],k[0][1],k[0][2]))
742
+ color = self.multiply(k[1],factor if factor <= 1 else 1)
757
743
  for xi in range(self.grating_length):
758
744
  for yi in range(self.grating_length):
759
- self.image[-j+self.image_size[1]//2+xi,
745
+ self.image[-j+self.image_size[1]//2+xi,
760
746
  i+self.image_size[0]//2+yi] = self.hex_to_bgr(color)
761
- else:
762
- for xi in range(self.grating_length):
763
- for yi in range(self.grating_length):
764
- self.image[-j+self.image_size[1]//2+xi,
765
- i+self.image_size[0]//2+yi] = self.hex_to_bgr(self.multiply(k[1],self.normalvect(raylight,k[0][0],k[0][1],k[0][2])))
766
- continue
767
747
  else:
768
748
  pass
769
749
  c += 1
@@ -39,6 +39,19 @@ class ray():
39
39
  cos = self.normalvect(vector,point1,point2,point3)
40
40
  return cos*brightness
41
41
 
42
+ def get_ray(self,point):
43
+ ray = []
44
+ for i in self.sunlight:
45
+ ray.append(i)
46
+ for i in self.pointlight:
47
+ dx = point[0]-i[0][0]
48
+ dy = point[1]-i[0][1]
49
+ dz = point[2]-i[0][2]
50
+ ray.append([[dx,dy,dz],i[1]/math.sqrt(dx**2+dy**2+dz**2)])
51
+ for i in self.ray:
52
+ ray.append([[i[1][0]-i[0][0],i[1][1]-i[0][1],i[1][2]-i[0][2]],i[2]])
53
+ return ray
54
+
42
55
  def get_value(self,point1,point2,point3):
43
56
  value = -1
44
57
  for i in self.sunlight:
File without changes
File without changes
File without changes