]> git.mxchange.org Git - flightgear.git/commitdiff
Rename utils/3dconvert to utils/Modeller and add Jim Wilson's animassist utility
authorehofman <ehofman>
Fri, 9 Jan 2004 21:19:44 +0000 (21:19 +0000)
committerehofman <ehofman>
Fri, 9 Jan 2004 21:19:44 +0000 (21:19 +0000)
configure.ac
utils/3dconvert/.cvsignore [deleted file]
utils/3dconvert/Makefile.am [deleted file]
utils/Makefile.am
utils/Modeller/.cvsignore [new file with mode: 0644]
utils/Modeller/3dconvert.cxx [new file with mode: 0644]
utils/Modeller/Makefile.am [new file with mode: 0644]
utils/Modeller/animassist.c [new file with mode: 0644]

index 21050c09c4ba2f842dc9f3064ca17f7f44f2df37..10892754a73084af1e1d56965842fc9604e3ab6e 100644 (file)
@@ -520,8 +520,8 @@ AC_CONFIG_FILES([ \
        tests/Makefile \
        utils/Makefile \
        utils/TerraSync/Makefile \
+       utils/Modeller/Makefile \
        utils/js_server/Makefile \
-       utils/3dconvert/Makefile \
 ])
 AC_OUTPUT
 
diff --git a/utils/3dconvert/.cvsignore b/utils/3dconvert/.cvsignore
deleted file mode 100644 (file)
index 661fa8a..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-.deps
-Makefile
-Makefile.in
-3dconvert
diff --git a/utils/3dconvert/Makefile.am b/utils/3dconvert/Makefile.am
deleted file mode 100644 (file)
index d568f52..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-bin_PROGRAMS = 3dconvert
-
-3dconvert_SOURCES = 3dconvert.cxx
-3dconvert_LDADD = -lplibssg -lplibsg -lplibul $(opengl_LIBS) $(audio_LIBS)
index 61c2ecf36b1e21b7be220f6c2742f172ec816e18..14a50d6f96350e12c577f80fc34882878d6983a4 100644 (file)
@@ -1 +1 @@
-SUBDIRS = TerraSync js_server 3dconvert
+SUBDIRS = TerraSync Modeller js_server
diff --git a/utils/Modeller/.cvsignore b/utils/Modeller/.cvsignore
new file mode 100644 (file)
index 0000000..661fa8a
--- /dev/null
@@ -0,0 +1,4 @@
+.deps
+Makefile
+Makefile.in
+3dconvert
diff --git a/utils/Modeller/3dconvert.cxx b/utils/Modeller/3dconvert.cxx
new file mode 100644 (file)
index 0000000..6ffc1ac
--- /dev/null
@@ -0,0 +1,32 @@
+#include <iostream>
+#include <GL/glut.h>
+#include <plib/ssg.h>
+
+using std::cerr;
+using std::endl;
+
+
+int
+main (int ac, char ** av)
+{
+    if (ac != 3) {
+        cerr << "Usage: " << av[0] << " <file_in> <file_out>" << endl;
+        return 1;
+    }
+
+    int fakeac = 1;
+    char * fakeav[] = { "3dconvert",
+                        "Convert a 3D Model",
+                        0 };
+    glutInit(&fakeac, fakeav);
+    glutCreateWindow(fakeav[1]);
+
+    ssgInit();
+    ssgEntity * object = ssgLoad(av[1]);
+    if (object == 0) {
+        cerr << "Failed to load " << av[1] << endl;
+        return 2;
+    }
+
+    ssgSave(av[2], object);
+}
diff --git a/utils/Modeller/Makefile.am b/utils/Modeller/Makefile.am
new file mode 100644 (file)
index 0000000..01168d5
--- /dev/null
@@ -0,0 +1,7 @@
+noinst_PROGRAMS = 3dconvert animassist
+
+3dconvert_SOURCES = 3dconvert.cxx
+3dconvert_LDADD = -lplibssg -lplibsg -lplibul $(opengl_LIBS) $(audio_LIBS)
+
+animassist_SOURCES = animassist.c
+
diff --git a/utils/Modeller/animassist.c b/utils/Modeller/animassist.c
new file mode 100644 (file)
index 0000000..6f368a4
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+// animassist.c
+//
+// Jim Wilson 5/8/2003
+//
+// Copyright (C) 2003  Jim Wilson - jimw@kelcomaine.com
+//
+// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+int main( int argc, char **argv ) {
+       float x1,y1,z1,x2,y2,z2 = 0;
+       float center_x,center_y,center_z,axis_x,axis_y,axis_z;
+       float vector_length;
+
+       if (argc < 7) {
+               printf("animassist - utility to calculate axis and center values for SimGear model animation\n\n");
+               printf("Usage: animassist x1 y1 z1 x2 y2 z2\n\n");
+               printf("Defining two vectors in SimGear coords (x1,y1,z1)  and (x2,y2,z2)\n\n");
+               printf("Conversion from model to SimGear:\n");
+               printf("SimGear Coord         AC3D Coordinate\n");
+               printf("     X                   =              X\n");
+               printf("     Y                   =              Z * -1\n");
+               printf("     Z                   =              Y\n\n");
+               printf("Note: no normalization done, so please make the 2nd vector the furthest out\n");
+       } else {
+    
+               x1  = atof(argv[1]);
+               y1  = atof(argv[2]); 
+               z1  = atof(argv[3]);
+               x2  = atof(argv[4]);
+               y2  = atof(argv[5]);
+               z2  = atof(argv[6]);
+
+               center_x = (x1+x2)/2;
+               center_y = (y1+y2)/2;
+               center_z = (z1+z2)/2;
+
+               vector_length = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1));
+
+               /* arbitrary axis defined by cos(theta) where theta is angle from x,y or z axis */
+               axis_x = (x2-x1)/vector_length;
+               axis_y = (y2-y1)/vector_length;
+               axis_z = (z2-z1)/vector_length;
+
+               printf("Flightgear Model XML for:\n");
+               printf("Axis from (%f,%f,%f) to (%f,%f,%f)\n", x1,y1,z1,x2,y2,z2);
+                                            printf("Assuming units in meters!\n\n");
+               printf("<center>\n");
+                                            printf(" <x-m>%f</x-m>\n",center_x);
+                                            printf(" <y-m>%f</y-m>\n",center_y);
+                                            printf(" <z-m>%f</z-m>\n",center_z);
+                                            printf("</center>\n\n");
+               printf("<axis>\n");
+                                            printf(" <x>%f</x>\n",axis_x);
+                                            printf(" <y>%f</y>\n",axis_y);
+                                            printf(" <z>%f</z>\n",axis_z);
+                                            printf("</axis>\n\n");
+       }
+
+       return 0;
+}