Can anybody give me any hints on how to create an interactive openGL application using CGKit? I may be wrong, but it seems like the 'viewer.py' script is not really suitable for creating an interactive game or interactive 3D modelling application in Python. What would be a good way to do this?
What problems have you had with the viewer script? Actually, this tool is intended to provide a simple framework for interactive applications like games or VR stuff (it's probably not really suited for a 3D modelling application though).
The viewer tool displays a scene continuously trying to maintain the specified framerate (30fps by default). You can connect to events like mouse, keyboard, joystick and handle them accordingly.
For a more specific help I'd need to know what you want to accomplish and what problems you have had.
- Matthias -
I haven't actually used CGKit besides running and hacking some of the test scripts, so I confess I'm not sure what's available. At this point, I'm still testing the various available 3D toolkits to see what's available. So I don't have any problems yet.
I am looking into developing a specialized 3D modelling application as a research project. Its intended to use a basically new form of interaction, but still using mouse and keyboard.
From what I understand, CGKit basically handles the data and models in a 3D scene and delegates rendering to other projects. I guess I'm wondering how much work it would be, and what options I have for setting up a custom rendering solution.
An example of something I doubt viewer.py can do is display two views of the same scene in different windows (can it do it in the same window?) I'm not certain I need to be able to do that but I'd like to leave the option open. :-)
> From what I understand, CGKit basically handles the data and models in a 3D
> scene and delegates rendering to other projects.
Sort of. But cgkit also contains its own code for doing OpenGL renderings which is used inside the standard viewer. But you're right, the Ogre-Viewer uses Ogre to render the scene and when rendered with the render tool, it's actually a RenderMan renderer that visualizes the scene.
If setting up a custom rendering solution is currently a viable option or not depends on what kind of rendering solution this will be and how efficient it has to be.
Of course, you don't have to use any of the provided viewer tools but can create your own application and still use the cgkit scene management. cgkit stores the 3D data and provides ways to manipulate it. If your application is going to use OpenGL you can even use cgkit's own drawing code to draw either the entire scene or each geometry independently by your own rendering code. Each geometry has a method drawGL() which you may call to draw this particular piece of geometry (see http://cgkit.sourceforge.net/doc2/node141.html\). You may also use the class GLRenderInstance to draw the entire scene (sorry, this class isn't documented, but you might have a look at the draw() method in viewer.py). Basically, you just create an instance of this class, set parameters like viewport settings, handedness, background color, viewing matrix, projection matrix, polygon mode, etc. and eventually call the paint() method with the root object of the scene.
If you're going to use Direct3D you have to extract the vertices and faces from the objects and call the appropriate Direct3D functions. If you can use something like display lists this might also be an option even with pure Python code (unless your scene uses a lot of dynamic meshes).
In the case of the Ogre-Viewer a Ogre scene graph is created from the cgkit scene at startup which is then visualized by Ogre. Changes of the cgkit scene are tracked and applied to the Ogre copy.
You would have to use a similar scheme if you wanted to use any other 3D engine out there.
> An example of something I doubt viewer.py can do is display two views of the
> same scene in different windows (can it do it in the same window?)
The viewer tool cannot do this, it only displays the scene in one single window using one single viewport (an exception is the stereo view but of course, these are no independent views anyway).
But if you have your own main application anyway, it is straightforward to add as you are then in control of rendering anyway.
All right, thanks for the info. That's a big help!
does cgkit have some kind of fixed 2d images,like a game having a top and bottom panels (always fixed and 2d) and a 3d scene, all i mean is like age of empires 3 or some other game. Is there some script or something for having 2d and 3d simultaneously?
You could achieve something like that by creating 3D geometry (probably just a plane) that is parented to the camera and placing a suitable texture on the geometry. But if you're planning on doing something like a 3D game that requires 2D elements then it might be better to create your own "viewer" application that has the appropriate elements using whatever GUI toolkit you like and provide a OpenGL widget for the 3D part.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.