Rename utils/3dconvert to utils/Modeller and add Jim Wilson's animassist utility
This commit is contained in:
parent
ce91286e19
commit
18eb0a35a2
6 changed files with 117 additions and 3 deletions
|
@ -520,8 +520,8 @@ AC_CONFIG_FILES([ \
|
||||||
tests/Makefile \
|
tests/Makefile \
|
||||||
utils/Makefile \
|
utils/Makefile \
|
||||||
utils/TerraSync/Makefile \
|
utils/TerraSync/Makefile \
|
||||||
|
utils/Modeller/Makefile \
|
||||||
utils/js_server/Makefile \
|
utils/js_server/Makefile \
|
||||||
utils/3dconvert/Makefile \
|
|
||||||
])
|
])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
SUBDIRS = TerraSync js_server 3dconvert
|
SUBDIRS = TerraSync Modeller js_server
|
||||||
|
|
32
utils/Modeller/3dconvert.cxx
Normal file
32
utils/Modeller/3dconvert.cxx
Normal file
|
@ -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);
|
||||||
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
bin_PROGRAMS = 3dconvert
|
noinst_PROGRAMS = 3dconvert animassist
|
||||||
|
|
||||||
3dconvert_SOURCES = 3dconvert.cxx
|
3dconvert_SOURCES = 3dconvert.cxx
|
||||||
3dconvert_LDADD = -lplibssg -lplibsg -lplibul $(opengl_LIBS) $(audio_LIBS)
|
3dconvert_LDADD = -lplibssg -lplibsg -lplibul $(opengl_LIBS) $(audio_LIBS)
|
||||||
|
|
||||||
|
animassist_SOURCES = animassist.c
|
||||||
|
|
79
utils/Modeller/animassist.c
Normal file
79
utils/Modeller/animassist.c
Normal file
|
@ -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;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue