The graphics part of Kivy live in Cython, however, the apply() is from
us. We don't expose a way to write custom instruction inside Python,
mostly for a performance issue. If you still want to try your own
instructions, you have no choice to create a .pyx in the
kivy/graphics/ directory, and put your instructions in it.
Care, pure Kivy 3D integration is not yet possible, cause of our fixed
vertex format and shader pipeline. You'll hit severals issue if you
try to add z coordinate :)
However, for another project, we've managed to use Panda3D inside
Kivy. Maybe you'll be interested on that point. Next week, we'll work
on the extension system of Kivy, as soon as the system work, we can
provide custom external extension (Panda3D, berkelium, poppler, ...)
Mathieu
2011/3/29 Olivier <olivier...@gmail.com>:
If you really want to do it yourself, i think you can use from
kivy.graphics.opengl import *
And use RenderContext() + Callback() class : rendercontext will allow
you to setup a custom vertex and fragment shader, and Callback will
call a python method when graphics engine need to update your element.
So yes, i think you might be able to use that approach if you want to
do 3D. Never tested though. :)
2011/3/29 Olivier <olivier...@gmail.com>:
The gluLooAt is implented though though kivy.graphics.transformation package.
Take a look at kivy/core/__init__.py in update_viewport() :
382 from kivy.graphics.transformation import Matrix
390 projection_mat = Matrix()
391 projection_mat.view_clip(0.0, width, 0.0, height, -1.0, 1.0, 0)
And then, the projection matrix is set in the render context :
392 self.render_context['projection_mat'] = projection_mat
They are no glUniformMatrix4fv, cause we are using shader for
rendering. Once you use shader, gl model matrix and projection matrix
are not used. All the transformation work is done inside vertex
shader.
If you check the file kivy/data/glsl/default.fs, you'll see a line :
21 gl_Position = projection_mat * modelview_mat * vec4(vPosition.xy,
0.0, 1.0) ;
Here you are, the projection_mat is the one you set in the
render_context['projection_mat'].
Now, i think you've understand the process, i can warn you about one
thing: the implementation of perspective matrix (in clip_matrix)
function is not yet done. :) Check how the orthogonal clip matrix is
done, and you can take a perspective matrix function from internet
(lgpl code or free domain), and push it in the clip_matrix if
perspective=True. Patch welcome :)
Mathieu
2011/4/1 Olivier <olivier...@gmail.com>:
The current patch is already available here:
http://txzone.net/files/contrib/panda3d/
I didn't retest since June on their latest svn, but i'm planning to
restart the panda port for Kivy + Android during october.
Regards,
Mathieu
2011/9/19 ADNAAN BADR <adn...@notionink.com>: