GSOF-3dWireFrame 1.1.1__tar.gz → 1.1.3__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.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Example_Drone.py +2 -2
  2. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Example_F16.py +1 -1
  3. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Example_dynamicWorld.py +6 -6
  4. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Example_motionWorld.py +8 -7
  5. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Example_staticWorld.py +1 -1
  6. gsof_3dwireframe-1.1.3/GSOF_3dWireFrame/Lib3D/WireFrame_display.py +60 -0
  7. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3/GSOF_3dWireFrame.egg-info}/PKG-INFO +2 -1
  8. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame.egg-info/requires.txt +1 -0
  9. {gsof_3dwireframe-1.1.1/GSOF_3dWireFrame.egg-info → gsof_3dwireframe-1.1.3}/PKG-INFO +2 -1
  10. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/pyproject.toml +2 -1
  11. gsof_3dwireframe-1.1.1/GSOF_3dWireFrame/Lib3D/WireFrame_display.py +0 -37
  12. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/AUTHORS +0 -0
  13. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Drone_Class.py +0 -0
  14. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/F16_Class.py +0 -0
  15. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Lib3D/Assembly.py +0 -0
  16. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Lib3D/Lib3D.py +0 -0
  17. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Lib3D/Object_WireFrame.py +0 -0
  18. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Lib3D/Object_base.py +0 -0
  19. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Lib3D/Objects.py +0 -0
  20. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Lib3D/Utils.py +0 -0
  21. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Lib3D/__init__.py +0 -0
  22. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/Lib3D/stlToObj.py +0 -0
  23. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/MathLib/MathLib.py +0 -0
  24. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/MathLib/__init__.py +0 -0
  25. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/attitudeViewer.py +0 -0
  26. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/modules/AttitudeViewer_class.py +0 -0
  27. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/modules/Controls.py +0 -0
  28. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/modules/__init__.py +0 -0
  29. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/Axis.json +0 -0
  30. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/F16.stl +0 -0
  31. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/LandingGear.json +0 -0
  32. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/Plume.json +0 -0
  33. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/Spark.json +0 -0
  34. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/cube.json +0 -0
  35. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/cube_flex.json +0 -0
  36. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/frame.json +0 -0
  37. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/house.json +0 -0
  38. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/net.json +0 -0
  39. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/plane.stl +0 -0
  40. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame/objects/pyramid.json +0 -0
  41. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame.egg-info/SOURCES.txt +0 -0
  42. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame.egg-info/dependency_links.txt +0 -0
  43. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/GSOF_3dWireFrame.egg-info/top_level.txt +0 -0
  44. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/LICENSE +0 -0
  45. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/README.md +0 -0
  46. {gsof_3dwireframe-1.1.1 → gsof_3dwireframe-1.1.3}/setup.cfg +0 -0
@@ -105,7 +105,7 @@ if __name__ == "__main__":
105
105
 
106
106
  clock = pygame.time.Clock()
107
107
  screen = newScreen("3D Wire Frame Shapes", SCREEN_WIDTH, SCREEN_HEIGHT, Colors.WHITE)
108
- wireframe = DISP.WireFrame(screen, pygame.draw.line, f=50, scale=20.0)
108
+ wireframe = DISP.WireFrame(screen, pygame.draw.line, f=1, scale=1000.0)
109
109
 
110
110
  fps = 30
111
111
  maxRps = 2
@@ -137,7 +137,7 @@ if __name__ == "__main__":
137
137
  camAngY_r = z*PI
138
138
  camAngZ_r = x*PI
139
139
 
140
- print(computePropellers(maxRps, camAngX_r, camAngY_r, camAngZ_r))
140
+ #print(computePropellers(maxRps, camAngX_r, camAngY_r, camAngZ_r))
141
141
  A, B, C, D = computePropellers(maxRps/2, camAngX_r, camAngY_r, camAngZ_r)
142
142
  A+=maxRps/2*sign(A)
143
143
  B+=maxRps/2*sign(B)
@@ -81,7 +81,7 @@ if __name__ == "__main__":
81
81
  pygame.init()
82
82
  clock = pygame.time.Clock()
83
83
  screen = newScreen("3D Wire Frame Shapes", SCREEN_WIDTH, SCREEN_HEIGHT, WHITE)
84
- wireframe = DISP.WireFrame(screen, pygame.draw.line, f=50, scale=20.0)
84
+ wireframe = DISP.WireFrame(screen, pygame.draw.line, f=0.5, scale=1000.0)
85
85
 
86
86
  fps = 30
87
87
  dt = 1/fps
@@ -22,13 +22,13 @@ def newScreen(title="New", resX=SCREEN_WIDTH, resY=SCREEN_HEIGHT, color=WHITE):
22
22
 
23
23
  if __name__ == "__main__":
24
24
  import json
25
- d = 4
25
+ d = 30
26
26
  solidHouse = Object(filename="./objects/house.json", color=(0,180,180), name="House").scale(10.0).setOrigin()
27
27
  window = Object(filename="./objects/frame.json", color=(200,0,0), name="Window").setCenter(scale=0.8)
28
28
  flexHouse = Assembly(objects = (
29
- Object(filename="./objects/cube.json", color=(190,190,190), name="Body").translate(0,0,0 +d).setOrigin(),
30
- Object(filename="./objects/pyramid.json", color=(90,90,90), name="Roof").translate(0,-2.5,0 +d).setOrigin(),
31
- Assembly(objects=(window,), name="Window-Assy").translate(0,0,-1 +d).setOrigin(),
29
+ Object(filename="./objects/cube.json", color=(190,190,190), name="Body").translate(0,0,0).setOrigin(),
30
+ Object(filename="./objects/pyramid.json", color=(90,90,90), name="Roof").translate(0,-2.5,0).setOrigin(),
31
+ Assembly(objects=(window,), name="Window-Assy").translate(0,0,-1).setOrigin(),
32
32
  ),
33
33
  connections=[
34
34
  [[0,4],[1,0]], #< Point-4 of object-0 to point-0 of object-1
@@ -41,12 +41,12 @@ if __name__ == "__main__":
41
41
 
42
42
  world = Assembly(objects = (
43
43
  solidHouse.translate(0,0,0).setOrigin(),
44
- flexHouse.translate(0,-0,0).setOrigin(),
44
+ flexHouse.translate(0,0,d).setOrigin(),
45
45
  ))
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, f=50, scale=80)
49
+ wireframe = DISP.WireFrame(screen, pygame.draw.line, scale=50*80)
50
50
  fps = 30
51
51
  dt = 1/fps
52
52
  t = 0.0
@@ -1,4 +1,4 @@
1
- import pygame
1
+ import pygame, math
2
2
  from Lib3D.Object_WireFrame import Object_wireFrame as Object
3
3
  from Lib3D.Assembly import Assembly
4
4
  from Lib3D import Objects
@@ -21,16 +21,17 @@ def newScreen(title="New", resX=SCREEN_WIDTH, resY=SCREEN_HEIGHT, color=WHITE):
21
21
  return screen
22
22
 
23
23
  if __name__ == "__main__":
24
- house = Object(filename="./objects/house.json", color=(0,180,180))
25
24
  world = Assembly(objects = (
26
- house,
25
+ Object(filename="./objects/house.json", color=(0,180,180), name="HOUSE"),
26
+ Object(Objects.net(20,20), color=(0,100,0), name="GROUND").scale(0.005)\
27
+ .rotate(x=math.pi/2, y=0, z=0).translate(-5, -1, -5).setOrigin(),
27
28
  ))
28
29
 
29
30
  pygame.init()
30
31
  clock = pygame.time.Clock()
31
32
  screen = newScreen("3D Wire Frame Shapes", SCREEN_WIDTH, SCREEN_HEIGHT, WHITE)
32
- wireframe = DISP.WireFrame(screen, pygame.draw.line, f=50, scale=10)
33
- viewer = Controls.Viewer( pos=(0,0,-400),
33
+ wireframe = DISP.WireFrame(screen, pygame.draw.line, scale=1000)
34
+ viewer = Controls.Viewer( pos=(0,0,-10),
34
35
  center=(int(screen.get_width()/2), int(screen.get_height()/2)),
35
36
  moveLeftKey = pygame.K_a,
36
37
  moveRightKey = pygame.K_d,
@@ -54,8 +55,8 @@ if __name__ == "__main__":
54
55
 
55
56
  keys = pygame.key.get_pressed()
56
57
  (mPosX, mPosY) = pygame.mouse.get_pos()
57
- wireframe.f += -(keys[pygame.K_1] - keys[pygame.K_2])*10
58
- viewer.update(keys, mPosX, mPosY, speed=2)
58
+ wireframe.scale += -(keys[pygame.K_1] - keys[pygame.K_2])*10
59
+ viewer.update(keys, mPosX, mPosY, speed=0.1)
59
60
 
60
61
  clearScreen(screen, WHITE)
61
62
  world.reset()
@@ -67,7 +67,7 @@ if __name__ == "__main__":
67
67
  pygame.init()
68
68
  clock = pygame.time.Clock()
69
69
  screen = newScreen("3D Wire Frame Shapes", SCREEN_WIDTH, SCREEN_HEIGHT, WHITE)
70
- wireframe = DISP.WireFrame(screen, pygame.draw.line, f=50, scale=10.0)
70
+ wireframe = DISP.WireFrame(screen, pygame.draw.line, f=1, scale=500.0)
71
71
 
72
72
  fps = 30
73
73
  dt = 1/fps
@@ -0,0 +1,60 @@
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GSOF_3dWireFrame
3
- Version: 1.1.1
3
+ Version: 1.1.3
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
@@ -23,6 +23,7 @@ Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
24
  License-File: AUTHORS
25
25
  Requires-Dist: pygame-ce
26
+ Requires-Dist: pymeshlab
26
27
  Dynamic: license-file
27
28
 
28
29
  # GSOF_3dWireFrame
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: GSOF_3dWireFrame
3
- Version: 1.1.1
3
+ Version: 1.1.3
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
@@ -23,6 +23,7 @@ Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
24
  License-File: AUTHORS
25
25
  Requires-Dist: pygame-ce
26
+ Requires-Dist: pymeshlab
26
27
  Dynamic: license-file
27
28
 
28
29
  # GSOF_3dWireFrame
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "GSOF_3dWireFrame"
7
- version = "1.1.1"
7
+ version = "1.1.3"
8
8
  description = "A 3D wireframe rendering library built on Pygame"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -29,6 +29,7 @@ classifiers = [
29
29
  ]
30
30
  dependencies = [
31
31
  "pygame-ce",
32
+ "pymeshlab"
32
33
  ]
33
34
 
34
35
  [project.urls]
@@ -1,37 +0,0 @@
1
- class WireFrame():
2
- def __init__(self, screen, line, f=50, scale=1.0):
3
- self.screen = screen
4
- self.line = line
5
- self.f = f
6
- self.scale = scale
7
- self.centerX, self.centerY = (int(screen.get_width()/2), int(screen.get_height()/2))
8
-
9
- def draw(self, obj, color=None) -> None:
10
- """ """
11
- for line in obj.getLines():
12
- p0 = self.camera(line.points[0])
13
- p1 = self.camera(line.points[1])
14
- if (p0[2] > self.f) or (p1[2] > self.f): #Skip lines in the back of the viewer
15
- lcolor = color
16
- if lcolor == None:
17
- lcolor = line.color
18
- self.drawLine( lcolor, p0, p1 ) #< Line from P0 to P1
19
-
20
- def camera(self, point) -> list:
21
- """ Perspective projection <https://en.wikipedia.org/wiki/3D_projection> """
22
- x, y, z = point
23
- z = -z
24
- if (self.f != None):
25
- if (z > self.f):
26
- s = (self.f/z)*self.scale
27
- else:
28
- s = 100000
29
- x *= s
30
- y *= s
31
- return (x,y,z)
32
-
33
- def drawLine(self, color, p0, p1):
34
- """ """
35
- p0 = (self.centerX +p0[0], self.centerY -p0[1])
36
- p1 = (self.centerX +p1[0], self.centerY -p1[1])
37
- self.line( self.screen, color, p0, p1 ) #< Line from P0 to P1