Author: ArcRiley
Date: 2007-07-04 16:33:50 -0400 (Wed, 04 Jul 2007)
New Revision: 348
Added:
trunk/pysoy/src/textures/Video.pxi
trunk/pysoy/src/transports/
trunk/pysoy/src/transports/File.pxi
trunk/pysoy/src/transports/Soy.pxi
trunk/pysoy/src/transports/Transport.pxi
trunk/pysoy/src/transports/soy.transports.pxd
trunk/pysoy/src/transports/soy.transports.pyx
Removed:
trunk/pysoy/src/storage/
trunk/pysoy/src/transports/File.pxi
trunk/pysoy/src/transports/Soy.pxi
trunk/pysoy/src/transports/Store.pxi
trunk/pysoy/src/transports/soy.storage.pxd
trunk/pysoy/src/transports/soy.storage.pyx
Modified:
trunk/pysoy/src/atoms/soy.atoms.pxd
trunk/pysoy/src/colors/Color.pxi
trunk/pysoy/src/materials/Material.pxi
trunk/pysoy/src/textures/Image.pxi
trunk/pysoy/src/textures/soy.textures.pxd
trunk/pysoy/src/textures/soy.textures.pyx
trunk/pysoy/src/widgets/Canvas.pxi
trunk/pysoy/src/widgets/Projector.pxi
Log:
more moving..
Modified: trunk/pysoy/src/atoms/soy.atoms.pxd
===================================================================
--- trunk/pysoy/src/atoms/soy.atoms.pxd 2007-07-04 20:32:03 UTC (rev 347)
+++ trunk/pysoy/src/atoms/soy.atoms.pxd 2007-07-04 20:33:50 UTC (rev 348)
@@ -20,6 +20,7 @@
cimport stdio
cimport soy._internals
cimport soy.bodies._bodies
+cimport soy.materials
cdef class Vertex :
cdef soy.bodies._bodies.Mesh _mesh
@@ -38,6 +39,7 @@
cdef Vertex _saved_a
cdef Vertex _saved_b
cdef Vertex _saved_c
+ cdef void *_saved_m
cdef void _addList(self,soy.bodies._bodies.Mesh,int)
cdef void _remList(self)
cdef void _setList(self)
Modified: trunk/pysoy/src/colors/Color.pxi
===================================================================
--- trunk/pysoy/src/colors/Color.pxi 2007-07-04 20:32:03 UTC (rev 347)
+++ trunk/pysoy/src/colors/Color.pxi 2007-07-04 20:33:50 UTC (rev 348)
@@ -28,10 +28,10 @@
cdef float *_getRGBA(self) :
cdef float ret[4]
- ret[0] = self._r/256.0
- ret[1] = self._g/256.0
- ret[2] = self._b/256.0
- ret[3] = self._a/256.0
+ ret[0] = self._r/255.0
+ ret[1] = self._g/255.0
+ ret[2] = self._b/255.0
+ ret[3] = self._a/255.0
return ret
property hex :
Modified: trunk/pysoy/src/materials/Material.pxi
===================================================================
--- trunk/pysoy/src/materials/Material.pxi 2007-07-04 20:32:03 UTC (rev
347)
+++ trunk/pysoy/src/materials/Material.pxi 2007-07-04 20:33:50 UTC (rev
348)
@@ -48,23 +48,31 @@
cdef void _render(self) :
- if self._color :
- (<soy.textures.Texture> self._color)._bind()
- else :
- gl.glDisable(gl.GL_TEXTURE_1D)
- gl.glDisable(gl.GL_TEXTURE_2D)
- gl.glDisable(gl.GL_TEXTURE_3D)
+ cdef float _white[4]
+ _white[0] = 1.0
+ _white[1] = 1.0
+ _white[2] = 1.0
+ _white[3] = 1.0
if self._shades == 0 :
gl.glShadeModel(gl.GL_SMOOTH)
else :
gl.glShadeModel(gl.GL_FLAT)
gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT,
(<soy.colors.Color> self._ambient)._getRGBA())
- gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE,
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE,
(<soy.colors.Color> self._diffuse)._getRGBA())
gl.glMaterialf (gl.GL_FRONT, gl.GL_SHININESS, self._shininess)
gl.glMaterialfv(gl.GL_FRONT, gl.GL_SPECULAR,
(<soy.colors.Color> self._specular)._getRGBA())
+ if self._color :
+ # for some reason _white works here while _getRGBA does not,
+ # even though it works for non-textured
+ gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT_AND_DIFFUSE, _white)
+ (<soy.textures.Texture> self._color)._bind()
+ else :
+ gl.glDisable(gl.GL_TEXTURE_1D)
+ gl.glDisable(gl.GL_TEXTURE_2D)
+ gl.glDisable(gl.GL_TEXTURE_3D)
property color :
Modified: trunk/pysoy/src/textures/Image.pxi
===================================================================
--- trunk/pysoy/src/textures/Image.pxi 2007-07-04 20:32:03 UTC (rev 347)
+++ trunk/pysoy/src/textures/Image.pxi 2007-07-04 20:33:50 UTC (rev 348)
@@ -26,7 +26,7 @@
cdef int b, c, lx, ly
cdef object d, idata
modes = {'L':1, 'LA':2, 'RGB':3, 'RGBA':4}
- idata = img.getdata()
+ idata = img.transpose(1).getdata()
if img.size[0] == 0 or img.size[1] == 0 :
raise ValueError('Image of non-null size must be provided')
if not modes.has_key(img.mode) :
Copied: trunk/pysoy/src/textures/Video.pxi (from rev 341,
trunk/pysoy/src/textures/Image.pxi)
===================================================================
--- trunk/pysoy/src/textures/Video.pxi (rev 0)
+++ trunk/pysoy/src/textures/Video.pxi 2007-07-04 20:33:50 UTC (rev 348)
@@ -0,0 +1,91 @@
+# PySoy's textures.Video class
+#
+# Copyright (C) 2007 Team PySoy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+cdef class Video (Texture) :
+ '''PySoy textures.Video Class
+
+ Renders an Ogg Theora stream to a texture
+ '''
+ def __new__(self, filename, *args, **keywords) :
+ cdef int f, i, lx, ly
+ cdef ogg.ogg_page _oggPage
+ cdef ogg_packet _oggPacket
+ cdef ogg.ogg_stream_state _oggStream
+ #
+ self._fd = stdio.fopen(filename, 'rb')
+ ogg.ogg_sync_init(&self._oy)
+ ogg.theora_comment_init(&self._tc)
+ ogg.theora_info_init(&self._ti)
+ while not f :
+ if _read() == 0 :
+ break
+ while ogg.ogg_sync_pageout(&self._oy, &_oggPage) > 0 :
+ if not ogg.ogg_page_bos(&_oggPage) :
+ queue_page(&_oggPage)
+ f = 1
+ break
+ ogg.ogg_stream_init(&_oggStream, ogg.ogg_page_serialno(&_oggPage))
+ ogg.ogg_stream_pagein(&_oggStream, &_oggPage)
+ ogg.ogg_stream_packetout(&_oggStream, &_oggPacket)
+
+ if(!theora_p && theora_decode_header(&ti,&tc,&op)>=0){
+ /* it is theora -- save this stream state */
+ memcpy(&to,&test,sizeof(test));
+ theora_p=1;
+ else :
+ /* whatever it is, we don't care about it */
+ ogg_stream_clear(&test);
+
+
+
+ lx = self._squareup(img.size[0])
+ ly = self._squareup(img.size[1])
+ if lx != img.size[0] or ly != img.size[1] :
+ idata = idata.resize((lx, ly))
+ self._resize(3, lx, ly, 1)
+ for b from 0 <= b < lx*ly :
+ d = idata[b]
+ for c from 0 <= c < self._chans :
+ self._texels[(b*self._chans)+c] = d[c]
+
+ cdef int _read(self) :
+ cdef char *_buffer
+ cdef int _bytes
+ _buffer = ogg.ogg_sync_buffer(&self._oy, 4096)
+ _bytes = stdio.fread(_buffer, 1, 4096, self._fd)
+ ogg.ogg_sync_wrote(&self._oy, _bytes)
+ return(_bytes)
+
+ cdef int _getOggPage(self, *) :
+
+ while 1 :
+ if _read() == 0 :
+ # End of File
+ return -1
+ while ogg.ogg_sync_pageout(&self._oy, &_oggPage) > 0 :
+ if not ogg.ogg_page_bos(&_oggPage) :
+ queue_page(&_oggPage)
+ f = 1
+ break
+
+
+ cdef #### :
+ cdef ogg.yuv_buffer yuv
+ ogg.theora_decode_YUVout(&self._td,&yuv);
+
Modified: trunk/pysoy/src/textures/soy.textures.pxd
===================================================================
--- trunk/pysoy/src/textures/soy.textures.pxd 2007-07-04 20:32:03 UTC (rev
347)
+++ trunk/pysoy/src/textures/soy.textures.pxd 2007-07-04 20:33:50 UTC (rev
348)
@@ -18,6 +18,7 @@
# $Id$
cimport gl
+cimport ogg
cimport py
cimport stdio
cimport soy._internals
@@ -37,3 +38,15 @@
cdef void _bind(self)
cdef void _resize(self, int, int, int, int)
cdef int _squareup(self, int)
+
+cdef class Video (Texture) :
+ cdef ogg.ogg_sync_state _oy
+ cdef ogg.ogg_page _og
+ cdef ogg.ogg_stream_state _vo
+ cdef ogg.ogg_stream_state _to
+ cdef ogg.theora_info _ti
+ cdef ogg.theora_comment _tc
+ cdef ogg.theora_state _td
+ cdef void *_fd
+ # C methods
+ cdef int _read(self)
Modified: trunk/pysoy/src/textures/soy.textures.pyx
===================================================================
--- trunk/pysoy/src/textures/soy.textures.pyx 2007-07-04 20:32:03 UTC (rev
347)
+++ trunk/pysoy/src/textures/soy.textures.pyx 2007-07-04 20:33:50 UTC (rev
348)
@@ -25,3 +25,4 @@
include "Texture.pxi"
include "Image.pxi"
+include "Video.pxi"
Copied: trunk/pysoy/src/transports (from rev 341, trunk/pysoy/src/storage)
Deleted: trunk/pysoy/src/transports/File.pxi
===================================================================
--- trunk/pysoy/src/storage/File.pxi 2007-07-04 02:23:20 UTC (rev 341)
+++ trunk/pysoy/src/transports/File.pxi 2007-07-04 20:33:50 UTC (rev 348)
@@ -1,59 +0,0 @@
-# PySoy storage.File Class
-#
-# Copyright (C) 2006,2007 Team PySoy
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-
-cdef class File :
- '''PySoy File
-
- This class handles loading and saving .soy and .ogg files to disk.
- '''
- def __new__(self, path, *args, **keywords) :
- cdef char _magic[4]
- self._path = path
- self._file = stdio.fopen(self._path, 'r')
- if not self._file :
- return
- if stdio.fread(<void *>_magic, 1, 4, self._file) < 4 :
- stdio.fclose(self._file)
- return
- if _magic[:4] != 'OggS' :
- stdio.fclose(self._file)
- raise IOError('Unknown file format')
- stdio.rewind(self._file)
-
- cdef int _read(self, ogg2_sync_state* _sync) :
- cdef unsigned char *_buff
- cdef int _byts
- _buff = ogg.ogg2_sync_bufferin(_sync, 4096)
- if _buff == NULL :
- return ogg.OGG2_EEOS
- _byts = stdio.fread(_buff, 1, 4096, self._file)
- if _byts == 0 :
- return ogg.OGG2_EEOS
- self._oset = self._oset + _byts
- return ogg.ogg2_sync_wrote(_sync, _byts)
- return
-
- cdef int _write(self, ogg2_sync_state* _sync) :
- cdef unsigned char *_buff
- cdef int _byts
- _byts = ogg.ogg2_sync_bufferout(_sync, &_buff)
- if _byts == 0 :
- return ogg.OGG2_SUCCESS
- _byts = stdio.fwrite(_buff, 1, _byts, self._file)
- return ogg.ogg2_sync_read(_sync, _byts)
Copied: trunk/pysoy/src/transports/File.pxi (from rev 347,
trunk/pysoy/src/storage/File.pxi)
===================================================================
--- trunk/pysoy/src/transports/File.pxi (rev 0)
+++ trunk/pysoy/src/transports/File.pxi 2007-07-04 20:33:50 UTC (rev 348)
@@ -0,0 +1,167 @@
+# PySoy storage.File Class
+#
+# Copyright (C) 2006,2007 Team PySoy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+cdef class File :
+ '''PySoy File
+
+ This class handles loading and saving .soy and .ogg files to disk.
+ '''
+ def __new__(self, *args, **keywords) :
+ self._chan = []
+
+ def __init__(self, path, *args, **keywords) :
+ cdef char _magic[4]
+ self._path = path
+ self._file = stdio.fopen(self._path, 'r')
+ if not self._file :
+ return
+ if stdio.fread(<void *>_magic, 1, 4, self._file) < 4 :
+ stdio.fclose(self._file)
+ return
+ if _magic[:4] != 'OggS' :
+ stdio.fclose(self._file)
+ raise IOError('Unknown file format')
+ stdio.rewind(self._file)
+
+ cdef int _read(self, ogg2_sync_state* _sync) :
+ cdef unsigned char *_buff
+ cdef int _byts
+ _buff = ogg.ogg2_sync_bufferin(_sync, 4096)
+ if _buff == NULL :
+ return ogg.OGG2_EEOS
+ _byts = stdio.fread(_buff, 1, 4096, self._file)
+ if _byts == 0 :
+ return ogg.OGG2_EEOS
+ self._oset = self._oset + _byts
+ return ogg.ogg2_sync_wrote(_sync, _byts)
+ return
+
+ cdef int _write(self, ogg2_sync_state* _sync) :
+ cdef unsigned char *_buff
+ cdef int _byts
+ _byts = ogg.ogg2_sync_bufferout(_sync, &_buff)
+ if _byts == 0 :
+ return ogg.OGG2_SUCCESS
+ _byts = stdio.fwrite(_buff, 1, _byts, self._file)
+ return ogg.ogg2_sync_read(_sync, _byts)
+
+ cdef void _scan(self) :
+ # Run scan for objects
+ _bytes = 1
+ _offset = 0
+ _page.header = NULL
+ _page.body = NULL
+ _packet.packet = NULL
+ _packbuffer = <ogg.ogg2pack_buffer *> py.PyMem_Malloc(
+ ogg.ogg2pack_buffersize())
+ if _packbuffer == NULL :
+ raise('Out of Memory')
+ _sync = ogg.ogg2_sync_create()
+ while _bytes>0 :
+ # This loops for each chained object in the file
+ streams = {}
+ _start = _offset
+ _inhead = 1
+
+ while True :
+ while not (_status==1 or _bytes==0) :
+ _status = ogg.ogg2_sync_pageout(_sync, &_page)
+ if _status==1 :
+ break
+ _filebuffer = ogg.ogg2_sync_bufferin(_sync, 4096)
+ _bytes = stdio.fread(_filebuffer, 1, 4096, self._file)
+ _status = ogg.ogg2_sync_wrote(_sync, _bytes)
+ if _status != ogg.OGG2_SUCCESS :
+ py.PyMem_Free(_packbuffer)
+ ogg.ogg2_page_release(&_page)
+ raise('Error writing to ogg2_sync buffer')
+ _status = ogg.ogg2_sync_pageout(_sync, &_page)
+ if _bytes==0 :
+ break
+ _serialno = ogg.ogg2_page_serialno(&_page)
+ _offset = _offset + _page.header_len + _page.body_len
+ if streams.has_key(_serialno) :
+ ogg.ogg2_page_release(&_page)
+ _inhead = 0
+ _status = 0
+ else :
+ if _inhead :
+ _end = _offset
+ # Read packet0 to a header string
+ _stream = ogg.ogg2_stream_create(_serialno)
+ _status = ogg.ogg2_stream_pagein(_stream, &_page)
+ _status = ogg.ogg2_stream_packetout(_stream, &_packet)
+ ogg.ogg2packB_readinit(_packbuffer, _packet.packet)
+ if ogg.ogg2packB_read(_packbuffer, 32, &_v) == 0 :
+ # detect then call the codec packet0 scanner
+ if _v == 1936685312 :
+ streams[_serialno] = ['.soy0','','']
+ # Read Class Name
+ ogg.ogg2packB_read(_packbuffer, 8, &_v)
+ for _i from 0 <= _i < _v :
+ ogg.ogg2packB_read(_packbuffer, 8, &_c)
+ _string[_i] = _c
+ streams[_serialno][1] = _string[:_v]
+ # Read Object Name
+ ogg.ogg2packB_read(_packbuffer, 8, &_v)
+ for _i from 0 <= _i < _v :
+ ogg.ogg2packB_read(_packbuffer, 8, &_c)
+ _string[_i] = _c
+ streams[_serialno][2] = _string[:_v]
+ elif _v == 24538994 :
+ streams[_serialno] = 'Vorbis'
+ elif _v == 2155112549L :
+ streams[_serialno] = 'Theora'
+ elif _v == 7828073 :
+ streams[_serialno] = 'Writ'
+ elif _v == 1399874917L :
+ streams[_serialno] = 'Speex'
+ elif _v == 2135313473L :
+ streams[_serialno] = 'FLAC'
+ else :
+ streams[_serialno] = 'Unknown'
+ ogg.ogg2_stream_destroy(_stream)
+ _status = 0
+ else :
+ break
+ codecs = streams.values()
+ codecs.sort()
+ if codecs[0][0] == '.soy0' :
+ for stream in streams :
+ if streams[stream][0] == '.soy0' :
+ modstr = '.'.join(streams[stream][1].split('.')[:-1])
+ clsstr = streams[stream][1].split('.')[-1]
+ module = __import__(modstr, [], [], [clsstr])
+ self._objs[streams[stream][2]] = module.__dict__[clsstr]()
+ # Ok, start main loop over, using this page first thing
+ _status = 1
+ py.PyMem_Free(_packbuffer)
+ ogg.ogg2_sync_destroy(_sync)
+
+ def __getitem__(self, key) :
+ return self._chan[key]
+
+ def __repr__(self) :
+ return self._chan.__repr__()
+
+ def __str__(self) :
+ return self._chan.__str__()
+
+ def __len__(self) :
+ return self._chan.__len__()
Deleted: trunk/pysoy/src/transports/Soy.pxi
===================================================================
--- trunk/pysoy/src/storage/Soy.pxi 2007-07-04 02:23:20 UTC (rev 341)
+++ trunk/pysoy/src/transports/Soy.pxi 2007-07-04 20:33:50 UTC (rev 348)
@@ -1,39 +0,0 @@
-# PySoy transports.Soy Class
-#
-# Copyright (C) 2006,2007 Team PySoy
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-
-cdef class Soy :
- '''PySoy "Soy" transport container
-
- This is a dict-like class for muxing PySoy datatypes together.
- '''
- def __new__(self) :
- self._objs = {}
-
- def __getitem__(self, key) :
- return self._objs[key]
-
- def __repr__(self) :
- return self._objs.__repr__()
-
- def __str__(self) :
- return self._objs.__str__()
-
- def keys(self) :
- return self._objs.keys()
-
Copied: trunk/pysoy/src/transports/Soy.pxi (from rev 347,
trunk/pysoy/src/storage/Soy.pxi)
===================================================================
--- trunk/pysoy/src/transports/Soy.pxi (rev 0)
+++ trunk/pysoy/src/transports/Soy.pxi 2007-07-04 20:33:50 UTC (rev 348)
@@ -0,0 +1,39 @@
+# PySoy transports.Soy Class
+#
+# Copyright (C) 2006,2007 Team PySoy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+cdef class Soy :
+ '''PySoy "Soy" transport container
+
+ This is a dict-like class for muxing PySoy datatypes together.
+ '''
+ def __new__(self) :
+ self._objs = {}
+
+ def __getitem__(self, key) :
+ return self._objs[key]
+
+ def __repr__(self) :
+ return self._objs.__repr__()
+
+ def __str__(self) :
+ return self._objs.__str__()
+
+ def keys(self) :
+ return self._objs.keys()
+
Deleted: trunk/pysoy/src/transports/Store.pxi
===================================================================
--- trunk/pysoy/src/storage/Store.pxi 2007-07-04 02:23:20 UTC (rev 341)
+++ trunk/pysoy/src/transports/Store.pxi 2007-07-04 20:33:50 UTC (rev
348)
@@ -1,131 +0,0 @@
-# PySoy storage.Store Class
-#
-# Copyright (C) 2006,2007 Team PySoy
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-
-cdef class Transport :
- '''PySoy Transport
-
- This class provides the basic data stream parsing for all transports.
- '''
- def __new__(self, *args, **keywords) :
- self._chan = []
-
- cdef void _scan(self) :
- # Run scan for objects
- _bytes = 1
- _offset = 0
- _page.header = NULL
- _page.body = NULL
- _packet.packet = NULL
- _packbuffer = <ogg.ogg2pack_buffer *> py.PyMem_Malloc(
- ogg.ogg2pack_buffersize())
- if _packbuffer == NULL :
- raise('Out of Memory')
- _sync = ogg.ogg2_sync_create()
- while _bytes>0 :
- # This loops for each chained object in the file
- streams = {}
- _start = _offset
- _inhead = 1
-
- while True :
- while not (_status==1 or _bytes==0) :
- _status = ogg.ogg2_sync_pageout(_sync, &_page)
- if _status==1 :
- break
- _filebuffer = ogg.ogg2_sync_bufferin(_sync, 4096)
- _bytes = stdio.fread(_filebuffer, 1, 4096, self._file)
- _status = ogg.ogg2_sync_wrote(_sync, _bytes)
- if _status != ogg.OGG2_SUCCESS :
- py.PyMem_Free(_packbuffer)
- ogg.ogg2_page_release(&_page)
- raise('Error writing to ogg2_sync buffer')
- _status = ogg.ogg2_sync_pageout(_sync, &_page)
- if _bytes==0 :
- break
- _serialno = ogg.ogg2_page_serialno(&_page)
- _offset = _offset + _page.header_len + _page.body_len
- if streams.has_key(_serialno) :
- ogg.ogg2_page_release(&_page)
- _inhead = 0
- _status = 0
- else :
- if _inhead :
- _end = _offset
- # Read packet0 to a header string
- _stream = ogg.ogg2_stream_create(_serialno)
- _status = ogg.ogg2_stream_pagein(_stream, &_page)
- _status = ogg.ogg2_stream_packetout(_stream, &_packet)
- ogg.ogg2packB_readinit(_packbuffer, _packet.packet)
- if ogg.ogg2packB_read(_packbuffer, 32, &_v) == 0 :
- # detect then call the codec packet0 scanner
- if _v == 1936685312 :
- streams[_serialno] = ['.soy0','','']
- # Read Class Name
- ogg.ogg2packB_read(_packbuffer, 8, &_v)
- for _i from 0 <= _i < _v :
- ogg.ogg2packB_read(_packbuffer, 8, &_c)
- _string[_i] = _c
- streams[_serialno][1] = _string[:_v]
- # Read Object Name
- ogg.ogg2packB_read(_packbuffer, 8, &_v)
- for _i from 0 <= _i < _v :
- ogg.ogg2packB_read(_packbuffer, 8, &_c)
- _string[_i] = _c
- streams[_serialno][2] = _string[:_v]
- elif _v == 24538994 :
- streams[_serialno] = 'Vorbis'
- elif _v == 2155112549L :
- streams[_serialno] = 'Theora'
- elif _v == 7828073 :
- streams[_serialno] = 'Writ'
- elif _v == 1399874917L :
- streams[_serialno] = 'Speex'
- elif _v == 2135313473L :
- streams[_serialno] = 'FLAC'
- else :
- streams[_serialno] = 'Unknown'
- ogg.ogg2_stream_destroy(_stream)
- _status = 0
- else :
- break
- codecs = streams.values()
- codecs.sort()
- if codecs[0][0] == '.soy0' :
- for stream in streams :
- if streams[stream][0] == '.soy0' :
- modstr = '.'.join(streams[stream][1].split('.')[:-1])
- clsstr = streams[stream][1].split('.')[-1]
- module = __import__(modstr, [], [], [clsstr])
- self._objs[streams[stream][2]] = module.__dict__[clsstr]()
- # Ok, start main loop over, using this page first thing
- _status = 1
- py.PyMem_Free(_packbuffer)
- ogg.ogg2_sync_destroy(_sync)
-
- def __getitem__(self, key) :
- return self._chan[key]
-
- def __repr__(self) :
- return self._chan.__repr__()
-
- def __str__(self) :
- return self._chan.__str__()
-
- def __len__(self) :
- return self._chan.__len__()
Copied: trunk/pysoy/src/transports/Transport.pxi (from rev 347,
trunk/pysoy/src/storage/Transport.pxi)
===================================================================
--- trunk/pysoy/src/transports/Transport.pxi (rev 0)
+++ trunk/pysoy/src/transports/Transport.pxi 2007-07-04 20:33:50 UTC (rev
348)
@@ -0,0 +1,131 @@
+# PySoy storage.Store Class
+#
+# Copyright (C) 2006,2007 Team PySoy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+cdef class Transport :
+ '''PySoy Transport
+
+ This class provides the basic data stream parsing for all transports.
+ '''
+ def __new__(self, *args, **keywords) :
+ self._chan = []
+
+ cdef void _scan(self) :
+ # Run scan for objects
+ _bytes = 1
+ _offset = 0
+ _page.header = NULL
+ _page.body = NULL
+ _packet.packet = NULL
+ _packbuffer = <ogg.ogg2pack_buffer *> py.PyMem_Malloc(
+ ogg.ogg2pack_buffersize())
+ if _packbuffer == NULL :
+ raise('Out of Memory')
+ _sync = ogg.ogg2_sync_create()
+ while _bytes>0 :
+ # This loops for each chained object in the file
+ streams = {}
+ _start = _offset
+ _inhead = 1
+
+ while True :
+ while not (_status==1 or _bytes==0) :
+ _status = ogg.ogg2_sync_pageout(_sync, &_page)
+ if _status==1 :
+ break
+ _filebuffer = ogg.ogg2_sync_bufferin(_sync, 4096)
+ _bytes = stdio.fread(_filebuffer, 1, 4096, self._file)
+ _status = ogg.ogg2_sync_wrote(_sync, _bytes)
+ if _status != ogg.OGG2_SUCCESS :
+ py.PyMem_Free(_packbuffer)
+ ogg.ogg2_page_release(&_page)
+ raise('Error writing to ogg2_sync buffer')
+ _status = ogg.ogg2_sync_pageout(_sync, &_page)
+ if _bytes==0 :
+ break
+ _serialno = ogg.ogg2_page_serialno(&_page)
+ _offset = _offset + _page.header_len + _page.body_len
+ if streams.has_key(_serialno) :
+ ogg.ogg2_page_release(&_page)
+ _inhead = 0
+ _status = 0
+ else :
+ if _inhead :
+ _end = _offset
+ # Read packet0 to a header string
+ _stream = ogg.ogg2_stream_create(_serialno)
+ _status = ogg.ogg2_stream_pagein(_stream, &_page)
+ _status = ogg.ogg2_stream_packetout(_stream, &_packet)
+ ogg.ogg2packB_readinit(_packbuffer, _packet.packet)
+ if ogg.ogg2packB_read(_packbuffer, 32, &_v) == 0 :
+ # detect then call the codec packet0 scanner
+ if _v == 1936685312 :
+ streams[_serialno] = ['.soy0','','']
+ # Read Class Name
+ ogg.ogg2packB_read(_packbuffer, 8, &_v)
+ for _i from 0 <= _i < _v :
+ ogg.ogg2packB_read(_packbuffer, 8, &_c)
+ _string[_i] = _c
+ streams[_serialno][1] = _string[:_v]
+ # Read Object Name
+ ogg.ogg2packB_read(_packbuffer, 8, &_v)
+ for _i from 0 <= _i < _v :
+ ogg.ogg2packB_read(_packbuffer, 8, &_c)
+ _string[_i] = _c
+ streams[_serialno][2] = _string[:_v]
+ elif _v == 24538994 :
+ streams[_serialno] = 'Vorbis'
+ elif _v == 2155112549L :
+ streams[_serialno] = 'Theora'
+ elif _v == 7828073 :
+ streams[_serialno] = 'Writ'
+ elif _v == 1399874917L :
+ streams[_serialno] = 'Speex'
+ elif _v == 2135313473L :
+ streams[_serialno] = 'FLAC'
+ else :
+ streams[_serialno] = 'Unknown'
+ ogg.ogg2_stream_destroy(_stream)
+ _status = 0
+ else :
+ break
+ codecs = streams.values()
+ codecs.sort()
+ if codecs[0][0] == '.soy0' :
+ for stream in streams :
+ if streams[stream][0] == '.soy0' :
+ modstr = '.'.join(streams[stream][1].split('.')[:-1])
+ clsstr = streams[stream][1].split('.')[-1]
+ module = __import__(modstr, [], [], [clsstr])
+ self._objs[streams[stream][2]] = module.__dict__[clsstr]()
+ # Ok, start main loop over, using this page first thing
+ _status = 1
+ py.PyMem_Free(_packbuffer)
+ ogg.ogg2_sync_destroy(_sync)
+
+ def __getitem__(self, key) :
+ return self._chan[key]
+
+ def __repr__(self) :
+ return self._chan.__repr__()
+
+ def __str__(self) :
+ return self._chan.__str__()
+
+ def __len__(self) :
+ return self._chan.__len__()
Deleted: trunk/pysoy/src/transports/soy.storage.pxd
===================================================================
--- trunk/pysoy/src/storage/soy.storage.pxd 2007-07-04 02:23:20 UTC (rev
341)
+++ trunk/pysoy/src/transports/soy.storage.pxd 2007-07-04 20:33:50 UTC (rev
348)
@@ -1,35 +0,0 @@
-# PySoy storage declarations
-#
-# Copyright (C) 2007 Team PySoy
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-
-cimport ogg
-cimport py
-cimport stdio
-cimport soy._internals
-
-cdef struct OggStream :
- char _name[257]
- ogg.ogg2_stream_state *state
-
-cdef class File :
- cdef object _path
- cdef object _objs
- cdef void* _file
- cdef int _mode # 0 = idle, 1 = load, 2 = save
- cdef ogg.ogg2_sync_state *_sync
- cdef OggStream _stat[256]
Deleted: trunk/pysoy/src/transports/soy.storage.pyx
===================================================================
--- trunk/pysoy/src/storage/soy.storage.pyx 2007-07-04 02:23:20 UTC (rev
341)
+++ trunk/pysoy/src/transports/soy.storage.pyx 2007-07-04 20:33:50 UTC (rev
348)
@@ -1,28 +0,0 @@
-'''Storage
-
- These classes are used to load and save PySoy data over various mediums
-'''
-__credits__ = '''Copyright (C) 2007 PySoy Group
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see http://www.gnu.org/licenses
-'''
-__author__ = '''Maintained by ArcRiley'''
-__date__ = 'Last change on '+ \
- '$Date$'[7:-20]+ \
- 'by '+'$Author$'[9:-2]
-__version__ = 'Trunk (r'+'$Rev$'[6:-2]+')'
-
-include "File.pxi"
-include "Soy.pxi"
-include "Store.pxi"
Copied: trunk/pysoy/src/transports/soy.transports.pxd (from rev 347,
trunk/pysoy/src/storage/soy.transports.pxd)
===================================================================
--- trunk/pysoy/src/transports/soy.transports.pxd
(rev 0)
+++ trunk/pysoy/src/transports/soy.transports.pxd 2007-07-04 20:33:50 UTC
(rev 348)
@@ -0,0 +1,35 @@
+# PySoy storage declarations
+#
+# Copyright (C) 2007 Team PySoy
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+
+cimport ogg
+cimport py
+cimport stdio
+cimport soy._internals
+
+cdef struct OggStream :
+ char _name[257]
+ ogg.ogg2_stream_state *state
+
+cdef class File :
+ cdef object _path
+ cdef object _objs
+ cdef void* _file
+ cdef int _mode # 0 = idle, 1 = load, 2 = save
+ cdef ogg.ogg2_sync_state *_sync
+ cdef OggStream _stat[256]
Copied: trunk/pysoy/src/transports/soy.transports.pyx (from rev 347,
trunk/pysoy/src/storage/soy.transports.pyx)
===================================================================
--- trunk/pysoy/src/transports/soy.transports.pyx
(rev 0)
+++ trunk/pysoy/src/transports/soy.transports.pyx 2007-07-04 20:33:50 UTC
(rev 348)
@@ -0,0 +1,27 @@
+'''Storage
+
+ These classes are used to load and save PySoy data over various mediums
+'''
+__credits__ = '''Copyright (C) 2007 PySoy Group
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see http://www.gnu.org/licenses
+'''
+__author__ = '''Maintained by ArcRiley'''
+__date__ = 'Last change on '+ \
+ '$Date$'[7:-20]+ \
+ 'by '+'$Author$'[9:-2]
+__version__ = 'Trunk (r'+'$Rev$'[6:-2]+')'
+
+include "Transport.pxi"
+include "File.pxi"
Modified: trunk/pysoy/src/widgets/Canvas.pxi
===================================================================
--- trunk/pysoy/src/widgets/Canvas.pxi 2007-07-04 20:32:03 UTC (rev 347)
+++ trunk/pysoy/src/widgets/Canvas.pxi 2007-07-04 20:33:50 UTC (rev 348)
@@ -24,14 +24,14 @@
'''
def __new__(self, parent, position=(0,0), size=(0,0),
texture=None, *args, **keywords) :
- self._verts[0].ty = 1.0
self._verts[1].px = 1.0
self._verts[1].tx = 1.0
- self._verts[1].ty = 1.0
self._verts[2].px = 1.0
self._verts[2].py = 1.0
self._verts[2].tx = 1.0
+ self._verts[2].ty = 1.0
self._verts[3].py = 1.0
+ self._verts[3].ty = 1.0
self._faces[0].a = 0
self._faces[0].b = 1
self._faces[0].c = 2
Modified: trunk/pysoy/src/widgets/Projector.pxi
===================================================================
--- trunk/pysoy/src/widgets/Projector.pxi 2007-07-04 20:32:03 UTC (rev
347)
+++ trunk/pysoy/src/widgets/Projector.pxi 2007-07-04 20:33:50 UTC (rev
348)
@@ -44,10 +44,10 @@
gl.glClear(gl.GL_DEPTH_BUFFER_BIT)
gl.glEnable(gl.GL_LIGHTING)
- bright[0]=1
- bright[1]=1
- bright[2]=1
- bright[3]=1
+ bright[0]=.5
+ bright[1]=.5
+ bright[2]=.5
+ bright[3]=.5
gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, bright);
self._camera._project()
gl.glDisable(gl.GL_LIGHTING)
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn