GSOF-3dWireFrame 1.1.3__tar.gz → 1.2.0__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 (46) hide show
  1. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_dynamicWorld.py +1 -1
  2. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_motionWorld.py +1 -1
  3. gsof_3dwireframe-1.2.0/GSOF_3dWireFrame/Lib3D/WireFrame_display.py +74 -0
  4. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0/GSOF_3dWireFrame.egg-info}/PKG-INFO +1 -1
  5. {gsof_3dwireframe-1.1.3/GSOF_3dWireFrame.egg-info → gsof_3dwireframe-1.2.0}/PKG-INFO +1 -1
  6. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/pyproject.toml +1 -1
  7. gsof_3dwireframe-1.1.3/GSOF_3dWireFrame/Lib3D/WireFrame_display.py +0 -60
  8. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/AUTHORS +0 -0
  9. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Drone_Class.py +0 -0
  10. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_Drone.py +0 -0
  11. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_F16.py +0 -0
  12. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_staticWorld.py +0 -0
  13. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/F16_Class.py +0 -0
  14. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Assembly.py +0 -0
  15. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Lib3D.py +0 -0
  16. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Object_WireFrame.py +0 -0
  17. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Object_base.py +0 -0
  18. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Objects.py +0 -0
  19. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Utils.py +0 -0
  20. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/__init__.py +0 -0
  21. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/stlToObj.py +0 -0
  22. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/MathLib/MathLib.py +0 -0
  23. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/MathLib/__init__.py +0 -0
  24. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/attitudeViewer.py +0 -0
  25. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/modules/AttitudeViewer_class.py +0 -0
  26. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/modules/Controls.py +0 -0
  27. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/modules/__init__.py +0 -0
  28. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/Axis.json +0 -0
  29. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/F16.stl +0 -0
  30. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/LandingGear.json +0 -0
  31. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/Plume.json +0 -0
  32. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/Spark.json +0 -0
  33. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/cube.json +0 -0
  34. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/cube_flex.json +0 -0
  35. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/frame.json +0 -0
  36. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/house.json +0 -0
  37. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/net.json +0 -0
  38. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/plane.stl +0 -0
  39. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/pyramid.json +0 -0
  40. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/SOURCES.txt +0 -0
  41. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/dependency_links.txt +0 -0
  42. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/requires.txt +0 -0
  43. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/top_level.txt +0 -0
  44. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/LICENSE +0 -0
  45. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/README.md +0 -0
  46. {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/setup.cfg +0 -0
@@ -46,7 +46,7 @@ if __name__ == "__main__":
46
46
  pygame.init()
47
47
  clock = pygame.time.Clock()
48
48
  screen = newScreen("3D Wire Frame Shapes", SCREEN_WIDTH, SCREEN_HEIGHT, WHITE)
49
- wireframe = DISP.WireFrame(screen, pygame.draw.line, scale=50*80)
49
+ wireframe = DISP.WireFrame(screen, pygame.draw.line, scale=50*80, minViewDistance=10)
50
50
  fps = 30
51
51
  dt = 1/fps
52
52
  t = 0.0
@@ -30,7 +30,7 @@ if __name__ == "__main__":
30
30
  pygame.init()
31
31
  clock = pygame.time.Clock()
32
32
  screen = newScreen("3D Wire Frame Shapes", SCREEN_WIDTH, SCREEN_HEIGHT, WHITE)
33
- wireframe = DISP.WireFrame(screen, pygame.draw.line, scale=1000)
33
+ wireframe = DISP.WireFrame(screen, pygame.draw.line, scale=1000, minViewDistance=1)
34
34
  viewer = Controls.Viewer( pos=(0,0,-10),
35
35
  center=(int(screen.get_width()/2), int(screen.get_height()/2)),
36
36
  moveLeftKey = pygame.K_a,
@@ -0,0 +1,74 @@
1
+ def _findLine(x1,y1,x2,y2) -> list:
2
+ DX = x2 -x1
3
+ DY = y2 -y1
4
+ Ay = DY/DX
5
+ By = y2 -Ay*x2
6
+ return (Ay, By)
7
+
8
+ def calcLine(a, b, x) -> float:
9
+ return a*x +b
10
+
11
+ class WireFrame():
12
+ def __init__(self, screen, line, f=1, scale=1000.0, minViewDistance=1, maxViewDistance=10000):
13
+ self.screen = screen #< Object to draw on
14
+ self.line = line #< function to draw a line
15
+ self.f = f #< Perspective factor
16
+ self.scale = scale #< Lens zoom
17
+ print("ViewDistance between %1.2f to %1.2f"%(minViewDistance,maxViewDistance))
18
+ self.minViewZ = abs(minViewDistance) #<
19
+ self.maxViewZ = abs(maxViewDistance) #<
20
+ self.centerX, self.centerY = (int(screen.get_width()/2), int(screen.get_height()/2))
21
+
22
+ def draw(self, obj, color=None) -> None:
23
+ """ """
24
+ for line in obj.getLines():
25
+ p1, p2 = line.points
26
+ #p1[2], p2[2] = -p1[2], -p2[2]
27
+ zmin, zmax = -self.minViewZ, -self.maxViewZ
28
+ if (p1[2] > zmax) or (p2[2] > zmax):
29
+ ### Both end are in view distance
30
+ if (p1[2] < zmin) or (p2[2] < zmin):
31
+ ### At least one end of the line is infront of the camera
32
+ self.clip(p1,p2)
33
+ p1 = self.camera(p1)
34
+ p2 = self.camera(p2)
35
+ lcolor = line.color if color == None else color
36
+ self.drawLine( lcolor, p1, p2 )
37
+
38
+ def clip(self, p1, p2) -> None:
39
+ zmin, zmax, z1, z2 = -self.minViewZ, -self.maxViewZ, p1[2], p2[2]
40
+ x1, x2 = p1[0], p2[0]
41
+ y1, y2 = p1[1], p2[1]
42
+ if z1 != z2:
43
+ Ax, Bx = _findLine(z1,x1,z2,x2)
44
+ Ay, By = _findLine(z1,y1,z2,y2)
45
+ if z1 > zmin:
46
+ p1[0], p1[1], p1[2] = calcLine(Ax, Bx, zmin), calcLine(Ay, By, zmin), zmin
47
+ if z2 < zmax:
48
+ p2[0], p2[1], p2[2] = calcLine(Ax, Bx, zmax), calcLine(Ay, By, zmax), zmax
49
+
50
+ elif z2 > zmin:
51
+ p2[0], p2[1], p2[2] = calcLine(Ax, Bx, zmin), calcLine(Ay, By, zmin), zmin
52
+ if z1 < zmax:
53
+ p1[0], p1[1], p1[2] = calcLine(Ax, Bx, zmax), calcLine(Ay, By, zmax), zmax
54
+
55
+ else:
56
+ if z2 < zmax:
57
+ p2[0], p2[1], p2[2] = calcLine(Ax, Bx, zmax), calcLine(Ay, By, zmax), zmax
58
+ if z1 < zmax:
59
+ p1[0], p1[1], p1[2] = calcLine(Ax, Bx, zmax), calcLine(Ay, By, zmax), zmax
60
+
61
+ def camera(self, point) -> list:
62
+ """ Perspective projection <https://en.wikipedia.org/wiki/3D_projection> """
63
+ x, y, z = point
64
+ s = self.scale
65
+ z *= -1
66
+ if (self.f != 0):
67
+ s = self.scale/z
68
+ return (x*s, y*s, z)
69
+
70
+ def drawLine(self, color, p0, p1):
71
+ """ """
72
+ p0 = (self.centerX +p0[0], self.centerY -p0[1])
73
+ p1 = (self.centerX +p1[0], self.centerY -p1[1])
74
+ self.line( self.screen, color, p0, p1 ) #< Line from P0 to P1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GSOF_3dWireFrame
3
- Version: 1.1.3
3
+ Version: 1.2.0
4
4
  Summary: A 3D wireframe rendering library built on Pygame
5
5
  Author-email: Guy Soffer <gsoffer@yahoo.com>
6
6
  License: GPL-3.0-or-later
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GSOF_3dWireFrame
3
- Version: 1.1.3
3
+ Version: 1.2.0
4
4
  Summary: A 3D wireframe rendering library built on Pygame
5
5
  Author-email: Guy Soffer <gsoffer@yahoo.com>
6
6
  License: GPL-3.0-or-later
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "GSOF_3dWireFrame"
7
- version = "1.1.3"
7
+ version = "1.2.0"
8
8
  description = "A 3D wireframe rendering library built on Pygame"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,60 +0,0 @@
1
- def _findLine(x1,y1,x2,y2) -> list:
2
- DX = x2 -x1
3
- DY = y2 -y1
4
- Ay = DY/DX
5
- By = y2 -Ay*x2
6
- return (Ay, By)
7
-
8
- def calcLine(a, b, x) -> float:
9
- return a*x +b
10
-
11
- class WireFrame():
12
- def __init__(self, screen, line, f=1, scale=1000.0, maxViewDistance=10000):
13
- self.screen = screen #< Object to draw on
14
- self.line = line #< function to draw a line
15
- self.f = f #< Perspective factor
16
- self.scale = scale #< Lens zoom
17
- self.maxViewZ = maxViewDistance #<
18
- self.minViewZ = abs(1.0) #<
19
- self.centerX, self.centerY = (int(screen.get_width()/2), int(screen.get_height()/2))
20
-
21
- def draw(self, obj, color=None) -> None:
22
- """ """
23
- for line in obj.getLines():
24
- p1, p2 = line.points
25
- #p1[2], p2[2] = -p1[2], -p2[2]
26
- z0 = -self.minViewZ
27
- if (p1[2] < z0) or (p2[2] < z0):
28
- ### At least one end of the line is infront of the camera
29
- self.clip(p1,p2)
30
- p1 = self.camera(p1)
31
- p2 = self.camera(p2)
32
- lcolor = line.color if color == None else color
33
- self.drawLine( lcolor, p1, p2 )
34
-
35
- def clip(self, p1, p2) -> None:
36
- z0, z1, z2 = -self.minViewZ, p1[2], p2[2]
37
- x1, x2 = p1[0], p2[0]
38
- y1, y2 = p1[1], p2[1]
39
- if z1 != z2:
40
- Ax, Bx = _findLine(z1,x1,z2,x2)
41
- Ay, By = _findLine(z1,y1,z2,y2)
42
- if z1 > z0:
43
- p1[0], p1[1], p1[2] = calcLine(Ax, Bx, z0), calcLine(Ay, By, z0), z0
44
- elif z2 > z0:
45
- p2[0], p2[1], p2[2] = calcLine(Ax, Bx, z0), calcLine(Ay, By, z0), z0
46
-
47
- def camera(self, point) -> list:
48
- """ Perspective projection <https://en.wikipedia.org/wiki/3D_projection> """
49
- x, y, z = point
50
- s =self.scale/10
51
- z *= -1
52
- if (self.f != 0):
53
- s = self.scale/z
54
- return (x*s, y*s, z)
55
-
56
- def drawLine(self, color, p0, p1):
57
- """ """
58
- p0 = (self.centerX +p0[0], self.centerY -p0[1])
59
- p1 = (self.centerX +p1[0], self.centerY -p1[1])
60
- self.line( self.screen, color, p0, p1 ) #< Line from P0 to P1