image = ctype.c_char_p(im.convert(RGBs).tostring("raw",RGBs))
and later...
opengles.glTexImage2D(GL_TEXTURE_2D,0,RGBv,ix,iy,0,RGBv,GL_UNSIGNED_BYTE, image)
image loading goes from several seconds to fractions of a millisecond
paddyg wrote:actually it's the eglchars() method that takes all the time. I tried saving the images as 'raw' strings but it seemed to take the same time and this is why.paddyg wrote:.tostring("raw",RGBs)
paddyg wrote:The way to make it all load fast seems to be to take out the python wrapper eglchars() completely. I haven't tested this exhaustively but it seems to work on a couple of things I've just tried so it should form the basis of 'a better method'. I use the ctypes.c_char_p() so only have to send a pointer, also don't need to convert it back with a byref. i.e.
image = ctype.c_char_p(im.convert(RGBs).tostring("raw",RGBs))
and later...
opengles.glTexImage2D(GL_TEXTURE_2D,0,RGBv,ix,iy,0,RGBv,GL_UNSIGNED_BYTE, image)
image loading goes from several seconds to fractions of a millisecond





also didn't get much joy from the camera class. Not really sure how to use it but I imagined the scene would change as the camera moved or turned as if viewed from the camera.paddyg wrote:I tried but failed to get material properties
paddyg wrote:Tim, looks good. Here are some pics of the latest iteration of loadModel. Here's a link to the files (large because of the 128 water pictures, sorry!) below pics is a copy of the readme in case you're interested but can't be bothered to load all the pics.
files: http://www.eldwick.org.uk/files/loadModel_mods.zip
(as with previous zips this needs the various other support files from https://github.com/tipam/pi3d/tree/)
readme.txt:
Some notes on the loadModel() class in pi3d
__init__ takes just the file path/name:
If the name is not “” it generates a dict object (vGroup) where each key is a 'group' name in the egg file (separate object in blender). Parsing still takes a while, I might try and do conversion of the {} structure in one go.
Each group can have only one material or texture (which will be taken from the last polygon as the group is parsed)
Material used to add colour to the commented out code (from Tims cube) but these colours disappear when lighting used. Ideally the material properties would get set with glMaterialfv() but can't get that to work.
If the texture is set using load_textureAlpha it seems to scramble the transparency and the depth calculation, not just for loadModel() but for others such as plane.
clone():
method returns a new object in which vGroup points to the vGroup of self. i.e. positions and rotations are available and have their own instance but the 3d object data is just a pointer to the original
reparentTo(loadModel obj):
method adds obj to a list of loadModels in self (and sets a parent pointer in obj to point to self). The positions and rotations of obj are then relative to self and when self.draw() runs it recursively draws all its children after working out where they should be
draw():
method is pretty much as before but 1. sets glShadeModel(GL_SMOOTH) 2. loops through each vGroup and draws that with the relevant texture or material 3. draws all the children
there are two helper methods (outside loadModel):
extBracket() does the parsing out of the <tab> key { values } and could well be re-written to try to make it faster by avoiding re-parsing bits of the string.
rotVector():
uses the opengles methods to speed up the process (used for calculting the location of child objects)
Other comments.
See the load_textureAlpha() comment above.
I use ctypes.c_float arrays for vertices, normals, tex_coords and ctypes.c_short for the triangles
I have altered quite a bit of the light stuff from the original pi3d. I'm not sure which bits are necessary and which are random changes while trying to get something working that just don't obviously break anything!
I add the w dimension as a parameter in the __init__ as this is needed to define directional lights (0) and spotlights (-1) and xyz actually represents xyzw.
I made self.no = eglint(GL_LIGHT0 + no) as I think this is what it's supposed to be, certainly the on() method shouldn't just enable LIGHT0
I set lighton to False to start with and change it as relevant in the on() and off() methods
I tried but failed to get material properties such as shininess to work either in the light class or in the loadModel class (see above)
Loading image files now uses ctypes c_char_p to it speed up. Also tried various ways of using arrays for the vertices, normals etc and passing pointers rather than using the python wrapper but didn't manage.
I made an eggtexturecard in python rather than trying to get the functionality from parsing an egg. Part of the reason for this is that the timing functions for changing frames are not built into the pi3d module as yet (and possibly don't really need to be)
As per Tim's comment; it would be a good idea to split loadModel into core functionality for object in different formats (obj etc) and functionality specific to parsing panda3d eggs.

Huulivoide wrote:When will be the source code be up? Pictures are nice, but source code one can play with would be nicer ^_^




juantar wrote:This might be a stupid question, but is there any way of practicing and learning to use Pi3D in a Windows machine? The reason I ask is that I spent most of my time in a Windows machine, so I would like to be able to write the python scripts in the Windows Desktop and then copying the python files to my raspberry pi when I get home.
JamesR wrote:Should this run under windows with python installed or am I being silly?
If egg files are recommended which software is recommended for the modelling and which exporter (versions) Do I need to do UV maps etc...
Cheers