SlideShare ist ein Scribd-Unternehmen logo
1 von 30
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 1
3D Computergrafik mit Python
Martin Christen, martin.christen@fhnw.ch
Fachhochschule Nordwestschweiz
Hochschule für Architektur, Bau und Geomatik
Institut Vermessung und Geoinformation
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 2
3D Computergrafik mit Python
Ich zeige 3 Fallbeispiele wie Python für die 3D
Computerfgrafik verwendet werden kann:
1. Teil: Python als Scriptsprache
2. Teil: Python für die Echtzeit-Darstellung von 3D
3. Teil: Python für die Prozessierung von Daten
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 3
1. Teil
Python als Scriptsprache
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 4
Blender
Blender ist eine freie 3D-Grafiksoftware. Hauptanwendung ist
die 3D-Modellierung, d.h. modellieren, texturieren, animieren,
rendern.
Blender verwendet Python als Skriptsprache.
Download-Link:
https://www.blender.org/download/
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 5
Blender
Die aktuelle Version von Blender ist 2.73 (20. Januar 2015).
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 6
Duch alle Objekte der Szene iterieren
for obj in bpy.data.objects:
print(obj)
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 7
Objekte verändern
import bpy
scene = bpy.context.scene
for object in scene.objects:
obj.location.x += 1.0
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 8
Weiterführende Infos
Python API-Referenz
(auch im Help-Menu zu finden)
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 9
Blender: Python API Referenz
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 10
2. Teil:
Python für die Echtzeit-Darstellung von 3D
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 11
Low Level 3D Programmierung mit Python
Low-level 3D-Programmierung hat den Vorteil, dass sehr
hardwarenah programmiert werden kann.
Die Low-Level Programmierung sollte nur dann verwendet
werden, wenn eine eigene Python-3D-Bibliothek erstellt
werden soll.
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 12
OpenGL
• OpenGL = Open Graphics Library
• Version 1.0 erschien 1992. (als Weiterentwicklung von IrisGL)
• Die aktuelle Version ist OpenGL 4.5 und erschien am 11. August 2014.
• OpenGL ist eine High-Performance Grafikprogrammierschnittstelle
(Grafik-API) die
– unabhängig ist von der (Grafik-)hardware
– Unabhängig von GUI (Fenstersystem) und Input-Geräten
– einen Sprachumfang von ~200 Befehlen hat.
– prinzipiell unabhängig von der Programmiersprache, also auch
Python!
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 13
OpenGL in Python nutzen
Es gibt verschiedene Möglichkeiten
• Verwendung von OpenGL in PySide und PyOpenGL
• Verwendung von OpenGL mit pyglet
• Verwendung von OpenGL mit pygame
Pyglet
http://www.pyglet.org/
Windows: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygle
PyOpenGL:
http://pyopengl.sourceforge.net/
Windows: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl
PyGame:
http://pygame.org/tags/opengl
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 14
High Level 3D
Es gibt zahlreiche 3D-Bibliothken für Python, unter anderem:
Pygame: http://pygame.org/news.html
Cgkit: http://cgkit.sourceforge.net/
Vispy: http://vispy.org/
VPython: http://vpython.org/
VTK: http://www.vtk.org/
3D Game Engines für Python:
Blender: http://www.blender.org
Panda3D: http://www.panda3d.org/
CrystalSpace: http://www.crystalspace3d.org/main/PyCrystal
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 15
3.Teil
Python für die Prozessierung von Daten
• Python kann auch für die (Vor-)Prozessierung von Daten
verwendet werden. Die effektive 3D-Darstellung erfolgt in
einer anderen Sprache.
• Zum Beispiel mit JavaScript/WebGL im Webbrowser.
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 16
Anwendung 1: OpenWebGlobe
MapData © OpenStreetMap contributors
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 17
Funktionsweise eines 3D-Globus (und 2D-Karten)
Tile System (global)
Kombination: Pyramide + Mosaik
Räumliche Aufteilung mittels Quadtree
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 18
Prozessierung von Tiles?
2D Image Tile
RGB(A)
256x256 Pixels (meistens...)
LOD Beschränkung: Anzahl Pixel
2D Vector Tile
Enthält 2D Geometrie, aufgrund Performance wird es
aber oft auch als Bild gerastert (oder Kombination)
LOD Beschränkung: Anzahl Vektoren (oder Pixel)
2D Elevation Tile (-> für 2.5D Tiles)
Höhenwerte
z.B. 17x17 Werte im Raster
LOD Beschränkung: Anzahl Höhenwerte
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 19
– Transformation der (lokalen) Daten in die Mercator-
Projektion (WGS-84)
– Kachelung der Original-Bilddaten für einen schnellen
Zugriff (räumliche Unterteilung in Quadtree)
– Kachelgrösse z.B. 256x256 Pixel
– Berechnung der Auflösungsstufen (Bildpyramide)
1 2
Bilddatenaufbereitung
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 20
Daten-Prozessierung mit Cloud
Download der
sichtbaren
Datenfragmente
Bilddaten, Höhendaten,
3D-Modelle, Punktwolken, POI
Web Viewer
• HTML5
• WebGL
• JavaScript
Prozessierung und
Caching von Tiles
(u.a. Python)
256
256
256
Upload Rohdaten
in Cloud
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 21
Proj.4 Bibliothek
• https://trac.osgeo.org/proj/
• Umgang / Konversion von geographischen Projektionen
• Python Version: pyproj
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 22
Rasterbilder mit gdal (http://www.gdal.org)
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 23
Anwendung 2: 3dmaps.ch (Release geplant im April 2015)
Webanwendung mit Flask (http://flask.pocoo.org/ )
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 24
Client: Scenes overview
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 25
Beispiel 1:
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 26
Beispiel 2:
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 27
Beispiel 3:
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 28
Funktionsweise
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 29
Fazit
Es gibt verschiedene Möglichkeiten Python für 3D-
Grafikanwendungen zu nutzen
Besondes gut eignet sich Python als Skriptsprache und für die
Datenprozessierung in der Cloud.
Für gewisse Echtzeitanwendungen, insbesondere in
Kombination mit PySide kann Python durchaus auch
verwendet werden.
PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 30
Fragen

Weitere ähnliche Inhalte

Was ist angesagt?

Flutter frame work
Flutter frame workFlutter frame work
Flutter frame worksamash
 
Dart presentation
Dart presentationDart presentation
Dart presentationLucas Leal
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastBartosz Kosarzycki
 
Gui Layout Presentation
Gui Layout PresentationGui Layout Presentation
Gui Layout Presentationtrangy
 
Unit 3 storage fundamentals
Unit 3 storage fundamentalsUnit 3 storage fundamentals
Unit 3 storage fundamentalsRaj vardhan
 
Windows xp and windows 7 installaton
Windows xp and windows 7 installatonWindows xp and windows 7 installaton
Windows xp and windows 7 installatonSiddharth Jain
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programmingsudhir singh yadav
 
Storage devices(present)
Storage devices(present)Storage devices(present)
Storage devices(present)Zawawi Mohamad
 
Linux for bioinformatics
Linux for bioinformaticsLinux for bioinformatics
Linux for bioinformaticscursoNGS
 
SSD - Solid State Drive PPT by Shyam jos
SSD - Solid State Drive PPT by Shyam jos SSD - Solid State Drive PPT by Shyam jos
SSD - Solid State Drive PPT by Shyam jos Shyam Jos
 
The Linux Command Cheat Sheet
The Linux Command Cheat SheetThe Linux Command Cheat Sheet
The Linux Command Cheat SheetTola LENG
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux Harish R
 
Corso Linux
Corso LinuxCorso Linux
Corso Linuxagnelloe
 
Introduction to Authorware
Introduction to AuthorwareIntroduction to Authorware
Introduction to AuthorwareJazihan Mahat
 
Input and output devices
Input and output devicesInput and output devices
Input and output devices13023901-016
 

Was ist angesagt? (20)

Pen drive
Pen drivePen drive
Pen drive
 
Flutter frame work
Flutter frame workFlutter frame work
Flutter frame work
 
Dart presentation
Dart presentationDart presentation
Dart presentation
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fast
 
Gui Layout Presentation
Gui Layout PresentationGui Layout Presentation
Gui Layout Presentation
 
Unit 3 storage fundamentals
Unit 3 storage fundamentalsUnit 3 storage fundamentals
Unit 3 storage fundamentals
 
Windows xp and windows 7 installaton
Windows xp and windows 7 installatonWindows xp and windows 7 installaton
Windows xp and windows 7 installaton
 
Nfs
NfsNfs
Nfs
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Storage devices(present)
Storage devices(present)Storage devices(present)
Storage devices(present)
 
Linux for bioinformatics
Linux for bioinformaticsLinux for bioinformatics
Linux for bioinformatics
 
SSD - Solid State Drive PPT by Shyam jos
SSD - Solid State Drive PPT by Shyam jos SSD - Solid State Drive PPT by Shyam jos
SSD - Solid State Drive PPT by Shyam jos
 
The Linux Command Cheat Sheet
The Linux Command Cheat SheetThe Linux Command Cheat Sheet
The Linux Command Cheat Sheet
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Java API
Java APIJava API
Java API
 
Corso Linux
Corso LinuxCorso Linux
Corso Linux
 
Introduction to Authorware
Introduction to AuthorwareIntroduction to Authorware
Introduction to Authorware
 
NetCAD/NetPRO 5.0 Dijital Kitabi
NetCAD/NetPRO 5.0 Dijital KitabiNetCAD/NetPRO 5.0 Dijital Kitabi
NetCAD/NetPRO 5.0 Dijital Kitabi
 
Лекція №4
Лекція №4Лекція №4
Лекція №4
 
Input and output devices
Input and output devicesInput and output devices
Input and output devices
 

Ähnlich wie 3d mit Python (PythonCamp)

Python in der Luft- und Raumfahrt
Python in der Luft- und RaumfahrtPython in der Luft- und Raumfahrt
Python in der Luft- und RaumfahrtAndreas Schreiber
 
OpenStreetMap in 3D using Python
OpenStreetMap in 3D using PythonOpenStreetMap in 3D using Python
OpenStreetMap in 3D using PythonMartin Christen
 
Günzel/Griesbaum -OpenShift und GitLab: Continuous delivery in der cloud
Günzel/Griesbaum -OpenShift und GitLab: Continuous delivery in der cloudGünzel/Griesbaum -OpenShift und GitLab: Continuous delivery in der cloud
Günzel/Griesbaum -OpenShift und GitLab: Continuous delivery in der cloudAndreas Günzel
 
Sommerkurs python 05_u_06_gui
Sommerkurs python 05_u_06_guiSommerkurs python 05_u_06_gui
Sommerkurs python 05_u_06_guiJoe OntheRocks
 
Docker for Python Development
Docker for Python DevelopmentDocker for Python Development
Docker for Python DevelopmentMartin Christen
 
Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer Infrastruktur
Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer InfrastrukturContinuous Delivery für Cloud-native Anwendungen auf Cloud-nativer Infrastruktur
Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer InfrastrukturQAware GmbH
 
C / C++ Api for Beginners
C / C++ Api for BeginnersC / C++ Api for Beginners
C / C++ Api for BeginnersUlrich Krause
 
Software-Engineering in der Luft- und Raumfahrt mit Open-Source-Tools
Software-Engineering in der Luft- und Raumfahrt mit Open-Source-ToolsSoftware-Engineering in der Luft- und Raumfahrt mit Open-Source-Tools
Software-Engineering in der Luft- und Raumfahrt mit Open-Source-ToolsAndreas Schreiber
 
Python, Plone und Zope in der Luft- und Raumfahrtforschung
Python, Plone und Zope in der Luft- und RaumfahrtforschungPython, Plone und Zope in der Luft- und Raumfahrtforschung
Python, Plone und Zope in der Luft- und RaumfahrtforschungAndreas Schreiber
 
3D - Spiel mit der Technik, Tekom 2016
3D - Spiel mit der Technik, Tekom 20163D - Spiel mit der Technik, Tekom 2016
3D - Spiel mit der Technik, Tekom 2016Robert Siegel
 
Überblick zum DFG-Projekt OCR-D
Überblick zum DFG-Projekt OCR-DÜberblick zum DFG-Projekt OCR-D
Überblick zum DFG-Projekt OCR-Dcneudecker
 
C API for Lotus Notes & Domino
C API for Lotus Notes & DominoC API for Lotus Notes & Domino
C API for Lotus Notes & DominoUlrich Krause
 
SharePointCommunity.ch SharePoint Lösungen für die Zukunft
SharePointCommunity.ch SharePoint Lösungen für die ZukunftSharePointCommunity.ch SharePoint Lösungen für die Zukunft
SharePointCommunity.ch SharePoint Lösungen für die ZukunftDavid Schneider
 
Python-Bibliotheken zur Datenvisualisierung
Python-Bibliotheken zur DatenvisualisierungPython-Bibliotheken zur Datenvisualisierung
Python-Bibliotheken zur Datenvisualisierungcusy GmbH
 
Fachreferat: Visual Studio 2012, Windows 8 und .NET 4.5
Fachreferat: Visual Studio 2012, Windows 8 und .NET 4.5Fachreferat: Visual Studio 2012, Windows 8 und .NET 4.5
Fachreferat: Visual Studio 2012, Windows 8 und .NET 4.5Digicomp Academy AG
 
Cloud Native Computing
Cloud Native ComputingCloud Native Computing
Cloud Native ComputingAarno Aukia
 
Architectures for .Net Core Applications
Architectures for .Net Core ApplicationsArchitectures for .Net Core Applications
Architectures for .Net Core ApplicationsRobin Sedlaczek
 
C/ C++ for Notes & Domino Developers
C/ C++ for Notes & Domino DevelopersC/ C++ for Notes & Domino Developers
C/ C++ for Notes & Domino DevelopersUlrich Krause
 

Ähnlich wie 3d mit Python (PythonCamp) (20)

Python in der Luft- und Raumfahrt
Python in der Luft- und RaumfahrtPython in der Luft- und Raumfahrt
Python in der Luft- und Raumfahrt
 
OpenStreetMap in 3D using Python
OpenStreetMap in 3D using PythonOpenStreetMap in 3D using Python
OpenStreetMap in 3D using Python
 
Günzel/Griesbaum -OpenShift und GitLab: Continuous delivery in der cloud
Günzel/Griesbaum -OpenShift und GitLab: Continuous delivery in der cloudGünzel/Griesbaum -OpenShift und GitLab: Continuous delivery in der cloud
Günzel/Griesbaum -OpenShift und GitLab: Continuous delivery in der cloud
 
Sommerkurs python 05_u_06_gui
Sommerkurs python 05_u_06_guiSommerkurs python 05_u_06_gui
Sommerkurs python 05_u_06_gui
 
Docker for Python Development
Docker for Python DevelopmentDocker for Python Development
Docker for Python Development
 
Was ist neu in .NET 4.5?
Was ist neu in .NET 4.5?Was ist neu in .NET 4.5?
Was ist neu in .NET 4.5?
 
Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer Infrastruktur
Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer InfrastrukturContinuous Delivery für Cloud-native Anwendungen auf Cloud-nativer Infrastruktur
Continuous Delivery für Cloud-native Anwendungen auf Cloud-nativer Infrastruktur
 
C / C++ Api for Beginners
C / C++ Api for BeginnersC / C++ Api for Beginners
C / C++ Api for Beginners
 
Cepicky pywps
Cepicky pywpsCepicky pywps
Cepicky pywps
 
Software-Engineering in der Luft- und Raumfahrt mit Open-Source-Tools
Software-Engineering in der Luft- und Raumfahrt mit Open-Source-ToolsSoftware-Engineering in der Luft- und Raumfahrt mit Open-Source-Tools
Software-Engineering in der Luft- und Raumfahrt mit Open-Source-Tools
 
Python, Plone und Zope in der Luft- und Raumfahrtforschung
Python, Plone und Zope in der Luft- und RaumfahrtforschungPython, Plone und Zope in der Luft- und Raumfahrtforschung
Python, Plone und Zope in der Luft- und Raumfahrtforschung
 
3D - Spiel mit der Technik, Tekom 2016
3D - Spiel mit der Technik, Tekom 20163D - Spiel mit der Technik, Tekom 2016
3D - Spiel mit der Technik, Tekom 2016
 
Überblick zum DFG-Projekt OCR-D
Überblick zum DFG-Projekt OCR-DÜberblick zum DFG-Projekt OCR-D
Überblick zum DFG-Projekt OCR-D
 
C API for Lotus Notes & Domino
C API for Lotus Notes & DominoC API for Lotus Notes & Domino
C API for Lotus Notes & Domino
 
SharePointCommunity.ch SharePoint Lösungen für die Zukunft
SharePointCommunity.ch SharePoint Lösungen für die ZukunftSharePointCommunity.ch SharePoint Lösungen für die Zukunft
SharePointCommunity.ch SharePoint Lösungen für die Zukunft
 
Python-Bibliotheken zur Datenvisualisierung
Python-Bibliotheken zur DatenvisualisierungPython-Bibliotheken zur Datenvisualisierung
Python-Bibliotheken zur Datenvisualisierung
 
Fachreferat: Visual Studio 2012, Windows 8 und .NET 4.5
Fachreferat: Visual Studio 2012, Windows 8 und .NET 4.5Fachreferat: Visual Studio 2012, Windows 8 und .NET 4.5
Fachreferat: Visual Studio 2012, Windows 8 und .NET 4.5
 
Cloud Native Computing
Cloud Native ComputingCloud Native Computing
Cloud Native Computing
 
Architectures for .Net Core Applications
Architectures for .Net Core ApplicationsArchitectures for .Net Core Applications
Architectures for .Net Core Applications
 
C/ C++ for Notes & Domino Developers
C/ C++ for Notes & Domino DevelopersC/ C++ for Notes & Domino Developers
C/ C++ for Notes & Domino Developers
 

Mehr von Martin Christen

Opening Session GeoPython & Python Machine Learning Conference
Opening Session GeoPython & Python Machine Learning Conference Opening Session GeoPython & Python Machine Learning Conference
Opening Session GeoPython & Python Machine Learning Conference Martin Christen
 
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHubEuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHubMartin Christen
 
Lightning Talk GeoBeer #25
Lightning Talk GeoBeer #25Lightning Talk GeoBeer #25
Lightning Talk GeoBeer #25Martin Christen
 
High-Quality Server Side Rendering using the OGC’s 3D Portrayal Service – App...
High-Quality Server Side Rendering using the OGC’s 3D Portrayal Service – App...High-Quality Server Side Rendering using the OGC’s 3D Portrayal Service – App...
High-Quality Server Side Rendering using the OGC’s 3D Portrayal Service – App...Martin Christen
 
Teaching with JupyterHub - lessons learned
Teaching with JupyterHub - lessons learnedTeaching with JupyterHub - lessons learned
Teaching with JupyterHub - lessons learnedMartin Christen
 
Mixed Reality Anwendungen mit 3D-Stadtmodellen
Mixed Reality Anwendungen mit 3D-StadtmodellenMixed Reality Anwendungen mit 3D-Stadtmodellen
Mixed Reality Anwendungen mit 3D-StadtmodellenMartin Christen
 
Gettiing Started with IoT using Raspberry Pi and Python
Gettiing Started with IoT using Raspberry Pi and PythonGettiing Started with IoT using Raspberry Pi and Python
Gettiing Started with IoT using Raspberry Pi and PythonMartin Christen
 
3D Computer Graphics with Python
3D Computer Graphics with Python3D Computer Graphics with Python
3D Computer Graphics with PythonMartin Christen
 
Visualisation of Complex 3D City Models on Mobile Webbrowsers Using Cloud-bas...
Visualisation of Complex 3D City Models on Mobile Webbrowsers Using Cloud-bas...Visualisation of Complex 3D City Models on Mobile Webbrowsers Using Cloud-bas...
Visualisation of Complex 3D City Models on Mobile Webbrowsers Using Cloud-bas...Martin Christen
 
Webilea: The OpenWebGlobe Project
Webilea: The OpenWebGlobe ProjectWebilea: The OpenWebGlobe Project
Webilea: The OpenWebGlobe ProjectMartin Christen
 
OpenWebGlobe - GeoSharing Bern
OpenWebGlobe - GeoSharing BernOpenWebGlobe - GeoSharing Bern
OpenWebGlobe - GeoSharing BernMartin Christen
 

Mehr von Martin Christen (13)

Opening Session GeoPython & Python Machine Learning Conference
Opening Session GeoPython & Python Machine Learning Conference Opening Session GeoPython & Python Machine Learning Conference
Opening Session GeoPython & Python Machine Learning Conference
 
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHubEuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
EuroPython 2019: GeoSpatial Analysis using Python and JupyterHub
 
Lightning Talk GeoBeer #25
Lightning Talk GeoBeer #25Lightning Talk GeoBeer #25
Lightning Talk GeoBeer #25
 
High-Quality Server Side Rendering using the OGC’s 3D Portrayal Service – App...
High-Quality Server Side Rendering using the OGC’s 3D Portrayal Service – App...High-Quality Server Side Rendering using the OGC’s 3D Portrayal Service – App...
High-Quality Server Side Rendering using the OGC’s 3D Portrayal Service – App...
 
Teaching with JupyterHub - lessons learned
Teaching with JupyterHub - lessons learnedTeaching with JupyterHub - lessons learned
Teaching with JupyterHub - lessons learned
 
Mixed Reality Anwendungen mit 3D-Stadtmodellen
Mixed Reality Anwendungen mit 3D-StadtmodellenMixed Reality Anwendungen mit 3D-Stadtmodellen
Mixed Reality Anwendungen mit 3D-Stadtmodellen
 
Presentation final 72
Presentation final 72Presentation final 72
Presentation final 72
 
Gettiing Started with IoT using Raspberry Pi and Python
Gettiing Started with IoT using Raspberry Pi and PythonGettiing Started with IoT using Raspberry Pi and Python
Gettiing Started with IoT using Raspberry Pi and Python
 
3D Computer Graphics with Python
3D Computer Graphics with Python3D Computer Graphics with Python
3D Computer Graphics with Python
 
Visualisation of Complex 3D City Models on Mobile Webbrowsers Using Cloud-bas...
Visualisation of Complex 3D City Models on Mobile Webbrowsers Using Cloud-bas...Visualisation of Complex 3D City Models on Mobile Webbrowsers Using Cloud-bas...
Visualisation of Complex 3D City Models on Mobile Webbrowsers Using Cloud-bas...
 
Webilea: The OpenWebGlobe Project
Webilea: The OpenWebGlobe ProjectWebilea: The OpenWebGlobe Project
Webilea: The OpenWebGlobe Project
 
OpenWebGlobe - GeoSharing Bern
OpenWebGlobe - GeoSharing BernOpenWebGlobe - GeoSharing Bern
OpenWebGlobe - GeoSharing Bern
 
GeoBeer July 3rd, 2013
GeoBeer July 3rd, 2013GeoBeer July 3rd, 2013
GeoBeer July 3rd, 2013
 

3d mit Python (PythonCamp)

  • 1. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 1 3D Computergrafik mit Python Martin Christen, martin.christen@fhnw.ch Fachhochschule Nordwestschweiz Hochschule für Architektur, Bau und Geomatik Institut Vermessung und Geoinformation
  • 2. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 2 3D Computergrafik mit Python Ich zeige 3 Fallbeispiele wie Python für die 3D Computerfgrafik verwendet werden kann: 1. Teil: Python als Scriptsprache 2. Teil: Python für die Echtzeit-Darstellung von 3D 3. Teil: Python für die Prozessierung von Daten
  • 3. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 3 1. Teil Python als Scriptsprache
  • 4. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 4 Blender Blender ist eine freie 3D-Grafiksoftware. Hauptanwendung ist die 3D-Modellierung, d.h. modellieren, texturieren, animieren, rendern. Blender verwendet Python als Skriptsprache. Download-Link: https://www.blender.org/download/
  • 5. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 5 Blender Die aktuelle Version von Blender ist 2.73 (20. Januar 2015).
  • 6. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 6 Duch alle Objekte der Szene iterieren for obj in bpy.data.objects: print(obj)
  • 7. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 7 Objekte verändern import bpy scene = bpy.context.scene for object in scene.objects: obj.location.x += 1.0
  • 8. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 8 Weiterführende Infos Python API-Referenz (auch im Help-Menu zu finden)
  • 9. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 9 Blender: Python API Referenz
  • 10. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 10 2. Teil: Python für die Echtzeit-Darstellung von 3D
  • 11. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 11 Low Level 3D Programmierung mit Python Low-level 3D-Programmierung hat den Vorteil, dass sehr hardwarenah programmiert werden kann. Die Low-Level Programmierung sollte nur dann verwendet werden, wenn eine eigene Python-3D-Bibliothek erstellt werden soll.
  • 12. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 12 OpenGL • OpenGL = Open Graphics Library • Version 1.0 erschien 1992. (als Weiterentwicklung von IrisGL) • Die aktuelle Version ist OpenGL 4.5 und erschien am 11. August 2014. • OpenGL ist eine High-Performance Grafikprogrammierschnittstelle (Grafik-API) die – unabhängig ist von der (Grafik-)hardware – Unabhängig von GUI (Fenstersystem) und Input-Geräten – einen Sprachumfang von ~200 Befehlen hat. – prinzipiell unabhängig von der Programmiersprache, also auch Python!
  • 13. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 13 OpenGL in Python nutzen Es gibt verschiedene Möglichkeiten • Verwendung von OpenGL in PySide und PyOpenGL • Verwendung von OpenGL mit pyglet • Verwendung von OpenGL mit pygame Pyglet http://www.pyglet.org/ Windows: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygle PyOpenGL: http://pyopengl.sourceforge.net/ Windows: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl PyGame: http://pygame.org/tags/opengl
  • 14. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 14 High Level 3D Es gibt zahlreiche 3D-Bibliothken für Python, unter anderem: Pygame: http://pygame.org/news.html Cgkit: http://cgkit.sourceforge.net/ Vispy: http://vispy.org/ VPython: http://vpython.org/ VTK: http://www.vtk.org/ 3D Game Engines für Python: Blender: http://www.blender.org Panda3D: http://www.panda3d.org/ CrystalSpace: http://www.crystalspace3d.org/main/PyCrystal
  • 15. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 15 3.Teil Python für die Prozessierung von Daten • Python kann auch für die (Vor-)Prozessierung von Daten verwendet werden. Die effektive 3D-Darstellung erfolgt in einer anderen Sprache. • Zum Beispiel mit JavaScript/WebGL im Webbrowser.
  • 16. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 16 Anwendung 1: OpenWebGlobe MapData © OpenStreetMap contributors
  • 17. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 17 Funktionsweise eines 3D-Globus (und 2D-Karten) Tile System (global) Kombination: Pyramide + Mosaik Räumliche Aufteilung mittels Quadtree
  • 18. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 18 Prozessierung von Tiles? 2D Image Tile RGB(A) 256x256 Pixels (meistens...) LOD Beschränkung: Anzahl Pixel 2D Vector Tile Enthält 2D Geometrie, aufgrund Performance wird es aber oft auch als Bild gerastert (oder Kombination) LOD Beschränkung: Anzahl Vektoren (oder Pixel) 2D Elevation Tile (-> für 2.5D Tiles) Höhenwerte z.B. 17x17 Werte im Raster LOD Beschränkung: Anzahl Höhenwerte
  • 19. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 19 – Transformation der (lokalen) Daten in die Mercator- Projektion (WGS-84) – Kachelung der Original-Bilddaten für einen schnellen Zugriff (räumliche Unterteilung in Quadtree) – Kachelgrösse z.B. 256x256 Pixel – Berechnung der Auflösungsstufen (Bildpyramide) 1 2 Bilddatenaufbereitung
  • 20. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 20 Daten-Prozessierung mit Cloud Download der sichtbaren Datenfragmente Bilddaten, Höhendaten, 3D-Modelle, Punktwolken, POI Web Viewer • HTML5 • WebGL • JavaScript Prozessierung und Caching von Tiles (u.a. Python) 256 256 256 Upload Rohdaten in Cloud
  • 21. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 21 Proj.4 Bibliothek • https://trac.osgeo.org/proj/ • Umgang / Konversion von geographischen Projektionen • Python Version: pyproj
  • 22. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 22 Rasterbilder mit gdal (http://www.gdal.org)
  • 23. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 23 Anwendung 2: 3dmaps.ch (Release geplant im April 2015) Webanwendung mit Flask (http://flask.pocoo.org/ )
  • 24. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 24 Client: Scenes overview
  • 25. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 25 Beispiel 1:
  • 26. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 26 Beispiel 2:
  • 27. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 27 Beispiel 3:
  • 28. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 28 Funktionsweise
  • 29. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 29 Fazit Es gibt verschiedene Möglichkeiten Python für 3D- Grafikanwendungen zu nutzen Besondes gut eignet sich Python als Skriptsprache und für die Datenprozessierung in der Cloud. Für gewisse Echtzeitanwendungen, insbesondere in Kombination mit PySide kann Python durchaus auch verwendet werden.
  • 30. PythonCamp 2015 Köln© 2015 M. Christen, IVGI/FHNW 30 Fragen