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

Re: Pi3D

Thu Nov 08, 2012 8:16 am

I backspaced and spaced and basically the program ran. So thanks Blackjack, its hard to see that its been tabbed, it might have been during code copying. Difficult for anyone to see when you have to retype it in windows...
I took screenshot, then the pi crashed, not just the game. I'm sure its my pi.
But, it was an indentation error then, but not the type of expecting to see. I'll learn.
Image
Image

But basically, I've completed the first task of using the create map function from an edited file. Its a start, now I just have to continue on.

KenT
Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: Pi3D

Thu Nov 08, 2012 11:15 am

might have been an indentation error as well , the first 'display' looks like it is one space further indented than the second.

IIRC python reports indentation in a first scan, the = in the if statement would have been reported in a second scan.

4 spaces not tabs will save you and others a lot of grief in the future, I learnt that the hard way :cry:

Midori shouldn't be as slow as half an hour to load. I wonder if you have run out of RAM. free -h from a terminal will tell you.

Thanks all for your pioneering work
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com

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

Re: Pi3D

Thu Nov 08, 2012 12:10 pm

I will definitely be checking the ram.
I know I have a problem with permissions on the pi, using apt-get 'software' it will read but not write from sites. But I thought I'd report the crashes.

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

Re: Pi3D

Thu Nov 08, 2012 7:10 pm

James, Well done on making headway with the elevationMap, don't discount bugs in the pong.py code and the library. Every now and then I find something causing a crash - normally, though, there is some information such as the subscript out of range error for the triangle lookup thing I mentioned before.

I have got to quite like python but (IMO) the worst aspect is its acceptance of any number of spaces or tabs to define blocks. On projects like this with lots of contributors it's very hard to keep to one standard and all the variations are invisible! (An option on Geany or Idle to colour code the indents would be great) As Tom Swirly is rattling through the code and converting it to a much more structured layout and using an indent of TWO SPACES I would recommend adopting that.

Paddy
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

Thu Nov 08, 2012 7:43 pm

Sounds like a good idea to follow suit.
I'm just trying to improve on what I've done, although its going to be a rehash of code.
What defines the ball movement in pong?
Does the clash and bouncing physics apply to the movement of the ball? The code defines monster movement, then some physics and then ball position on line 159, but are the ball sx values in reference to the physics code?

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

Re: Pi3D

Thu Nov 08, 2012 10:05 pm

James, like many of these demo programs pong is a hacked copy of something else and possibly not the most logical arrangement! As you will have spotted sx,sy,sz are location components of the ball and dsx,dsy,dsz are velocity components in so far as each loop the locations are incremented by these amounts. 'Gravity' simply works by adding a small negative value to dsy each loop. If clashTest() returns True then it also provides components of the normal vector at that location and dsx,dsy,dsz are modified by a standard reflection operation R = I - 2(I.N)N (in words: find how much of the ball's velocity is in the same (but opposite) direction as the normal then add double that amount in the direction of the normal!) To keep it moving I use a factor just over 2. There is also a bit of a bodge in which I 'jump' the ball out by 0.1 radius, even so there are instances where the ball 'sinks' into walls.
If the speed it too high I reduce it.
Then I check what's happening with the mouse to see where the 'home' bat should move (actually this involves moving EVERYTHING ELSE, the point of view remains at 0,0,0 which is rather difficult to get the hang of)
Then I check if the ball has got to either side (x direction) and if it has reverse the dsx value (giving a random boost at one side)
Then I check to see if the ball has reached either end (home or monster's) i.e. in the z direction. There's a bit of extra checking to see if the bat's in the right place and bounce or restart accordingly
Finally the ball position is set to sx,sy,sz In actual fact I could have written ball.x, ball.y, ball.z instead.
Hope that helps figuring it out. Do you get any error message when the program crashes?
Paddy
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

Thu Nov 08, 2012 10:43 pm

That is clearer, thanks Paddy. I'm probably going to have to leave checking it unitl tomorrow now as I'll need to concentrate on the little bits of code.
I didn't get an error in geany, I don't know if there's an error output file written anywhere for either the pi or pi3d.
Yes, i accept that code generally does get used and abused in this way. Its just quite odd, as if i get to grips with it, all I'd have done is basically edited and created some different textures, albeit badly.
Having said that, where to move on with things might be of course trickier. Anyway I'll work on what I've done and then probably post up the files sometime next week either working or not working.

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

Re: Pi3D

Fri Nov 09, 2012 10:15 am

James, it's worth finding out what causes the crash as it's additional information useful to others. What *exactly* happens? i.e. a) graphics window freezes but mouse still moves and escape character still works. b) nothing works but ctrl+C gets you out c) ditto but ctrl+shift+\ gets you out d) you can just close the terminal window but nothing else works e).. f).. z) the RPi crashes, screen goes blank, smoke curls up from behind the monitor.

I am trying to update Tom Swirly's code to reflect things I have done on my branch and I will no longer maintain my branch so at some stage you might need to download that and jump ships (It's not all there yet though).

Paddy
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D

Fri Nov 09, 2012 5:16 pm

paddyg wrote: (It's not all there yet though).
I'm up to present with my changes now so now only doing things relevant to the new layout. Everything seems to work ok but if anyone fancies downloading the https://github.com/rec/pi3d/ and testing it that would be good.

If you do, the demos are in a subdirectory so to run them from geany you need to change the details (down arrow next to the brown ladder) execute -> 'python Demo.py "%e"' , working directory -> '/home/pi/rec/pi3d/' or wherever you have it on your RPi. Otherwise run in a terminal. You still need to ctrl+shif+\ to quit after running some of them
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

Fri Nov 09, 2012 10:27 pm

The crashes have involved a total pi freeze and it has frozen the game but the mouse works off the game window so I can close down geany (I didn't notice an error message) and restart the game.
Normally I open the pi3d file in geany and run from there, so the change shouldn't be a bother.

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

Re: Pi3D

Sat Nov 10, 2012 12:23 am

James, that doesn't sound like something wrong with the software (though that would certainly be my first suspect). It sounds like the kind of thing that had happend to me when, say, I had used a USB stick and got in a muddle plugging and plugging keyboards or mice and not umounted it before pulling it out. Are you sure that you have enough power? My set up is raspbian with pretty much no tweaks or altered ram allocation, just installed the image library.

Actually just re-reading your post. When you say total pi freeze that doesn't square with being able to use the mouse and shut down geany!! If you make the display window small what do you see being printed on the terminal window? Have you tried ctrl+shift+\ on the terminal window?
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

Sat Nov 10, 2012 12:22 pm

I haven't tried control shift/ but I can say I ran the pi3d files from a USB stick directly, so this is more than likely the issue. You can breath a little easier now.

I'll have to try it later this evening and see if it remains stable. Definitely perhaps a warning about running directly from USB maybe needed in the readme.

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

Re: Pi3D

Sat Nov 10, 2012 5:28 pm

James, it's a \ downhill not / uphill, but it doesn't seem to work in the terminal window that geany produces.
I'm not really sure about running python scripts on usb stick, I'll give it a try. I suppose it will draw a little current but probably less than the mouse or keyboard that you would otherwise have plugged in. (Though, thinking about it you will probably need both those for many of the programs so you must have an adaptor i.e. additional power supply)
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

Sat Nov 10, 2012 8:54 pm

Ok, looks like I need to start again and work through problems. I've d/l the rec and hadn't appreciated that in order to run the demos from geany you have to additionally make changes to the 'Build Menu Commands'
At present I am getting a error whereIf I put in Demo.py (sensibly as you did state) and point to the directory that Demo.py is in, I just get the message from the demo of the mousemovement i.e. Mouse to move left and right and up and down
It is from the Pong file as i edited to Moose and it responded accordingly. Hmm

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

Re: Pi3D

Sun Nov 11, 2012 8:20 am

James, if you get the message "Mouse to move left and right and up and down" it sounds like the program's working. Doesn't anything else happen?

I should have added that running from a terminal (as an alternative to geany's cog button) you need to be in the top folder of the download, whatever you called it. So something like:
[email protected] ~ $ cd rec/pi3d
[email protected] ~/rec/pi3d $ python Demo.py Pong
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 Nov 11, 2012 11:00 am

Yes, that works.
It loaded the game, but it still crashed after about 10 secs. I still have the control of the desktop.
I've loaded up the forestwalk and roamed around there and it only crashes when I hit the edge. It might be occurring when he ball hits the wall, the last crash I noticed this.
Unfortunately Pong will only reload after I restart the pi, if it has been previously loaded, perhaps even on opening the files??? Odd.
I need to run through these thing though to double check all these running issues. Which hopefully I can do on and off during he day.
But I wanted to give you an idea of the progress of issues. Can the collisions be requiring too much memory. I have a nasty feeling I've clocked it and forgot. :roll:

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

Re: Pi3D

Sun Nov 11, 2012 2:40 pm

James, thanks for keeping on feeding info. I've tried running from USB and it seems to work ok (though I have to manage without keyboard). Also I've apt-getted myself up to the latest version of the raspian and still everything ok. I thought I had stopped the crash when going off the edge of the map but found and patched pi3d/shape/ElevationMap.py lines 134 and 136 to -2 rather than -1. This should have been generating an error message in the terminal window, do you not get anything with Pong.py? If you can't see the terminal window make the Display() size smaller
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D

Sun Nov 11, 2012 5:17 pm

paddyg wrote: (An option on Geany or Idle to colour code the indents would be great)
rather belatedly found geany's view/editor options. I will certainly keep white spaces and indent guides on in future.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Raw 3D data to something useful?

Wed Nov 14, 2012 6:40 pm

This might not be the right place for this post but I guess this is where I'll get the help I need.

I'm working on a project that outputs 3D data in a raw format, ie. a list of XYZ co-ordinates and nothing more.

To view the "model" at the moment I'm creating cubes in Pi3D at each point and using mergeShape to build the finished product. This is okay for a few dozen points in the testing stages but obviously not great when I start generating thousands.

So here's the question....
Is there an easy way to convert the raw data into a readable format?
Or is there a better way to build the model in Pi3D?

Just thought about merging triangles... Is that an option?

All help appreciated and will post more details about the project when it's a bit more polished.
Apple say... Monkey do !!

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

Re: Pi3D

Wed Nov 14, 2012 10:49 pm

dave, are the x,y,z locations generated by the python code doing the graphics or are they stored in a file? You could either convert your xyz list to an obj file then use the loadModel (or Model as it's now called see github.com/rec/pi3d) or, probably easier, roll your own adaptation of one of the shape files. If you could think of a general purpose use for this kind of functionality I might be prepared to write one but I suspect it is rather 'niche'. (Are the cubes all the same rotation, scale and texture?)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D

Wed Nov 14, 2012 10:50 pm

james, did you get to the bottom of why Pong.py crashed?
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D

Thu Nov 15, 2012 3:42 am

Sorry for being absent - I just had a six(!) day internet outage, very frustrating!

Lots of action here...

A week or two ago, I sent a message to one of the moderators of the Raspberry forum, eupton, asking if we could get our own board here, but so far, no luck.

He doesn't seem very active, should I contact perhaps liz or scep...?

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2848
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Pi3D

Thu Nov 15, 2012 7:30 am

Eben and Liz are on holiday this week (and next week I think) Tom.
Alex Eames RasPi.TV, RasP.iO

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

Re: Pi3D

Thu Nov 15, 2012 7:37 am

Paddy,
I've d/l a new debian image, and am even using midori.
This is my current error from Tom's most recent updated rec.
[email protected] ~ $ cd pi3d
[email protected] ~/pi3d $ cd pi3d
[email protected] ~/pi3d/pi3d $ python Demo.py Pong
Traceback (most recent call last):
File "Demo.py", line 37, in <module>
__import__('demos.' + d)
File "/home/pi/pi3d/pi3d/demos/Pong.py", line 18, in <module>
from pi3d import Draw
File "/home/pi/pi3d/pi3d/pi3d/Draw.py", line 2, in <module>
from pi3d import Texture
File "/home/pi/pi3d/pi3d/pi3d/Texture.py", line 2, in <module>
import Image
ImportError: No module named Image
[email protected] ~/pi3d/pi3d $
Its trickier now to get the files to run correctly before I can even see any actual problems.

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: Pi3D

Thu Nov 15, 2012 7:41 am

Hi again Paddy, at the moment the co-ordinates are written to a file as the generator and displayer are two separate scripts but that will change shortly. I'll look at converting the data into an OBJ file, that will probably be the best for now.

The project is a 3D laser scanner so ideally I need to form a mesh but the cubes worked for a quick-and-dirty test and I got the result I wanted and yes, they're all the same size,etc.. Once I've got this data problem sorted I can work on resolution and automation.

Thanks for the help.
Apple say... Monkey do !!

Return to “Python”