• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 934
  • Last Modified:

OpenGL filing cabinet, file drawers (draws) and reports

I am still grappling with some basic OpenGL concepts and building in interactivity.

Suppose I want a filing cabinet with 4 drawers. Clicking on a draw opens it and displays say 6 suspension files with labels (tabs). Clicking on a tab extracts a report..maybe open in another window.

Can someone give me an overview of the key tasks involved and how they might be implemented in OpenGL?

In particular, should I use a modelling program like Blender3D to build the filing cabinet? If so, what do I get out of that (?some polygons) and how do I incorporate that object into my openGL app.

Secondly, how do I simulate a drawer opening? And report extraction? These seem to me like animations of some sort .. where do I look for an approach to doing these?


  • 2
  • 2
1 Solution
here's the way to go
1.  Build the 3d models in a 3d modeller like blender , anim8or. Save them in common format like 3ds, obj. For importing 3ds data into ur opengl  app u can use l3ds lib . obj is a very simple human readable format and an importer can be manually written.
Another option would be to go for milkshape3d(shareware). Its cpp exporters are readily available, moreover  they support export of animation, which *very few* cpp exporters support.

2. There is no way out for the animation stuff. u need to be creative for that ;)

3. For the interaction part there is something called the selection matrix in opengl.
a. Basically u first associate a id(generated by ogl) with a 'drawer' (or any set of polys).
b. Then render all the selectable items to the selection buffer.(same as render to modelview with a simple change of glMatrixMode(GL_SELECT) ).
c. Finally u read every frame what objects were selected and do the processing.
I can't tell if this is one example, or something bigger.  For just the example:

Build the model as a hierarchy of objects, connected together.  Each object should follow a naming convention, so that you can 'look them up' by name out of the hierarchy.  Blender or any other app will do fine -- you'll want something to do both modeling and animation.

Using a hierarchy means that pulling out the drawer automatically pulls out the folders ('children' of the drawer object).

Build up a set of well-named animations for each action, sub-action, manipulating the cabinet, and a table-based lookup of some sort for accessing which animation to play when.  It'll be state-based, as you'll manage where you are in interaction with the object.  Closed, drawer 1 open, drawer 2 open, drawer 3 open, drawer 4 open, 6 files open per drawer open state... etc.  Based on the state and the action, you know whether you play an opening animation or a closing animation based on the given subobject.  I would say if one drawer is open, and you click another drawer, play 'close' old drawer, then 'open' new drawer.

If you are having problems with basic openGL concepts, make sure you are grounded before you start working with 3rd-party modeling and animation formats!  nehe.gamedev.net is one of the better sets of tutorials out there, make sure you work through a chunk of them and get to a point where you feel comfortable.  There's specifically one dealing with 'Picking', clicking on objects in 3D and getting a result back (I think it's #32) -- the GLUT library has a set of functions specifically dealing with picking of objects/polygons.

Since the above system is state-based, you know at any given point in time what object you were opening.  When you get to opening a file, you could certainly launch anything you want using OS calls (word doc, web page, etc.)

Mutley2003Author Commented:

thanks for the feedback .. I follow most of what you are saying, however when you say

"Build the model as a hierarchy of objects, connected together"

I am a little confused. Is "a hierarchy of objects" an inbuilt OpenGL concept ? Just thinking about OpenGL calls, I don't seem to have come across a way in which "objects" are built, let alone connected. Just zillions of GlVertex calls "grouped" (I suppose you could say) by GlBegin and GlEnd.

So, suppose I have something like a simple hinge .. 2 rods joined together at a single point. (2D will do). How do I say - in OpenGL - that these two are "connected" (rather than just happening to occupy a certain overlapping area).

And I still don't "get" why I need modelling software at all .. as far as I can see, all I get out of this is the ability to move zillions of polygons around and do some more or less freehand drawing (at which I am no good).

Well, thanks for your patience.
No.  OpenGL (and D3D) at their core are simply manipulating vertices and polygons/triangles.  You create software constructs that represent meshes -- collections of polygons that form a single object.

Go through tutorials at nehe.gamedev.net if you want a good walkthrough of different, progressive stages of extending from basic OpenGL into more complex work, including working with outside models.

Hierarchies and 'connected' are again concepts in YOUR software.  You need to manage the connections, traverse the hierarchies, and update positions/matrices.  (Well, in really advanced GL/D3D, on advanced boards, you can let hardware do some of that manipulation -- but you are still managing the hierarchy, the objects, the offsets between the objects, etc.).

You don't >need< modeling software, if you want to hand-create coordinates of vertices and triangles and meshes, you are more than welcome to -- and the majority of samples from gamedev.net certainly introduce concepts that way.  But at the end of the day, as you progress in 3D, unless you are working from procedural data sets of some sort, it is likely you will find yourself dealing with data from modeling software.  Maybe you have to write an importer, or you have to deal with a model format from someone else's importer.   The Granny SDK is a good example of a third party commercial system that deals with both exporting/formatting of data AND hierarchical modeling AND texturing AND most importantly the application of different animation sets on a given model.

Sorry if I've overwhelmed you with this, just trying to paint you a better picture of 'the big picture'... ;)

Mutley2003Author Commented:

A lucid explanation, again. Thank you.

btw, the Granny SDK is about $10,000 ..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now