Sign in to follow this  
Raubkatze

Can Python be used for 3D programming?

Recommended Posts

Hey there!

 

I've been wondering can Python be used for 3D? I mean, there are a lot of games in Java (say, Minecraft), JavaScript, etc. But is Python capable of running a 3D game (like, again, Minecraft) without lagging? If so which libraries would you reccomend (Pyglet, PyOGRE, PyOpenGL?).

 

Thanks.

Share this post


Link to post
Share on other sites

Yes, it can be used for 3D programming.

Normally, computationally intensive functionality is turned into Python extensions and written in C/C++.

Panda3D is a good example (I think) of a good marriage between 3D game programming using Python and an efficient core written in C++.

Share this post


Link to post
Share on other sites

I've built a couple of 3D demos using Pyglet/OpenGL - it's a pretty nice language/toolkit combo to play around with.

 

I think Ashima IV is the only one in pure python - a number of the larger projects have significant C++ code to provide performance in key areas.

Share this post


Link to post
Share on other sites
Blender is written in Python, it's as 3D as you can get.
http://www.blender.org/

Actually no, it exposes Python as scripting language but the core isn't written in Python: https://github.com/dfelinto/blender-git/ Hell, there it seems to be quite the amount of plain C there.

 

In any case, that Blender isn't written in Python has nothing to do with this, all you need is a GPU API binding (like PyOpenGL) and you're good to go. PyOpenGL is a binding for raw OpenGL, PyOgre seems to be a binding for Ogre rendering engine, which is a completely different thing.

Edited by TheChubu

Share this post


Link to post
Share on other sites

Blender is written in Python, it's as 3D as you can get.

http://www.blender.org/

 

Blender is actually mostly C++. If it was purely python, it would not run so well.

 

It uses python as an extension. Most of it's plugins and also some of it's main functionality is written in python however. But all python is used for is controlling it's logic. Not the actual computation.

 

Source: Actual source code repository.

 

You can make a 3D program completely from python. And it will run. But AI wouldn't expect anything complex being done in it, or it will run as slow as solidified tar.

Edited by Tangletail

Share this post


Link to post
Share on other sites

 

Blender is written in Python, it's as 3D as you can get.

http://www.blender.org/

 

Blender is actually mostly C++. If it was purely python, it would not run so well.

 

It uses python as an extension. Most of it's plugins and also some of it's main functionality is written in python however. But all python is used for is controlling it's logic. Not the actual computation.

 

Source: Actual source code repository.

 

You can make a 3D program completely from python. And it will run. But AI wouldn't expect anything complex being done in it, or it will run as slow as solidified tar.

 

Well then, I guess I am going for Java :)

Share this post


Link to post
Share on other sites
Take note that Java is faster but not all that much.

I take issue with that:

 

http://benchmarksgame.alioth.debian.org/u64/compare.php?lang=python3&lang2=java

 

You'll find much bigger differences between Python and Java than between Java and C for example. 

 

HotSpot is a very, very good VM. JIT output isn't an issue, it will use AVX if your CPU supports it, it can de-virtualize calls on the fly based on runtime profiling of the code, it can reorder branches and prune them if necessary based on which one gets executed the most, etc.

 

The issue generally lies in the amount of indirection which you find in common "idiomatic" Java code. Every object access is a pointer indirection, which is something you can have in mind for the lower layers while designing the project. Then again "pointer chasing" isn't an inherent issue of Java, its just something the language doesn't gives you many tools to mitigate. Java as it is lacks easy ways to control the memory layout of anything (except maybe abusing inheritance and direct buffers, which isn't pretty).

 

And on a side note, nobody is making Halo alone, regardless of the language used.

Edited by TheChubu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this