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.
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_dynamicWorld.py +1 -1
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_motionWorld.py +1 -1
- gsof_3dwireframe-1.2.0/GSOF_3dWireFrame/Lib3D/WireFrame_display.py +74 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0/GSOF_3dWireFrame.egg-info}/PKG-INFO +1 -1
- {gsof_3dwireframe-1.1.3/GSOF_3dWireFrame.egg-info → gsof_3dwireframe-1.2.0}/PKG-INFO +1 -1
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/pyproject.toml +1 -1
- gsof_3dwireframe-1.1.3/GSOF_3dWireFrame/Lib3D/WireFrame_display.py +0 -60
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/AUTHORS +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Drone_Class.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_Drone.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_F16.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Example_staticWorld.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/F16_Class.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Assembly.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Lib3D.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Object_WireFrame.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Object_base.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Objects.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Utils.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/__init__.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/stlToObj.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/MathLib/MathLib.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/MathLib/__init__.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/attitudeViewer.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/modules/AttitudeViewer_class.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/modules/Controls.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/modules/__init__.py +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/Axis.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/F16.stl +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/LandingGear.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/Plume.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/Spark.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/cube.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/cube_flex.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/frame.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/house.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/net.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/plane.stl +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/objects/pyramid.json +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/SOURCES.txt +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/dependency_links.txt +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/requires.txt +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/top_level.txt +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/LICENSE +0 -0
- {gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/README.md +0 -0
- {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,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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/Lib3D/Object_WireFrame.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame/modules/AttitudeViewer_class.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gsof_3dwireframe-1.1.3 → gsof_3dwireframe-1.2.0}/GSOF_3dWireFrame.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|