mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 11:18:26 +02:00
reformatted the file
This commit is contained in:
parent
7683083deb
commit
cdbb2f6493
1 changed files with 31 additions and 26 deletions
|
@ -1,12 +1,12 @@
|
||||||
import pygame
|
import pygame
|
||||||
import OpenGL
|
|
||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
from OpenGL.GL import *
|
from OpenGL.GL import *
|
||||||
from OpenGL.GLU import *
|
from OpenGL.GLU import *
|
||||||
import pywavefront
|
import pywavefront
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
scene = pywavefront.Wavefront(r"D:\Users\RC606\Desktop\Programme\MKWF-Install\test\Track-WU8\map_model.obj", collect_faces=True)
|
scene = pywavefront.Wavefront(r"D:\Users\RC606\Desktop\Programme\MKWF-Install\test\Track-WU8\map_model.obj",
|
||||||
|
collect_faces=True)
|
||||||
|
|
||||||
scene_box = (scene.vertices[0], scene.vertices[0])
|
scene_box = (scene.vertices[0], scene.vertices[0])
|
||||||
for vertex in scene.vertices:
|
for vertex in scene.vertices:
|
||||||
|
@ -20,7 +20,8 @@ scaled_size = 5
|
||||||
scene_scale = [scaled_size / max_scene_size for i in range(3)]
|
scene_scale = [scaled_size / max_scene_size for i in range(3)]
|
||||||
scene_trans = [-(scene_box[1][i] + scene_box[0][i]) / 2 for i in range(3)]
|
scene_trans = [-(scene_box[1][i] + scene_box[0][i]) / 2 for i in range(3)]
|
||||||
|
|
||||||
def Model():
|
|
||||||
|
def model():
|
||||||
glPushMatrix()
|
glPushMatrix()
|
||||||
glScalef(*scene_scale)
|
glScalef(*scene_scale)
|
||||||
glTranslatef(*scene_trans)
|
glTranslatef(*scene_trans)
|
||||||
|
@ -33,8 +34,10 @@ def Model():
|
||||||
for face in mesh.faces:
|
for face in mesh.faces:
|
||||||
for vertex_i in face:
|
for vertex_i in face:
|
||||||
height = scene.vertices[vertex_i][color_axe]
|
height = scene.vertices[vertex_i][color_axe]
|
||||||
if height > max_height: max_height = height
|
if height > max_height:
|
||||||
elif height < min_height: min_height = height
|
max_height = height
|
||||||
|
elif height < min_height:
|
||||||
|
min_height = height
|
||||||
|
|
||||||
min_height -= (max_height - min_height) // 4
|
min_height -= (max_height - min_height) // 4
|
||||||
|
|
||||||
|
@ -50,6 +53,7 @@ def Model():
|
||||||
|
|
||||||
glPopMatrix()
|
glPopMatrix()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
display = (600, 600)
|
display = (600, 600)
|
||||||
window = pygame.display.set_mode(display, DOUBLEBUF | OPENGL)
|
window = pygame.display.set_mode(display, DOUBLEBUF | OPENGL)
|
||||||
|
@ -60,7 +64,7 @@ def main():
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||||
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
|
||||||
Model()
|
model()
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
|
||||||
|
|
||||||
pix = glReadPixels(0, 0, *display, GL_RGB, GL_UNSIGNED_BYTE)
|
pix = glReadPixels(0, 0, *display, GL_RGB, GL_UNSIGNED_BYTE)
|
||||||
|
@ -68,4 +72,5 @@ def main():
|
||||||
image.save("test.png")
|
image.save("test.png")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue