[Mirra] Mirra

enrike enrike at ixi-software.net
Wed Nov 29 12:58:16 CET 2006


hi ben

I am getting a copy of OSX 10.4 tomorrow so I will be able to test this 
properly soon. Did you manage to make it install properly in the end?

Now I am working on wxPython support for Mirra but it is pretty tricky I 
have a bug on Linux that i have been days trying to find fix. No much 
luck so far. WxPython is nice for people wanting to combine both opengl 
rendering and normal widgets (menus, dialogues).

So far I havent been able to go into the nurbs stuff yet. I got a book 
on OpenGL programming so I guess in the next months I will be able to 
improve and extend the rendering possibilities.

Btw, i am working with ChucK for the sound engines in the apps I build 
with mirra, and it integrates with python really well. Much better than 
PD, I think i am going for that solution.

best

enrike


B. Bogart wrote:
> Hi Enrike,
> 
> I'll check again at school, but I already assumed all this when
> installing the first time, being sure to run python2.4 setup.py install
> and so forth.
> 
> Does mirra bail on only pygame, pyopengl ? or also on py2exe? (which we
> did not install)
> 
> Maybe that was it...
> 
> I'll investigate more next week.
> 
> I'll ask the resident openGL guru at my University about the NURBS stuff.
> 
> .b.
> 
> enrike wrote:
>> hi again ben
>>
>> to put the prev email in few lines:
>> the version of python that runs the installer script (setup.py), and the
>> one you use to run mirra scripts must be the same that has the libraries
>> (pyopengl,pygame) installed. Otherwise when it tests if they are there
>> it quits.
>>
>> on /usr/bin there is a python symlink that points into either python2.3
>> or python 2.4. I would say you need to find which of them has the
>> libraries installed (like i described in prev email) and makes the
>> python symlink point to that one.
>>
>> But this should have been automatically when you install python2.4 on
>> top of the built-in python version. Of course all this if you have
>> actually installed a newer version of python on your system. Otherwise I
>> would say the libraries are not installed properly.
>>
>> I hope this helps, let me know if you get it running
>>
>> enrike
>>
>>
>> B. Bogart wrote:
>>> Hi Enrike,
>>>
>>> Thanks for the long email with lots of detail.
>>>
>>> I had some troubles with the OSX installation of Mirra, on a g5 10.4
>>> machine. Even though the wxpython, pygame and pyopengl extensions are
>>> installed mirra fails to install saying it depends on those libs (which
>>> I suppose means it does not seem em.)
>>>
>>> Since 10.4 comes with python, when you install OSX binary extensions
>>> (and python2.4 itself) what is the relation between the version included
>>> in the system and the newer version? Are the extensions all installed to
>>> the same place, or do they only work in one or the other.
>>>
>>> We downloaded everything from the python.org site directly...
>>>
>>> Now I can't remember if we tried import opengl, import pygame in the
>>> interactive interpreter... hmmmm.
>>>
>>> I'm subscribing to the list as we speak.
>>>
>>> I'll keep hacking away and keep you posted. I did not consider there was
>>> a render method in main!!! I'll start with that before creating my own
>>> class (which I don't have much time for ATM) still no luck with the
>>> NURBS, I need a GL guru, too many arrays as arguments...
>>>
>>> .b.
>>>
>>> enrike wrote:
>>>> hi ben
>>>>
>>>> B. Bogart wrote:
>>>>> Hi Enrike!
>>>>>
>>>>> We met at piksel this year, talked a whole lot about processing.
>>>>>
>>>>> So I've started to use Mirra to get a few of the folks here off
>>>>> processing. The first guy wants to compute nice spline curves fast.
>>>>>
>>>>> I'm using the 05 openGL example that inherets from circle, but what is
>>>>> the cleanest simplest way to use raw opengL commands in mirra? I
>>>>> tried a
>>>>> few things but could not get it to work. does it have to happen inside
>>>>> the render method of an existing class?
>>>> yes or in the main render, but careful with pushmatrix/popmatrix
>>>>
>>>> i am not sure whats in the current online version but if you check in
>>>> the svn server (devel.goto10.org) you will find under examples a couple
>>>> of them called
>>>> directdrawOpenGL.py
>>>> and
>>>> 05complesshapesOpenGL.py
>>>>
>>>> both are different ways of doing pure opengl directly either in the main
>>>> app's render of within the built-in classes render method.
>>>> In general you could create any class that inherits from graphics.Base
>>>> and code opengl inside the render. I actually attach the examples to
>>>> this email
>>>>
>>>>> I'm also slowly figuring out how to render nurbs curves in openGL...
>>>> there are some built in functions in the Gl library for this i think.
>>>> The pyOpenGL reference is here
>>>> http://pyopengl.sourceforge.net/documentation/manual/
>>>> here are some
>>>> http://pyopengl.sourceforge.net/documentation/manual/gluBeginCurve.3G.xml
>>>>
>>>> http://pyopengl.sourceforge.net/documentation/manual/gluBeginSurface.3G.xml
>>>>
>>>> http://pyopengl.sourceforge.net/documentation/manual/gluBeginTrim.3G.xml
>>>> http://pyopengl.sourceforge.net/documentation/manual/gluDeleteNurbsRenderer.3G.xml
>>>>
>>>>
>>>> I can see that there are few others, I have never used them. Let me know
>>>> if you get something to work and we can add it to mirra. great!
>>>>
>>>>> If you can send me a simple example that just renders a poly with
>>>>> glBegin(POLYGON) -> Vertex3f(...) -> glEnd() that would be a great
>>>>> start.
>>>>>
>>>>> Once I get going on Mirra I would like to contribute shape classes to
>>>>> it, is there any guide for contribution other than the existing src?
>>>> not at all... I havent thought about that and sadly do not have any
>>>> experience of working in the same code with other people. I am open to
>>>> suggestions. The latest code is always in the svn server at
>>>> devel.goto10.org section ixi > python > mirra
>>>>
>>>> I guess you should read carefully the documentation.html included in the
>>>>  distribution, it is as well online here
>>>> http://ixi-software.net/content/download/mirra/documentation.html
>>>> There are some descriptions of different parts of the system that i
>>>> guess would help you understanding better why it is like it is now.
>>>>
>>>> there is also a mailing list for this type of issues here:
>>>> http://lists.goto10.org/cgi-bin/mailman/listinfo/mirra
>>>> but we are only two subscribed at the moment :( if you subscribe to it
>>>> and have this conversations in the mailing list it would be great. it
>>>> would feel like the beginning of something for me :)
>>>>
>>>> I was yesterday talking for couple of hours to Tom Better
>>>> (nullpointer.co.uk) who is very good at opengl and he was talking to me
>>>> about ways to optimise it, but doesnt sound very easy tak to do. Well
>>>> ... we will see. As i said in bergen it is a working prototype.
>>>>
>>>> if you want to have new types of shapes using curves what I would do it
>>>> to define a new class in your working file that extends Base, this will
>>>> give you access to all the methods and props from Base (described in the
>>>> docs). Then you would extend the render method to allow that class to
>>>> draw itself as a shape with curves. But you could also just new class
>>>> and as long as you trigger a function where the drawing happens from the
>>>> main app render method it should work
>>>>
>>>> the way it the built in shapes is that he engine knows a function to
>>>> draw each type of shapes, then the classes just call that function from
>>>> the render method passing its prorpoerties, for example a Circle calls
>>>> engine.drawCircle(self.x,self.y,self.z,self.width .....)
>>>>
>>>> If you get your nurbs class to work please send it to me and i cant try
>>>> to add that new function to the engine and create a new class for it. Or
>>>> you would do it yourself as well but i am not sure my explanation is
>>>> very clear ... I would say the more straight way would be to define a
>>>> class extending Base, this autamatically adds an instance of it to the
>>>> render stack and calls its the render methods once per frame.
>>>>
>>>> please let me know any question of wishes or anything you want to add or
>>>> change. And keep me up to date with what you do, this is really nice and
>>>> i would be more than happy to help.
>>>>
>>>> thanks!
>>>>
>>>> enrike
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> #!/usr/bin/env python
>>>>
>>>> from mirra import main
>>>> from mirra.graphics import *
>>>> from mirra import utilities
>>>>
>>>>
>>>> """ Mirra : 2D graphic engine in OpenGL by www.ixi-software.net
>>>>     Check out documentation files
>>>> """
>>>>
>>>>
>>>> class MirraApp(main.App):
>>>>     """ main appplication class, handles window contains events and
>>>> graphics manager.
>>>>         Subclasses main.App and extends its public methods
>>>>     """
>>>>     def setUp(self):
>>>>         """ set here the main window properties and characteristics
>>>>         """
>>>>         self.env = "pygame" # enviroment : 'pygame', 'wx'
>>>>         self.caption = "mirra example drawing complex shapes 1" #
>>>> window name
>>>>         self.size = 640,460 # window size. Note: if fullScreen is set
>>>> to 1 then you MUST pass the current screen resolution here
>>>>         self.pos = 100,100 # window top left location
>>>>         self.fullScreen = 0 # fullscreen / non fullscreen
>>>>         self.frameRate = 35 # set refresh framerate
>>>>
>>>>     def start(self):
>>>>         """ First thing to happen after the instance has been
>>>> initalisiated
>>>>             good place to instanciate classes and init stuff
>>>>         """
>>>>         for z in range(20):
>>>>             w,h = self.size
>>>>             x,y = utilities.randPoint(1,1,w,h)
>>>>             s = Shape(x, y, z, 50, (0.5, 0,8, 0.2, 0.7))
>>>>             s.interactiveState = 2
>>>>             s.rotation = utilities.randint(1,360)
>>>>
>>>>
>>>>
>>>> class Shape(Circle):
>>>>     """ totally overwrites the Circle render function
>>>>         but yet it uses its other methods and props such as
>>>> intersection, it is
>>>>         dragable, it has rotation prop (though this does not rotate
>>>> the shape itself)
>>>>     """
>>>>     def step(self):
>>>>         """ in this case this does not rotate the shape because the
>>>> render method
>>>>         is totally overwriten. But I use this prop in the new render
>>>> to rotate it
>>>>         """
>>>>         self.rotation += 1
>>>>        
>>>>     def render(self,engine):
>>>>         rad = 8
>>>>         inner = rad-2
>>>>                 glPushMatrix() # puch main
>>>>                 glTranslatef(self.x, self.y, -self.z) # where we draw
>>>> this shape?
>>>>         glRotate(self.rotation, 0, 0, 0.1) # here is the rotation
>>>> happening, # shapes rotation
>>>>         glColor4f (self.color[0], self.color[1],self.color[2],
>>>> self.color[3]) # shapes color
>>>>         gluDisk(engine.q, 0, self.width/2, 50, 1)
>>>>
>>>>         glPushMatrix() # push circles
>>>>                glColor4f (0.2, 0.5, 0.2, 0.7) # orbital circles color
>>>>                 glTranslatef(-self.radius, 0, 0)
>>>>         gluDisk(engine.q, inner, rad, 20, 1)
>>>>
>>>>         glTranslatef(self.radius, -self.radius, 0)
>>>>         gluDisk(engine.q, inner, rad, 20, 1)
>>>>
>>>>         glTranslatef(self.radius, self.radius, 0)
>>>>         gluDisk(engine.q, inner, rad, 20, 1)
>>>>
>>>>         glTranslatef(-self.radius, self.radius, 0)
>>>>         gluDisk(engine.q, inner, rad, 20, 1)
>>>>
>>>>         glPopMatrix() # pop from circles
>>>>                     glPopMatrix() # pop from main circle
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> if __name__ == '__main__': MirraApp() # init always your main app
>>>> class that extends main.App
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> #!/usr/bin/env python
>>>>
>>>> from mirra import main
>>>> from mirra.graphics import *
>>>> from mirra import utilities
>>>> """ Mirra : 2D graphic engine in OpenGL by www.ixi-software.net
>>>>     Check out documentation files
>>>> """
>>>> from OpenGL.GL import *
>>>>
>>>>
>>>> class MirraApp(main.App):
>>>>     """ main appplication class, handles window contains events and
>>>> graphics manager.
>>>>         Subclasses main.App and extends its public methods
>>>>     """
>>>>     def setUp(self):
>>>>         """ set here the main window properties and characteristics
>>>>         """
>>>>         self.env = "pygame" # enviroment : 'pygame', 'wx'
>>>>         self.caption = "direct drawing with OpenGL using graphics
>>>> engine instance" # window name
>>>>         self.size = 640,460 # window size. Note: if fullScreen is set
>>>> to 1 then you MUST pass the current screen resolution here
>>>>         self.pos = 100,100 # window top left location
>>>>         self.fullScreen = 0 # fullscreen / non fullscreen
>>>>         self.frameRate = 20 # set refresh framerate
>>>>
>>>>
>>>>     def render(self, e):
>>>>         """ this is receives an instance of the graphics engine 'e'
>>>> that allows to call drawing functions direclty
>>>>         from main application.
>>>>         this method receives an instance of the graphics engine 'e'
>>>> that allows to call drawing functions
>>>>         direclty from main application. Drawing calls from here are
>>>> excuted after all objects on stack
>>>>         are drawn, this means that Z position has no value, they go
>>>> on top of everything and get drawn
>>>>         in order of execution
>>>>         """
>>>>         # draw a line
>>>>         glPushMatrix()
>>>>
>>>>         glTranslatef(self.size[0]/2, self.size[1]/2, 0) # translate
>>>> to window center p0int
>>>> ##        glRotatef(rotation, 0, 0, 0.1)
>>>>         glColor3f (1.0, 0, 0)
>>>>         glLineWidth(10)
>>>>
>>>>         glBegin(GL_LINES)
>>>>         glVertex2i(10, -100) # draw pixel points
>>>>         glVertex2i(200, -200)
>>>>         glEnd()
>>>>         glPopMatrix()
>>>>
>>>>         # draw a circle
>>>>         glPushMatrix()
>>>>                 glTranslatef(200, 200, 0) # translate to window
>>>> center point
>>>>         glColor4f (0.3, 0.5, 0.2, 0.3)
>>>>         gluDisk(gluNewQuadric(), 90, 100, 30, 1) # there is a
>>>> gluNewQuadric() in engine, we could access it with e.q
>>>>                 glPopMatrix()
>>>>        
>>>> if __name__ == '__main__': MirraApp() # init always your main app
>>>> class that extends main.App
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
> 
> 




More information about the Mirra mailing list