diff --git a/configure.ac b/configure.ac index 21050c09c..10892754a 100644 --- a/configure.ac +++ b/configure.ac @@ -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/Makefile.am b/utils/Makefile.am index 61c2ecf36..14a50d6f9 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -1 +1 @@ -SUBDIRS = TerraSync js_server 3dconvert +SUBDIRS = TerraSync Modeller js_server diff --git a/utils/3dconvert/.cvsignore b/utils/Modeller/.cvsignore similarity index 100% rename from utils/3dconvert/.cvsignore rename to utils/Modeller/.cvsignore diff --git a/utils/Modeller/3dconvert.cxx b/utils/Modeller/3dconvert.cxx new file mode 100644 index 000000000..6ffc1ac7b --- /dev/null +++ b/utils/Modeller/3dconvert.cxx @@ -0,0 +1,32 @@ +#include +#include +#include + +using std::cerr; +using std::endl; + + +int +main (int ac, char ** av) +{ + if (ac != 3) { + cerr << "Usage: " << av[0] << " " << 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/3dconvert/Makefile.am b/utils/Modeller/Makefile.am similarity index 59% rename from utils/3dconvert/Makefile.am rename to utils/Modeller/Makefile.am index d568f5216..01168d528 100644 --- a/utils/3dconvert/Makefile.am +++ b/utils/Modeller/Makefile.am @@ -1,4 +1,7 @@ -bin_PROGRAMS = 3dconvert +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 index 000000000..6f368a46c --- /dev/null +++ b/utils/Modeller/animassist.c @@ -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 +#include +#include + +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("
\n"); + printf(" %f\n",center_x); + printf(" %f\n",center_y); + printf(" %f\n",center_z); + printf("
\n\n"); + printf("\n"); + printf(" %f\n",axis_x); + printf(" %f\n",axis_y); + printf(" %f\n",axis_z); + printf("\n\n"); + } + + return 0; +}