summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--INSTALL80
-rw-r--r--LICENSE341
-rw-r--r--docs/msGLExport.txt1
-rw-r--r--make.conf30
-rw-r--r--opengl/.cvsignore2
-rw-r--r--opengl/GNUmakefile77
-rw-r--r--opengl/dialog.h35
-rw-r--r--opengl/dialog.rc23
-rw-r--r--opengl/generate.cpp392
-rw-r--r--opengl/generate.h72
-rw-r--r--opengl/gldialog.cpp142
-rw-r--r--opengl/gldialog.h63
-rw-r--r--opengl/main.cpp74
-rw-r--r--test/.cvsignore1
-rw-r--r--test/GNUmakefile57
-rw-r--r--test/mstest.cpp36
-rw-r--r--wrapper/.cvsignore3
-rw-r--r--wrapper/makefile33
-rw-r--r--wrapper/mingwms.cpp70
-rw-r--r--wrapper/mingwms.h65
20 files changed, 1597 insertions, 0 deletions
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..0e983fa
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,80 @@
+These Milkshape plugins require a DLL that allows the plugin to function
+(DON'T get me started on the genius of returning C++ classes from DLLs...)
+
+Details on building this are in step II.
+
+----------------------------------------------------------------------------
+I. GETTING STARTED
+----------------------------------------------------------------------------
+
+Pre-requisites:
+
+ mingw with msys.
+
+ Microsoft C++ Compiler (I used the free Visual C++ 2003 Toolkit).
+
+ Windows Platform SDK. This should only be a temporary requirement until
+ I clean up my dialog resource files.
+
+ w32dlib -- this is a simple Win32 dialog library available from:
+ http://www.wherewilliputthisbloodything?/
+
+ Edit make.conf and set the path to your Milkshape SDK as appropriate.
+
+
+----------------------------------------------------------------------------
+II. BUILDING THE DLL WRAPPER
+----------------------------------------------------------------------------
+
+To build:
+
+ 1. Open a command tool (with paths set to the MS C++ compiler) and cd
+ into the wrapper directory.
+
+ 2. type 'nmake'.
+
+ 3. Copy the resulting mingwms.dll to your Milkshape application directory.
+
+
+----------------------------------------------------------------------------
+III. BUILDING THE TEST DLL
+----------------------------------------------------------------------------
+
+You can skip this if your feeling over-confident...
+
+ 1. Open an MSYS shell.
+
+ 2. cd ./test
+
+ 3. Type make.
+
+ 4. Copy the resulting mstest.dll to your Milkshape application directory.
+
+ 5. Run Milkshape and test the "Mingw test plugin". It simply displays
+ the names of the meshes in a model using the medium of Message Boxes.
+
+
+----------------------------------------------------------------------------
+IV. BUILDING THE (SIMPLE) OPENGL DLL
+----------------------------------------------------------------------------
+
+You can skip this if your feeling over-confident...
+
+ 1. Open an MSYS shell.
+
+ 2. cd ./opengl
+
+ 3. make depend
+
+ 3. make
+
+ 4. Copy the resulting msGLExport.dll to your Milkshape directory.
+
+ 5. Run Milkshape, load a model and you can export using "Simple OpenGL".
+
+ 6. Docs for this will (one day) be available in docs/msGLExport.txt
+
+
+
+----------------------------------------------------------------------
+$Id: INSTALL,v 1.1 2005-04-15 00:53:56 ianc Exp $
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..abd3cf7
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,341 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
diff --git a/docs/msGLExport.txt b/docs/msGLExport.txt
new file mode 100644
index 0000000..f3cb54b
--- /dev/null
+++ b/docs/msGLExport.txt
@@ -0,0 +1 @@
+!! TODO !!
diff --git a/make.conf b/make.conf
new file mode 100644
index 0000000..28e6e68
--- /dev/null
+++ b/make.conf
@@ -0,0 +1,30 @@
+# MSPlugins - any Milkshape plugins I write
+#
+# Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -------------------------------------------------------------------------
+#
+# $Id: make.conf,v 1.1 2005-04-15 00:53:56 ianc Exp $
+#
+
+
+# 1. Set this to the location of your Milkshape SDK directory
+#
+MILKSHAPE = E:/SDK/ms3dsdk174/msLib
+
+
+# END OF FILE
diff --git a/opengl/.cvsignore b/opengl/.cvsignore
new file mode 100644
index 0000000..1efcba0
--- /dev/null
+++ b/opengl/.cvsignore
@@ -0,0 +1,2 @@
+msGLExport.dll
+dialog.RES \ No newline at end of file
diff --git a/opengl/GNUmakefile b/opengl/GNUmakefile
new file mode 100644
index 0000000..0259322
--- /dev/null
+++ b/opengl/GNUmakefile
@@ -0,0 +1,77 @@
+# MSPlugins - Simple OpenGL Milkshape plugin
+#
+# Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -------------------------------------------------------------------------
+#
+# $Id: GNUmakefile,v 1.1 2005-04-15 00:53:56 ianc Exp $
+#
+include ../make.conf
+
+TARGET = msGLExport
+
+RES = dialog
+
+SOURCES = main.cpp \
+ gldialog.cpp \
+ generate.cpp
+
+HEADERS = $(RES).h \
+ gldialog.h \
+ generate.h
+
+OBJECTS = $(SOURCES:.cpp=.o) $(RES).o
+
+OUTDLL = $(TARGET).dll
+
+OUTLIB = $(TARGET).a
+
+WRAPPER = ../wrapper
+
+DLLLIBS = $(WRAPPER)/mingwms.lib $(MILKSHAPE)/lib/msModelLib.lib \
+ `w32dlib-config --libs`
+
+FLAGS = -I$(WRAPPER) -I$(MILKSHAPE) -Wall `w32dlib-config --cflags`
+
+
+$(OUTDLL): $(OBJECTS)
+ dllwrap --output-lib=$(OUTLIB) --dllname=$(OUTDLL) \
+ --driver-name=c++ $(OBJECTS) $(DLLLIBS)
+
+# Unfortunately the windres resource compiler doesn't like my RC, so you
+# need RC.EXE from the Platform SDK to compile it to a RES first.
+#
+$(RES).o: $(RES).res
+ windres -v -i $(RES).res -o $(RES).o
+
+$(RES).res: $(RES).rc $(RES).h
+ rc $(RES).rc
+
+%.o: %.cpp
+ $(CXX) -c $(FLAGS) $< -o $@
+
+-include depend.mak
+
+clean:
+ -rm -f $(OUTDLL) $(OUTLIB) $(OBJECTS) $(RES).res depend.mak
+
+depend:
+ @echo Dependencies updated....
+ $(CXX) -MM $(FLAGS) $(SOURCES) > depend.mak
+
+
+# END OF FILE
diff --git a/opengl/dialog.h b/opengl/dialog.h
new file mode 100644
index 0000000..4955fd6
--- /dev/null
+++ b/opengl/dialog.h
@@ -0,0 +1,35 @@
+//
+// msGLExport - OpenGL exporter for Milkshape
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+// $Id$
+//
+#define GL_DIALOG 101
+
+#define IDC_BUT_SELECTDIR 3004
+#define IDC_TXT_FUNCNAME 3009
+#define IDC_CHK_TEXTURE 3008
+#define IDC_CHK_DEFINE 3010
+#define IDC_BUT_CANCEL 3002
+#define IDC_BUT_GENERATE 3001
+#define IDC_TXT_INFO 3000
+#define IDC_TXT_DIR 3003
+#define IDC_CHK_FORCECOG 3011
+#define IDC_CHK_BLITZMAX 3012
diff --git a/opengl/dialog.rc b/opengl/dialog.rc
new file mode 100644
index 0000000..68f85e5
--- /dev/null
+++ b/opengl/dialog.rc
@@ -0,0 +1,23 @@
+#include <windows.h>
+#include "dialog.h"
+
+GL_DIALOG DIALOG 0, 0, 337, 181
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
+CAPTION "OpenGL Export"
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+FONT 8, "MS Sans Serif"
+{
+ CONTROL "...", IDC_BUT_SELECTDIR, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 240, 90, 25, 15
+ CONTROL "", IDC_TXT_FUNCNAME, EDIT, ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 65, 110, 145, 12
+ CONTROL "Use Textures", IDC_CHK_TEXTURE, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 5, 135, 60, 10
+ CONTROL "Generate info", IDC_CHK_DEFINE, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 75, 135, 85, 10
+ CONTROL "Cancel", IDC_BUT_CANCEL, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 170, 160, 75, 15
+ CONTROL "Generate", IDC_BUT_GENERATE, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_DISABLED | WS_TABSTOP, 255, 160, 75, 15
+ CONTROL "", IDC_TXT_INFO, EDIT, ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL, 5, 15, 325, 70
+ CONTROL "", IDC_TXT_DIR, EDIT, ES_LEFT | ES_AUTOHSCROLL | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_BORDER, 65, 90, 170, 12
+ CONTROL "Directory", -1, STATIC, SS_LEFT | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 90, 30, 10
+ CONTROL "Function/object", -1, STATIC, SS_LEFT | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 110, 55, 10
+ CONTROL "Force COG to 0,0,0", IDC_CHK_FORCECOG, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 165, 135, 75, 10
+ CONTROL "Generate for Blitz MAX", IDC_CHK_BLITZMAX, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 248, 135, 85, 10
+ CONTROL "Info:", -1, STATIC, SS_LEFT | SS_CENTERIMAGE | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 5, 15, 10
+}
diff --git a/opengl/generate.cpp b/opengl/generate.cpp
new file mode 100644
index 0000000..cdce010
--- /dev/null
+++ b/opengl/generate.cpp
@@ -0,0 +1,392 @@
+// Generate.cpp: implementation of the Generate class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include <sstream>
+#include <algorithm>
+#include <cctype>
+#include <cstdio>
+#include <w32dlib/w32dlib.h>
+#include "generate.h"
+#include "msLib.h"
+
+#define INDENT " "
+#define EOL "\r\n"
+
+#define FLT_MAX 10e35
+#define FLT_MIN -10e35
+
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+Generate::Generate(msModel *model) : m_model(model),
+
+ m_cogx(0),
+ m_cogy(0),
+ m_cogz(0),
+
+ m_appcogx(0),
+ m_appcogy(0),
+ m_appcogz(0),
+
+ m_max_x(FLT_MIN),
+ m_min_x(FLT_MAX),
+ m_max_y(FLT_MIN),
+ m_min_y(FLT_MAX),
+ m_max_z(FLT_MIN),
+ m_min_z(FLT_MAX)
+{
+ CalcModelBounds();
+}
+
+Generate::~Generate()
+{
+}
+
+//////////////////////////////////////////////////////////////////////
+// Public members
+//////////////////////////////////////////////////////////////////////
+
+std::string Generate::Info()
+{
+ std::ostringstream str;
+
+ str << "Create files : " << EOL
+ << "\t" << m_dir << "\\" << m_funcName << ".c" << EOL
+ << "\t" << m_dir << "\\" << m_funcName << ".h" << EOL << EOL
+ << "Centre of gravity : "
+ << (m_cogx-m_appcogx) << ","
+ << (m_cogy-m_appcogy) << ","
+ << (m_cogz-m_appcogz) << EOL
+ << "Lowest X co-ord : " << m_min_x-m_appcogx << EOL
+ << "Highest X co-ord : " << m_max_x-m_appcogx << EOL
+ << "Lowest Y co-ord : " << m_min_y-m_appcogx << EOL
+ << "Highest Y co-ord : " << m_max_y-m_appcogx << EOL
+ << "Lowest Z co-ord : " << m_min_z-m_appcogx << EOL
+ << "Highest Z co-ord : " << m_max_z-m_appcogx << EOL;
+
+ return str.str();
+}
+
+void Generate::MakeFiles()
+{
+ std::FILE *fp;
+ int len;
+ std::string fname_c;
+ std::string fname_h;
+ std::string def;
+ std::string missing;
+
+ len=m_funcName.length()+6;
+
+ fname_c=m_dir+"\\"+m_funcName;
+ fname_h=fname_c+".h";
+ fname_c+=".c";
+
+ for(std::string::const_iterator i=m_funcName.begin();
+ i!=m_funcName.end();++i)
+ {
+ def+=std::toupper(*i);
+ }
+
+ // Generate header
+ //
+ if (!(fp=fopen(fname_h.c_str(),"w")))
+ {
+ W32DLib::Common::Error(0,"Couldn't create header file");
+ return;
+ }
+
+ std::fprintf(fp,"%s","/* Code generated with Milkshape "
+ "Export OpenGL plugin\n*/\n");
+ std::fprintf(fp,"\n");
+
+ std::fprintf(fp,"#ifndef %s_H\n#define %s_H\n\n",
+ def.c_str(),def.c_str());
+
+ std::fprintf(fp,"%s","#ifdef _cplusplus\nextern \"C\" {\n#endif\n\n");
+
+
+ std::fprintf(fp,"void %s(GLfloat x, GLfloat y, GLfloat z,\n",
+ m_funcName.c_str());
+ std::fprintf(fp,"%sGLfloat rot_x, GLfloat rot_y, GLfloat rot_z",
+ Space(len));
+
+ if (m_useTexture)
+ {
+ std::fprintf(fp,",\n%sGLint tid);\n\n", Space(len));
+ }
+ else
+ {
+ std::fprintf(fp,");\n\n");
+ }
+
+ if (m_useInfo)
+ {
+ std::fprintf(fp,"#define %s_COG_X %f\n",def.c_str(),m_cogx-m_appcogx);
+ std::fprintf(fp,"#define %s_COG_Y %f\n",def.c_str(),m_cogy-m_appcogy);
+ std::fprintf(fp,"#define %s_COG_Z %f\n\n",def.c_str(),m_cogz-m_appcogz);
+
+ std::fprintf(fp,"#define %s_MIN_X %f\n",def.c_str(),m_min_x-m_appcogx);
+ std::fprintf(fp,"#define %s_MAX_X %f\n",def.c_str(),m_max_x-m_appcogx);
+ std::fprintf(fp,"#define %s_MIN_Y %f\n",def.c_str(),m_min_y-m_appcogy);
+ std::fprintf(fp,"#define %s_MAX_Y %f\n",def.c_str(),m_max_y-m_appcogy);
+ std::fprintf(fp,"#define %s_MIN_Z %f\n",def.c_str(),m_min_z-m_appcogz);
+ std::fprintf(fp,"#define %s_MAX_Z %f\n\n",def.c_str(),
+ m_max_z-m_appcogz);
+
+ float sx=m_max_x-m_min_x;
+ float sy=m_max_y-m_min_y;
+ float sz=m_max_z-m_min_z;
+
+ std::fprintf(fp,"#define %s_SIZE_X %f\n",def.c_str(),sx);
+ std::fprintf(fp,"#define %s_SIZE_Y %f\n",def.c_str(),sy);
+ std::fprintf(fp,"#define %s_SIZE_Z %f\n\n",def.c_str(),sz);
+ }
+
+ std::fprintf(fp,"#define %s_TEXTURED %d\n\n",def.c_str(),m_useTexture?1:0);
+
+ std::fprintf(fp,"%s","#ifdef _cplusplus\n}\n#endif\n\n");
+
+ std::fprintf(fp,"#endif /* %s_H */\n\n",def.c_str());
+
+ std::fprintf(fp,"%s","/* END OF FILE */\n");
+
+ std::fclose(fp);
+
+ // Generate C source
+ //
+ if (!(fp=fopen(fname_c.c_str(),"w")))
+ {
+ W32DLib::Common::Error(0,"Couldn't create source file");
+ return;
+ }
+
+ std::fprintf(fp,"%s","/* Code generated with Milkshape "
+ "Export OpenGL plugin\n*/\n");
+
+ std::fprintf(fp,"%s","#include <GL/gl.h>\n\n");
+
+ std::fprintf(fp,"void %s(GLfloat x, GLfloat y, GLfloat z,\n",
+ m_funcName.c_str());
+ std::fprintf(fp,"%sGLfloat rot_x, GLfloat rot_y, GLfloat rot_z",
+ Space(len));
+
+ if (m_useTexture)
+ {
+ std::fprintf(fp,",\n%sGLint tid)\n", Space(len));
+ }
+ else
+ {
+ std::fprintf(fp,")\n");
+ }
+
+ std::fprintf(fp,"{\n");
+
+ std::fprintf(fp,INDENT "glPushMatrix();\n");
+ std::fprintf(fp,INDENT "glLoadIdentity();\n");
+ std::fprintf(fp,INDENT "glTranslatef(x,y,z);\n");
+ std::fprintf(fp,INDENT "glRotatef(rot_x,1.0f,0.0f,0.0f);\n"),
+ std::fprintf(fp,INDENT "glRotatef(rot_y,0.0f,1.0f,0.0f);\n"),
+ std::fprintf(fp,INDENT "glRotatef(rot_z,0.0f,0.0f,1.0f);\n"),
+ std::fprintf(fp,"\n");
+
+ std::fprintf(fp,INDENT "glBegin(GL_TRIANGLES);\n");
+
+ if (m_useTexture)
+ {
+ std::fprintf(fp,INDENT "glBindTexture(GL_TEXTURE_2D,tid);\n");
+ }
+
+ std::fprintf(fp,"\n");
+
+ for(int m=0;m<m_model->nNumMeshes;m++)
+ {
+ msMesh *mesh=m_model->pMeshes+m;
+
+ std::fprintf(fp,INDENT "/* Mesh %d - %s\n",m+1,mesh->szName);
+ std::fprintf(fp,INDENT "*/\n");
+
+ if (mesh->nMaterialIndex<0)
+ {
+ missing+=mesh->szName;
+ missing+="\n";
+
+ std::fprintf(fp,INDENT "glColor3f(1.0f,1.0f,1.0f);\n");
+ }
+ else
+ {
+ msMaterial *mat=m_model->pMaterials+mesh->nMaterialIndex;
+
+ std::fprintf(fp,INDENT "glColor3f(%f,%f,%f);\n",
+ mat->Diffuse[0],
+ mat->Diffuse[1],
+ mat->Diffuse[2]);
+ }
+
+ for(int t=0;t<mesh->nNumTriangles;t++)
+ {
+ msTriangle *tri;
+
+ tri=mesh->pTriangles+t;
+
+ if (!(tri->nFlags&eHidden))
+ {
+ // To allow vertex order to be tweaked...
+ //
+ static int order[3]={0,1,2};
+
+ for(int i=0;i<3;i++)
+ {
+ msVertex *v=mesh->pVertices+tri->nVertexIndices[order[i]];
+
+ std::fprintf(fp,INDENT "glVertex3f(%f,%f,%f);\n",
+ v->Vertex[0]-m_appcogx,
+ v->Vertex[1]-m_appcogy,
+ v->Vertex[2]-m_appcogz);
+
+ if (m_useTexture)
+ {
+ std::fprintf(fp,INDENT "glTexCoord2f(%f,%f);\n",
+ v->u,
+ v->v);
+ }
+ }
+ }
+ }
+
+ std::fprintf(fp,"\n");
+ }
+
+ std::fprintf(fp,INDENT "glEnd();\n");
+ std::fprintf(fp,INDENT "glPopMatrix();\n");
+
+ std::fprintf(fp,"}\n");
+
+ std::fclose(fp);
+
+ if (missing.length()>0)
+ {
+ missing="The following meshes had no material:\n\n"+missing;
+ missing+="\n\nThey were given the colour white.";
+
+ W32DLib::Common::Message(0,missing);
+ }
+}
+
+
+void Generate::Setup(const std::string& dir,
+ const std::string& funcname,
+ bool texture,
+ bool info,
+ bool forceCOG)
+{
+ m_dir=dir;
+ m_funcName=funcname;
+ m_useTexture=texture;
+ m_useInfo=info;
+ m_forceCOG=forceCOG;
+
+ if (m_forceCOG)
+ {
+ m_appcogx=m_cogx;
+ m_appcogy=m_cogy;
+ m_appcogz=m_cogz;
+ }
+ else
+ {
+ m_appcogx=0;
+ m_appcogy=0;
+ m_appcogz=0;
+ }
+}
+
+
+std::string Generate::GenerateFuncname()
+{
+ std::string fn;
+ char *name;
+
+ msMesh *mesh=msModel_GetMeshAt(m_model,0);
+
+ name=mesh->szName;
+
+ for(int f=0;name[f];f++)
+ {
+ if (std::isalpha(name[f]) || (f && name[f]=='_'))
+ {
+ fn+=name[f];
+ }
+ }
+
+ if (fn=="")
+ {
+ fn="object";
+ }
+
+ return fn;
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// Private members
+//////////////////////////////////////////////////////////////////////
+
+const char *Generate::Space(int len)
+{
+ static int cyc=0;
+ static char buff[10][128];
+ int f;
+
+ cyc=(cyc+1)%10;
+
+ for(f=0;f<len && f < 126;f++)
+ {
+ buff[cyc][f]=' ';
+ }
+
+ buff[cyc][f]=0;
+
+ return &buff[cyc][0];
+}
+
+
+void Generate::CalcModelBounds()
+{
+ for(int m=0;m<m_model->nNumMeshes;m++)
+ {
+ msMesh *mesh;
+
+ mesh=m_model->pMeshes+m;
+
+ for(int t=0;t<mesh->nNumTriangles;t++)
+ {
+ msTriangle *tri;
+
+ tri=mesh->pTriangles+t;
+
+ if (!(tri->nFlags&eHidden))
+ {
+ for(int i=0;i<3;i++)
+ {
+ msVertex *v=mesh->pVertices+tri->nVertexIndices[i];
+
+ m_min_x=std::min(m_min_x,v->Vertex[0]);
+ m_max_x=std::max(m_max_x,v->Vertex[0]);
+
+ m_min_y=std::min(m_min_y,v->Vertex[1]);
+ m_max_y=std::max(m_max_y,v->Vertex[1]);
+
+ m_min_z=std::min(m_min_z,v->Vertex[2]);
+ m_max_z=std::max(m_max_z,v->Vertex[2]);
+ }
+ }
+ }
+ }
+
+ m_cogx=m_min_x+(m_max_x-m_min_x)/2;
+ m_cogy=m_min_y+(m_max_y-m_min_y)/2;
+ m_cogz=m_min_z+(m_max_z-m_min_z)/2;
+}
diff --git a/opengl/generate.h b/opengl/generate.h
new file mode 100644
index 0000000..2aa1ec1
--- /dev/null
+++ b/opengl/generate.h
@@ -0,0 +1,72 @@
+// msGLExport - OpenGL exporter for Milkshape
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+// $Id$
+//
+#ifndef GENERATE_H
+#define GENERATE_H
+
+#include <string>
+#include <msLib.h>
+
+class Generate
+{
+public:
+ Generate(msModel *model);
+ virtual ~Generate();
+
+ std::string GenerateFuncname();
+ void Setup(const std::string& dir,
+ const std::string& funcname,
+ bool texture,
+ bool info,
+ bool forceCOG);
+ void MakeFiles();
+ std::string Info();
+
+private:
+ msModel *m_model;
+ std::string m_funcName;
+ std::string m_dir;
+ bool m_useTexture;
+ bool m_useInfo;
+ bool m_forceCOG;
+
+ float m_cogx;
+ float m_cogy;
+ float m_cogz;
+
+ float m_appcogx;
+ float m_appcogy;
+ float m_appcogz;
+
+ float m_max_x;
+ float m_min_x;
+ float m_max_y;
+ float m_min_y;
+ float m_max_z;
+ float m_min_z;
+
+ const char *Space(int len);
+
+ void CalcModelBounds();
+};
+
+#endif // GENERATE_H
diff --git a/opengl/gldialog.cpp b/opengl/gldialog.cpp
new file mode 100644
index 0000000..c279944
--- /dev/null
+++ b/opengl/gldialog.cpp
@@ -0,0 +1,142 @@
+// msGLExport - OpenGL exporter for Milkshape
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+static const char rcs_id[]="$Id$";
+
+#include "gldialog.h"
+#include "dialog.h"
+
+
+/////////////////////////////////////////////////////////////////////////////
+// GLDialog dialog
+
+
+GLDialog::GLDialog(Generate& gen)
+ : m_gen(gen)
+ , m_dirButton(this,IDC_BUT_SELECTDIR,0)
+ , m_funcName(this,IDC_TXT_FUNCNAME,0)
+ , m_useTexture(this,IDC_CHK_TEXTURE,0)
+ , m_useInfo(this,IDC_CHK_DEFINE,0)
+ , m_cancelButton(this,IDC_BUT_CANCEL,0)
+ , m_genButton(this,IDC_BUT_GENERATE,0)
+ , m_info(this,IDC_TXT_INFO,0)
+ , m_dir(this,IDC_TXT_DIR,0)
+ , m_forceCOG(this,IDC_CHK_FORCECOG,0)
+ , m_blitzMax(this,IDC_CHK_BLITZMAX,0)
+{
+ char path[1024];
+
+ GetCurrentDirectory(sizeof path,path);
+
+ m_fname=path;
+
+ m_dirButton.OnPress
+ (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnSelect));
+
+ m_cancelButton.OnPress
+ (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnCancel));
+
+ m_genButton.OnPress
+ (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnGenerate));
+
+ m_funcName.OnTextChanged
+ (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnChange));
+
+ m_useTexture.OnPress
+ (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnChange));
+
+ m_useInfo.OnPress
+ (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnChange));
+
+ m_forceCOG.OnPress
+ (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnChange));
+
+ m_blitzMax.OnPress
+ (this,static_cast<W32DLib::W32DLibCallback>(&GLDialog::OnChange));
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// GLDialog public members
+
+int GLDialog::ResourceID()
+{
+ return GL_DIALOG;
+}
+
+
+void GLDialog::OnInit()
+{
+ m_dir.SetText(m_fname);
+ m_funcName.SetText(m_gen.GenerateFuncname());
+ m_genButton.Enable(true);
+ Preview();
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+// GLDialog message handlers
+
+BOOL GLDialog::OnGenerate(UINT msg, WPARAM wp, LPARAM lp)
+{
+ Close(IDOK);
+ return TRUE;
+}
+
+
+BOOL GLDialog::OnSelect(UINT msg, WPARAM wp, LPARAM lp)
+{
+ if (W32DLib::Common::SelectDir(m_wnd,"Select Directory",m_fname))
+ {
+ OnChange(msg,wp,lp);
+ }
+ return TRUE;
+}
+
+
+BOOL GLDialog::OnCancel(UINT msg, WPARAM wp, LPARAM lp)
+{
+ Close(IDCANCEL);
+ return TRUE;
+}
+
+
+BOOL GLDialog::OnChange(UINT msg, WPARAM wp, LPARAM lp)
+{
+ Preview();
+ m_genButton.Enable(m_funcName.GetText().length()!=0);
+ return TRUE;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// GLDialog private members
+
+void GLDialog::Preview()
+{
+ m_gen.Setup(m_fname,
+ m_funcName.GetText(),
+ m_useTexture.GetState(),
+ m_useInfo.GetState(),
+ m_forceCOG.GetState());
+
+ m_info.SetText(m_gen.Info());
+}
diff --git a/opengl/gldialog.h b/opengl/gldialog.h
new file mode 100644
index 0000000..675454d
--- /dev/null
+++ b/opengl/gldialog.h
@@ -0,0 +1,63 @@
+// msGLExport - OpenGL exporter for Milkshape
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+// $Id$
+//
+#ifndef GLDIALOG_H
+#define GLDIALOG_H
+
+#include <w32dlib/w32dlib.h>
+#include "generate.h"
+
+class GLDialog : public W32DLib::Dialog
+{
+public:
+ GLDialog(Generate& gen);
+
+ int ResourceID();
+
+ void OnInit();
+
+private:
+
+ Generate& m_gen;
+
+ W32DLib::Button m_dirButton;
+ W32DLib::Text m_funcName;
+ W32DLib::AutoCheck m_useTexture;
+ W32DLib::AutoCheck m_useInfo;
+ W32DLib::Button m_cancelButton;
+ W32DLib::Button m_genButton;
+ W32DLib::Text m_info;
+ W32DLib::Text m_dir;
+ W32DLib::AutoCheck m_forceCOG;
+ W32DLib::AutoCheck m_blitzMax;
+
+ std::string m_fname;
+
+ BOOL OnGenerate(UINT msg, WPARAM wp, LPARAM lp);
+ BOOL OnSelect(UINT msg, WPARAM wp, LPARAM lp);
+ BOOL OnCancel(UINT msg, WPARAM wp, LPARAM lp);
+ BOOL OnChange(UINT msg, WPARAM wp, LPARAM lp);
+
+ void Preview();
+};
+
+#endif // GLDIALOG_H
diff --git a/opengl/main.cpp b/opengl/main.cpp
new file mode 100644
index 0000000..19ca5a9
--- /dev/null
+++ b/opengl/main.cpp
@@ -0,0 +1,74 @@
+// msGLExport - OpenGL exporter for Milkshape
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+static const char rcs_id[]="$Id$";
+
+#include <cstring>
+#include <cstdio>
+
+#include "mingwms.h"
+#include "msLib.h"
+
+#include "gldialog.h"
+
+
+// ----------------------------------------------------------------------
+// MINGW WRAPPER FUNCTIONS
+//
+static const char* GetTitle()
+{
+ return "Simple OpenGL";
+}
+
+static int Execute(msModel* model)
+{
+ if (!model)
+ {
+ return -1;
+ }
+
+ if (msModel_GetMeshCount(model)<1)
+ {
+ W32DLib::Common::Error(NULL,"No meshes in the model!");
+ return 0;
+ }
+
+ W32DLib::Common::Initialise();
+
+ Generate gen(model);
+ GLDialog dlg(gen);
+
+ if (dlg.ShowModal(W32DLib::Common::GetInstance(),NULL)==IDOK)
+ {
+ SetCursor(LoadCursor(NULL,IDC_WAIT));
+ gen.MakeFiles();
+ SetCursor(LoadCursor(NULL,IDC_ARROW));
+ }
+
+ return 1;
+}
+
+PLUGIN_SPEC void* CreatePlugIn()
+{
+ return CreateMINGWPlugin(MS_TYPE_EXPORT, GetTitle, Execute);
+}
+
+
+// END OF FILE
diff --git a/test/.cvsignore b/test/.cvsignore
new file mode 100644
index 0000000..140a633
--- /dev/null
+++ b/test/.cvsignore
@@ -0,0 +1 @@
+mstest.dll \ No newline at end of file
diff --git a/test/GNUmakefile b/test/GNUmakefile
new file mode 100644
index 0000000..58e7b44
--- /dev/null
+++ b/test/GNUmakefile
@@ -0,0 +1,57 @@
+# MSPlugins - test Milkshape plugin
+#
+# Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -------------------------------------------------------------------------
+#
+# $Id: GNUmakefile,v 1.1 2005-04-15 00:53:56 ianc Exp $
+#
+
+include ../make.conf
+
+TARGET = mstest
+
+SOURCES = mstest.cpp
+
+HEADERS =
+
+OBJECTS = $(SOURCES:.cpp=.o)
+
+OUTDLL = $(TARGET).dll
+
+WRAPPER = ../wrapper
+
+DLLLIBS = $(WRAPPER)/mingwms.lib $(MILKSHAPE)/lib/msModelLib.lib \
+ `w32dlib-config --libs`
+ #`w32dlib-config --archive`
+
+FLAGS = -I$(WRAPPER) -I$(MILKSHAPE) `w32dlib-config --cflags`
+
+
+$(OUTDLL): $(OBJECTS)
+ dllwrap --dllname=$(OUTDLL) --driver-name=c++ $(OBJECTS) $(DLLLIBS)
+
+%.o: %.cpp
+ $(CXX) -c $(FLAGS) $< -o $@
+
+mstest.o: mstest.cpp
+
+clean:
+ -rm -f $(OUTDLL) *.o
+
+
+# END OF FILE
diff --git a/test/mstest.cpp b/test/mstest.cpp
new file mode 100644
index 0000000..1a63d6d
--- /dev/null
+++ b/test/mstest.cpp
@@ -0,0 +1,36 @@
+#include <w32dlib/w32dlib.h>
+
+#include "mingwms.h"
+#include "msLib.h"
+
+static const char* GetTitle()
+{
+ return "Mingw test plugin";
+}
+
+static int Execute(msModel* model)
+{
+ if (!model)
+ return -1;
+
+ if (msModel_GetMeshCount(model)<1)
+ {
+ W32DLib::Common::Error(NULL, "No meshes in the model!");
+ return 0;
+ }
+
+ for(int i = 0; i < msModel_GetMeshCount(model); ++i)
+ {
+ msMesh* mesh = msModel_GetMeshAt(model, i);
+ char buf[256];
+ msMesh_GetName(mesh, buf, 255);
+ W32DLib::Common::Message(NULL, buf);
+ }
+
+ return 0;
+}
+
+PLUGIN_SPEC void* CreatePlugIn()
+{
+ return CreateMINGWPlugin(MS_TYPE_TOOL, GetTitle, Execute);
+}
diff --git a/wrapper/.cvsignore b/wrapper/.cvsignore
new file mode 100644
index 0000000..9af734a
--- /dev/null
+++ b/wrapper/.cvsignore
@@ -0,0 +1,3 @@
+mingwms.lib
+mingwms.exp
+mingwms.dll \ No newline at end of file
diff --git a/wrapper/makefile b/wrapper/makefile
new file mode 100644
index 0000000..fb0d73a
--- /dev/null
+++ b/wrapper/makefile
@@ -0,0 +1,33 @@
+# MSPlugins - This makefile makes a DLL that allows MINGW Milkshape plugins
+# to be written.
+#
+# Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -------------------------------------------------------------------------
+#
+# $Id: makefile,v 1.1 2005-04-15 00:53:56 ianc Exp $
+#
+
+!INCLUDE ../make.conf
+
+mingwms.dll: mingwms.cpp mingwms.h
+ cl /LD /I$(MILKSHAPE) /DBUILDDLL mingwms.cpp
+
+clean:
+ del mingwms.dll mingwms.exp mingwms.lib mingwms.obj
+
+# END OF FILE
diff --git a/wrapper/mingwms.cpp b/wrapper/mingwms.cpp
new file mode 100644
index 0000000..e0d9458
--- /dev/null
+++ b/wrapper/mingwms.cpp
@@ -0,0 +1,70 @@
+// MSPlugins - MINGW Milkshape wrapper
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+static const char rcs_id[]="$Id$";
+
+#include <msPlugin.h>
+#include "mingwms.h"
+
+class MingwPlugin : public cMsPlugIn
+{
+public:
+ MingwPlugin(int type, const char * (*GetName)(), int (*Exectute)(msModel*))
+ {
+ m_type=type;
+ m_getname=GetName;
+ m_execute=Exectute;
+ }
+
+ int GetType()
+ {
+ return m_type;
+ }
+
+ const char *GetTitle()
+ {
+ return m_getname();
+ }
+
+ int Execute(msModel *p)
+ {
+ return m_execute(p);
+ }
+
+private:
+ int m_type;
+ const char * (*m_getname)();
+ int (*m_execute)(msModel*);
+};
+
+extern "C"
+{
+
+SPEC void *CreateMINGWPlugin (int tool_type,
+ const char * (*GetName)(),
+ int (*Exectute)(msModel*))
+{
+ return static_cast<void*>(new MingwPlugin(tool_type,GetName,Exectute));
+}
+
+}
+
+
+// END OF FILE
diff --git a/wrapper/mingwms.h b/wrapper/mingwms.h
new file mode 100644
index 0000000..1df87d7
--- /dev/null
+++ b/wrapper/mingwms.h
@@ -0,0 +1,65 @@
+// MSPlugins - MINGW Milkshape wrapper
+//
+// Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk)
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// -------------------------------------------------------------------------
+//
+#ifndef MINGWMS_H
+
+#define MINGWMS_H "$Id$"
+
+#ifdef BUILDDLL
+#define SPEC __declspec(dllexport)
+#else
+#define SPEC __declspec(dllimport)
+#endif
+
+// Handy #define for defining your plugin
+//
+#define PLUGIN_SPEC extern "C" __declspec(dllexport)
+
+extern "C"
+{
+
+// These are the tool types
+//
+#define MS_TYPE_IMPORT 1
+#define MS_TYPE_EXPORT 2
+#define MS_TYPE_TOOL 3
+#define MS_TYPE_EDIT 4
+#define MS_TYPE_VERTEX 5
+#define MS_TYPE_FACE 6
+#define MS_TYPE_ANIMATE 7
+
+// Forward definition of the Milkshape model struct.
+//
+struct msModel;
+
+// Call this interface to create a Milkshape compatible cMsPlugIn class.
+//
+SPEC void *CreateMINGWPlugin
+ (int tool_type, // One of MS_TYPE_xx above.
+ const char * (*GetName)(), // Returns the plugin's name.
+ int (*Exectute)(msModel*)); // Runs the tool.
+
+
+}
+
+#endif // MINGWMS_H
+
+
+// END OF FILE