put this in a new func in doc_man and call it from doc_man, main, and gui:
				new_model = model_load(filename, open_fdd->fmt);

				if( new_model == NULL ) {
					bb_push_message_f( 3.0, "Failed to load file %s", filename );
				} else {
					docs_add_model( new_model );
					docs_switch_model( new_model );
					result = TRUE;

					bb_push_message_f( 2.5, "Loaded file %s", filename );
					break;
				}
				


'realize' signal in glpreview was acting weird b/c you should have used 
g_signal_connect_after to connect to the signal, not g_signal_connect

BUG - in hole detection: figure-eight holes aren't detected

find out if a gtk tree store will do a g_object_unref on the gdkpixbufs that 
we pass into it; it SHOULD unref... after all, it DOES make a copy of the 
pixbuf

problem, once we implement mesh add/delete undo:
	user deletes mesh
	user deletes texture used by mesh
	user hits "undo", restoring mesh
	mesh now has bogus texture pointer 
	
	


NEW FEATURES
------------
X add drag-and-drop 'target' for kludge3d window, so that model files can be 
  dragged into window in order to load them
X extra column in group_browser : toggle mesh visible/not visible
X extra column in tex_man : icon of texture image
- click on cursor-coordinates-field to cycle through various model statistics
  (num verts/polys/meshes, depth of undo stack, etc)
X ability to flip ortho views around
X tex_app should show texture as it would appear in-engine; ie the texture 
  should be repeated in the window according to the tex-repeat vals of the mesh 
  that the polys belong to
- CUT, COPY, PASTE FOR POLYGONS
o load pngs
o load tgas (loader can be found in citybuilder code)
o load bmps (loader can be found in graphthing code)
X multiple documents loaded at once.  goes hand-in-hand with re-org of 
  doc_load_save; would put that sort of GUI stuff in a "model_man.c" or "doc_man.c".
  could either have a new notebook tab w/ list of loaded models (click-to-set-current)
  or could put in menu list
- finish support for 3d file formats (texture loading, specifically)
	texture loading:
		X wavefront
		- 3ds
	texture saving:
		- wavefront
		- 3ds (when saving for 3ds is impl)
	material loading:
		- ac3d
		- wavefront
		- 3ds
	material saving:
		- ac3d
		- wavefront
		- 3ds (when saving for 3ds is impl)
- insert external file (probably listed on the "group" tab)
X new tool: interactive scale of selected verts, polygons
X new tool: thin/fatten selected polys
X md2 loader?
X frame selector for md2 loader
- mesh deform (pull on vert, elastic effect on other verts in mesh)
X mesh smooth (there's something called the L???? (Laplace?) Method, used in 
  image processing and 3d modellers... just takes the average of the N 
  surrounding vertices as the new value for a given vertex)
X new tool: remove unused verts
X new tool: weld verts together (not just snap)
X new tool: model-wide vertex weld
	copy model's vert list
	for every vert in copied list
		if vert still exists in model vert list
			find all verts near vert, and weld them all together
- for 3d view:  "walkthrough" mode
- 3ds format saving
X tex_app tool: flip polys
- allow user to pick line color for tex app... choices might be 
  black, white, red, & reverse
X new tool: polygon subdivide
X new tool: triangle-ify
X new tool: turn edge.  select two *triangles* that *share an edge* and turn 
  the edge
- keep track of model dirty/clean; 
	possible soln: model becomes dirty after any call to action_do, 
	becomes clean after (successful) call to model_save
X max-undo-stack-length, give user control over max-undo-stack-length
- put current-document name in title bar
X preferences dialog:
	prefs.c,h - to store settings, load/save to file, doesn't use glib or gtk
				so that #including the header doesn't impact compile time
	prefs_dialog.c,h - handles gui stuff
X undo-related preferences: undo stack length (or unlimited), 'enable undo for 
	memory-intensive actions' (ie individual vert movements, like 'snap to grid'
	etc)
- implement undo for individual vert movements, like 'snap to grid'; could make 
	use of the 'object' field in the action struct, so that ACTION_VERT_MOVEs 
	with multiple objects can be distinguished from those with single objs
- when implementing polygon copy/cut/paste: perhaps it would be wise to 
  serialize the cut/copied data into some sort of XML-based (or at least some 
  kind of text-based) format.  That way, the normal X clipboard mechanisms can 
  be used.  You can use the same code to serialize/deserialize the data as 
  would be used to save/load an XML-formatted external file; pasting thus 
  becomes equivalent to inserting an external model file, only the source is a 
  block of text rather than a file pointer.
- XML file format load/save
- 'clear' button for log window, or some sort of length-limit (with pref, of 
  course)
- just an idea: move the coord display (currently in the bottom bar area) into 
  the individual views.  Use the same font-drawing code as is used for the 
  origin axis labels.  Use XOR drawing rather than regular drawing, so that you 
  don't need to redraw the entire view whenever the mouse is moved.  
  Freeing up the entire bottom bar for the message area would help eliminate 
  the need for "multi-part" messages and warnings.
- support for object materials (diffuse, ambient, etc colors)


USABILITY ISSUES
----------------
X preferences are displayed out-of-order in pref_man.  This is because the 
  widgets are created in the order they are stored in the prefs.c hash table
  (which is rarely the same order in which the prefs were created).  To fix, 
  would need to create a linkedlist which mirrors the contents of the hash 
  table (but stores the prefs in the correct order).  Doing this would also 
  allow the hash table to become private again, and the ll could be made 
  public.
X vertex drawing is slooooow.  any way to speed it up?  maybe billboarding?
  does billboarding update the z buffer properly?  I'm not worried if verts 
  have wrong drawing order from aesthetic point of view; it *would*, however, 
  affect picking.
		step1 - try putting vertex draw action in an ogl display list
		if that is not fast enough
		step2 - try billboarded quads
X tooltips for global scope radio buttons
X remove 'mesh' global scope radio button
- put label in tex_app dialog, telling user where to go in order to set 
  texture repeat values.  (or even put a button there that opens the 
  edit-current-mesh dialog directly)
~ ability to change elevation of 3d view's lookat point :)
X set keyboard accel'tors for mesh new/edit/etc, other dialogs too
X should probably notify user if user selects polys from different meshes and 
  tries to edit their texture coords
- when option "show vertices" is disabled, verts can't be selected
  (desired behavior or not?)
- keyboard shortcuts for tool palettes (1-4 on keyboard)
- bottom-bar messages are not displayed in a satisfactory manner.  A rapid 
  series of polygon additions, for example, will result in a series of messages 
  (displayed out-of-order) lasting up to a minute, and having no relevance 
  to the task that the user is currently working on.  The idea in the 
  "NEW FEATURES" section regarding moving the coord display into the individual 
  views would help alleviate this, as it would eliminate the need for 
  multi-part messages.
- allow user to disable the display of cursor coordinates via a Pref
- allow user to set whether models, when loaded, should have nearby verts 
  welded or left individual.  Could call it "Automatically weld nearby 
  vertices when a model is loaded"


BUGS
----
- need to check all uses of g_hash_table, esp when hashing strings
  g_hash_tables don't behave as we previously believed, and require that all
  strings are 'alive' for the entire lifetime of the hash table
X crash if try to undo interactive-extrude 
X fix show-normals
X build system needs tweaking: situation where python is installed, but 
  dev. header files & lib are not (or headers are in wrong place?) causes 
  problems,
  needs a "completely disable python, don't try to autodetect" option
  UPDATE - use '--disable-python' to completely disable python and avoid 
  autodetection
X when selecting primitives, opengl's picking list gets filled up too easily;
  need to set that value higher (maybe see S. Baker email re possible soln)
x groupbtns "select" button does not place an undo marker on the undo stack
- changing selected group causes resize event
~ vert rotate around active axis (tool tab -> button) fucks up the clipboard
  (why?) UPDATE - can't reproduce bug
X keyboard shortcuts in tex_app act weird; end up changing input focus 
  between widgets
X hide/show vertices/polys code is naive and buggy to the point of uselessness.
  verts/polys should be made visible before being deleted!
  Also, vertex_hide_selected (and likely poly too) shouldn't mess w/ the 
  sel verts list directly, as this will screw up the undo stuff
- for ac3d format saver : 2-point polys are not tagged as line segments
  (the SURF tag...)
X drag events (like vertex-move, etc) can get messed up if the user does 
  something in the middle of the drag, before the button is released.  
  Example: user has obj-move bound to one mouse button, and obj-del on another.
  user clicks, holds, drags using the obj-move btn, and before releasing, 
  clicks and releases the obj-del btn.  The undo system will get seriously
  messed up.
X polygon undelete adds verts back to poly in wrong order, causes backwards 
  polys
X crash if close texapp window via WM's 'X' rather than the 'Close' button
  then try to open texapp window again
X buffer overrun in tex_pcx.c
- 64-bit systems: I'm passing around the pointer value for Vertex 
  objects (which may be 64 bits long) as an int, which (on some 64 bit systems) 
  is 32 bits long.  This is done in several places in the code, specifically:
  - the opengl selection stuff (pointers are used as the 'names' for the name stack [the name entries are glints, 32 bits long])
- grids for all 3 planes are drawn in iso views; only need to draw 1 for each 
  view, rather than all 3
X In poly_find_normal, getting non-unit-length vectors as result.  Need to 
  normalize the result (following the vector_cross_prod)
o need to flatten model *before* consolidating verts that are nearby, OR...
X 'loc' keyword not handled correctly:
	should probably be acted upon *before* verts are added to model, rather 
	than as a post-process 
X chdir to model's directory when loading / looking for textures, then change 
  back to pwd when finished (pwd may not be same as model's dir, and texture 
  names are now relative to the model's path)
X gdkpixbuf tex loader has problems w/ angeleyes.jpg


CODE / ARCHITECTURE / SYSTEM ISSUES
-----------------------------------
X model_delete can not be successfully run without 'the_model' being set to 
  the model being deleted.  This is because some funcs, specifically 
  sel_vert_unselect_all (which must be called by model_delete) require that 
  the_model be set to the correct value.  This should be considered a design 
  flaw, and should be fixed.  The soln is not so simple; even if the model is 
  added as an argument to sel_*, there are still situations where this can not 
  be obtained (by code that must be run at model-deletion time, like 
  vertex_remove)
X move "selected_*" stuff to Model
X move "hidden_*" stuff to Model
X move clipboard code to clipboard.c, move clipboard_* there too
X (maybe) move selection code out of vert.c and poly.c and into model.c or 
  clipboard.c, or start a new file, selection.c 
X verts should know the polys they belong to?
X share one ogl context amongst the 4 views?
o vert/marker/etc shapes should be in an ogl display list
X remove instances of "struct model_doc"; it's Model now.
- change undo_enable/undo_disable such that, instead of turning undo_enabled
  on/off, they increment/decrement it.  This way, code that does this:
  func1: undo_disable
  func1: func2
  func2: undo_disable
  func2: do stuff
  func2: undo_enable
  func2: return
  func1: do stuff
  func1: undo_enable
  ... won't cause problems.  Test undo_enabled against 0 (or whatever the 
  initial value is) to determine if undo is enabled.
  (UPDATE - see above item)
- change model_set_currents such that it only changes current_* to the 
  defaults if 1) any of current_* is null 2) any of current_* can't be found in 
  model (UPDATE not really important)
- I'd like to be able to pass ints into the notify signal functions.
  That way, instead of having 3 ::model-*-changed signals, we'd have just 
  ::model-changed, and a bitmask indicating which aspects of the model changed.
  UPDATE - actually, that bitmask thing is a bad idea, but it would still be 
  nice to be able to pass args into the signal funcs.
X gtk2 effort:
x	gtkglarea -> gtkglext
	switch glpreview.c from gtk_widget_get_gl_context/gtk_widget_get_gl_drawable to view->glcontext/view->gldrawable
x	axis markers for origin
x	remove/change deprecated stuff
x	group_browser needs rewrite
	x	finish splitting into 3 files
	fix pixmap code (switch to gdkpixbuf or gtkimage) in 
		x toolbar
		x toolbox
		x group_btns
		x tex_man
x	tex_man needs rewrite
x	texture loading to be handled by gdkpixbuf
X should probably check to see if 3ds stuff still works
- pango stuff for origin markers is (kinda) in wrong place; maybe should move 
  'glp_build_font' out of glpreview and into view
- texturing is inefficient, glp_set_current_tex in particular... we should 
  have ogl "remember" textures; would mean changes to Texture struct, 
  texture would have to be initialized/created/etc once for each context/view...
  etc
- mesh.c : mesh_polygon_add should prolly check to see if nearby vert exists 
  in *model* (old code used to check verts in mesh, but new code doesn't 
  check anything)  If this change is made, can probably simplify 
  pywrapper.c's poly_insert().

- reformat code; 4 spaces indentation -> tabs

X move gui stuff out of doc_load_save, into a sep file
X compile with --with-dev and fix EVERYTHING
- move picking stuff out of glpreview.c and into sep file
- rename glpreview to something that makes sense

- finish the undo stuff: 
	X vertex add, del, etc
	- arbitrary single-vert movements, needed for tools that do weird things 
	  like snap-to-blah, etc
X fix texture paths.  basename only?  or (better, but more difficult) path of 
  texture relative to model's filename.
  if decide to use basename, could add Preference to allow user control over 
  texture search path, ie ".:./textures:..:../textures"
- change the detect-if-a-file-or-dir-exists code to use glib's g_file_test()



MDI-RELATED ISSUES
------------------

x move clipboard stuff to sep file
x move sel.* stuff to Model
x move hidden* stuff to Model
x move partially_completed_tri to Model
x move undo lists to Model
x move undo-enabled flag to Model
x need "doc-changed" event in addn to "doc-structure-changed" event;
  most listeners for "doc-structure-changed" whould also listen for 
  "doc-changed", and a couple new listeners for just "doc-changed" would be 
  written.  
  Example: group browser would simply listen for both
  Example: tex app would listen for just "doc-changed"
  (maybe no need for existing "doc-structure-changed" listeners to also listen 
  for "doc-changed"... maybe BOTH "doc-changed" and "doc-structure-changed" 
  should be issued when doc is switched)
  



UNSORTED, MOSTLY COMPLETED STUFF
--------------------------------
x loading wavefront objects from cmd line causes segfault?
x model.c new function: model_set_default_current()  - 
  would set currentMesh and currentnode 
  to reasonable defaults.  would be useful in many places in the code.  
  we may have this actually implemented somewhere, it's just a matter of finding 
  it and turning it into a func.
	
X python wrapper funcs really don't need to refresh all 4 windows after every 
  action.  Could have them refresh after script finishes or something like that.
? segfault if try to load non-existant file from command line?
  'kludge3d foo'  (or is it just files w/ no .extension?) 
  UPDATE - unable to reproduce 
x deleting a group/mesh causes currentmesh to become invalid; should prolly 
  at least set it to the first group/mesh or something like that...
X texture repeat entry fields in tex_app don't work
o mouse buttons 4 & 5 to zoom in and out 
X delete selected verts/polys (ctrl-K)
X re-org texture stuff
X finish error-queue stuff
X rename model Model
X rename tex Texture
X move model_root, model_verts, model_textures, current_node, etc to 
  a global struct model_doc (aka Model) (call it something like the_model...)
X change everything in model.c to take a Model as arg
~ expose events don't seem to work any more
~ weird opengl behavior; for non-mesa ogl implementations, ogl viewport won't 
  be redrawn after a resize 

~ some form of documentation
X port to gtk2

- replace some instances of g_slist_append with g_slist_prepend (maybe)
X fix the damned drag-n-drop AGAIN

X interactive rotate
X interactive extrude, not just "extrude, and move the sel.polys 1 unit in direction of normal"
X move polygons
X here's how interactive extrude, poly move, and poly rotate could work:
  on mousedown: unsel all verts, perform extrude if needed, sel verts in polys
  on mousemove: perform actions on sel verts
  on mouseup: well... that's it really
  The disadvantage would be that we'd lose the currently selected vert list...

X architecture issue:  verts should be stored in one-big-list

? the initialization/startup code should take care of creating the root node...
  no need for the importers to do this...

X polys w/ numverts != 3 ???
X hide/show verts, polys and groups
X some way to join groups together
X some way to split groups apart
o switch to imlib for loading images?

X command-line option to load a file on startup (ie 'kludge3d teapot.ac')

X texapp dialog
X load textures when loading model
X fix save-texture-info when saving model (when does this break?)
  update: saving texture info doesn't work w/ >1 texture ?
X clear all tex lists on newmodel / loadmodel

X rewrite vertex / poly selection (use ogl selection buffer, etc)
o add prefab insertion (cubes, etc)
X finish group ops ("duplicate group", dnd stuff, etc )
X figure out why ogl is being so weird wrt :
    X texturing (only textures the xy view, changes the linecolor afterwards, etc)
    X vertex order (changes to "ccw", "cw", "all" only affect the 3d view)
    X polygon sorting (in "all" mode, polys are drawn out-of-order)

X grid snap

X about main.c:
    X toolbar should initialize click_mode[], not main
    X group_manager should handle setting the current_* stuff

X "new" should do more than it currently does... it should also create a 
  new mesh as a child of the World (so that people know not to add stuff to the
  root group)

X group_manager should make the World the selected group when there is a 
  newmodel or loadmodel (or should it be the first non-world group?)

X implement tool-palette switching  ie ctrl-1 sets mousebuttons to something
  like vertsel,viewzoom,viewpan  ctrl-2 would be tritex,triadd,viewpan  ...etc

x fix X crashes
x fix weird selection/dragging behaviour
x add AC3d file format saving/loading... remove b3d format support
x multiple vertex selection
x zooming/panning in the 2d views, with extra button-states
x extrude, or at least vertex copy&paste
x heirarchical mesh grouping / object tree



