Pi3D


216 posts   Page 3 of 9   1, 2, 3, 4, 5, 6 ... 9
by JamesR » Mon Aug 13, 2012 10:39 am
Thanks, I've had a chance to consider the differences in things. I might try emulating as the raspberry pi is someone painful at loading etc although using another computer to reference is quite handy.

I have succesfully loaded a model now. I have to work on the materials and textures angles as that doesn't appear to work. Nevertheless that's because the references aren't made in the egg file to the textures rather than pi3d.

It would be interesting to know how the triceratops model was made. I think the chicken converter probably did a better job but it means using an older version of blender. The property boxes are still proving tricky to learn what does what under what heading. After that you have to interpret the code.
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by paddyg » Sat Aug 18, 2012 2:06 pm
I've not read through the comments here recently. Sorry for the general lack of information about what does and doesn't work, over the next few days I will try and get some more 'manual' for the loadModel() stuff on my github (in the wiki on github/paddywwoof/pi3d) I might have another look at the animation [feature of egg files] but I think it will be a nightmare in python (on the pi).

I am now running on raspbian and do all the coding in geany on the pi and it's not too bad really. I try to avoid large polygon models but it's possible to get quite complicated scenes that render fast by merging bits together.

I have done a couple more tweaks that speed things up and make them look better. On the video below I have a) made a surface 'tiled' see-through texture over a general terrain image and b) made it so that objects loaded in egg files can be merged onto a map. The video also shows that I have managed to get right through the maze (at long last!)

http://www.youtube.com/watch?v=scsb5HrxG24
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by paddyg » Sat Aug 18, 2012 2:13 pm
paddyg wrote:... animation [feature of egg files] but I think it will be a nightmare in python (on the pi)
actually I did install cython on the pi a while ago and compiled one of the functions in the loadModel() and it did improve speed quite a bit (30%) So once the code's stopped evolving it might be worth making a cython version in parallel.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by MrHarcombe » Sun Aug 19, 2012 5:46 pm
Um... I realise it's probably me, but I'm just trying this out and it's failing for me.

I've tried running the examples from both the command-line and Geany, and get the same/similar results:

Code: Select all
Pi3D module - version 0.05
Copyright (c) Tim Skillman, 2012
Updates available from www.github.com/tipam/pi3d
Screen size 1920 1080
3297512448: * failed to add service - already in use?


Any thoughts?
Posts: 17
Joined: Mon Jul 09, 2012 7:31 pm
Location: Market Harborough
by MrHarcombe » Sun Aug 19, 2012 7:12 pm
MrHarcombe wrote:Um... I realise it's probably me, but I'm just trying this out and it's failing for me.

I've tried running the examples from both the command-line and Geany, and get the same/similar results:

Code: Select all
Pi3D module - version 0.05
Copyright (c) Tim Skillman, 2012
Updates available from www.github.com/tipam/pi3d
Screen size 1920 1080
3297512448: * failed to add service - already in use?


Any thoughts?


Scratch that. After an "rpi-update" I'm getting a whole other set of issues. Mostly seeming to do with the fact that the textures files are predominantly 0 bytes! Time to re-download, methinks.
Posts: 17
Joined: Mon Jul 09, 2012 7:31 pm
Location: Market Harborough
by MrHarcombe » Sun Aug 19, 2012 8:48 pm
MrHarcombe wrote:
MrHarcombe wrote:Um... I realise it's probably me, but I'm just trying this out and it's failing for me.

I've tried running the examples from both the command-line and Geany, and get the same/similar results:

Code: Select all
Pi3D module - version 0.05
Copyright (c) Tim Skillman, 2012
Updates available from www.github.com/tipam/pi3d
Screen size 1920 1080
3297512448: * failed to add service - already in use?


Any thoughts?


Scratch that. After an "rpi-update" I'm getting a whole other set of issues. Mostly seeming to do with the fact that the textures files are predominantly 0 bytes! Time to re-download, methinks.


...and... sorted. Sorry for the noise.
Posts: 17
Joined: Mon Jul 09, 2012 7:31 pm
Location: Market Harborough
by paddyg » Mon Aug 20, 2012 11:02 pm
paddyg wrote: over the next few days I will try and get some more 'manual' for the loadModel() stuff on my github (in the wiki on github/paddywwoof/pi3d)
not added anything to the manual but there are some updates on the code (my branch. Tim will have to decide what to incorporate). Basically it's stuff to make the elevation map work better, textures, lighting and normals etc
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by paddyg » Thu Aug 23, 2012 8:01 am
Just updated my branch at github https://github.com/paddywwoof/pi3d with a version of the loader for obj files which is quite a bit faster than the egg file loader (partly because I put the numbers directly into ctype arrays rather than into python arrays then convert them, I will make the same improvement to the egg loader) However obj files are generally much smaller for the same model and are generally easier to wade through.

I put in a cow and a triceratops model. They're not the ones used for the eggsamples so I put in their egg versions for comparison. Also I didn't have the correct texture files so just allocated a random other one.

Let me know any bugs that need sorting
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by JamesR » Thu Aug 23, 2012 8:04 am
That sounds brilliant. Where do you adapt the code from or is it just pure unadulterated programming knowledge?
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by MoeSzyslak » Thu Aug 23, 2012 8:00 pm
Nice topic!
Posts: 3
Joined: Thu Aug 23, 2012 12:01 am
by JamesR » Thu Aug 23, 2012 9:50 pm
Is it too obvious to have replaced the filename in the sample loader file for the .egg file for the .obj file. I've looked through the pi3d code and there's not a lot different in there which suggests use the same loadmodel code.

Anyway all I got was a black screen, but no errors in geany, so maybe its a lighting problem?
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by paddyg » Thu Aug 23, 2012 10:36 pm
JamesR wrote:That sounds brilliant. Where do you adapt the code from or is it just pure unadulterated programming knowledge?
Possibly bits missing elsewhere (see your next post!). I had been struck by how much nearer the structure of obj was to the arrays I used to get the egl data so I searched on google and found some python to convert obj to js then hacked that (put a ref in the comments at the top).
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by JamesR » Thu Aug 23, 2012 10:44 pm
So is it just a concept or have I coded my file wrong. I.e. I was presuming you can load obj models with that file set.
Cheers
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by paddyg » Thu Aug 23, 2012 11:09 pm
JamesR wrote:Is it too obvious to have replaced the filename in the sample loader file for the .egg file for the .obj file.
that's all I did in the end. Though it was after various permutations altering things so I might have made it work on my set up and not remembered to post every last scrap of what I did, I will look further.

JamesR wrote:Anyway all I got was a black screen, but no errors in geany, so maybe its a lighting problem?
It won't be lighting if the equivalent egg file works ok. You will definitely need the modified line in pi3d under loadModel... draw() that tells it to run loaderEgg.draw() if the extension is egg or obj I don't think I altered loaderEgg but I will recommit it to my repository and any changes will show up.

OOPS, just done this and I seem to have missed this off the commit before last so all the other alterations to allow loadModel objects to be merged will have been missing. Sorry to anyone who tried this.

While I was trying to get the new code to work yesterday I got a black screen much of the time and it was finally sorted by getting the draw to use loaderEgg. Obviously you need to have the version I have just committed!!

When Tim gets back in a week or two there will probably be a timely sort out of my various suggested improvements which will find all the holes.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by paddyg » Fri Aug 24, 2012 10:40 am
Sorry again for missing the changes to loaderEgg in my commit on the 20th (if anyone tried it out). I have made loaderEgg put data straight into ctype arrays as per loaderObj but it doesn't seem to speed it up at al!

JamesR, did the loaderObj work in the end?
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by JamesR » Fri Aug 24, 2012 3:41 pm
Ok, I'm getting a blue screen now, but no obj model. Should the draw() function in the Pi3d file call the Loaderegg file for the obj file?
I did try changing it to call the Loaderobj file but you start getting issues.
I did try adding the def draw from the Loaderegg to the Loaderobj, there's loading of indices and vertices etc, the it doesn't like the texID line. I expect that was completely the wrong way to go about things.

Puzzling.
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by JamesR » Fri Aug 24, 2012 3:43 pm
Although, presumably rereading your last post, the Loaderegg file has been adjusted accordingly.
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by paddyg » Sat Aug 25, 2012 5:17 pm
JamesR wrote:Although, presumably rereading your last post, the Loaderegg file has been adjusted accordingly.

JamesR, sounds like you did something along the lines of what I did to get it working. Originally I had a copy of draw in loaderObj and called that from pi3d but it didn't like something. I kept finding odds and ends that weren't quite right and fixing them so I can't really tell what was breaking it but at some point I decided that there should only be one version of draw (which should probably should be moved back into pi3d) as the loaders are just what they say on the tin: functions to load the info from files to the same object. The changes I made a few days ago also brought the structures of loadModel object more in line with the rest of Tim's stuff to allow them to be merged. Each item in the dictionary object vGroup is initialised to a create_shape() now, which involved changing quite a bit of it. You will definitely need the latest version (from my repository) of loaderEgg.py for this to work.

So, short answer is yes. In fact the line in pi3d.loadModel.draw() should look like this:
if self.exf == 'egg' or self.exf == 'obj': loaderEgg.draw(self,tex,n)
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by paddyg » Sat Aug 25, 2012 5:21 pm
JamesR, just thought: are you definitely loading the model where you can see it? The same model saved (from blender) as egg seems to appear Xrotated 90degrees so it could be off the top or bottom.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by JamesR » Sat Aug 25, 2012 6:09 pm
Interesting that I actually got somewhere understanding a bit of how the code works.

The triceratops .egg file works but the triceratops2.obj doesn't show the model. It should be fine, shouldn't it?

But, I did think about the obj export options in blender. I made a simple textured figure. Selected a lot of options and then exported. With my blender model, geany is reporting what I think is a vertices error.
The obj. File doesn't look esp. Any different from the ones you provided. I might try changing model position. It might be in front of the camera then.

My main problem is one monitor and not enough plug sockets... Otherwise I could run through things more often.
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by JamesR » Sat Aug 25, 2012 7:01 pm
It's the scale! The 0.05 is far too small for the .obj file. I was looking at the rotation thinking it can't really matter to see it that it's facing 90deg in any direction, and then saw the scale.

1,1,1 is viewable in the sample file for the egg triceratops.

Well done Paddy, great work. Funny how the simple things evade the mind.
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by JamesR » Sun Aug 26, 2012 8:45 am
Are there specific boxes to check/uncheck for the model export. The triceratops will load but ironically my model won't.

It basically reports
Loaderobj.py, line 302
Self.cGroup[g].normals[i*3*k] = c_float(normals[f['normals]'][v]-1][k])
IndexError: list index out of range
Posts: 78
Joined: Sun Aug 05, 2012 11:21 pm
by paddyg » Sun Aug 26, 2012 11:05 am
JamesR wrote:Are there specific boxes to check/uncheck for the model export. The triceratops will load but ironically my model won't.

It basically reports
Loaderobj.py, line 302
Self.cGroup[g].normals[i*3*k] = c_float(normals[f['normals]'][v]-1][k])
IndexError: list index out of range
JameR. YES. My fault for not explaining, there were some handy hints in the python script I borrowed from but I didn't copy those bits. Basically the loader expects normals. All the ones I exported using:
Context: Selection Only
Output Options: Rotate X90
Export: Edges, Materials, UVs, Normals, HQ
Blender Obj...: Keep Vert order

It's quite possible to calculate normals (which is why blender defaults not doing) by taking the cross product of two edges leading to that vertex (which is what I do in my 'improvement' to the elevation map script) but it's very slow in python on the pi and instantaneous from blender as it's already done the calcs in c.

Something else to go in the manual (and I will put in some nicer error catching).

PS thanks for struggling through with this and providing feedback.
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by paddyg » Sun Aug 26, 2012 11:16 am
JamesR wrote:Interesting that I actually got somewhere understanding a bit of how the code works.
...
My main problem is one monitor and not enough plug sockets... Otherwise I could run through things more often.
Python is quite good for getting the hang of what's going on. (Despite the extremely bad, retrograde step of using invisible characters instead of semicolons and curly brackets!!!) 'Bad' programming where everything is in one long script is actually much easier to figure out than tidy hierarchical things where the functionality is hidden in a great, great, great grandparent class and every class is in its own file.

I resorted to buying another monitor from a TV shop, they get loads in as part exchange and seem open to bargaining along the lines of "the computer only cost £15, you can't expect me to pay more than £25 for the monitor" etc
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
User avatar
Posts: 851
Joined: Sat Jan 28, 2012 11:57 am
Location: Bingley, Yorkshire
by BlackJack » Sun Aug 26, 2012 1:12 pm
@paddyg: Why is meaningful indentation an extremely bad and retrograde step? It is not invisible as the first character after the indentation clearly makes the amount of invisible space before it visible. In all languages with curly braces (or other non whitespace syntax to denote blocks), programmers also indent the code in addition to the syntax for the compiler. At least if they want something readable and maintainable. So either of it is redundant. Question is, what is more readable and easier to grasp for a human being: lots of code with curly braces and no indentation or indentation that conveys the structure of the code and no curly braces‽
Code: Select all
while not self.asleep():
    sheep += 1
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am