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

Re: Pi3D

Thu Nov 15, 2012 8:03 am

@JamesR: Just a guess based on the traceback: You are missing the Python Imaging Library (PIL). The Debian package name is `python-imaging`.

Code: Select all

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

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

Re: Pi3D

Thu Nov 15, 2012 8:59 am

dave, sounds interesting. Obviously putting cubes at each 'point' is requiring six times as many polygons as you really need and will produce a 'blocky' model (sorry!) However it's not trivial to join points to their neighbours unless they are regimented in some way. i.e. each horizontal band has the same number of points and the end joins back to the begining as a series of loops one above the other. Producing an obj file is pretty much the same difficulty as generating the 3d model directly in the ctype arrays: you have to figure out which face each vertex belongs to. You could put tetrahedra on each point so you (only) used four times as many polygons as you needed.
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 15, 2012 9:36 am

BlackJack wrote:@JamesR: Just a guess based on the traceback: You are missing the Python Imaging Library (PIL). The Debian package name is `python-imaging`.
I have forgetten to do that bit.
I'll adress that a bit later today

Thanks

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

Re: Pi3D

Thu Nov 15, 2012 3:01 pm

Pong now works, as run from Geany. So all my fault for slight overclocking.
No errors, perfect running. Thanks for the patience.

Finally I can try to do something for myself.

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

Re: Pi3D

Thu Nov 15, 2012 3:46 pm

Tom, when you mentioned having a pi3d category on the forum I did pm Liz as originator of this thread. I also thought of 'reporting' your post to bring it to the attention of an administrator!

Dave, thinking about this it's probably more generally useful to convert your laser scan to a standard 3d model file like obj. If your points are reasonably evenly spread over a reasonably smooth surface then the algorithm to generate faces and triangles probably won't be too bad. There's almost certainly one out there that you could use.

James, thanks for all the testing! I wouldn't have thought of seeing what happened running with different amounts of overclocking, memory allocation or from a USB. I did do a few tweaks to the collision testing on the ElevationMap yesterday but if you've re-installed everything you probably have that. It now checks if the ball is touching the plane between vertices (ought to) also it keeps score and I've given the opposition a bit more of a turn of speed so it's quite hard to beat. https://www.youtube.com/watch?v=t7TZIY-Ymm0
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 5:12 pm

> ImportError: No module named Image

This sort of error is pretty common when you're using someone else's Python package!

Assuming that the package isn't broken (and I was using it last night so I assume it is not) it nearly always means that you haven't installed one of the dependencies - in this case, I believe it's the Python Imaging Library, PIL.

To install it, open a terminal and then say:

Code: Select all

sudo apt-get install python-imaging
Let us know if that worked!

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

Re: Pi3D

Thu Nov 15, 2012 5:19 pm

URG, silly me. I hadn't seen the next page before I wrote my previous post - I was up late last night and the coffee is still kicking in!

Eventually, we'll probably create an installer that will automatically install the dependencies just to avoid such issues as the above.

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

Re: Pi3D

Thu Nov 15, 2012 5:44 pm

No worries Tom, it's annoying as I knew that one, I'd completely failed to recognise the problem or remember.
I'm going to try and upload something soon.
You guys can tell me if how badly I've misread things so far.

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

Re: Pi3D

Thu Nov 15, 2012 7:06 pm

https://github.com/JamesR1/pi3d/downloads

Ok, I've uploaded a piece of code essentially extracted from bits of Paddys. I've uploaded it with textures.
There's an error around the 'break' at the end of the code (or was). I think it would be easier for people to look at it and see where the flaws are. There may be bits not needed and bits missing.

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

Re: Pi3D

Thu Nov 15, 2012 7:07 pm

This thread has become rather long, so I just started a new thread here.

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

Re: Pi3D

Thu Nov 15, 2012 7:15 pm

JamesR: I don't seem to see what the changes are in that repo?

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

Re: Pi3D

Thu Nov 15, 2012 8:16 pm

Tom,
There should be 5 files on the d/l page, so its a demo files and texture files.
There not with the set of normal files, I couldn't see how to do that.

Actually I don't know if they can be d/l by everyone else then.
They can if you right click on the file name and 'save as'
I really don't know how to add them to the repo of files under my name.

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

Re: Pi3D

Thu Nov 15, 2012 8:49 pm

github! I have to log on to the help page to figure out what to do quite often. (I need to check up on how to go about merging Tom's latest mods to my local version. (Might wait until he's enlarged on the threading first ;) ))
James, I will have a look at the files you've put up
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 15, 2012 9:02 pm

That help page made no sense until at least it says to upload via the d/l.
Do I actually have the ability to put a complete set of files up?

Would be great if you can have a look Paddy.

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

Re: Pi3D

Thu Nov 15, 2012 9:17 pm

JamesR: it seems you're basically doing the right things so far, you have a fork of the project... but it appears as if none of the changes you have made have been committed - if you look at the commits for your project, it shows none from you!

To successfully push a change, you need to do the following three steps.

1. git add the new files to the project
2. git commit the changes
3. git push those changes back to github.

My theory is that you didn't succeed with pushing the changes back.

Here's a tolerable git tutorial that might help you!

Another possibility is, I believe, to simply check out the original branch or my fork, make the changes to that but don't push, and then send us a pull request...

We should definitely work through this together so we have a good workflow that we can document, do the same every time, and then forget about. :-D

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

Re: Pi3D

Thu Nov 15, 2012 9:32 pm

James, yes you need to work your way through the 'bootcamp' instructions. You keep selecting which files to commit, commit them and every now and then merge them back to the master. As per Tom's links. It's not very user friendly but definitely worth pursuing.

Looking at your script, very briefly, there seems to be something odd with the indentation from 101 down, I would try moving it in line with the 'if clash...' I will have a look at it on my Pi
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 15, 2012 9:57 pm

Ahhh.
I found paying attention to bit where the github has its own folder on your pc that you have to put the files on helps.
Then its as simple as knowing which page you enter your name and email.
...And Syncing...
But thanks Tom. The windows gui software could be better explained by them.

They are there!!!!!!!!
Next thing to do then is to Fork from Rec for consistency. I ran it (or tried) originally from rec recent updates.
Now I'm on windows I can check the pi... I've ordered a £5 HDMi cable swtich so fingers crossed. Ideally I can leave the pi on all day and just off and on etc.
Last edited by JamesR on Thu Nov 15, 2012 10:04 pm, edited 1 time in total.

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

Re: Pi3D

Thu Nov 15, 2012 9:59 pm

James, looking a bit more at your code:
1. I've now moved over to Tom's new structure which is better in many ways so there would be many improvements by swapping over (though I can understand not wanting to get to grips with new ways of doing things)
2. you seem to update the ball locations sx,sy,sz but not change the ball location with them. ball.position() in the new system (maybe in the old too I can't remember)

Also I think you would be much better off doing everything githubwise from your RPi (Your last comment sounded a bit like you were using it on windows) Assuming of course that you have internet connection to it!!
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D

Thu Nov 15, 2012 10:22 pm

James, you make the light directional by setting the w value to 0. However if you move around your map using the matrix transformations (lines 63,64) which is the way it seems to be done, this actually rotates EVERYTHING and the lighting goes wonky unless you move it in a specific way (see Amazing.py I don't need to do this in Pong.py as there is no rotation) I would probably use a point light (w=1 the default value) Might be nice to add some fog, generally makes things more interesting
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 15, 2012 10:44 pm

Yes, I've been using windows.
Seeings as I can get midori to work I'm sure github would be simple(ish)
Although uploading might be useful on windows. I'll see how I go.

Yes the #bounce off edges and give random boost bit is missing. (Its useful to leave all the original notes for reference at this point)

But, now I can read it better and wonder in Pong, how do you define the score?

Code: Select all

  # write up the score
  Draw.string(arialFont, str(score[0]), -10, 20, -5, 0.0, 0.05, 0.05)
  Draw.string(arialFont, str(score[1]), 10, 20, -5, 0.0, 0.05, 0.05)
Is it basically worked out on
IF.... the bat is in position off the ball on the line and then the ball takes on attributes from it.
OR (Else) The bat is not and 1 is added to the score?

Lol. The light. I've never seen it run..... Screenshot??? :o

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

Re: Pi3D

Fri Nov 16, 2012 12:36 am

James, the scoring kind of works as you say, it's most concisely described by the code! Read from if sz > maphalf: #player end.. I basically check the distance of the ball from the middle of 'you' or the monster (using pythagoras). If it's a greater distance then the other side gets a point. If it's a smaller distance then the z velocity of the ball gets reversed (with random boost) and the x and y velocities are incremented by the mouse speed.

Try commenting out the light.on()
pong1.jpg
pong1.jpg (56.26 KiB) Viewed 3001 times
pong.jpg
pong.jpg (28.87 KiB) Viewed 3001 times
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

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

Re: Pi3D

Fri Nov 16, 2012 11:09 am

James, I put a copy of your files on my RPi and worked by way down Piom to make it work with the new format (sorry, if you really wanted to stay with the old one but you can probably convert it back)
here: https://github.com/paddywwoof/pi3d/downloads
I've marked the significant changes with lots of ##############s
it didn't really need much, the main things being not setting up variables before you tried to use them in expressions (some of them redundant anyway i.e. monster variables) and the completely scrambled indentation for the key pressing (would have been simple to sort with a few {}s!). Your walls are a bit thin for the resolution of the map so end up as a ridge of spikes. Also you might want to stop the camera being able to cross walls as per my comments. You will see what I mean about the light if you watch the shadows as you rotate. Change to point light improves this.

I don't know what you plan for the gameplay but the monster/ball could rotate to point at you and move towards you if you're in front of it and near. And obviously kill you it it gets you!

When the threading is sorted out it should be possible for adjacent maps to be loaded in the background so you don't get to an edge. (NB note to self: the height and clash methods assume that the location of the map is 0,0,0 which won't work if 'tiling' multiple maps)
Attachments
Piom.jpg
Piom.jpg (18.61 KiB) Viewed 2988 times
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 16, 2012 11:21 am

Paddy, that's brilliant.
I was very surprised that none of the include options where present when I looked this morning at the code.
That shouldn't have happened. The rest of the stuff which I'll have to go through later will be a learning curve. I think basically you've hit the nail on the head with this map is that the monster should kill you if it hits you.
The threading may actually enable me to make a bit of a proper game it this then.
And thanks for the insight into the scoring, I was wondering if it could be used to pick up objects etc if the actor is close enough, i presume a cursor could be used on a fixed screen like Pong's to do some sort of picking task.

I do want to use the new format, so no worries there.
Thanks.

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

Re: Pi3D

Fri Nov 16, 2012 9:31 pm

I've had a good look through and reread your remarks.
Most things make basic sense. It's all the calc that is the tricky thing to comprehend. The loading certain features is pretty much fine.
I can pretty much start a new thread on this I think.
I'll have a play with some of the variables, then I'll probably ask a few more questions. Silly things end up being important.
Thanks it's great to have something to work from.

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Pi3D - Trouble Loading .obj Files

Thu Mar 27, 2014 8:32 pm

This may deserve its own thread as I'm not sure how complicated the topic may get, but I'm having trouble loading .obj files that aren't already in the demo models subdirectory. I've tried loading a few dozen models from various sources (Blender, Alias/Wavefront, etc.) and they all wind up breaking the initialization after the shaders have properly compiled but before the display is launched. It doesn't matter whether there is a reference to a .mtl (materials, for the uninitiated) file, although those that do use one seem to also have trouble finding the .mtl file, even if it's in the same directory as the .obj file. I'm sure I'm having a forest/trees/senior moment and that I've missed something glaringly obvious that can be pointed out to me by the most casual of observers.

A typical error trace looks like:

shader uv_reflect, Compiled
shader uv_reflect, Compiled
/home/pi/pi3d_demos-master/models
Traceback (most recent call level):
File "LoadModelObj.py", line 17, in <model>
mymodel=pi3d.Model(file_string='models/cube.obj', name='cube', z=4)
File "/usr/local/lib/python2.7/dist-packages/pi3d/shape/Model.py", line 36 in
__init__
self.model = loaderObj.loadFileOBJ(self, file_string)
File "/usr/local/lib/python2.7/dist-packages/pi3d/loader/loaderObj.py", line 249, in loadFileOBJ
material_lib = parse_mtl(open(os.path.join(filePath, mtllib), 'r'))
IOError: [Errno 21] Is a directory: u'/home/pi/pi3d_demos-master/models/'
couldn't set to delete
couldn't set to delete

------------------
(program exited with code: 1)
Press return to continue

In looking for differences in the demo files vs. the foreign versions, at first I thought that maybe the loader was allergic to certain kinds of white space (e.g., blank lines), or that some files had extraneous ^M embedded carriage returns at the ends of every line, but eliminating those had no effect. The above errors suggest the files are in the wrong location(s), but they're in the models subdirectory alongside the working demo files and all I did was change the name of the .obj file from "teapot.obj" to "cube.obj" and the object name from "teapot" to "cube" in LoadModelObj.py. The .mtl file references in the .obj files all refer to the current directory (e.g., ./cube.mtl), where they exist. I'm not sure what the "couldn't set to delete" errors are from and why there are two of that same error - is it the object that can't be set to delete because it was never loaded? It can't be files that can't be deleted due to permissions, as I hope it's not trying to delete any files.

Like I said, I'm probably missing something obvious as I am a bit sleep deprived, but any help would be greatly appreciated - thanks!
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

Return to “Python”