Exemple #1
0
from Engine3D import Engine
import pygame
from GeometricShapes import MobiusStrip

window = pygame.display.set_mode((700, 700))
engine = Engine(window)

m = MobiusStrip([350, 350, 0], 100, 10)
m.surface_set([0, 0, 0], [255, 0, 255])
while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit()

    window.fill((91, 91, 91))

    m.rotate_mode()
    engine.addToDraw([m, False, False, True])

    engine.draw()

    pygame.display.flip()
    pygame.time.Clock().tick(60)
Exemple #2
0
window = pygame.display.set_mode((500, 500))
engine = Engine(window)

sp = UniformSphere([250, 250, 0], 100, 2000)
sp.point_set(1, '', [100, 100, 100], [0, 0, 255])

gen = OpenSimplex()
for i in range(len(sp.points)):
    a = sp.points[i].copy()
    a -= sp.center
    a.setLength((gen.noise3d(sp.points[i][0] / 25, sp.points[i][1] / 25,
                             sp.points[i][2] / 25) + 1) * 20)
    sp.points[i] += a

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit()

    window.fill((0, 0, 0))

    sp.rotate_mode()

    engine.addToDraw([sp, True, False, False])

    engine.draw()

    pygame.display.flip()
    pygame.time.Clock().tick(60)
Exemple #3
0
# Creating PyGame Surface
window = pygame.display.set_mode((700, 700))

# Creating Engine3D object with the pygame surface
engine = Engine(window)

# Creating Mesh in position [250, 250, 0] and size 300px and 10 cells each side
mesh = Mesh([350, 350, 0], 300, 10)

while True:
    # PyGame key event
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit()

    # Filling the screen
    window.fill((91, 91, 91))

    # Setting rotation mode by the mouse on this object
    mesh.rotate_mode()

    # Adding to draw list the objects [object, isPoints, isLines, isSurfaces]
    engine.addToDraw([mesh, True, True, True])

    # Draw the world
    engine.draw()

    # Update the display
    pygame.display.flip()
    pygame.time.Clock().tick(60)
Exemple #4
0
    v = Vector()
    for i in s:
        v += sphere.points[i]
    v /= len(s)
    v -= sphere.center
    c = (v.length() - 100) / 200 * 2 - 1
    sCol.append(getColor(c))
sphere.surface_set(*sCol)

for p in range(len(sphere.points)):
    v = sphere.points[p].copy()
    v -= sphere.center
    if v.length() < 200:
        v.setLength(200 - v.length())
        sphere.points[p] += v

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            quit()

    window.fill((0, 0, 0))

    sphere.rotate_mode()

    engine.addToDraw([sphere, False, False, True])
    engine.draw()

    pygame.display.flip()
    pygame.time.Clock().tick(60)