User avatar
paddyg
Posts: 2561
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D

Sun Aug 26, 2012 6:24 pm

BlackJack wrote:@paddyg: Why is meaningful indentation an extremely bad and retrograde step?
I suppose it's just that python implements the white spaces in a very slack way. i.e. the programmer has to have the self discipline to either stick to tab characters or an amount of spaces (in just the same way that programmers have to lay their code out in a tidy way even using ;} systems.) If you're coding for yourself it's probably not an issue but with a project like this you will find that one py file will contain a mixture of tabs and different number of space characters.

I would say that on fifty percent of the modifications I have made to the pi3d files I have got an 'unrecognised indent' error. At first I used geany's Document convert tab to spaces however that resulted in a vast amount of work as all the indentation becomes scrambled. Python lets you get away with a first indent of eight spaces then a second indent of two tabs (4 long each) then two tabs and one space then three tabs and five spaces then four tabs and one space. If you look through the pi3d.py code you will find things similar (though not so extreme).
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D

Sun Aug 26, 2012 6:25 pm

Thanks Paddy, I'm still struggling through. But I think it's pretty important to get good 3d models with a fairly simple setup for everyone using it, so it's worthwhile.

I'm still getting the same error in blender 262.
I can't see the hq option.
But presumably you don't need
Animation
Apply modifiers
Triangulate faces
Write nurbs
Polygroups
Objects as OBJ objects
Objects as OBJ groups
Material groups
Keep vertex order.

There isn't specifically a 90deg for x option. Just
Forward
Up
Path.

Although I have only gone as far as creating and saving a texture image, without the uv stage. It might be the issue.

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: Pi3D

Sun Aug 26, 2012 6:42 pm

@paddyg: If you start python with the ``-t`` option you get warnings when spaces and tabs are mixed. ``-tt`` treats this even as a syntax error. Static code checkers should warn about anything other than the four space characters per level as suggested by the Python style guide.

Code: Select all

while not self.asleep():
    sheep += 1

User avatar
paddyg
Posts: 2561
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D

Sun Aug 26, 2012 6:48 pm

The blender version on this pc is 2.49, I will install the latest now so I can see what you're seeing. I think it should manage without UVs but it will need materials. So you should have two files an .obj and a .mtl
the .obj should have a mtllib line, lots of v lines, lots of vt lines (but should cope without), lots of vn lines, a usemtl line (that matches a ref in the .mtl file) and lots of f lines. Have a look through the files you've generated and see what's missing.

The texture image won't be picked up without the uv stage in blender (I was going to give you some instructions but they have probably changed from 2.49 still shouldn't be difficult) I have to either select the keep vertex order or group by material etc but I don't think it is needed. It ought to pick up the material colours etc from the mtl file but I haven't been able to get pi3d to render these while the light is switched on. Work ok in the dark for some reason!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
paddyg
Posts: 2561
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D

Sun Aug 26, 2012 6:57 pm

BlackJack wrote:@paddyg: If you start python with the ``-t`` option you get warnings when spaces and tabs are mixed.
I might change the geany setup to that, though I don't really need warning as I know the code is packed full of it. Up to Tim to fix it really. Geany certainly doesn't warn about the mixture I just gave as an example.

It would be really nice if the editor showed the spaces and tabs in a different colour (from white, and ideally from each other)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D

Sun Aug 26, 2012 8:23 pm

paddyg wrote: the .obj should have a mtllib line, lots of v lines, lots of vt lines (but should cope without), lots of vn lines, a usemtl line (that matches a ref in the .mtl file) and lots of f lines. Have a look through the files you've generated and see what's missing.

The texture image won't be picked up without the uv stage in blender (I was going to give you some instructions but they have probably changed from 2.49 still shouldn't be difficult) I have to either select the keep vertex order or group by material etc but I don't think it is needed. It ought to pick up the material colours etc from the mtl file but I haven't been able to get pi3d to render these while the light is switched on. Work ok in the dark for some reason!
The obj files have when I've checked them looked the same as the ones you provided.
Yeah, It could be my model as well.
Do you have any idea what could be out of range. Like there are too many vertices or something in the model. I could try a square box and hexagon to be fair.

User avatar
paddyg
Posts: 2561
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D

Sun Aug 26, 2012 10:20 pm

Just installed and done a few models with blender 2.6. Quite a lot of differences! However it basically seems to do the same thing. I saved with the following setting:
Image
I did need to edit some of the image files' paths so they pointed to the right relative place on the pi. Are you sure they are all in the right place?

The error you mentioned earlier is almost certainly because the normals are not being set in the f lines. These should go something like
f: v/u/n v2/u2/n2 v3/u3/n3 etc
where n, n2, n3 get put into the array on the right of line 302. The array on the left is not so likely to get a subscript error because I set its size from the number of vertices.

I have quite happily loaded models 1.2MB obj files with 30,000 v lines resulting in arrays of 45,000 indices (triangle corners), 90,000 vertices, 90,000 normals, 60,000 uv coords. And then made a couple of additional 'clones' of these objects for drawing. I have the default memory for the graphics processor.

The main thing to try is setting a uv mesh for the image and make sure normals are included in the obj export.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: Pi3D

Thu Sep 20, 2012 6:20 pm

Hiya. Sorry, but I downloaded pi3d the other day and having trouble getting the bouncingballs demo to run. at first it gives me mixed indentations/tabs error, then when I fix those, I get 'libbcm_host.so' file not found error. I'm using a recent version of raspbian updated to the latest turbo enabled firmware, and I've tried running it from IDLE and the command line. Any help would be much appreciated :)

In case it's any help, I'm also getting 'stuff is missing' errors when trying to ./make quake 3 from source...
note: I may or may not know what I'm talking about...

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: Pi3D

Fri Sep 21, 2012 12:00 pm

toxibunny wrote:Hiya. Sorry, but I downloaded pi3d the other day and having trouble getting the bouncingballs demo to run. at first it gives me mixed indentations/tabs error, then when I fix those, I get 'libbcm_host.so' file not found error. I'm using a recent version of raspbian updated to the latest turbo enabled firmware, and I've tried running it from IDLE and the command line. Any help would be much appreciated :)

In case it's any help, I'm also getting 'stuff is missing' errors when trying to ./make quake 3 from source...
UPDATE: I fixed it with instructions I found at http://www.raspbian.org/RaspbianXBMC, specifically parts 5 and 6:
www.raspbian.org/RaspbianXBMC wrote:5. Copy /opt/vc/include to /usr/include.

Code: Select all

 sudo cp -R /opt/vc/include/* /usr/include
    sudo cp /opt/vc/include/interface/vcos/pthreads/* /usr/include/interface/vcos
6. Create symbolic links for libEGL and libGLESv2 from /opt/vc/lib to /usr/lib and /usr/lib/arm-linux-gnueabihf

Code: Select all

sudo ln -fs /opt/vc/lib/libEGL.so /usr/lib/libEGL.so
    sudo ln -fs /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so
    sudo ln -fs /opt/vc/lib/libEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.1
    sudo ln -fs /opt/vc/lib/libEGL_static.a /usr/lib/libEGL_static.a
    sudo ln -fs /opt/vc/lib/libEGL_static.a /usr/lib/arm-linux-gnueabihf/libEGL_static.a
    sudo ln -fs /opt/vc/lib/libGLESv2.so /usr/lib/libGLESv2.so
    sudo ln -fs /opt/vc/lib/libGLESv2.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so
    sudo ln -fs /opt/vc/lib/libGLESv2.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2
    sudo ln -fs /opt/vc/lib/libGLESv2_static.a /usr/lib/libGLESv2_static.a
    sudo ln -fs /opt/vc/lib/libGLESv2_static.a /usr/lib/arm-linux-gnueabihf/libGLESv2_static.a
    sudo ln -fs /opt/vc/lib/libbcm_host.so /usr/lib/libbcm_host.so
    sudo ln -fs /opt/vc/lib/libbcm_host.so /usr/lib/arm-linux-gnueabihf/libbcm_host.so
    sudo ln -fs /opt/vc/lib/libvchiq_arm.a /usr/lib/libvchiq_arm.a
    sudo ln -fs /opt/vc/lib/libvchiq_arm.a /usr/lib/arm-linux-gnueabihf/libvchiq_arm.a
    sudo ln -fs /opt/vc/lib/libvchiq_arm.so /usr/lib/libvchiq_arm.so
    sudo ln -fs /opt/vc/lib/libvchiq_arm.so /usr/lib/arm-linux-gnueabihf/libvchiq_arm.so
    sudo ln -fs /opt/vc/lib/libvcos.a /usr/lib/libvcos.a
    sudo ln -fs /opt/vc/lib/libvcos.a /usr/lib/arm-linux-gnueabihf/libvcos.a
    sudo ln -fs /opt/vc/lib/libvcos.so /usr/lib/libvcos.so
    sudo ln -fs /opt/vc/lib/libvcos.so /usr/lib/arm-linux-gnueabihf/libvcos.so
I've now tried out most of the demos (after editing them for non-HDTV resolutions), and I'm really impressed! I'm surprised more people aren't using it. I'll port my game-in-progress from the pygame graphics to this, and post results. Might take me a while though...
note: I may or may not know what I'm talking about...

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D

Fri Sep 21, 2012 12:35 pm

It is clever.
Though I've had to take a break for a while as I have other things to do.

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: Pi3D

Fri Sep 21, 2012 3:05 pm

Are there, in your opinion, any major things missing? I'm not talking about the shape creation stuff, but more like popular OpenGL stuff.

For example, how difficult would it be to add a bump/normal map texture to an object using this? I have a bit of python knowledge, and I've read a bit about openGL, but I wouldn't know how to start using openGL from scratch (which is why I like py3d). Is it just a case of copying the texture code and changing a couple of things, or is it a lot more complicated than that..?
note: I may or may not know what I'm talking about...

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D

Fri Sep 21, 2012 4:00 pm

That's probably a little further detail than I could go to. If you send Paddy a specific message he may reply.
Technically, if you read the previous posts it takes you through the difficulties of putting in a textured object. I stumbled a little over wht I was doing, went back to scratch building the objects and texturing then stopped.

If you find Paddy's extension bit of the pi3d GitHub it has textured obj. Files. The next phase of issue is animations, and mouse interaction. I think pigame has the mouse1 etc buttons coded.

Now the weathers getting worse I shall probably return to it. Hopefully use what we have. Though there's still enough warm weather to be building the outside world I guess. :D

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: Pi3D

Fri Sep 28, 2012 8:10 pm

Hi. Just a bit of info as I take my first steps... First steps are changing the sourcecode and seeing what happens, right?

Well, I'm running things through composite on a standard definition TV, and obviously things were a bit jaggy. I figured that seeing as pi3d seems to be designed for HD resolutions, that adding a bit of anti-aliasing would be simple to achieve (as long as opengles supported anti-aliasing, that is)

So I googled 'opengles fsaa' and found a thread on these very forums that said by adding a couple of lines to eglChooseConfig(), either FSAA or MSAA would be achieved. (sorry, I know what FSAA is, but I don't know what MSAA is)

...so I looked through the pi3d source code - the 'include' bit, and found the bit with eglChooseConfig(), and added those couple of lines.

Yes, it did make the jaggies smoother :], but it reduced the framerate so much that I figured out things were better off without it.:[

Raspi team member and super-expert Dom says that adding FSAA shouldn't affect performance so much, and that there must be something else going on... so I'm telling you all about it.

Sorry if this is a hassle - love the pi, love pi3d, just thought I'd point it out. Relevant information is good, right?

Here's the thread I got the FSAA tips from: http://www.raspberrypi.org/phpBB3/viewt ... =33&t=6573

Edit: after a bit of googling, I now know that MSAA and FSAA are pretty much the same thing...
note: I may or may not know what I'm talking about...

User avatar
paddyg
Posts: 2561
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D

Sat Sep 29, 2012 3:01 pm

Thanks tox and sorry not to respond previously, been busy on a couple of other things. Tim Skillman (who did most of the work on pi3d) has done some work on shaders and got a chunk of open gl es2 stuff working. I might rattle his cage when I get some space next week.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

herbst
Posts: 3
Joined: Thu Oct 04, 2012 3:11 pm

Re: Pi3D

Thu Oct 04, 2012 3:14 pm

Heyho,

I would like to try Pi3d as well, but when I run e.g. Earth.py on the Pi I get an
"assert self.surface != EGL_NO_SURFACE". Any idea how to get around that?

Best regards
herbst

herbst
Posts: 3
Joined: Thu Oct 04, 2012 3:11 pm

Re: Pi3D

Thu Oct 04, 2012 3:57 pm

Well, had an error that said "can't create surface" - was due to me having wrong memory split settings. 128/128 works fine. Great library!

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D

Sat Oct 20, 2012 8:03 am

HI Paddy,
Looks like the weathers turned to the worst and I've invested in an hdmi monitor. Its brilliant.

To get me restarted on things can you give us a clue on how the actual map design works in amazing with the Maze map?
There are a few details on the image to take note of but there don't appear to be any specific refences to colours etc in the program files.
I tried a simple outline of a map, saved as 256x256.png but it didn't think much of me doing that.
As it is plainly the simplest map creation the world has probably seen in gaming it would be great to use it. Then hopefully I can get back to scratch modelling.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4257
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Pi3D

Sat Oct 20, 2012 11:45 am

I don't know that particular program, but the algorithm to generate a maze is fairly simple to describe.

The maze is an n-dimensional array of cells. (n is could be 3, but in this case is 2.) Each maze cell has flags to tell if it is open to the right or up. (Adjacent cells handle the other two sides.) Start with all the cells closed.

Start anywhere. Start creating a list of cells you have visited.
For each cell you visit, chose a side to open at random, either right or up. If the cell you would go to is open on the top or right, (or you are on that edge of the maze,) then you can't go there; chose again.
If you can't go right or up, then backtrack one cell back down your visited list and try again.

When your visited list is empty and you can't backtrack when you need to, you have finished.

The algorithm ensures that there is exactly one path between any two points on the maze. So you can put the start and finish positions anywhere.

Try it with paper and pencil first to get a feel for it.

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D

Sun Oct 21, 2012 12:15 pm

Hmm. It's probably relevant, but it doesn't really describe the reality of what Paddy has actually produced. Which methodologically would make life a lot simpler to understand the real interaction between the coding, the maze outline that exists in a jpg and then how other features fit in around it.

You can describe a skybox, but it doesn't deal with its actual parameters, which is what I'm wondering.
You could d/l the amazing.pi, files from Paddy's GitHub extension and look at that rurwin, so it's possible to make actual references.

User avatar
paddyg
Posts: 2561
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Pi3D

Wed Oct 31, 2012 2:53 pm

James
Sorry to be so lax about checking and responding to things on the forum (I will try and set it up to email me for future). You have probably worked everything out by now but the maze uses the createElevationMapFromTexture which, in the constructor takes an image as a grey scale value for elevation scaled by the height value, you set the number of divisions and how many repeats to use when tiling the image on it. The image to use as the texture is added later as per Tim's standard method for rendering 3d objects. In my maze I have two elevation maps the top one being textured as surface detail and tiled with a smaller repeat size (this obviously has to be mainly see though to get the large scale image showing through)
I have to test the gradient of the ground as I move around to decide whether I can move forward or not.
There are probably lots of additional things you can do with the elevation map system. I thought about having a 'sandwich' system to produce a tunnel.
I will definitely get back into fiddling around with the pi next week. Let me know if there's anything you need to know.
Paddy
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: Pi3D

Wed Oct 31, 2012 4:41 pm

Heya paddy. Have you been getting that guy's bug reports?

Edit: Tom Swirly. He's been having some problems, and noticed some stuff the rest of us haven't. Threads here, here, and here.

I'd noticed the 'won't paint the background unless it's painting something else as well' thing too, but hadn't put two and two together...
note: I may or may not know what I'm talking about...

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D

Wed Oct 31, 2012 8:12 pm

They are interesting posts. A bit harsh to critisize as I don't think there's a queue of people to design and code pi3d with perhaps a limited amount of contributions. Hopefully Tom can make some positive contributions and I do hope to see his finished project.

Paddy, I haven't worked it out I'm afraid, but I've figured conceptually how the texture map basically works. What are the white bits for?
So if you draw a greyscale gradient from white to black, you should get a slope basically?
It's easy enough to spot mymap and mymap1, and two definitions of size from.
Dark grey equals a narrow wall path with light grey a wider path area I guess, although 0.1 seems a bit small.
It's translating the values that makes the difference.
But if I create a line drawing in greyscale the it should follow?
I would need similar sizing, but you can't use white for the ground I guess.

Tom Swirly
Posts: 168
Joined: Tue Sep 25, 2012 1:08 am

Re: Pi3D

Wed Oct 31, 2012 9:56 pm

Well, I just found another issue - and this thread, don't know how I missed it!

Basically, what I've discovered is that you have to do everything in pi3d on the main thread - which includes loading textures.

It took me a long time to get to that final conclusion - I didn't understand why my images were intermittently showing, but we're dynamically loading images from documents in response to messages, and so of course those images were being loaded on another worker thread.

This isn't great - you don't want to be doing file I/O on the display thread - but at least I have it all worked out, I hope.

Sorry if I sound grumpy but I've spent a lot of time tracking these issues down and if it hadn't been for the storm I'd have massively fallen on my posterior for this deliverable (I guess it's an ill-wind etc - I'm doing my bit, we have unplanned refugees from Manhattan sheltering here...)

Now let me read the whole thread and comment. :-)
Last edited by Tom Swirly on Wed Oct 31, 2012 10:25 pm, edited 1 time in total.

Tom Swirly
Posts: 168
Joined: Tue Sep 25, 2012 1:08 am

Re: Pi3D

Wed Oct 31, 2012 10:23 pm

Oooh, good to see someone who knows this code around!

pi3d definitely the only really usable thing for graphics on Python on the RP unless you roll your own - pygame was SO slow it was easy to eat all the CPU and then send the RP into unresponsiveness!

So now we know it can be done - which is a huge step.

So how to evolve pi3d? It has a huge amount of valuable code but is currently hard to use.

My new feature list might be:
  • standard Python packaging of the library
  • extending the functionality to cover "most of" the OpenGL ES 2.0 library
  • modularizing
  • documenting and regularizing the code.
  • dealing with the thread issue.
The packaging is extremely important to get people to use it. Most Python packages, you just type sudo python setup.py install and you're off and running; you don't have to have the source code in your source tree. And since pi3d uses that trick with the Python include path to use the include subdirectory, it doesn't play well with other people's codebases - unless you tweak that, you have to dump all the code at the top level, which wreaks havoc with a well-organized project.

As for "modularizing", IMHO pi3d logically splits into the following parts
  • More or less literal wrappers for Open GL functionality.
  • Higher-level facilities build on top of those wrappers e.g. createElevationMapFromTexture
  • The loaderEgg
  • Utilities to do things like dot products and vector operations.
  • Collections of OpenGL ES integer constants.
I believe that most of these parts should be spun-off into separate subpackages, if only to make it easier for people to read. There will be a lot of people like myself who only want the OpenGL ES and not the higher-level stuff, for example.

Dealing with the thread issue might be easy or hard. I'm not really sure how Python threads interact with binary libraries like OpenGL ES. On the other hand, there are all sorts of Python libraries to real-time systems that seem to handle multiple threads really well - like pyaudio.

If it can't be fixed, it should be clear to developers that it'll only work from the main thread...

And I can certainly help with this in any way necessary!

JamesR
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm

Re: Pi3D

Wed Oct 31, 2012 10:27 pm

Good luck and hope you get things done.
So that may mean you haven't seen some of Paddy's work, although it does follow the same lines.
Would love to see what you've managed to do with it. I'm looking through some pi3d stuff wondering about using mouse functions etc.

Return to “Python”